@capybara-hq/plugin-sdk 0.1.0-rc.8 → 0.1.0-rc.80
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/README.md +1 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +11 -3
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/device-provider.md +15 -0
- package/agent-docs/extension-points/file-preview.md +3 -1
- package/agent-docs/extension-points/identity-source.md +2 -0
- package/agent-docs/extension-points/model-provider.md +3 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extensions.md +77 -4
- package/agent-docs/plugin-format.md +45 -10
- package/agent-docs/setup.md +54 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/avatar-presets.d.ts +8 -0
- package/dist/avatar-presets.js +17 -0
- package/dist/bootstrap.d.ts +109 -1
- package/dist/bootstrap.js +185 -2
- package/dist/cards.d.ts +60 -13
- package/dist/cards.js +88 -18
- package/dist/channel.d.ts +128 -47
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +28 -6
- package/dist/config-ui.js +88 -25
- package/dist/config-url-fetch.d.ts +19 -0
- package/dist/config-url-fetch.js +43 -0
- package/dist/connector-auth.d.ts +13 -2
- package/dist/connector-auth.js +82 -8
- package/dist/connector.d.ts +74 -32
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +224 -30
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +23 -13
- package/dist/define-extension.js +19 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +339 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +285 -50
- package/dist/device-protocol.js +755 -90
- package/dist/device-provider.d.ts +780 -0
- package/dist/device-provider.js +409 -0
- package/dist/device-service.d.ts +126 -0
- package/dist/device-service.js +211 -0
- package/dist/dial-in.d.ts +286 -0
- package/dist/dial-in.js +213 -0
- package/dist/directory.d.ts +15 -12
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +7 -3
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +43 -10
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +125 -20
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +71 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +70 -9
- package/dist/identity.js +46 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.js +28 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +210 -75
- package/dist/model.js +152 -19
- package/dist/native-failure.d.ts +13 -0
- package/dist/native-failure.js +31 -0
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/network-classes.d.ts +98 -0
- package/dist/network-classes.js +291 -0
- package/dist/permissions.d.ts +65 -22
- package/dist/permissions.js +139 -43
- package/dist/platform-only.d.ts +27 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +30 -6
- package/dist/plugin-manifest.js +147 -55
- package/dist/plugin-package.d.ts +82 -39
- package/dist/plugin-package.js +68 -41
- package/dist/push.d.ts +75 -0
- package/dist/push.js +87 -0
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +2343 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +480 -0
- package/dist/sandbox-runtime-source.d.ts +47 -0
- package/dist/sandbox-runtime-source.js +73 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +8 -2
- package/dist/secret.js +11 -4
- package/dist/setup-check.d.ts +128 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +356 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +86 -72
- package/dist/setup-guide.js +340 -108
- package/dist/shell-capabilities.d.ts +211 -0
- package/dist/shell-capabilities.js +44 -0
- package/dist/shell-environment.d.ts +57 -0
- package/dist/shell-environment.js +21 -0
- package/dist/skill-invocation.d.ts +5 -0
- package/dist/skill-invocation.js +4 -3
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +40 -26
- package/dist/storage.d.ts +52 -25
- package/dist/svg-viewbox.d.ts +10 -0
- package/dist/svg-viewbox.js +24 -0
- package/dist/theme-assets.d.ts +25 -9
- package/dist/theme-assets.js +87 -47
- package/dist/theme-tokens.generated.d.ts +26 -2
- package/dist/theme-tokens.generated.js +17 -0
- package/dist/theme.d.ts +48 -10
- package/dist/theme.js +100 -21
- package/dist/tool.d.ts +156 -30
- package/dist/tool.js +91 -9
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +385 -0
- package/dist/ui-resolve.d.ts +35 -0
- package/dist/ui-resolve.js +42 -0
- package/dist/ui-slots.d.ts +65 -0
- package/dist/ui-slots.js +261 -0
- package/dist/ui.d.ts +245 -77
- package/dist/ui.js +104 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/dist/web.d.ts +26 -20
- package/package.json +12 -1
- package/schemas/bootstrap-extra.v1.schema.json +186 -0
- package/schemas/bootstrap.v1.schema.json +20 -0
- package/schemas/connector-template.v1.schema.json +62 -4
- package/schemas/plugin.v1.schema.json +74 -143
- package/schemas/theme.v1.schema.json +77 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
- package/dist/sandbox.d.ts +0 -254
- 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": [
|
|
@@ -226,129 +223,50 @@
|
|
|
226
223
|
"place": {
|
|
227
224
|
"type": "string",
|
|
228
225
|
"enum": [
|
|
229
|
-
"channel-connection"
|
|
226
|
+
"channel-connection",
|
|
227
|
+
"connector-template",
|
|
228
|
+
"extension-deployment",
|
|
229
|
+
"device-connection"
|
|
230
230
|
]
|
|
231
231
|
},
|
|
232
|
-
"
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"en": {
|
|
236
|
-
"type": "string",
|
|
237
|
-
"minLength": 1,
|
|
238
|
-
"maxLength": 100,
|
|
239
|
-
"pattern": "\\S"
|
|
240
|
-
},
|
|
241
|
-
"zh": {
|
|
242
|
-
"type": "string",
|
|
243
|
-
"minLength": 1,
|
|
244
|
-
"maxLength": 100,
|
|
245
|
-
"pattern": "\\S"
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
"required": [
|
|
249
|
-
"en"
|
|
250
|
-
],
|
|
251
|
-
"additionalProperties": false
|
|
252
|
-
},
|
|
253
|
-
"steps": {
|
|
254
|
-
"maxItems": 20,
|
|
255
|
-
"type": "array",
|
|
256
|
-
"items": {
|
|
257
|
-
"type": "object",
|
|
258
|
-
"properties": {
|
|
259
|
-
"en": {
|
|
260
|
-
"type": "string",
|
|
261
|
-
"minLength": 1,
|
|
262
|
-
"maxLength": 2000,
|
|
263
|
-
"pattern": "\\S"
|
|
264
|
-
},
|
|
265
|
-
"zh": {
|
|
266
|
-
"type": "string",
|
|
267
|
-
"minLength": 1,
|
|
268
|
-
"maxLength": 2000,
|
|
269
|
-
"pattern": "\\S"
|
|
270
|
-
},
|
|
271
|
-
"mode": {
|
|
272
|
-
"type": "string",
|
|
273
|
-
"maxLength": 64
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
"required": [
|
|
277
|
-
"en"
|
|
278
|
-
],
|
|
279
|
-
"additionalProperties": false
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
"files": {
|
|
283
|
-
"maxItems": 8,
|
|
232
|
+
"templates": {
|
|
233
|
+
"minItems": 1,
|
|
234
|
+
"maxItems": 64,
|
|
284
235
|
"type": "array",
|
|
285
236
|
"items": {
|
|
286
|
-
"type": "
|
|
287
|
-
"
|
|
288
|
-
"path": {
|
|
289
|
-
"type": "string",
|
|
290
|
-
"minLength": 3,
|
|
291
|
-
"maxLength": 512,
|
|
292
|
-
"allOf": [
|
|
293
|
-
{
|
|
294
|
-
"pattern": "^\\.\\/"
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
"pattern": "\\.(?:tmpl|ya?ml|json|txt)$"
|
|
298
|
-
}
|
|
299
|
-
]
|
|
300
|
-
},
|
|
301
|
-
"title": {
|
|
302
|
-
"type": "object",
|
|
303
|
-
"properties": {
|
|
304
|
-
"en": {
|
|
305
|
-
"type": "string",
|
|
306
|
-
"minLength": 1,
|
|
307
|
-
"maxLength": 100,
|
|
308
|
-
"pattern": "\\S"
|
|
309
|
-
},
|
|
310
|
-
"zh": {
|
|
311
|
-
"type": "string",
|
|
312
|
-
"minLength": 1,
|
|
313
|
-
"maxLength": 100,
|
|
314
|
-
"pattern": "\\S"
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
"required": [
|
|
318
|
-
"en"
|
|
319
|
-
],
|
|
320
|
-
"additionalProperties": false
|
|
321
|
-
},
|
|
322
|
-
"language": {
|
|
323
|
-
"type": "string",
|
|
324
|
-
"enum": [
|
|
325
|
-
"yaml",
|
|
326
|
-
"json",
|
|
327
|
-
"text"
|
|
328
|
-
]
|
|
329
|
-
},
|
|
330
|
-
"mode": {
|
|
331
|
-
"type": "string",
|
|
332
|
-
"maxLength": 64
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
"required": [
|
|
336
|
-
"path",
|
|
337
|
-
"title",
|
|
338
|
-
"language"
|
|
339
|
-
],
|
|
340
|
-
"additionalProperties": false
|
|
237
|
+
"type": "string",
|
|
238
|
+
"pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
|
|
341
239
|
}
|
|
342
240
|
}
|
|
343
241
|
},
|
|
344
242
|
"required": [
|
|
345
243
|
"id",
|
|
346
|
-
"place"
|
|
347
|
-
"title"
|
|
244
|
+
"place"
|
|
348
245
|
],
|
|
349
246
|
"additionalProperties": false
|
|
350
247
|
}
|
|
351
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
|
+
},
|
|
352
270
|
"extension": {
|
|
353
271
|
"type": "object",
|
|
354
272
|
"properties": {
|
|
@@ -433,36 +351,10 @@
|
|
|
433
351
|
],
|
|
434
352
|
"additionalProperties": false
|
|
435
353
|
}
|
|
436
|
-
},
|
|
437
|
-
"org": {
|
|
438
|
-
"maxItems": 1000,
|
|
439
|
-
"type": "array",
|
|
440
|
-
"items": {
|
|
441
|
-
"type": "object",
|
|
442
|
-
"properties": {
|
|
443
|
-
"path": {
|
|
444
|
-
"type": "string",
|
|
445
|
-
"maxLength": 1000
|
|
446
|
-
},
|
|
447
|
-
"secret": {
|
|
448
|
-
"type": "boolean"
|
|
449
|
-
},
|
|
450
|
-
"hot": {
|
|
451
|
-
"type": "boolean"
|
|
452
|
-
}
|
|
453
|
-
},
|
|
454
|
-
"required": [
|
|
455
|
-
"path",
|
|
456
|
-
"secret",
|
|
457
|
-
"hot"
|
|
458
|
-
],
|
|
459
|
-
"additionalProperties": false
|
|
460
|
-
}
|
|
461
354
|
}
|
|
462
355
|
},
|
|
463
356
|
"required": [
|
|
464
|
-
"deployment"
|
|
465
|
-
"org"
|
|
357
|
+
"deployment"
|
|
466
358
|
],
|
|
467
359
|
"additionalProperties": false
|
|
468
360
|
}
|
|
@@ -500,15 +392,54 @@
|
|
|
500
392
|
"type": "string"
|
|
501
393
|
},
|
|
502
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
|
+
}
|
|
503
413
|
},
|
|
504
|
-
"
|
|
414
|
+
"assets": {
|
|
415
|
+
"maxItems": 256,
|
|
416
|
+
"type": "array",
|
|
417
|
+
"items": {
|
|
418
|
+
"type": "string",
|
|
419
|
+
"maxLength": 512
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
"integrity": {
|
|
505
423
|
"type": "object",
|
|
506
424
|
"propertyNames": {
|
|
507
|
-
"type": "string"
|
|
425
|
+
"type": "string",
|
|
426
|
+
"maxLength": 512
|
|
508
427
|
},
|
|
509
|
-
"additionalProperties": {
|
|
428
|
+
"additionalProperties": {
|
|
429
|
+
"type": "string",
|
|
430
|
+
"maxLength": 128
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
"apiVersion": {
|
|
434
|
+
"type": "integer",
|
|
435
|
+
"minimum": 1,
|
|
436
|
+
"maximum": 9007199254740991
|
|
510
437
|
}
|
|
511
438
|
},
|
|
439
|
+
"required": [
|
|
440
|
+
"integrity",
|
|
441
|
+
"apiVersion"
|
|
442
|
+
],
|
|
512
443
|
"additionalProperties": false
|
|
513
444
|
}
|
|
514
445
|
},
|
|
@@ -212,9 +212,86 @@
|
|
|
212
212
|
"favicon": {
|
|
213
213
|
"type": "string",
|
|
214
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
|
|
215
227
|
}
|
|
216
228
|
},
|
|
217
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
|
+
}
|
|
218
295
|
}
|
|
219
296
|
},
|
|
220
297
|
"required": [
|
|
@@ -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.
|
package/dist/org-access.d.ts
DELETED
|
@@ -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;
|
package/dist/org-access.js
DELETED
|
@@ -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
|
-
}
|
package/dist/sandbox.d.ts
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sandbox contract `sandbox@2`: a single-select, brokered extension point (extensions may not
|
|
3
|
-
* `requires` it; the kernel's `SandboxService` consumes it). The provider implements only the
|
|
4
|
-
* primitives below; the kernel builds `glob` / `grep` / `edit` from `exec` plus `readFile` /
|
|
5
|
-
* `writeFile`.
|
|
6
|
-
*
|
|
7
|
-
* `@2` separates an environment's **file system** from its **instance**: the file system
|
|
8
|
-
* (`createFileSystem`) lives until the environment is deleted (`destroyFileSystem`); instances
|
|
9
|
-
* (`create`) attach to it and come and go (`destroy` drops the instance and keeps the files).
|
|
10
|
-
*/
|
|
11
|
-
/** Sandbox extension point ref. */
|
|
12
|
-
export declare const SANDBOX_EXTENSION_POINT = "sandbox@2";
|
|
13
|
-
/** The roots inside the sandbox the model may access. */
|
|
14
|
-
export declare const SANDBOX_ROOTS: readonly ["/workspace", "/skills", "/tmp"];
|
|
15
|
-
/** Sandbox resource and egress limits. */
|
|
16
|
-
export interface SandboxLimits {
|
|
17
|
-
cpu: number;
|
|
18
|
-
memoryMb: number;
|
|
19
|
-
diskMb: number;
|
|
20
|
-
egress: "none" | "allowlist" | "open";
|
|
21
|
-
/** Egress allowlist (used when `egress` is `allowlist`); each entry passes {@link validateAllowHost}. */
|
|
22
|
-
allowHosts: string[];
|
|
23
|
-
}
|
|
24
|
-
/** The absolute roots inside one instance (a device may place them anywhere on its host). */
|
|
25
|
-
export interface SandboxRoots {
|
|
26
|
-
workspace: string;
|
|
27
|
-
skills: string;
|
|
28
|
-
tmp: string;
|
|
29
|
-
}
|
|
30
|
-
/** The roots every container-like provider uses; the same paths as {@link SANDBOX_ROOTS}. */
|
|
31
|
-
export declare const DEFAULT_SANDBOX_ROOTS: Readonly<SandboxRoots>;
|
|
32
|
-
/** The provider's instance handle. */
|
|
33
|
-
export interface SandboxHandle {
|
|
34
|
-
/** The provider's instance id. */
|
|
35
|
-
id: string;
|
|
36
|
-
/** The instance's roots; absent means {@link DEFAULT_SANDBOX_ROOTS}. */
|
|
37
|
-
roots?: SandboxRoots;
|
|
38
|
-
}
|
|
39
|
-
/** The roots of an instance, falling back to {@link DEFAULT_SANDBOX_ROOTS}. */
|
|
40
|
-
export declare function rootsOf(h: SandboxHandle): SandboxRoots;
|
|
41
|
-
/** The provider's file system handle (an environment's files, independent of any instance). */
|
|
42
|
-
export interface FileSystemHandle {
|
|
43
|
-
/** The provider's file system id. */
|
|
44
|
-
id: string;
|
|
45
|
-
}
|
|
46
|
-
/** Who runs an `exec` (informational in phase 1: audit and attribution). */
|
|
47
|
-
export interface SandboxActor {
|
|
48
|
-
accountId: string;
|
|
49
|
-
conversationId: string;
|
|
50
|
-
}
|
|
51
|
-
/** Result of a command. */
|
|
52
|
-
export interface ExecResult {
|
|
53
|
-
/** null on timeout or when aborted while running (`timedOut` is then true / false). */
|
|
54
|
-
exitCode: number | null;
|
|
55
|
-
stdout: string;
|
|
56
|
-
stderr: string;
|
|
57
|
-
truncated: boolean;
|
|
58
|
-
timedOut: boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* The instance is definitely gone on the provider's side (container removed, E2B sandbox expired).
|
|
62
|
-
* `exec` / `readFile` / `writeFile` / `stat` must throw it (not a plain Error) when they find the
|
|
63
|
-
* instance gone; the kernel then rebuilds the instance and retries once. A transient connection
|
|
64
|
-
* failure throws a plain error.
|
|
65
|
-
*/
|
|
66
|
-
export declare class SandboxGoneError extends Error {
|
|
67
|
-
readonly sandboxGone: true;
|
|
68
|
-
constructor(message: string, opts?: {
|
|
69
|
-
cause?: unknown;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/** Duck-typed check (not instanceof), so a plugin bundling another plugin-sdk copy still matches. */
|
|
73
|
-
export declare function isSandboxGoneError(e: unknown): e is SandboxGoneError;
|
|
74
|
-
/**
|
|
75
|
-
* The file system is definitely gone on the provider's side (volume removed, E2B sandbox killed).
|
|
76
|
-
* `create` throws it instead of attaching the instance to a new, empty file system; the kernel then
|
|
77
|
-
* reports the environment's files as lost rather than handing out a silently empty workspace.
|
|
78
|
-
*/
|
|
79
|
-
export declare class FileSystemGoneError extends Error {
|
|
80
|
-
readonly fileSystemGone: true;
|
|
81
|
-
constructor(message: string, opts?: {
|
|
82
|
-
cause?: unknown;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/** Duck-typed check (not instanceof), so a plugin bundling another plugin-sdk copy still matches. */
|
|
86
|
-
export declare function isFileSystemGoneError(e: unknown): e is FileSystemGoneError;
|
|
87
|
-
/**
|
|
88
|
-
* A holder tag (`exec` argument `tag`, {@link SandboxProvider.killTagged}): the kernel passes its
|
|
89
|
-
* lease tokens (UUIDs). Providers check tags against it before putting them in a command line or a
|
|
90
|
-
* kill pattern.
|
|
91
|
-
*/
|
|
92
|
-
export declare const SANDBOX_TAG_RE: RegExp;
|
|
93
|
-
/**
|
|
94
|
-
* The `sandbox@2` implementation (provided by a sandbox plugin such as Docker or E2B).
|
|
95
|
-
*
|
|
96
|
-
* **File systems and instances.** `createFileSystem` makes an environment's files; they live until
|
|
97
|
-
* `destroyFileSystem` (the environment is deleted). `create` makes an instance attached to an
|
|
98
|
-
* existing file system; `destroy` / `destroyByName` drop the instance only and keep the files, and
|
|
99
|
-
* `suspend` keeps them too. When the file system is gone, `create` must throw
|
|
100
|
-
* {@link FileSystemGoneError} and never create an empty one in its place (a Docker provider checks
|
|
101
|
-
* its volumes exist before mounting them, because Docker would otherwise create empty volumes).
|
|
102
|
-
*
|
|
103
|
-
* **Gone instances.** When the instance is definitely gone: `resume` returns `gone`; `exec` /
|
|
104
|
-
* `readFile` / `writeFile` / `stat` / `killAll` / `killTagged` throw {@link SandboxGoneError};
|
|
105
|
-
* `suspend` / `destroy` succeed as usual.
|
|
106
|
-
*
|
|
107
|
-
* **Auto-start**: when the instance still exists but is stopped or paused (for a reason outside the
|
|
108
|
-
* kernel: host or daemon restart, a process in the sandbox stopping its init, an idle sweep that
|
|
109
|
-
* stopped the instance before recording `suspended`...), `exec` / `readFile` / `writeFile` /
|
|
110
|
-
* `stat` / `killAll` / `killTagged` must start it transparently first (like `resume`, files kept)
|
|
111
|
-
* and then run, never fail: the kernel trusts only the `running` it recorded itself. Auto-start
|
|
112
|
-
* must be idempotent under concurrent calls: two calls that both find the instance stopped both
|
|
113
|
-
* start it without failing.
|
|
114
|
-
*
|
|
115
|
-
* **Time limits apply inside the sandbox too**: besides stopping a command after `timeoutMs` on the
|
|
116
|
-
* provider's side, `exec` must make the command in the sandbox kill itself shortly (a few seconds)
|
|
117
|
-
* after `timeoutMs`. When a kernel replica crashes, the provider-side timer goes with it, and a
|
|
118
|
-
* dropped connection does not end the command; the in-sandbox limit keeps it from running
|
|
119
|
-
* indefinitely next to the next holder's commands.
|
|
120
|
-
*
|
|
121
|
-
* **Abort**: every method must respond to `signal` promptly (fail at once when already aborted, end
|
|
122
|
-
* with the abort reason as soon as possible when aborted mid-way): the kernel relies on it to stop
|
|
123
|
-
* on lock loss, run abort or timeout, and ignoring it may let two holders operate on one instance.
|
|
124
|
-
* An aborted `exec` must kill its running command (and the processes it spawned), not just stop
|
|
125
|
-
* waiting for its output; an `exec` aborted after its command started resolves normally with
|
|
126
|
-
* `exitCode: null`, `timedOut: false` (and the output collected so far), it does not reject. An
|
|
127
|
-
* `exec` called with an already aborted signal rejects at once.
|
|
128
|
-
*
|
|
129
|
-
* **Concurrent use** (required in `@2`): the sessions of one environment share its instance, so the
|
|
130
|
-
* kernel calls `exec`, `readFile`, `writeFile` and `stat` concurrently on one instance. Those four
|
|
131
|
-
* methods must be safe to call concurrently. Each `exec` labels its command with its `tag`, and an
|
|
132
|
-
* aborted `exec` kills only its own command.
|
|
133
|
-
*/
|
|
134
|
-
export interface SandboxProvider {
|
|
135
|
-
/** `exec` / `readFile` / `writeFile` / `stat` may run concurrently on one instance (required). */
|
|
136
|
-
readonly concurrentExec: true;
|
|
137
|
-
/**
|
|
138
|
-
* Whether the provider isolates the sessions of one environment from each other inside the
|
|
139
|
-
* instance (a declared capability; absent means false).
|
|
140
|
-
*/
|
|
141
|
-
readonly sessionIsolation?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Creates an environment's file system. `name` looks like `cap-env-<environmentId>`. If a file
|
|
144
|
-
* system with this name already exists, return it.
|
|
145
|
-
*/
|
|
146
|
-
createFileSystem(args: {
|
|
147
|
-
name: string;
|
|
148
|
-
limits: SandboxLimits;
|
|
149
|
-
signal: AbortSignal;
|
|
150
|
-
}): Promise<FileSystemHandle>;
|
|
151
|
-
/** Deletes the file system and its files. Succeeds when it does not exist. */
|
|
152
|
-
destroyFileSystem(fs: FileSystemHandle, signal: AbortSignal): Promise<void>;
|
|
153
|
-
/**
|
|
154
|
-
* Deletes the file system made under `name` by `createFileSystem`; succeeds when there is none.
|
|
155
|
-
* The kernel uses it when it has no handle (`createFileSystem` finished on the provider's side
|
|
156
|
-
* but the kernel stopped before recording the handle), and in its one-off cleanup of
|
|
157
|
-
* per-conversation sandboxes with `cap-<conversationId>` names that a `sandbox@1` provider's
|
|
158
|
-
* `create` made together with their files (Docker: the `cap-<conversationId>-workspace` and
|
|
159
|
-
* `-skills` volumes); a provider removes those under the same call.
|
|
160
|
-
*/
|
|
161
|
-
destroyFileSystemByName(name: string, signal: AbortSignal): Promise<void>;
|
|
162
|
-
/**
|
|
163
|
-
* Creates an instance attached to `fileSystem`. Without `image` the provider uses its own
|
|
164
|
-
* published image. Throws {@link FileSystemGoneError} when the file system is gone.
|
|
165
|
-
*/
|
|
166
|
-
create(args: {
|
|
167
|
-
name: string;
|
|
168
|
-
image?: string;
|
|
169
|
-
limits: SandboxLimits;
|
|
170
|
-
fileSystem: FileSystemHandle;
|
|
171
|
-
signal: AbortSignal;
|
|
172
|
-
}): Promise<SandboxHandle>;
|
|
173
|
-
/** `gone` means the provider no longer has this instance. */
|
|
174
|
-
resume(h: SandboxHandle, signal: AbortSignal): Promise<"resumed" | "gone">;
|
|
175
|
-
/** Files must be kept. Succeeds when the instance does not exist. */
|
|
176
|
-
suspend(h: SandboxHandle, signal: AbortSignal): Promise<void>;
|
|
177
|
-
/** Drops the instance only; the file system and its files are kept. Succeeds when it does not exist. */
|
|
178
|
-
destroy(h: SandboxHandle, signal: AbortSignal): Promise<void>;
|
|
179
|
-
/**
|
|
180
|
-
* Drops the instance made under `name` by `create` (instance only, files kept); succeeds when
|
|
181
|
-
* there is none. The kernel uses it when it has no handle (`create` finished on the provider's
|
|
182
|
-
* side but the kernel stopped before recording the handle), and in its one-off cleanup of
|
|
183
|
-
* per-conversation sandboxes with `cap-<conversationId>` names made by a `sandbox@1` provider's
|
|
184
|
-
* `create`.
|
|
185
|
-
*/
|
|
186
|
-
destroyByName(name: string, signal: AbortSignal): Promise<void>;
|
|
187
|
-
/**
|
|
188
|
-
* Kills every running command started through `exec` in this instance (and the processes they
|
|
189
|
-
* spawned that did not start their own session). The kernel calls it only when no other holder
|
|
190
|
-
* can be running commands (an instance just resumed from `suspended`, or under the exclusive
|
|
191
|
-
* lease), never while another session may be; to clean up after one crashed holder it uses
|
|
192
|
-
* {@link SandboxProvider.killTagged}. Processes a command put in the background in their own
|
|
193
|
-
* session are not guaranteed to be killed.
|
|
194
|
-
*/
|
|
195
|
-
killAll(h: SandboxHandle, signal: AbortSignal): Promise<void>;
|
|
196
|
-
/**
|
|
197
|
-
* Kills every running `exec` command labelled with one of `tags` (and its process tree), leaving
|
|
198
|
-
* other commands running. The kernel calls it for the tags of holders that crashed while live
|
|
199
|
-
* holders keep running commands. Tags match {@link SANDBOX_TAG_RE}. Match whole tags: one tag
|
|
200
|
-
* may be a prefix of another (`ab` of `ab-cd`), and killing `ab` must not touch `ab-cd`'s
|
|
201
|
-
* commands.
|
|
202
|
-
*/
|
|
203
|
-
killTagged(h: SandboxHandle, tags: string[], signal: AbortSignal): Promise<void>;
|
|
204
|
-
/**
|
|
205
|
-
* Runs a command. `maxOutputBytes` caps stdout and stderr **combined**; the rest is dropped and
|
|
206
|
-
* `truncated` is true.
|
|
207
|
-
*/
|
|
208
|
-
exec(h: SandboxHandle, args: {
|
|
209
|
-
command: string;
|
|
210
|
-
cwd?: string;
|
|
211
|
-
env?: Record<string, string>;
|
|
212
|
-
timeoutMs: number;
|
|
213
|
-
maxOutputBytes: number;
|
|
214
|
-
signal: AbortSignal;
|
|
215
|
-
/**
|
|
216
|
-
* The holder's tag ({@link SANDBOX_TAG_RE}); label the command with it so
|
|
217
|
-
* {@link SandboxProvider.killTagged} can find it.
|
|
218
|
-
*/
|
|
219
|
-
tag: string;
|
|
220
|
-
/** Who runs the command; informational in phase 1 (record it, do not act on it). */
|
|
221
|
-
actor: SandboxActor;
|
|
222
|
-
}): Promise<ExecResult>;
|
|
223
|
-
/**
|
|
224
|
-
* Reads a file (at most `maxBytes`; longer files are truncated and `truncated` is true). Returns
|
|
225
|
-
* null when it does not exist or is a directory.
|
|
226
|
-
*/
|
|
227
|
-
readFile(h: SandboxHandle, path: string, opts: {
|
|
228
|
-
maxBytes: number;
|
|
229
|
-
signal: AbortSignal;
|
|
230
|
-
}): Promise<{
|
|
231
|
-
data: Uint8Array;
|
|
232
|
-
truncated: boolean;
|
|
233
|
-
} | null>;
|
|
234
|
-
/** Parent directories are created. */
|
|
235
|
-
writeFile(h: SandboxHandle, path: string, data: Uint8Array, signal: AbortSignal): Promise<void>;
|
|
236
|
-
stat(h: SandboxHandle, path: string, signal: AbortSignal): Promise<{
|
|
237
|
-
size: number;
|
|
238
|
-
isDir: boolean;
|
|
239
|
-
} | null>;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* The root-independent checks of a path inside an instance (non-empty, at most 4096 characters, no
|
|
243
|
-
* control characters or backslashes, absolute, no empty or `..` segments); returns the errors,
|
|
244
|
-
* empty when valid. {@link validateSandboxPath} adds root membership.
|
|
245
|
-
*/
|
|
246
|
-
export declare function validateSandboxPathShape(p: string): string[];
|
|
247
|
-
/**
|
|
248
|
-
* Checks a path inside an instance; returns the errors, empty when valid: the
|
|
249
|
-
* {@link validateSandboxPathShape} checks, then root membership. `roots`: the instance's roots
|
|
250
|
-
* ({@link rootsOf}); absent means {@link SANDBOX_ROOTS}. The path must be one of them or under one.
|
|
251
|
-
*/
|
|
252
|
-
export declare function validateSandboxPath(p: string, roots?: SandboxRoots): string[];
|
|
253
|
-
/** 校验出站白名单主机名:小写、无协议与端口、可选前导 `*.`、IDN 只认 punycode。 */
|
|
254
|
-
export declare function validateAllowHost(h: string): string[];
|