manifest.json

manifest.json

manifest.json

Function

manifest.json is the identity and runtime declaration of the extension package. It tells BT: whether this package is a .bts extension, what the extension is called, what backend is used to run it, where is the entry file, what is the minimum BT version, what permissions are required, how many parameters and return values are allowed to be transmitted in a single call, and the extension runtime mode.

Syntax

Pure BT extension example:

WASM extension only needs to change the backend related fields to:

WASM shared runtime Configuration example:

Parameters

FieldTypeDescription
formatStringFixed to bts.
format_versionNumberPackage format version, use 1.
nameStringExtension package name, only lowercase letters, numbers and underscores can be used, and it starts with a lowercase letter.
versionStringExtend its own version, using three-stage SemVer, such as 1.0.0.
descriptionStringOptional description text.
authorStringOptional author text.
kindStringBackend type, can only be bt or wasm.
abiStringBackend ABI, must match kind.
bt_min_versionStringMinimum BT version required by the extension.
api_versionNumberbindings semantic version, use 1.
entryStringThe relative path within the package of the backend entry file.
bindingsStringbindings Relative path within the package describing the file.
permissionsArrayArray of capability permissions of the extended declaration. Only write the required permissions; do not write the unnecessary permissions.
limitsObjectThe upper limit of the parameter and return value encoding size for a single call.
runtimeObjectOptional runtime mode configuration; default is equivalent to mode: "thread_local".

kind and abi

kindabimeaning
btbts-bt-1The entry file is BT source code, and the functions and object methods are executed by pure BT Runner.
wasmbts-wasi-1The entry file is the WASM module, and the call is completed through WASI P1 and BtValueBinary.

If kind and abi do not match, the extension will report an error during the loading phase.

runtime runtime configuration

FieldTypeDefault valueDescription
modeStringthread_localRuntime mode, can only be thread_local or shared.
workersNumber1Shared mode worker number, range 1..=64.
queue_limitNumber1024shared mode waiting queue length, range 1..=65536.
call_timeout_msNumber30000Shared mode single call timeout, range 1..=300000.
idle_ttl_msNumber300000Shared mode idle retention time, range 1..=3600000.
max_objectsNumber65536The upper limit of the number of shared mode service-level objects, range 1..=65536.
max_worker_objectsNumber4096The upper limit of the number of objects in a single worker in shared mode is in the range of 1..=4096 and cannot be greater than max_objects.
max_inflight_callsNumber64The upper limit of the number of calls in shared mode execution, the range is 1..=4096.

When runtime is missing, the extension continues to use the current thread's local Runner cache and does not change existing extension behavior. The first version of mode=shared only allows kind=wasm. Pure BT extension declaration shared will report an error during the manifest verification phase.

The current version has been connected to the project level ExtensionService. The WASM extension that declares mode=shared will create an independent bounded worker queue. The entry function can return the original value or the extended object through the worker; when returning the extended object, the host will allocate host_object_id and route back to the local object ID of the worker who created the object before calling the object method. A Chinese error will be returned when the queue is full, the service is shut down, the call during execution exceeds the upper limit, the number of service-level objects or the number of single worker objects exceeds the upper limit.

call_timeout_ms does not just call the thread wait limit. The shared worker will enable the Wasmtime epoch interrupt. After the timeout, the host will mark the target worker, trigger the WASM trap, and rebuild the WASM Store/Instance after the worker returns to avoid timeout calls permanently occupying service capacity. Service statistics will include workers, queued, running, completed, failed, timed_out, objects and the number of objects per worker.

Permission Description

PermissionDescription
fs_readAllows declaration of read file path parameters.
fs_writeAllows declaration of write file path parameters.
netReserved for network communication capability declaration.
httpReserved for HTTP client capability declarations.
processReserved for process capability declarations.
envReserved for environment variable capability declarations.

permissions Only string arrays can be used, such as ["fs_read", "fs_write"]. The permissions must be allowed at the same time as the permission configuration of the running process. The extension declares a certain permission, but when the running process prohibits this capability, the extension will fail to load.

Return Value

manifest.json is not a script function and has no runtime return value. When the verification is successful, BT will continue to read bindings and entry files; when the verification fails, the loading process returns a Chinese error and stops loading the extension.

Code Examples

Correspondence between pure BT extension entry and manifest:

manifest.entry points to src/lib.bt containing this source code, manifest.kind writes bt, manifest.abi writes bts-bt-1.

Notes

  • entry and bindings must be safe relative paths within the package. Absolute paths, backslashes, empty paths, ., .. or paths with drive letters cannot be used.
  • entry cannot point to the same file as bindings.
- limits.max_args_bytes and limits.max_result_bytes cannot be 0 or exceed the host hard cap.
  • Unknown fields cannot appear in runtime to prevent extension authors from mistakenly thinking that unimplemented configurations have taken effect.
  • runtime.mode=shared does not change the BT request variable lifecycle, nor does it allow normal script global variables to be shared across requests.
- runtime.mode=shared already supports extended object host routing; when close() or dispose() is marked as lifecycle: "dispose" and the call succeeds, the host object handle becomes invalid.
  • call_timeout_ms of runtime.mode=shared will trigger the WASM interrupt and running state reconstruction of the target worker, and cannot be used to accurately cancel the long-term blocking host call.
  • Extension names, entry names, parameter names and method names should comply with BT's snake_case naming style.