Skip to content

Agent templates payloads service

consortium.server.services.agent_templates_payloads_service

AgentTemplatesPayloadsService(agent_template_id)

reserve_payload_id()

See PayloadsService.reserve_resource_id.

create_payload_file(build_parameters, content, payload_data=None, payload_id=None, name=None, description='') async

Creates a file-based payload associated with the bound agent template.

Forwards to PayloadsService.create_payload_file, injecting the agent template ID bound to this service so the caller does not need to supply it.

Parameters:

Name Type Description Default
build_parameters dict[str, Any]

Parameters used to build the agent generator from the bound agent template (validated against the template).

required
content str | bytes | TextIO | BinaryIO

The file content to write to the repository, supplied either as an in-memory str or bytes, or as an open text or binary file object that is read to exhaustion.

required
payload_data dict[str, Any] | None

Arbitrary metadata attached to the payload. When None, no extra metadata is stored.

None
payload_id str | UUID | None

A previously reserved ID to assign to this payload. When None, a new ID is generated automatically.

None
name str | None

A human-readable name for the payload file. When None, the resource UUID is used.

None
description str

An optional description for the payload.

''

Returns:

Type Description
Payload

The created payload.

Raises:

Type Description
AgentTemplateIDNotFoundError

If the bound agent template ID no longer exists.

MissingRequiredAgentTemplateOptionError

If a required option is absent from build_parameters.

AgentTemplateOptionNotFoundError

If build_parameters contains an unknown option name.

AgentTemplateOptionValueValidationError

If an option value in build_parameters fails type or constraint validation.

AgentTemplateValidatingFunctionError

If the agent template's validating function rejects the resolved options.

ResourceIDReservationNotFoundError

If payload_id is provided but has no corresponding reservation.

RepositoryResourceFileSystemError

If the file cannot be written to disk.

RepositoryMetadataFileSystemError

If the metadata file cannot be written to disk.

create_payload_directory(build_parameters, content, payload_data=None, payload_id=None, archive_file_format='zip', name=None, description='') async

Creates a directory-based payload associated with the bound agent template.

Forwards to PayloadsService.create_payload_directory, injecting the agent template ID bound to this service so the caller does not need to supply it.

Parameters:

Name Type Description Default
build_parameters dict[str, Any]

Parameters used to build the agent generator from the bound agent template (validated against the template).

required
content bytes | BinaryIO

The archive content to extract into the repository directory, supplied either as raw bytes or as an open binary file object that is read to exhaustion.

required
payload_data dict[str, Any] | None

Arbitrary metadata attached to the payload. When None, no extra metadata is stored.

None
payload_id str | UUID | None

A previously reserved ID to assign to this payload. When None, a new ID is generated automatically.

None
archive_file_format Literal['zip', 'tar', 'gztar', 'bztar', 'xztar']

The format of the archive to extract. Defaults to "zip".

'zip'
name str | None

A human-readable name for the payload directory. When None, the resource UUID is used.

None
description str

An optional description for the payload.

''

Returns:

Type Description
Payload

The created payload.

Raises:

Type Description
AgentTemplateIDNotFoundError

If the bound agent template ID no longer exists.

MissingRequiredAgentTemplateOptionError

If a required option is absent from build_parameters.

AgentTemplateOptionNotFoundError

If build_parameters contains an unknown option name.

AgentTemplateOptionValueValidationError

If an option value in build_parameters fails type or constraint validation.

AgentTemplateValidatingFunctionError

If the agent template's validating function rejects the resolved options.

ResourceIDReservationNotFoundError

If payload_id is provided but has no corresponding reservation.

RepositoryResourceFileSystemError

If the directory cannot be created or the archive cannot be unpacked into it.

RepositoryMetadataFileSystemError

If the metadata file cannot be written to disk.

add_payload_file(build_parameters, path, payload_data=None, payload_id=None, name=None, description='', copy=False) async

Registers an existing file on disk as a payload for the bound agent template.

Forwards to PayloadsService.add_payload_file, injecting the agent template ID bound to this service so the caller does not need to supply it.

Parameters:

Name Type Description Default
build_parameters dict[str, Any]

Parameters used to build the agent generator from the bound agent template (validated against the template).

required
path Path | str

Path to the existing file to register.

required
payload_data dict[str, Any] | None

Arbitrary metadata attached to the payload. When None, no extra metadata is stored.

None
payload_id str | UUID | None

A previously reserved ID to assign to this payload. When None, a new ID is generated.

None
name str | None

A human-readable name for the payload file. When None, the original filename is used.

None
description str

An optional description for the payload.

''
copy bool

When False (default) the source file is moved into the repository. When True the source file is copied and the original is left in place.

False

Returns:

Type Description
Payload

The registered payload.

Raises:

Type Description
AgentTemplateIDNotFoundError

If the bound agent template ID no longer exists.

MissingRequiredAgentTemplateOptionError

If a required option is absent from build_parameters.

AgentTemplateOptionNotFoundError

If build_parameters contains an unknown option name.

AgentTemplateOptionValueValidationError

If an option value in build_parameters fails type or constraint validation.

AgentTemplateValidatingFunctionError

If the agent template's validating function rejects the resolved options.

ResourceIDReservationNotFoundError

If payload_id is provided but has no corresponding reservation.

RepositoryResourceFileSystemError

If no file exists at path, or the file cannot be moved or copied into the repository.

RepositoryMetadataFileSystemError

If the metadata file cannot be written to disk afterwards.

add_payload_directory(build_parameters, path, payload_data=None, payload_id=None, name=None, description='', copy=False) async

Registers an existing directory on disk as a payload for the bound agent template.

Forwards to PayloadsService.add_payload_directory, injecting the agent template ID bound to this service so the caller does not need to supply it.

Parameters:

Name Type Description Default
build_parameters dict[str, Any]

Parameters used to build the agent generator from the bound agent template (validated against the template).

required
path Path | str

Path to the existing directory to register.

required
payload_data dict[str, Any] | None

Arbitrary metadata attached to the payload. When None, no extra metadata is stored.

None
payload_id str | UUID | None

A previously reserved ID to assign to this payload. When None, a new ID is generated.

None
name str | None

A human-readable name for the payload directory. When None, the original directory name is used.

None
description str

An optional description for the payload.

''
copy bool

When False (default) the source directory is moved into the repository. When True the source directory is copied and the original is left in place.

False

Returns:

Type Description
Payload

The registered payload.

Raises:

Type Description
AgentTemplateIDNotFoundError

If the bound agent template ID no longer exists.

MissingRequiredAgentTemplateOptionError

If a required option is absent from build_parameters.

AgentTemplateOptionNotFoundError

If build_parameters contains an unknown option name.

AgentTemplateOptionValueValidationError

If an option value in build_parameters fails type or constraint validation.

AgentTemplateValidatingFunctionError

If the agent template's validating function rejects the resolved options.

ResourceIDReservationNotFoundError

If payload_id is provided but has no corresponding reservation.

RepositoryResourceFileSystemError

If no directory exists at path, or the directory or any file within it cannot be moved or copied into the repository.

RepositoryMetadataFileSystemError

If the metadata file cannot be written to disk afterwards.

delete_payload_by_payload_id(payload_id) async

Deletes a payload's repository resource.

Forwards to PayloadsService.delete_payload_by_resource_id. A payload is just a repository resource whose data field carries its metadata, so deleting the resource removes the payload in full and a PAYLOAD_DELETED event is emitted unconditionally on success.

Parameters:

Name Type Description Default
payload_id str | UUID

The ID of the payload to delete.

required

Raises:

Type Description
ResourceNotFoundError

If no payload with the given ID exists.

RepositoryResourceFileSystemError

If the resource cannot be removed from disk.

RepositoryMetadataFileSystemError

If the metadata file cannot be written to disk.

get_payload_by_payload_id(payload_id)

See PayloadsService.get_payload_by_resource_id.

get_all_payloads()

See PayloadsService.get_all_payloads.