From 89d3bf5a3d8347c2d14d5a4bcaf5457a99969ffb Mon Sep 17 00:00:00 2001 From: hiren <20088337+hirenr@users.noreply.github.com> Date: Wed, 12 Nov 2025 00:49:29 +0530 Subject: [PATCH 01/10] Simplification of run:* tasks Signed-off-by: hiren <20088337+hirenr@users.noreply.github.com> --- dsl-reference.md | 45 +++++++++++++++++++++++++++++++++++++++----- schema/workflow.yaml | 34 ++++++++++++++++++++++++++------- 2 files changed, 67 insertions(+), 12 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index c605988e..8c3ee3b8 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -928,6 +928,8 @@ Enables the execution of external processes encapsulated within a containerized | ports | `map` | `no` | The container's port mappings, if any | | volumes | `map` | `no` | The container's volume mappings, if any | | environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | +| stdin | `string` | `no` | A runtime expression, if any, passed as argv to the command or default container CMD| +| arguments | `string[]` | `no` | A list of the arguments, if any, passed as argv to the command or default container CMD | | lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. | ###### Examples @@ -939,10 +941,28 @@ document: name: run-container-example version: '0.1.0' do: +document: + dsl: 1.0.0 + namespace: examples + name: call-script-input-type-example + version: 1.0.0-alpha1 +do: + - setInput: + set: + message: Hello World - runContainer: + input: + from: ${ .message } run: container: - image: fake-image + image: alpine + command: | + input=$(cat) + echo "STDIN was: $input" + echo "ARGS are $1 $2" + arguments: + - Foo + - Bar ``` > [!NOTE] @@ -961,9 +981,11 @@ Enables the execution of custom scripts or code within a workflow, empowering wo | language | `string` | `yes` | The language of the script to run.
*Supported values are: [`js`](https://tc39.es/ecma262/2024/) and [`python`](https://www.python.org/downloads/release/python-3131/).* | | code | `string` | `no` | The script's code.
*Required if `source` has not been set.* | | source | [externalResource](#external-resource) | `no` | The script's resource.
*Required if `code` has not been set.* | -| arguments | `map` | `no` | A list of the arguments, if any, of the script to run | +| stdin | `string` | `no` | A runtime expression, if any, to the script as standard input (stdin).| +| arguments | `string[]` | `no` | A list of the arguments, if any, to the script as argv | | environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured script process | + > [!WARNING] > To ensure cross-compatibility, Serverless Workflow strictly limits the versions of supported scripting languages. These versions may evolve with future releases. If you wish to use a different version of a language, you may do so by utilizing the [`container process`](#container-process). @@ -1001,7 +1023,8 @@ Enables the execution of shell commands within a workflow, enabling workflows to | Name | Type | Required | Description | |:--|:---:|:---:|:---| | command | `string` | `yes` | The shell command to run | -| arguments | `map` | `no` | A list of the arguments of the shell command to run | +| stdin | `string` | `no` | A runtime expression, if any, to the shell command as standard input (stdin).| +| arguments | `string[]` | `no` | A list of the arguments, if any, to the shell command as argv | | environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | ###### Examples @@ -1013,10 +1036,22 @@ document: name: run-shell-example version: '0.1.0' do: + - setInput: + set: + message: Hello World - runShell: + input: + from: ${ .message } run: shell: - command: 'echo "Hello, ${ .user.name }"' + stdin: ${ . } + command: | + input=$(cat) + echo "STDIN was: $input" + echo "ARGS are $1 $2" + arguments: + - Foo + - Bar ``` ##### Workflow Process @@ -2829,4 +2864,4 @@ Describes the client of a [Model Context Protocol (MCP)](https://modelcontextpro ```yaml name: synapse version: '1.0.0-alpha5.2' -``` \ No newline at end of file +``` diff --git a/schema/workflow.yaml b/schema/workflow.yaml index e47ff664..2859369a 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -809,6 +809,16 @@ $defs: type: object title: ContainerEnvironment description: A key/value mapping of the environment variables, if any, to use when running the configured process. + stdin: + type: string + title: ContainerStdin + description: A runtime expression, if any, passed as argv to the command or default container CMD + arguments: + type: array + title: ContainerArguments + description: A list of the arguments, if any, passed as argv to the command or default container CMD + items: + type: string lifetime: $ref: '#/$defs/containerLifetime' title: ContainerLifetime @@ -828,11 +838,16 @@ $defs: type: string title: ScriptLanguage description: The language of the script to run. + stdin: + type: string + title: ScriptStdin + description: A runtime expression, if any, to the script as standard input (stdin). arguments: - type: object + type: array title: ScriptArguments - description: A key/value mapping of the arguments, if any, to use when running the configured script. - additionalProperties: true + description: A list of the arguments, if any, to the script as argv + items: + type: string environment: type: object title: ScriptEnvironment @@ -870,11 +885,16 @@ $defs: type: string title: ShellCommand description: The shell command to run. + stdin: + type: string + title: ShellStdin + description: A runtime expression, if any, to the shell command as standard input (stdin). arguments: - type: object + type: array title: ShellArguments - description: A list of the arguments of the shell command to run. - additionalProperties: true + description: A list of the arguments, if any, to the shell command as argv + items: + type: string environment: type: object title: ShellEnvironment @@ -1928,4 +1948,4 @@ $defs: export: $ref: '#/$defs/export' title: SubscriptionIteratorExport - description: An object, if any, used to customize the content of the workflow context. \ No newline at end of file + description: An object, if any, used to customize the content of the workflow context. From 9a1d6ae742003938125e0d9f13e20afe1388d234 Mon Sep 17 00:00:00 2001 From: hiren <20088337+hirenr@users.noreply.github.com> Date: Wed, 12 Nov 2025 01:04:10 +0530 Subject: [PATCH 02/10] Added Examples Signed-off-by: hiren <20088337+hirenr@users.noreply.github.com> --- dsl-reference.md | 6 --- .../run-container-stdin-and-arguments.yaml | 22 +++++++++ examples/run-script-with-arguments.yaml | 14 ------ .../run-script-with-stdin-and-arguments.yaml | 46 +++++++++++++++++++ examples/run-shell-stdin-and-arguments.yaml | 22 +++++++++ 5 files changed, 90 insertions(+), 20 deletions(-) create mode 100644 examples/run-container-stdin-and-arguments.yaml delete mode 100644 examples/run-script-with-arguments.yaml create mode 100644 examples/run-script-with-stdin-and-arguments.yaml create mode 100644 examples/run-shell-stdin-and-arguments.yaml diff --git a/dsl-reference.md b/dsl-reference.md index 8c3ee3b8..ddd7b257 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -940,12 +940,6 @@ document: namespace: test name: run-container-example version: '0.1.0' -do: -document: - dsl: 1.0.0 - namespace: examples - name: call-script-input-type-example - version: 1.0.0-alpha1 do: - setInput: set: diff --git a/examples/run-container-stdin-and-arguments.yaml b/examples/run-container-stdin-and-arguments.yaml new file mode 100644 index 00000000..9c40d549 --- /dev/null +++ b/examples/run-container-stdin-and-arguments.yaml @@ -0,0 +1,22 @@ +document: + dsl: '1.0.2' + namespace: test + name: run-container-stdin-and-arguments + version: '0.1.0' +do: + - setInput: + set: + message: Hello World + - runContainer: + input: + from: ${ .message } + run: + container: + image: alpine + command: | + input=$(cat) + echo "STDIN was: $input" + echo "ARGS are $1 $2" + arguments: + - Foo + - Bar diff --git a/examples/run-script-with-arguments.yaml b/examples/run-script-with-arguments.yaml deleted file mode 100644 index 78a25ea6..00000000 --- a/examples/run-script-with-arguments.yaml +++ /dev/null @@ -1,14 +0,0 @@ -document: - dsl: '1.0.2' - namespace: samples - name: run-script-with-arguments - version: 0.1.0 -do: - - log: - run: - script: - language: javascript - arguments: - message: ${ .message } - code: > - console.log(message) \ No newline at end of file diff --git a/examples/run-script-with-stdin-and-arguments.yaml b/examples/run-script-with-stdin-and-arguments.yaml new file mode 100644 index 00000000..f0a4b4ef --- /dev/null +++ b/examples/run-script-with-stdin-and-arguments.yaml @@ -0,0 +1,46 @@ +document: + dsl: 1.0.2 + namespace: examples + name: run-script-with-stdin-and-arguments + version: 1.0.0 +do: + - setInput: + set: + url: https://petstore.swagger.io/v2/pet/2 + - runScript: + output: + as: "${ fromjson }" + run: + script: + language: javascript + stdin: ${ . } + environment: + url: https://petstore.swagger.io/v2/pet/2 + arguments: + - https://petstore.swagger.io/v2/pet/2 + code: | + // Reading Input from STDIN + const input = await new Promise((resolve) => { + let data = ''; + process.stdin.setEncoding('utf8'); + process.stdin.on('data', chunk => data += chunk); + process.stdin.on('end', () => { + try { + resolve(JSON.parse(data)); + } catch (error) { + resolve({}) + } + }); + }); + + const responseStdin = await fetch(input.url); + + // Reading from argv + const [_, __, url] = process.argv; + const responseArgv = await fetch(url); + + // Reading from env + const envUrl = process.env.url; + const responseEnv = await fetch(envUrl); + + console.log(JSON.stringify({responseStdin: responseStdin.data, responseArgv: responseArgv.data, responseEnv: responseEnv.data })) diff --git a/examples/run-shell-stdin-and-arguments.yaml b/examples/run-shell-stdin-and-arguments.yaml new file mode 100644 index 00000000..5eeb4b6f --- /dev/null +++ b/examples/run-shell-stdin-and-arguments.yaml @@ -0,0 +1,22 @@ +document: + dsl: 1.0.2 + namespace: examples + name: run-script-with-stdin-and-arguments + version: 1.0.0 +do: + - setInput: + set: + message: Hello World + - runShell: + input: + from: ${ .message } + run: + shell: + stdin: ${ . } + command: | + input=$(cat) + echo "STDIN was: $input" + echo "ARGS are $1 $2" + arguments: + - Foo + - Bar From 0a0152c4de857cf8e62002c40d683258129955e6 Mon Sep 17 00:00:00 2001 From: hiren <20088337+hirenr@users.noreply.github.com> Date: Wed, 12 Nov 2025 01:16:33 +0530 Subject: [PATCH 03/10] Updated examples to add missing stdin in runContainer examples Signed-off-by: hiren <20088337+hirenr@users.noreply.github.com> --- dsl-reference.md | 1 + examples/run-container-stdin-and-arguments.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/dsl-reference.md b/dsl-reference.md index ddd7b257..ec4f5657 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -950,6 +950,7 @@ do: run: container: image: alpine + stdin: ${ . } command: | input=$(cat) echo "STDIN was: $input" diff --git a/examples/run-container-stdin-and-arguments.yaml b/examples/run-container-stdin-and-arguments.yaml index 9c40d549..1bed2db8 100644 --- a/examples/run-container-stdin-and-arguments.yaml +++ b/examples/run-container-stdin-and-arguments.yaml @@ -17,6 +17,7 @@ do: input=$(cat) echo "STDIN was: $input" echo "ARGS are $1 $2" + stdin: ${ . } arguments: - Foo - Bar From fe19df811202f0185e46e97003055a25c8059c39 Mon Sep 17 00:00:00 2001 From: hiren <20088337+hirenr@users.noreply.github.com> Date: Wed, 12 Nov 2025 00:49:29 +0530 Subject: [PATCH 04/10] Simplification of run:* tasks Signed-off-by: hiren <20088337+hirenr@users.noreply.github.com> --- dsl-reference.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dsl-reference.md b/dsl-reference.md index ec4f5657..de619d3a 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -930,6 +930,8 @@ Enables the execution of external processes encapsulated within a containerized | environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | | stdin | `string` | `no` | A runtime expression, if any, passed as argv to the command or default container CMD| | arguments | `string[]` | `no` | A list of the arguments, if any, passed as argv to the command or default container CMD | +| stdin | `string` | `no` | A runtime expression, if any, passed as argv to the command or default container CMD| +| arguments | `string[]` | `no` | A list of the arguments, if any, passed as argv to the command or default container CMD | | lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. | ###### Examples From 4b85bb94767b8ebf4d869b95c91410324cab5f14 Mon Sep 17 00:00:00 2001 From: hiren <20088337+hirenr@users.noreply.github.com> Date: Wed, 12 Nov 2025 02:39:54 +0530 Subject: [PATCH 05/10] Updated with a simpler example! Signed-off-by: hiren <20088337+hirenr@users.noreply.github.com> --- .../run-script-with-stdin-and-arguments.yaml | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/examples/run-script-with-stdin-and-arguments.yaml b/examples/run-script-with-stdin-and-arguments.yaml index f0a4b4ef..5faefd3d 100644 --- a/examples/run-script-with-stdin-and-arguments.yaml +++ b/examples/run-script-with-stdin-and-arguments.yaml @@ -4,43 +4,27 @@ document: name: run-script-with-stdin-and-arguments version: 1.0.0 do: - - setInput: - set: - url: https://petstore.swagger.io/v2/pet/2 - runScript: output: as: "${ fromjson }" run: script: language: javascript - stdin: ${ . } + stdin: "Hello Workflow" environment: - url: https://petstore.swagger.io/v2/pet/2 + foo: bar arguments: - - https://petstore.swagger.io/v2/pet/2 + - hello code: | // Reading Input from STDIN - const input = await new Promise((resolve) => { - let data = ''; - process.stdin.setEncoding('utf8'); - process.stdin.on('data', chunk => data += chunk); - process.stdin.on('end', () => { - try { - resolve(JSON.parse(data)); - } catch (error) { - resolve({}) - } - }); - }); - - const responseStdin = await fetch(input.url); + import { readFileSync } from 'node:fs'; + const stdin = readFileSync(process.stdin.fd, 'utf8'); + console.log('stdin > ', stdin) // Output: stdin > Hello Workflow // Reading from argv - const [_, __, url] = process.argv; - const responseArgv = await fetch(url); + const [_, __, arg] = process.argv; + console.log('arg > ', arg) // Output: arg > hello // Reading from env - const envUrl = process.env.url; - const responseEnv = await fetch(envUrl); - - console.log(JSON.stringify({responseStdin: responseStdin.data, responseArgv: responseArgv.data, responseEnv: responseEnv.data })) + const foo = process.env.foo; + console.log('env > ', foo) // Output: env > bar From c3c89ad07d058c1fc7c52d1cb006861db39f4a7c Mon Sep 17 00:00:00 2001 From: hiren <20088337+hirenr@users.noreply.github.com> Date: Wed, 12 Nov 2025 03:55:12 +0530 Subject: [PATCH 06/10] Removed duplicate entries for stdin and arguments in the container configuration section Signed-off-by: hiren <20088337+hirenr@users.noreply.github.com> --- dsl-reference.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index de619d3a..ec4f5657 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -930,8 +930,6 @@ Enables the execution of external processes encapsulated within a containerized | environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | | stdin | `string` | `no` | A runtime expression, if any, passed as argv to the command or default container CMD| | arguments | `string[]` | `no` | A list of the arguments, if any, passed as argv to the command or default container CMD | -| stdin | `string` | `no` | A runtime expression, if any, passed as argv to the command or default container CMD| -| arguments | `string[]` | `no` | A list of the arguments, if any, passed as argv to the command or default container CMD | | lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. | ###### Examples From 9c7b97953ea6c4bf953998cb1fd219d6dacdc72a Mon Sep 17 00:00:00 2001 From: hiren <20088337+hirenr@users.noreply.github.com> Date: Thu, 13 Nov 2025 10:30:44 +0530 Subject: [PATCH 07/10] Updated fixes for Copilot reviews Signed-off-by: hiren <20088337+hirenr@users.noreply.github.com> --- examples/run-script-with-stdin-and-arguments.yaml | 2 -- examples/run-shell-stdin-and-arguments.yaml | 2 +- schema/workflow.yaml | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/run-script-with-stdin-and-arguments.yaml b/examples/run-script-with-stdin-and-arguments.yaml index 5faefd3d..915a0266 100644 --- a/examples/run-script-with-stdin-and-arguments.yaml +++ b/examples/run-script-with-stdin-and-arguments.yaml @@ -5,8 +5,6 @@ document: version: 1.0.0 do: - runScript: - output: - as: "${ fromjson }" run: script: language: javascript diff --git a/examples/run-shell-stdin-and-arguments.yaml b/examples/run-shell-stdin-and-arguments.yaml index 5eeb4b6f..22171d7d 100644 --- a/examples/run-shell-stdin-and-arguments.yaml +++ b/examples/run-shell-stdin-and-arguments.yaml @@ -1,7 +1,7 @@ document: dsl: 1.0.2 namespace: examples - name: run-script-with-stdin-and-arguments + name: run-shell-with-stdin-and-arguments version: 1.0.0 do: - setInput: diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 2859369a..40569a4a 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -812,7 +812,7 @@ $defs: stdin: type: string title: ContainerStdin - description: A runtime expression, if any, passed as argv to the command or default container CMD + description: A runtime expression, if any, passed as standard input (stdin) to the command or default container CMD arguments: type: array title: ContainerArguments @@ -847,7 +847,7 @@ $defs: title: ScriptArguments description: A list of the arguments, if any, to the script as argv items: - type: string + type: string environment: type: object title: ScriptEnvironment @@ -894,7 +894,7 @@ $defs: title: ShellArguments description: A list of the arguments, if any, to the shell command as argv items: - type: string + type: string environment: type: object title: ShellEnvironment From 71d1765adcc0b7260509b26c19ed029787e61e66 Mon Sep 17 00:00:00 2001 From: hiren <20088337+hirenr@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:17:07 +0530 Subject: [PATCH 08/10] Updated example for run-script-example Signed-off-by: hiren <20088337+hirenr@users.noreply.github.com> --- dsl-reference.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index ec4f5657..220cf277 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -994,19 +994,21 @@ Enables the execution of custom scripts or code within a workflow, empowering wo ```yaml document: - dsl: '1.0.2' - namespace: test + dsl: 1.0.2 + namespace: examples name: run-script-example - version: '0.1.0' + version: 1.0.0 do: - runScript: run: script: - language: js + language: javascript arguments: - greetings: Hello, world! - code: > - console.log(greetings) + - hello + - world + code: | + const [_, __, arg0, arg1] = process.argv; + console.log('arg > ', arg0, arg1) ``` ##### Shell Process From 365d7caef71d61ae751621d3b2508defa6257753 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 13 Nov 2025 06:44:06 -0600 Subject: [PATCH 09/10] Update dsl-reference.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- dsl-reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsl-reference.md b/dsl-reference.md index 220cf277..53eb3f5c 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -928,7 +928,7 @@ Enables the execution of external processes encapsulated within a containerized | ports | `map` | `no` | The container's port mappings, if any | | volumes | `map` | `no` | The container's volume mappings, if any | | environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | -| stdin | `string` | `no` | A runtime expression, if any, passed as argv to the command or default container CMD| +| stdin | `string` | `no` | A runtime expression, if any, passed as standard input to the command or default container CMD| | arguments | `string[]` | `no` | A list of the arguments, if any, passed as argv to the command or default container CMD | | lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. | From 0c0ea9a254c5cf5b2cb5992f3ffd2f5d63a28bb9 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 13 Nov 2025 06:44:20 -0600 Subject: [PATCH 10/10] Update dsl-reference.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- dsl-reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsl-reference.md b/dsl-reference.md index 53eb3f5c..8c115817 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -1002,7 +1002,7 @@ do: - runScript: run: script: - language: javascript + language: js arguments: - hello - world