roboto.templating#
Generic {{name}} placeholder substitution shared across the SDK.
The same lightweight templating primitive powers reusable agent definitions
(client-side substitution of caller-supplied values before a thread starts) and
event triggers (server-side substitution of event-derived variables into a
target’s request). A VariableResolver binds placeholders to a source of
values, so the substitution engine stays agnostic to where those values come from.
Submodules#
Package Contents#
- class roboto.templating.MappingResolver(values)#
A
VariableResolverbacked by a flatname -> valuemapping.Values are coerced to
stron access; a missing key or aNonevalue resolves toNone(leaving the placeholder unexpanded).- Parameters:
values (Mapping[str, Any])
- resolve(name)#
- Parameters:
name (str)
- Return type:
Optional[str]
- roboto.templating.PLACEHOLDER_RE#
Recognizes
{{name}}placeholders. Names start with a letter or underscore; dots are allowed so dotted names ({{dataset.id}},{{action.name}}) work as a namespace convention for entity-bound expansion by aVariableResolver. The engine treats the full dotted string as one opaque key — the resolver decides what, if anything, it expands to.
- roboto.templating.VARIABLE_NAME_RE#
Mirrors
PLACEHOLDER_REso every declared variable name is referenceable by{{name}}.
- class roboto.templating.VariableResolver#
Bases:
ProtocolDecides what each
{{name}}placeholder expands to during substitution.Implementations bind placeholders to a source of values — a flat mapping for agent launch, or a lazily-hydrated event namespace for triggers — keeping the substitution engine itself agnostic to where values come from.
- resolve(name)#
Return the substitution string for placeholder
name, orNone.- Parameters:
name (str) – The placeholder name written between
{{and}}, dots included (e.g.dataset.id).- Returns:
The string to splice in, or
Noneto leave the literal{{name}}in place.- Return type:
Optional[str]
- roboto.templating.collect_placeholders(node)#
Return every
{{name}}placeholder found in the string leaves ofnode.nodeis the JSON form of a template (nested dicts, lists, scalars). Only string values are scanned; placeholder syntax in dict keys is rejected so a templated key can’t silently collapse two entries into one.- Raises:
ValueError – A dict key contains
{{...}}placeholder syntax.- Parameters:
node (Any)
- Return type:
set[str]
- roboto.templating.substitute(node, resolver)#
Return a copy of
nodewith each{{name}}in a string leaf expanded viaresolver.Embedded and repeated placeholders within one string are supported. A name the resolver returns
Nonefor is left as the literal{{name}}; callers that require full resolution validate the placeholder set up front withcollect_placeholders().- Parameters:
node (Any)
resolver (VariableResolver)
- Return type:
Any