Expression Functions Reference
This reference lists all available functions in KDeps expressions. These functions can be used in any field that supports string interpolation ({{ }}) or in expr blocks.
Core Functions
get(key, typeHint?)
Retrieves data from any source.
- key: The key to look up.
- typeHint (optional): Force a specific source (
param,header,session,memory,item,env,file,filepath,filetype).
Examples:
get('q') # Auto-detect source
get('Authorization', 'header') # Get from headers
get('user_id', 'session') # Get from session
get('API_KEY', 'env') # Get environment variableset(key, value, storage?)
Stores data in memory or session.
- key: The key to store.
- value: The value to store.
- storage (optional): Storage type (
memoryorsession). Default ismemory.
Examples:
set('count', 1) # Store in memory (request-scoped)
set('user', data, 'session') # Store in session (persistent)file(pattern, selector?)
Accesses uploaded files or local files.
- pattern: Glob pattern or file name.
- selector (optional):
first,last,count,all,mime:<type>.
Examples:
file('*.jpg') # Get all JPG files content
file('*.pdf', 'first') # Get content of first PDF
file('*', 'count') # Get total file countinfo(field)
Retrieves request metadata.
- field: One of
requestId,timestamp,path,method,clientIp,sessionId,filecount,files,filetypes.
Examples:
info('requestId') # Get request ID
info('clientIp') # Get client IPData Handling Functions
json(data)
Converts data to a JSON string.
- data: The data to stringify.
Examples:
json(get('userData')) # Convert object to JSON stringsafe(obj, path)
Safely accesses nested properties without panicking on nil values.
- obj: The object to access.
- path: Dot-notation path to the property.
Examples:
safe(user, "profile.address.city") # Returns city or nil if path invaliddebug(obj)
Returns a pretty-printed JSON string representation of an object for debugging.
- obj: The object to inspect.
Examples:
debug(get('httpResponse')) # Inspect complex object structuredefault(value, fallback)
Returns a fallback value if the primary value is nil or empty.
- value: The value to check.
- fallback: The value to return if primary is nil/empty.
Examples:
default(get('limit'), 10) # Return 10 if limit is missingInput/Output Functions
input(name, type?)
Accesses input data (similar to get but strictly for inputs).
- name: Input name.
- type (optional):
param,header,body.
Examples:
input('q') # Get query param
input('body') # Get request bodyoutput(resourceId)
Accesses the output of a completed resource.
- resourceId: The actionId of the resource.
Examples:
output('llmResource') # Get LLM outputIteration Functions
item(type?)
Accesses current iteration context.
- type (optional):
current,prev,next,index,count,values.
Examples:
item('current') # Current item value
item('index') # Current index (0-based)
item('count') # Total items countSession Functions
session()
Returns the entire session data object.
Examples:
session() # Get all session data