Type System - cprima-forks/uipath-ai-skills GitHub Wiki

Type System

Types flow through the system in short-form names (from JSON specs) and must be resolved to XAML-qualified names before emission.

TYPE_MAP_BASE

The canonical mapping from short-form names to XAML-qualified types, defined in utils.py:

Short form XAML type Notes
String x:String
Int32 x:Int32
Int64 x:Int64
Boolean x:Boolean
Double x:Double
Decimal x:Decimal
Object x:Object
DateTime s:DateTime
TimeSpan s:TimeSpan
SecureString ss:SecureString triggers has_securestring flag
UiElement ui:UiElement
QueueItem ui:QueueItem
GenericValue ui:GenericValue
DataTable sd:DataTable triggers has_datatable flag
DataRow sd:DataRow
Dictionary scg:Dictionary(x:String, x:Object)
Array_String s:String[]
Array_Int32 s:Int32[]
Array_Object s:Object[]
JObject njl:JObject
JArray njl:JArray
MailMessage snm:MailMessage

Short forms are used in JSON specs for arguments[].type and variables[].type. _normalize_argument_type in _wf_types.py resolves them to XAML types at generation time.

Common LLM Hallucinations

_normalize_argument_type catches two specific patterns LLMs frequently produce:

Dictionary long form: LLMs write Dictionary(String, Object) or scg:Dictionary(x:String, x:Object). Both are normalised to the correct scg:Dictionary(x:String, x:Object).

x: array types: LLMs write x:String[]. The x: (XAML language) namespace has no array support. The correct prefix is s: (System): s:String[]. The _ARRAY_TYPE_FIXES dict in _helpers.py handles this correction.

_VAR_TYPE_LOOKUP and Type Inference

At the start of generate_workflow, variable and argument types are indexed by name:

_VAR_TYPE_LOOKUP = {v["name"]: TYPE_MAP_BASE.get(v["type"], v["type"])
                    for v in variables + arguments}

This lookup enables multiple_assign to infer the type argument for a two-element assignment [variable, expression] without requiring the spec to explicitly supply the type:

if len(assign) == 2:
    inferred_type = _VAR_TYPE_LOOKUP.get(assign[0], "x:String")
    enriched.append([assign[0], assign[1], inferred_type])

Without this enrichment, MultipleAssign would emit x:TypeArguments="x:String" for every assignment, which is wrong for DataTable or UiElement variables.

Type Validation in Spec Validation

_validate_spec in _wf_validation.py checks argument and variable types against TYPE_MAP_BASE keys plus already-prefixed types (e.g., x:String, sd:DataTable). Bare unprefixed types that are not in TYPE_MAP_BASE are rejected with a descriptive error pointing to valid short forms.