Metadata system
The TEN framework uses a metadata system to define, validate, and manage configuration data across all components in your application. The system applies consistently to all package types in the framework, namely:
- App: Main application containers that orchestrate the overall system behavior
- Extension: Individual functional components that implement specific features or capabilities
- Extension Group: Collections of related extensions that work together as a coordinated unit
- Protocol: Communication protocol handlers that manage data exchange between components
- System: Core framework components that provide essential runtime services
The metadata system provides several key benefits:
- Type safety and validation: Ensures data integrity by validating property types and values at runtime, preventing common configuration errors before they cause application failures.
- Clear API definitions: Establishes standardized interfaces between components, making it easier to understand how different parts of your application communicate and what data they expect.
- Runtime flexibility: Allows you to modify configuration settings while your application runs, enabling dynamic behavior changes without requiring restarts or redeployment.
- Dependency management: Tracks relationships between components and their version requirements, ensuring compatibility and proper loading order.
The metadata system consists of two main files in each package:
manifest.json
for structural definitions and schemasproperty.json
for runtime configuration values
Manifest File System
The manifest.json
file serves as the primary metadata definition for each TEN package. Located in the package's root directory, it defines the package's core metadata and API specifications:
- Package identification: Name and version following semantic versioning
- Dependencies: Required packages and their version constraints
- API schema definitions: Type definitions for properties and messages
- Property schemas: Data type specifications for package configuration
- Message schemas: Input/output message format definitions
The TEN schema in manifest.json
provides metadata about the package's external API, enabling:
- Property validation: Validates properties when the runtime gets/sets them
- Data conversion: Converts JSON to TEN package or message properties using the
from_json
API - Compatibility checks: Verifies if messages can be routed between extensions according to the TEN schema
File structure and required fields
The manifest.json
file contains the following main sections:
type
: Package type: app, extension, extension_group, protocol, systemname
: Unique package identifierversion
: Semantic version numberdependencies
: Array of required packages with version constraintsapi
: Complete API specification including properties and message definitions
Dependencies Section
Dependencies specify other packages required for this package to function properly. Each dependency includes:
API schema definitions
The api
section defines the complete interface specification for the package, including:
property
: Package property schemas with type definitionscmd_in
/cmd_out
: Command message schemas for input and outputdata_in
/data_out
: Data message schemas for input and outputvideo_frame_in
/video_frame_out
: Video frame message schemasaudio_frame_in
/audio_frame_out
: Audio frame message schemas
The TEN schema in manifest.json
is not a JSON schema. It describes TEN value metadata that are central to the TEN runtime, while JSON serves only as a representation format.
Example manifest.json
:
Property File System
The property.json
file, located in the package's root directory, contains runtime configuration values that the TEN framework can modify during execution. These properties:
- Store configurable settings and parameters
- Support runtime modification without restarting the application
- Must conform to any schema definitions specified in the manifest file
The property system enables dynamic configuration management, allowing your TEN application to adapt its behavior based on runtime conditions or user preferences.
Property types
The TEN framework manages two distinct types of properties:
-
Message properties are associated with messages exchanged between extensions within the framework. These properties define specific data or parameters carried within a message, such as:
- Command parameters and arguments
- Data payloads and content
- Metadata for audio/video frames
- Custom message attributes
-
Package properties are associated with TEN packages themselves (extensions, apps, etc.). These properties define configuration or settings specific to a package, such as:
- Runtime behavior settings
- Initialization parameters
- Feature flags and options
- Connection and timeout values
Defining properties in property.json
The property.json
file defines package properties using JSON format. Properties can include various data types and nested structures:
Each property name in the property.json
file must be unique.
Property schema definitions
You can define TEN schemas for properties in the manifest.json
file, enabling the TEN runtime to handle these properties more effectively. The runtime behavior depends on whether properties have corresponding schema definitions:
Property defined | Schema defined | Runtime behavior |
---|---|---|
Yes | Yes | Validates values against schema and enforces type checking |
Yes | No | Uses default JSON handling (numbers become float64) |
Property validation rules
When TEN schemas are defined for properties, the runtime validates:
- Type compliance: Ensures property values match their declared types
- Value constraints: Enforces any specified ranges or validation rules
- Required properties: Verifies that mandatory properties are present
- Format validation: Checks string formats, numeric ranges, and other constraints
Setting properties in start_graph
You can override default property values when starting a TEN application by specifying them in the start_graph
command. The runtime processes these values according to their TEN schema definitions and applies them to the appropriate package instances: