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[set_context], whereset_contextdefaults to"prev".
2. Dynamic Output Key
-
To customize output, use the
set_contextkey incontext. -
If
set_contextis not provided, it defaults to"prev". -
Example:
const setName = context?.set_context ?? "prev"; context[setName] = result; -
This allows the workflow to store results under a custom context variable or reuse the previous step’s output.
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 using the same
set_contextvalue:context[setName + ".error"] = { errorMessage };
5. Syntax
- Follow language-specific function signatures (JS (ES6 only, named function export), Python, PHP, Ruby).
- Only use
argsandcontext. - Always prefix the function with
nyno_if no other prefix is provided.
6. Language Choice Guideline
- Choose the language that best fits the task.
- Prefer the language with the strongest or most mature library support for what you need (e.g. APIs, SDKs, file formats, ML, scraping).
- Performance, ecosystem, and developer ergonomics are valid reasons to choose one language over another.
7. Examples
Example Python extension
# extensions/hello-py/command.py
def hello_py(args, context):
name = args[0] if args else "World"
set_name = context.get("set_context", "prev")
context[set_name] = 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";
$setName = $context["set_context"] ?? "prev";
$context[$setName] = "Hello, $name from PHP!";
return 0;
}
Example Ruby extension
# extensions/hello-rb/command.rb
def hello_rb(args, context)
name = args[0] || "World"
set_name = context["set_context"] || "prev"
context[set_name] = "Hello, #{name} from Ruby!"
return 0
end
JS Example using context to pass data between steps
export function some_extension(args, context) {
const result = args[0] || "default value";
const setName = context?.set_context ?? "prev";
// Save output in context for the next step
context[setName] = result;
return 0; // default path
}