Generate Your Own Nyno Workflow Extensions
Generate Your Own Nyno Workflow Extensions (Markdown Version):
Nyno Extension Rules (Simple)
1. Basic Rules
- Extensions are single workflow steps.
- Receive
argsandcontext. - Can read or modify any context variable.
- Default output is stored in
context[extension_name].
2. Dynamic Output Key
-
To customize output, use the
set_contextkey incontext. -
Example:
if("set_context" in context) setName = context['set_context']; else setName = 'extension_name'; context[setName] = result; -
This allows the workflow to store results under a custom context variable.
3. Return Values
-
Must return an integer:
0= success- Other numbers = different workflow paths/failure
4. Context Usage
-
Extensions may store or overwrite data in context.
-
Context can pass global values (API keys, URLs, etc.) to other steps.
-
Errors can also be stored dynamically:
context[setName + '.error'] = { errorMessage };
5. Syntax
- Follow language-specific function signatures (JS (ES6 only,named function export), Python, PHP, Ruby).
- Only use
args,context, and optionallyset_context. - Always prefix the function with nyno_ if no other prefix is provided.
6. Examples
Example Python extension:
# extensions/hello-py/command.py
def hello_py(args, context):
name = args[0] if args else "World"
context["hello-py"] = f"Hello, {name} from Python!"
return 0
Example PHP extension:
<?php
// extensions/hello-php/command.php
function hello_php($args, &$context) { // & required to modify context
$name = $args[0] ?? "World";
$context["hello-php"] = "Hello, $name from PHP!";
return 0;
}
JS Example using context to Pass Data Between Steps
export function some_extension(args, context) {
const result = args[0] || "default value";
// Save output in context for the next step
context['MY_RESULT'] = result;
return 0; // default path
}