@capybara-hq/plugin-sdk 0.1.0-rc.7 → 0.1.0-rc.71

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.
Files changed (146) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +11 -3
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +3 -1
  9. package/agent-docs/extension-points/model-provider.md +3 -1
  10. package/agent-docs/extension-points/object-store.md +2 -0
  11. package/agent-docs/extension-points/push-provider.md +17 -0
  12. package/agent-docs/extensions.md +77 -4
  13. package/agent-docs/plugin-format.md +51 -12
  14. package/agent-docs/setup.md +54 -0
  15. package/dist/agent-template.d.ts +15 -6
  16. package/dist/agent-template.js +32 -13
  17. package/dist/avatar-presets.d.ts +8 -0
  18. package/dist/avatar-presets.js +17 -0
  19. package/dist/bootstrap.d.ts +109 -1
  20. package/dist/bootstrap.js +185 -2
  21. package/dist/cards.d.ts +60 -13
  22. package/dist/cards.js +88 -18
  23. package/dist/channel.d.ts +128 -47
  24. package/dist/channel.js +10 -5
  25. package/dist/client-css.d.ts +36 -0
  26. package/dist/client-css.js +326 -0
  27. package/dist/client-section.d.ts +35 -0
  28. package/dist/client-section.js +133 -0
  29. package/dist/config-ui.d.ts +28 -6
  30. package/dist/config-ui.js +88 -25
  31. package/dist/config-url-fetch.d.ts +19 -0
  32. package/dist/config-url-fetch.js +43 -0
  33. package/dist/connector-auth.d.ts +13 -2
  34. package/dist/connector-auth.js +82 -8
  35. package/dist/connector.d.ts +74 -32
  36. package/dist/context.d.ts +40 -0
  37. package/dist/context.js +2 -0
  38. package/dist/ctx.d.ts +210 -30
  39. package/dist/ctx.js +9 -1
  40. package/dist/define-extension.d.ts +23 -13
  41. package/dist/define-extension.js +19 -5
  42. package/dist/device-denied-paths.d.ts +20 -0
  43. package/dist/device-denied-paths.js +118 -0
  44. package/dist/device-operation.d.ts +339 -0
  45. package/dist/device-operation.js +312 -0
  46. package/dist/device-protocol.d.ts +285 -50
  47. package/dist/device-protocol.js +755 -90
  48. package/dist/device-provider.d.ts +708 -0
  49. package/dist/device-provider.js +325 -0
  50. package/dist/device-service.d.ts +52 -0
  51. package/dist/device-service.js +105 -0
  52. package/dist/dial-in.d.ts +239 -0
  53. package/dist/dial-in.js +155 -0
  54. package/dist/directory.d.ts +15 -12
  55. package/dist/extension-point.d.ts +2 -0
  56. package/dist/extension-point.js +7 -3
  57. package/dist/field-meta.d.ts +19 -0
  58. package/dist/field-meta.js +54 -0
  59. package/dist/file-preview.d.ts +43 -10
  60. package/dist/git-hosts.d.ts +53 -0
  61. package/dist/git-hosts.js +98 -0
  62. package/dist/hooks.d.ts +125 -20
  63. package/dist/hooks.js +5 -0
  64. package/dist/http-access.d.ts +71 -0
  65. package/dist/http-access.js +12 -0
  66. package/dist/identity.d.ts +38 -9
  67. package/dist/identity.js +21 -1
  68. package/dist/index.d.ts +31 -4
  69. package/dist/index.js +31 -4
  70. package/dist/model-params.d.ts +41 -22
  71. package/dist/model-params.js +28 -15
  72. package/dist/model.d.ts +210 -75
  73. package/dist/model.js +152 -19
  74. package/dist/net.d.ts +52 -0
  75. package/dist/net.js +34 -0
  76. package/dist/network-classes.d.ts +98 -0
  77. package/dist/network-classes.js +291 -0
  78. package/dist/permissions.d.ts +65 -22
  79. package/dist/permissions.js +139 -43
  80. package/dist/platform-only.d.ts +27 -0
  81. package/dist/platform-only.js +35 -0
  82. package/dist/plugin-manifest.d.ts +40 -9
  83. package/dist/plugin-manifest.js +171 -60
  84. package/dist/plugin-package.d.ts +82 -39
  85. package/dist/plugin-package.js +68 -41
  86. package/dist/push.d.ts +75 -0
  87. package/dist/push.js +87 -0
  88. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  89. package/dist/sandbox-linux-runtime-source.js +2343 -0
  90. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  91. package/dist/sandbox-native-runtime-source.js +476 -0
  92. package/dist/sandbox-runtime-source.d.ts +47 -0
  93. package/dist/sandbox-runtime-source.js +73 -0
  94. package/dist/sandbox-write-denies.d.ts +139 -0
  95. package/dist/sandbox-write-denies.js +869 -0
  96. package/dist/secret.d.ts +8 -2
  97. package/dist/secret.js +11 -4
  98. package/dist/setup-check.d.ts +128 -0
  99. package/dist/setup-check.js +142 -0
  100. package/dist/setup-guide-parse.d.ts +121 -0
  101. package/dist/setup-guide-parse.js +356 -0
  102. package/dist/setup-guide-render.d.ts +45 -0
  103. package/dist/setup-guide-render.js +351 -0
  104. package/dist/setup-guide.d.ts +86 -72
  105. package/dist/setup-guide.js +340 -108
  106. package/dist/shell-capabilities.d.ts +211 -0
  107. package/dist/shell-capabilities.js +44 -0
  108. package/dist/shell-environment.d.ts +57 -0
  109. package/dist/shell-environment.js +21 -0
  110. package/dist/skill.d.ts +27 -17
  111. package/dist/skill.js +40 -26
  112. package/dist/storage.d.ts +52 -25
  113. package/dist/svg-viewbox.d.ts +10 -0
  114. package/dist/svg-viewbox.js +24 -0
  115. package/dist/theme-assets.d.ts +55 -0
  116. package/dist/theme-assets.js +489 -0
  117. package/dist/theme-readability.d.ts +37 -0
  118. package/dist/theme-readability.js +145 -0
  119. package/dist/theme-tokens.generated.d.ts +299 -0
  120. package/dist/theme-tokens.generated.js +184 -0
  121. package/dist/theme.d.ts +190 -0
  122. package/dist/theme.js +471 -0
  123. package/dist/tool.d.ts +104 -30
  124. package/dist/tool.js +29 -9
  125. package/dist/ui-parts.d.ts +23 -0
  126. package/dist/ui-parts.js +385 -0
  127. package/dist/ui-resolve.d.ts +35 -0
  128. package/dist/ui-resolve.js +42 -0
  129. package/dist/ui-slots.d.ts +65 -0
  130. package/dist/ui-slots.js +261 -0
  131. package/dist/ui.d.ts +232 -77
  132. package/dist/ui.js +104 -27
  133. package/dist/url.d.ts +4 -1
  134. package/dist/url.js +4 -1
  135. package/dist/web.d.ts +26 -20
  136. package/package.json +13 -1
  137. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  138. package/schemas/bootstrap.v1.schema.json +20 -0
  139. package/schemas/connector-template.v1.schema.json +62 -4
  140. package/schemas/plugin.v1.schema.json +93 -143
  141. package/schemas/theme.v1.schema.json +302 -0
  142. package/agent-docs/extension-points/sandbox.md +0 -15
  143. package/dist/org-access.d.ts +0 -27
  144. package/dist/org-access.js +0 -35
  145. package/dist/sandbox.d.ts +0 -254
  146. package/dist/sandbox.js +0 -153
@@ -138,9 +138,6 @@
138
138
  "minLength": 3,
139
139
  "maxLength": 512,
140
140
  "pattern": "^\\.\\/"
141
- },
142
- "pinned": {
143
- "type": "boolean"
144
141
  }
145
142
  },
146
143
  "required": [
@@ -194,6 +191,25 @@
194
191
  "additionalProperties": false
195
192
  }
196
193
  },
194
+ "themes": {
195
+ "maxItems": 10,
196
+ "type": "array",
197
+ "items": {
198
+ "type": "object",
199
+ "properties": {
200
+ "path": {
201
+ "type": "string",
202
+ "minLength": 3,
203
+ "maxLength": 512,
204
+ "pattern": "^\\.\\/"
205
+ }
206
+ },
207
+ "required": [
208
+ "path"
209
+ ],
210
+ "additionalProperties": false
211
+ }
212
+ },
197
213
  "setupGuides": {
198
214
  "maxItems": 8,
199
215
  "type": "array",
@@ -207,129 +223,50 @@
207
223
  "place": {
208
224
  "type": "string",
209
225
  "enum": [
210
- "channel-connection"
226
+ "channel-connection",
227
+ "connector-template",
228
+ "extension-deployment",
229
+ "device-connection"
211
230
  ]
212
231
  },
213
- "title": {
214
- "type": "object",
215
- "properties": {
216
- "en": {
217
- "type": "string",
218
- "minLength": 1,
219
- "maxLength": 100,
220
- "pattern": "\\S"
221
- },
222
- "zh": {
223
- "type": "string",
224
- "minLength": 1,
225
- "maxLength": 100,
226
- "pattern": "\\S"
227
- }
228
- },
229
- "required": [
230
- "en"
231
- ],
232
- "additionalProperties": false
233
- },
234
- "steps": {
235
- "maxItems": 20,
236
- "type": "array",
237
- "items": {
238
- "type": "object",
239
- "properties": {
240
- "en": {
241
- "type": "string",
242
- "minLength": 1,
243
- "maxLength": 2000,
244
- "pattern": "\\S"
245
- },
246
- "zh": {
247
- "type": "string",
248
- "minLength": 1,
249
- "maxLength": 2000,
250
- "pattern": "\\S"
251
- },
252
- "mode": {
253
- "type": "string",
254
- "maxLength": 64
255
- }
256
- },
257
- "required": [
258
- "en"
259
- ],
260
- "additionalProperties": false
261
- }
262
- },
263
- "files": {
264
- "maxItems": 8,
232
+ "templates": {
233
+ "minItems": 1,
234
+ "maxItems": 64,
265
235
  "type": "array",
266
236
  "items": {
267
- "type": "object",
268
- "properties": {
269
- "path": {
270
- "type": "string",
271
- "minLength": 3,
272
- "maxLength": 512,
273
- "allOf": [
274
- {
275
- "pattern": "^\\.\\/"
276
- },
277
- {
278
- "pattern": "\\.(?:tmpl|ya?ml|json|txt)$"
279
- }
280
- ]
281
- },
282
- "title": {
283
- "type": "object",
284
- "properties": {
285
- "en": {
286
- "type": "string",
287
- "minLength": 1,
288
- "maxLength": 100,
289
- "pattern": "\\S"
290
- },
291
- "zh": {
292
- "type": "string",
293
- "minLength": 1,
294
- "maxLength": 100,
295
- "pattern": "\\S"
296
- }
297
- },
298
- "required": [
299
- "en"
300
- ],
301
- "additionalProperties": false
302
- },
303
- "language": {
304
- "type": "string",
305
- "enum": [
306
- "yaml",
307
- "json",
308
- "text"
309
- ]
310
- },
311
- "mode": {
312
- "type": "string",
313
- "maxLength": 64
314
- }
315
- },
316
- "required": [
317
- "path",
318
- "title",
319
- "language"
320
- ],
321
- "additionalProperties": false
237
+ "type": "string",
238
+ "pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
322
239
  }
323
240
  }
324
241
  },
325
242
  "required": [
326
243
  "id",
327
- "place",
328
- "title"
244
+ "place"
329
245
  ],
330
246
  "additionalProperties": false
331
247
  }
332
248
  },
249
+ "suggestedAppearance": {
250
+ "type": "object",
251
+ "properties": {
252
+ "theme": {
253
+ "type": "string",
254
+ "pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
255
+ },
256
+ "replacements": {
257
+ "type": "object",
258
+ "propertyNames": {
259
+ "type": "string",
260
+ "maxLength": 100
261
+ },
262
+ "additionalProperties": {
263
+ "type": "string",
264
+ "maxLength": 100
265
+ }
266
+ }
267
+ },
268
+ "additionalProperties": false
269
+ },
333
270
  "extension": {
334
271
  "type": "object",
335
272
  "properties": {
@@ -414,36 +351,10 @@
414
351
  ],
415
352
  "additionalProperties": false
416
353
  }
417
- },
418
- "org": {
419
- "maxItems": 1000,
420
- "type": "array",
421
- "items": {
422
- "type": "object",
423
- "properties": {
424
- "path": {
425
- "type": "string",
426
- "maxLength": 1000
427
- },
428
- "secret": {
429
- "type": "boolean"
430
- },
431
- "hot": {
432
- "type": "boolean"
433
- }
434
- },
435
- "required": [
436
- "path",
437
- "secret",
438
- "hot"
439
- ],
440
- "additionalProperties": false
441
- }
442
354
  }
443
355
  },
444
356
  "required": [
445
- "deployment",
446
- "org"
357
+ "deployment"
447
358
  ],
448
359
  "additionalProperties": false
449
360
  }
@@ -481,15 +392,54 @@
481
392
  "type": "string"
482
393
  },
483
394
  "additionalProperties": {}
395
+ }
396
+ },
397
+ "additionalProperties": false
398
+ },
399
+ "client": {
400
+ "type": "object",
401
+ "properties": {
402
+ "entry": {
403
+ "type": "string",
404
+ "maxLength": 512
405
+ },
406
+ "styles": {
407
+ "maxItems": 64,
408
+ "type": "array",
409
+ "items": {
410
+ "type": "string",
411
+ "maxLength": 512
412
+ }
484
413
  },
485
- "org": {
414
+ "assets": {
415
+ "maxItems": 256,
416
+ "type": "array",
417
+ "items": {
418
+ "type": "string",
419
+ "maxLength": 512
420
+ }
421
+ },
422
+ "integrity": {
486
423
  "type": "object",
487
424
  "propertyNames": {
488
- "type": "string"
425
+ "type": "string",
426
+ "maxLength": 512
489
427
  },
490
- "additionalProperties": {}
428
+ "additionalProperties": {
429
+ "type": "string",
430
+ "maxLength": 128
431
+ }
432
+ },
433
+ "apiVersion": {
434
+ "type": "integer",
435
+ "minimum": 1,
436
+ "maximum": 9007199254740991
491
437
  }
492
438
  },
439
+ "required": [
440
+ "integrity",
441
+ "apiVersion"
442
+ ],
493
443
  "additionalProperties": false
494
444
  }
495
445
  },
@@ -0,0 +1,302 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://capybarahq.com/schemas/theme.v1.schema.json",
4
+ "title": "Capybara theme file themes/<id>.json",
5
+ "type": "object",
6
+ "properties": {
7
+ "$schema": {
8
+ "type": "string",
9
+ "maxLength": 512
10
+ },
11
+ "name": {
12
+ "type": "object",
13
+ "properties": {
14
+ "zh": {
15
+ "type": "string",
16
+ "minLength": 1,
17
+ "maxLength": 100,
18
+ "pattern": "\\S"
19
+ },
20
+ "en": {
21
+ "type": "string",
22
+ "minLength": 1,
23
+ "maxLength": 100,
24
+ "pattern": "\\S"
25
+ }
26
+ },
27
+ "required": [
28
+ "zh",
29
+ "en"
30
+ ],
31
+ "additionalProperties": false
32
+ },
33
+ "description": {
34
+ "type": "object",
35
+ "properties": {
36
+ "en": {
37
+ "type": "string",
38
+ "minLength": 1,
39
+ "maxLength": 1024,
40
+ "pattern": "\\S"
41
+ },
42
+ "zh": {
43
+ "type": "string",
44
+ "minLength": 1,
45
+ "maxLength": 1024,
46
+ "pattern": "\\S"
47
+ }
48
+ },
49
+ "required": [
50
+ "en"
51
+ ],
52
+ "additionalProperties": false
53
+ },
54
+ "schemes": {
55
+ "type": "object",
56
+ "properties": {
57
+ "dark": {
58
+ "type": "object",
59
+ "properties": {
60
+ "color": {
61
+ "type": "object",
62
+ "propertyNames": {
63
+ "type": "string",
64
+ "maxLength": 64
65
+ },
66
+ "additionalProperties": {
67
+ "type": "string",
68
+ "maxLength": 256
69
+ }
70
+ },
71
+ "shadow": {
72
+ "type": "object",
73
+ "propertyNames": {
74
+ "type": "string",
75
+ "maxLength": 64
76
+ },
77
+ "additionalProperties": {
78
+ "type": "string",
79
+ "maxLength": 256
80
+ }
81
+ },
82
+ "radius": {
83
+ "type": "object",
84
+ "properties": {
85
+ "sm": {
86
+ "type": "integer",
87
+ "minimum": 0,
88
+ "maximum": 16
89
+ },
90
+ "md": {
91
+ "type": "integer",
92
+ "minimum": 0,
93
+ "maximum": 16
94
+ },
95
+ "bubble": {
96
+ "type": "integer",
97
+ "minimum": 0,
98
+ "maximum": 16
99
+ }
100
+ },
101
+ "additionalProperties": false
102
+ }
103
+ },
104
+ "additionalProperties": false
105
+ },
106
+ "light": {
107
+ "type": "object",
108
+ "properties": {
109
+ "color": {
110
+ "type": "object",
111
+ "propertyNames": {
112
+ "type": "string",
113
+ "maxLength": 64
114
+ },
115
+ "additionalProperties": {
116
+ "type": "string",
117
+ "maxLength": 256
118
+ }
119
+ },
120
+ "shadow": {
121
+ "type": "object",
122
+ "propertyNames": {
123
+ "type": "string",
124
+ "maxLength": 64
125
+ },
126
+ "additionalProperties": {
127
+ "type": "string",
128
+ "maxLength": 256
129
+ }
130
+ },
131
+ "radius": {
132
+ "type": "object",
133
+ "properties": {
134
+ "sm": {
135
+ "type": "integer",
136
+ "minimum": 0,
137
+ "maximum": 16
138
+ },
139
+ "md": {
140
+ "type": "integer",
141
+ "minimum": 0,
142
+ "maximum": 16
143
+ },
144
+ "bubble": {
145
+ "type": "integer",
146
+ "minimum": 0,
147
+ "maximum": 16
148
+ }
149
+ },
150
+ "additionalProperties": false
151
+ }
152
+ },
153
+ "additionalProperties": false
154
+ }
155
+ },
156
+ "additionalProperties": false
157
+ },
158
+ "fonts": {
159
+ "maxItems": 8,
160
+ "type": "array",
161
+ "items": {
162
+ "type": "object",
163
+ "properties": {
164
+ "family": {
165
+ "type": "string",
166
+ "pattern": "^[A-Za-z0-9 -]{1,64}$"
167
+ },
168
+ "file": {
169
+ "type": "string",
170
+ "maxLength": 512
171
+ },
172
+ "weight": {
173
+ "type": "integer",
174
+ "minimum": 100,
175
+ "maximum": 900
176
+ },
177
+ "style": {
178
+ "type": "string",
179
+ "enum": [
180
+ "normal",
181
+ "italic"
182
+ ]
183
+ },
184
+ "role": {
185
+ "type": "string",
186
+ "enum": [
187
+ "prose",
188
+ "mono"
189
+ ]
190
+ }
191
+ },
192
+ "required": [
193
+ "family",
194
+ "file",
195
+ "weight",
196
+ "role"
197
+ ],
198
+ "additionalProperties": false
199
+ }
200
+ },
201
+ "logo": {
202
+ "type": "object",
203
+ "properties": {
204
+ "mark": {
205
+ "type": "string",
206
+ "maxLength": 512
207
+ },
208
+ "wordmark": {
209
+ "type": "string",
210
+ "pattern": "\\S"
211
+ },
212
+ "favicon": {
213
+ "type": "string",
214
+ "maxLength": 512
215
+ },
216
+ "illustration": {
217
+ "type": "string",
218
+ "maxLength": 512
219
+ },
220
+ "appIcon": {
221
+ "type": "string",
222
+ "maxLength": 512
223
+ },
224
+ "appIconMaskable": {
225
+ "type": "string",
226
+ "maxLength": 512
227
+ }
228
+ },
229
+ "additionalProperties": false
230
+ },
231
+ "decoration": {
232
+ "type": "string",
233
+ "enum": [
234
+ "dither",
235
+ "none"
236
+ ]
237
+ },
238
+ "avatars": {
239
+ "maxItems": 12,
240
+ "type": "array",
241
+ "items": {
242
+ "type": "object",
243
+ "properties": {
244
+ "id": {
245
+ "type": "string",
246
+ "pattern": "^[a-z0-9][a-z0-9-]{0,31}$"
247
+ },
248
+ "name": {
249
+ "type": "object",
250
+ "properties": {
251
+ "en": {
252
+ "type": "string",
253
+ "pattern": "\\S"
254
+ },
255
+ "zh": {
256
+ "type": "string",
257
+ "pattern": "\\S"
258
+ }
259
+ },
260
+ "required": [
261
+ "en"
262
+ ],
263
+ "additionalProperties": false
264
+ },
265
+ "file": {
266
+ "type": "string",
267
+ "maxLength": 512
268
+ }
269
+ },
270
+ "required": [
271
+ "id",
272
+ "name",
273
+ "file"
274
+ ],
275
+ "additionalProperties": false
276
+ }
277
+ },
278
+ "hideAvatarPresets": {
279
+ "type": "array",
280
+ "items": {
281
+ "type": "string",
282
+ "enum": [
283
+ "capybara",
284
+ "black-bear",
285
+ "panda",
286
+ "elephant",
287
+ "fox",
288
+ "owl",
289
+ "penguin",
290
+ "rabbit",
291
+ "turtle",
292
+ "whale"
293
+ ]
294
+ }
295
+ }
296
+ },
297
+ "required": [
298
+ "name",
299
+ "schemes"
300
+ ],
301
+ "additionalProperties": false
302
+ }
@@ -1,15 +0,0 @@
1
- # Authoring: extension point sandbox
2
-
3
- <!-- generated:extension-point -->
4
- - Name: `sandbox` (a ref is `sandbox@<major>`)
5
- - Runs an environment's instance and keeps its files for agents' commands (Docker, E2B).
6
- - Providers: one at a time
7
- - Enabled per org: no
8
- - Brokered by the platform: yes (extensions use it only through `ctx`)
9
- <!-- /generated -->
10
-
11
- Contract: SandboxProvider (`sandbox.ts`)
12
-
13
- The kernel accepts only `sandbox@2`. An environment is one instance plus a file system that outlives it. Implement the file system (`createFileSystem`, `destroyFileSystem`, `destroyFileSystemByName`), the instance on it (`create`, which throws `FileSystemGoneError` when the file system is gone instead of making an empty one; `resume`, `suspend`; `destroy` and `destroyByName`, which drop the instance and keep the files), and the instance's `exec`, `readFile`, `writeFile`, `stat`, `killAll` and `killTagged` (`concurrentExec` is required: several conversations share one instance). Aborting a command must kill it. Locking, suspension timing and destruction are the kernel's job, not yours. Never publish a docker socket proxy on a host address.
14
-
15
- See `extensions` for the rules every extension follows.
@@ -1,27 +0,0 @@
1
- import type { z } from "zod";
2
- /**
3
- * How an org may treat a deployment config field: `readonly` (the org sees it, never sets it) or
4
- * `override` (an org may set its own value). A field without a level is deployment-only.
5
- */
6
- export type OrgAccess = "readonly" | "override";
7
- /**
8
- * Marks a deployment config field with an org access level (Zod 4 meta `{ org: access }`), merging
9
- * with existing meta (`secret`, `hot`, `ui`), so `orgAccess(secret(x), …)` and
10
- * `secret(orgAccess(x, …))` are the same. `configJsonSchema` publishes it as `"x-org"`.
11
- *
12
- * The author's promise for `override`: the extension reads the field from the per-call `config`
13
- * the kernel passes with each request, not from `ctx.config`, and the field may be absent from
14
- * `ctx.config` (the deployment value is the default, which an org may replace per call).
15
- *
16
- * The per-call config of an org that has its own copy still contains the platform's hidden
17
- * (platform-only) secrets, which an org cannot set; it never contains an overridable platform
18
- * secret. Never send a hidden secret to an endpoint taken from an overridable field: an org could
19
- * point that endpoint at a server it controls.
20
- */
21
- export declare function orgAccess<T extends z.ZodTypeAny>(schema: T, access: OrgAccess): T;
22
- /**
23
- * The org access level of a schema's meta, or undefined when it has none. It sees through
24
- * `.optional()`, `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (the
25
- * outermost level wins), so it agrees with the `"x-org"` that `configJsonSchema` publishes.
26
- */
27
- export declare function orgAccessOf(schema: z.ZodTypeAny): OrgAccess | undefined;
@@ -1,35 +0,0 @@
1
- /**
2
- * Marks a deployment config field with an org access level (Zod 4 meta `{ org: access }`), merging
3
- * with existing meta (`secret`, `hot`, `ui`), so `orgAccess(secret(x), …)` and
4
- * `secret(orgAccess(x, …))` are the same. `configJsonSchema` publishes it as `"x-org"`.
5
- *
6
- * The author's promise for `override`: the extension reads the field from the per-call `config`
7
- * the kernel passes with each request, not from `ctx.config`, and the field may be absent from
8
- * `ctx.config` (the deployment value is the default, which an org may replace per call).
9
- *
10
- * The per-call config of an org that has its own copy still contains the platform's hidden
11
- * (platform-only) secrets, which an org cannot set; it never contains an overridable platform
12
- * secret. Never send a hidden secret to an endpoint taken from an overridable field: an org could
13
- * point that endpoint at a server it controls.
14
- */
15
- export function orgAccess(schema, access) {
16
- return schema.meta({ ...(schema.meta() ?? {}), org: access });
17
- }
18
- /** The wrappers a field's org level is read through, as `configJsonSchema` inherits meta. */
19
- const WRAPPERS = new Set(["default", "prefault", "optional", "nullable", "readonly", "catch"]);
20
- /**
21
- * The org access level of a schema's meta, or undefined when it has none. It sees through
22
- * `.optional()`, `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (the
23
- * outermost level wins), so it agrees with the `"x-org"` that `configJsonSchema` publishes.
24
- */
25
- export function orgAccessOf(schema) {
26
- let node = schema;
27
- while (node) {
28
- const v = node.meta()?.org;
29
- if (v === "readonly" || v === "override")
30
- return v;
31
- const def = node._zod.def;
32
- node = WRAPPERS.has(def.type) ? def.innerType : undefined;
33
- }
34
- return undefined;
35
- }