Class: PromptObjects::Universal::JoinRuns

Inherits:
Primitive show all
Defined in:
lib/prompt_objects/universal/join_runs.rb

Instance Attribute Summary

Attributes inherited from Capability

#state

Instance Method Summary collapse

Methods inherited from Primitive

#initialize

Methods inherited from Capability

#descriptor, execution_policy, execution_policy_definition, #execution_policy_definition, #execution_policy_signature, #initialize, #resolved_execution_policy

Constructor Details

This class inherits a constructor from PromptObjects::Primitive

Instance Method Details

#descriptionObject



10
11
12
# File 'lib/prompt_objects/universal/join_runs.rb', line 10

def description
  "Wait for one or more related dispatched runs and return their terminal statuses/results in input order."
end

#nameObject



8
# File 'lib/prompt_objects/universal/join_runs.rb', line 8

def name = "join_runs"

#parametersObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/prompt_objects/universal/join_runs.rb', line 14

def parameters
  {
    type: "object",
    properties: {
      run_ids: { type: "array", items: { type: "string" } },
      timeout: { type: "number", description: "Optional timeout in seconds" }
    },
    required: ["run_ids"]
  }
end

#receive(message, context:) ⇒ Object

Raises:



25
26
27
28
29
30
31
32
# File 'lib/prompt_objects/universal/join_runs.rb', line 25

def receive(message, context:)
  run_ids = message[:run_ids] || message["run_ids"]
  raise Error, "run_ids must not be empty" unless run_ids.is_a?(Array) && run_ids.any?

  timeout = message[:timeout] || message["timeout"]
  timeout = [[timeout.to_f, 0.1].max, 300].min if timeout
  JSON.generate(context.env.join_runs(run_ids, context: context, timeout: timeout))
end