Skip to content

feat(builder): expose ProcessCommand as command.processAsync in Execute Script V2#259

Open
Copilot wants to merge 2 commits intomasterfrom
copilot/add-process-command-action
Open

feat(builder): expose ProcessCommand as command.processAsync in Execute Script V2#259
Copilot wants to merge 2 commits intomasterfrom
copilot/add-process-command-action

Conversation

Copy link

Copilot AI commented Mar 12, 2026

Execute Script V2 lacked a native way to process LIME/Blip commands from within scripts, forcing workarounds. This adds a command.processAsync(payload) helper following the same conventions as context, request, and time.

Changes

  • New Command.cs (ExecuteScriptV2/Functions/) — Command class exposing processAsync(object payload) to the V8 engine. Reuses the same command conversion and metadata injection logic as ProcessCommandAction. Returns the serialized JSON response string.
  • FunctionsRegistrable.cs — accepts ISender, IEnvelopeSerializer, IConfiguration and registers the command host object.
  • ExecuteScriptV2Action.cs — adds ISender and IEnvelopeSerializer constructor dependencies; threads them into RegisterFunctions.
  • README.md — documents command.processAsync with usage examples.
  • Tests — 4 new test cases: valid GET, valid SET with result parsing, null payload failure, and invalid JSON payload failure.

Usage

async function run() {
    const resultJson = await command.processAsync({
        method: 'get',
        uri: '/account'
    });

    const result = JSON.parse(resultJson);

    if (result.status === 'success') {
        return result.resource.fullName;
    }

    return null;
}
Original prompt

This section details on the original issue you should resolve

<issue_title>feat(builder): support ProcessCommand action in Execute Script V2</issue_title>
<issue_description>## Context
Execute Script V2 already exposes helper functions for some Builder actions, but it still does not provide a dedicated function to execute Process Command.
This blocks script scenarios that need to trigger commands in a native, consistent way with the other available functions.

References

Problem

Execute Script V2 is missing a public function, similar to existing exposed action helpers, that encapsulates and runs ProcessCommandAction.

Goal

Expose a new function in Execute Script V2 to process commands using the same conventions as other script-exposed actions and reusing ProcessCommandAction internally.

Proposed Solution

  1. Add a new script-exposed function in Execute Script V2, following the same naming and signature style used by existing functions.
  2. Internally build and execute ProcessCommandAction.
  3. Keep validation, serialization, and exception handling aligned with current Execute Script V2 behavior.
  4. Update Execute Script V2 documentation with usage examples.

Acceptance Criteria

  1. A new Execute Script V2 function is available to execute Process Command.
  2. The function produces the same behavior expected from ProcessCommandAction when used outside scripts.
  3. Invalid command payloads fail with predictable, traceable error messages.
  4. Automated tests cover success and failure scenarios.
  5. Documentation is updated with at least one real example.

Minimum Test Scenarios

  1. Valid command execution returns the expected result.
  2. Invalid command payload fails according to current Execute Script V2 error handling patterns.
  3. Execution respects script timeout and cancellation behavior.
  4. Existing scripts remain compatible with no breaking changes.

Expected Impact

This enables richer automations in Execute Script V2, removes workarounds, and brings script capabilities closer to native Builder actions.

Risks and Considerations

  1. Ensure the new function does not allow command execution beyond existing platform constraints.
  2. Keep tracing and logs consistent for troubleshooting.
  3. Validate performance impact inside the Execute Script V2 runtime.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@cyber-sast
Copy link

cyber-sast commented Mar 12, 2026

Logo
Checkmarx One – Scan Summary & Detailsfb548838-a285-4e93-8797-b331719993ff

Great job! No new security vulnerabilities introduced in this pull request


Communicate with Checkmarx by submitting a PR comment with @Checkmarx followed by one of the supported commands. Learn about the supported commands here.

Co-authored-by: lucasoares <10624972+lucasoares@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for ProcessCommand action in Execute Script V2 feat(builder): expose ProcessCommand as command.processAsync in Execute Script V2 Mar 12, 2026
@lucasoares lucasoares marked this pull request as ready for review March 13, 2026 12:26
Copilot AI review requested due to automatic review settings March 13, 2026 12:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Execute Script V2 host object (command) so JavaScript scripts can process LIME/Blip commands natively (similar to the Builder ProcessCommand action), and updates documentation and tests accordingly.

Changes:

  • Exposes command.processAsync(payload) to Execute Script V2 scripts and returns the serialized command response JSON.
  • Threads ISender, IEnvelopeSerializer, and IConfiguration into Execute Script V2 function registration to support command processing.
  • Adds unit tests and updates Execute Script V2 README with usage examples.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Take.Blip.Builder/Actions/ExecuteScriptV2/README.md Documents the new command.processAsync helper with examples.
src/Take.Blip.Builder/Actions/ExecuteScriptV2/Functions/FunctionsRegistrable.cs Registers the new command host object and expands registration dependencies.
src/Take.Blip.Builder/Actions/ExecuteScriptV2/Functions/Command.cs Implements Command.ProcessAsync to convert payload → LIME CommandISender.ProcessCommandAsync → serialize response.
src/Take.Blip.Builder/Actions/ExecuteScriptV2/ExecuteScriptV2Action.cs Adds constructor dependencies and passes them into RegisterFunctions.
src/Take.Blip.Builder.UnitTests/Actions/ExecuteScript2ActionTests.cs Adds test coverage for success and failure scenarios of command.processAsync.
src/Take.Blip.Builder.Benchmark/Actions/ExecuteScriptBenchmarkTests.cs Updates benchmark setup for new ExecuteScriptV2Action constructor signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 30 to +35
public ExecuteScriptV2Action(
IConfiguration configuration,
IHttpClient httpClient,
ILogger logger)
ILogger logger,
ISender sender,
IEnvelopeSerializer envelopeSerializer)
Comment on lines 30 to 38
public static void RegisterFunctions(this ScriptEngine engine,
ExecuteScriptV2Settings settings,
IHttpClient httpClient, IContext context,
Time time,
ILogger logger,
ISender sender,
IEnvelopeSerializer envelopeSerializer,
IConfiguration configuration,
CancellationToken cancellationToken)
Comment on lines +89 to +92
var command = _convertToCommand(settings);
command.Id = Lime.Protocol.EnvelopeId.NewId();

var resultCommand = await _sender.ProcessCommandAsync(command, _cancellationToken);
Comment on lines +97 to +101
private LimeCommand _convertToCommand(JObject settings)
{
if (settings.TryGetValue(LimeCommand.TYPE_KEY, out var type)
&& Regex.IsMatch(type.ToString(), SERIALIZABLE_PATTERN, default, Constants.REGEX_TIMEOUT)
&& settings.TryGetValue(LimeCommand.RESOURCE_KEY, out var resource))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(builder): support ProcessCommand action in Execute Script V2

4 participants