conductor_ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +142 -0
- data/LICENSE +190 -0
- data/README.md +517 -0
- data/examples/agentic_workflows/llm_chat.rb +106 -0
- data/examples/dynamic_workflow.rb +177 -0
- data/examples/event_handler.rb +94 -0
- data/examples/event_listener_examples.rb +430 -0
- data/examples/helloworld/greetings_worker.rb +24 -0
- data/examples/helloworld/helloworld.rb +99 -0
- data/examples/kitchensink.rb +213 -0
- data/examples/metadata_journey.rb +189 -0
- data/examples/metrics_example.rb +284 -0
- data/examples/new_dsl_demo.rb +141 -0
- data/examples/orkes/http_poll.rb +83 -0
- data/examples/orkes/secrets_example.rb +69 -0
- data/examples/orkes/wait_for_webhook.rb +90 -0
- data/examples/prompt_journey.rb +245 -0
- data/examples/rag_workflow.rb +167 -0
- data/examples/schedule_journey.rb +244 -0
- data/examples/simple_worker.rb +125 -0
- data/examples/simple_workflow.rb +89 -0
- data/examples/task_context_example.rb +257 -0
- data/examples/task_listener_example.rb +192 -0
- data/examples/worker_configuration_example.rb +282 -0
- data/examples/workflow_dsl.rb +316 -0
- data/examples/workflow_ops.rb +305 -0
- data/lib/conductor/client/authorization_client.rb +238 -0
- data/lib/conductor/client/integration_client.rb +108 -0
- data/lib/conductor/client/metadata_client.rb +139 -0
- data/lib/conductor/client/prompt_client.rb +58 -0
- data/lib/conductor/client/scheduler_client.rb +132 -0
- data/lib/conductor/client/schema_client.rb +32 -0
- data/lib/conductor/client/secret_client.rb +48 -0
- data/lib/conductor/client/task_client.rb +168 -0
- data/lib/conductor/client/workflow_client.rb +242 -0
- data/lib/conductor/configuration/authentication_settings.rb +17 -0
- data/lib/conductor/configuration.rb +103 -0
- data/lib/conductor/exceptions.rb +86 -0
- data/lib/conductor/http/api/application_resource_api.rb +107 -0
- data/lib/conductor/http/api/authorization_resource_api.rb +56 -0
- data/lib/conductor/http/api/event_resource_api.rb +133 -0
- data/lib/conductor/http/api/gateway_auth_resource_api.rb +48 -0
- data/lib/conductor/http/api/group_resource_api.rb +76 -0
- data/lib/conductor/http/api/integration_resource_api.rb +145 -0
- data/lib/conductor/http/api/metadata_resource_api.rb +231 -0
- data/lib/conductor/http/api/prompt_resource_api.rb +81 -0
- data/lib/conductor/http/api/role_resource_api.rb +60 -0
- data/lib/conductor/http/api/scheduler_resource_api.rb +211 -0
- data/lib/conductor/http/api/schema_resource_api.rb +82 -0
- data/lib/conductor/http/api/secret_resource_api.rb +134 -0
- data/lib/conductor/http/api/task_resource_api.rb +321 -0
- data/lib/conductor/http/api/token_resource_api.rb +42 -0
- data/lib/conductor/http/api/user_resource_api.rb +59 -0
- data/lib/conductor/http/api/workflow_bulk_resource_api.rb +91 -0
- data/lib/conductor/http/api/workflow_resource_api.rb +451 -0
- data/lib/conductor/http/api_client.rb +437 -0
- data/lib/conductor/http/models/authentication_config.rb +67 -0
- data/lib/conductor/http/models/authorization_request.rb +39 -0
- data/lib/conductor/http/models/base_model.rb +162 -0
- data/lib/conductor/http/models/bulk_response.rb +39 -0
- data/lib/conductor/http/models/conductor_application.rb +39 -0
- data/lib/conductor/http/models/conductor_user.rb +53 -0
- data/lib/conductor/http/models/create_or_update_application_request.rb +24 -0
- data/lib/conductor/http/models/create_or_update_role_request.rb +27 -0
- data/lib/conductor/http/models/event_handler.rb +130 -0
- data/lib/conductor/http/models/generate_token_request.rb +27 -0
- data/lib/conductor/http/models/group.rb +36 -0
- data/lib/conductor/http/models/integration.rb +70 -0
- data/lib/conductor/http/models/integration_api.rb +53 -0
- data/lib/conductor/http/models/integration_api_update.rb +43 -0
- data/lib/conductor/http/models/integration_update.rb +36 -0
- data/lib/conductor/http/models/permission.rb +24 -0
- data/lib/conductor/http/models/poll_data.rb +33 -0
- data/lib/conductor/http/models/prompt_template.rb +59 -0
- data/lib/conductor/http/models/prompt_template_test_request.rb +43 -0
- data/lib/conductor/http/models/rerun_workflow_request.rb +37 -0
- data/lib/conductor/http/models/role.rb +27 -0
- data/lib/conductor/http/models/schema_def.rb +59 -0
- data/lib/conductor/http/models/search_result.rb +187 -0
- data/lib/conductor/http/models/skip_task_request.rb +27 -0
- data/lib/conductor/http/models/start_workflow_request.rb +68 -0
- data/lib/conductor/http/models/subject_ref.rb +35 -0
- data/lib/conductor/http/models/tag_object.rb +36 -0
- data/lib/conductor/http/models/target_ref.rb +39 -0
- data/lib/conductor/http/models/task.rb +156 -0
- data/lib/conductor/http/models/task_def.rb +95 -0
- data/lib/conductor/http/models/task_exec_log.rb +30 -0
- data/lib/conductor/http/models/task_result.rb +115 -0
- data/lib/conductor/http/models/task_result_status.rb +24 -0
- data/lib/conductor/http/models/token.rb +33 -0
- data/lib/conductor/http/models/upsert_group_request.rb +30 -0
- data/lib/conductor/http/models/upsert_user_request.rb +39 -0
- data/lib/conductor/http/models/workflow.rb +202 -0
- data/lib/conductor/http/models/workflow_def.rb +73 -0
- data/lib/conductor/http/models/workflow_schedule.rb +100 -0
- data/lib/conductor/http/models/workflow_state_update.rb +30 -0
- data/lib/conductor/http/models/workflow_status_constants.rb +57 -0
- data/lib/conductor/http/models/workflow_task.rb +169 -0
- data/lib/conductor/http/models/workflow_test_request.rb +67 -0
- data/lib/conductor/http/rest_client.rb +211 -0
- data/lib/conductor/orkes/models/access_key.rb +56 -0
- data/lib/conductor/orkes/models/granted_permission.rb +27 -0
- data/lib/conductor/orkes/models/metadata_tag.rb +15 -0
- data/lib/conductor/orkes/models/rate_limit_tag.rb +15 -0
- data/lib/conductor/orkes/orkes_clients.rb +69 -0
- data/lib/conductor/version.rb +5 -0
- data/lib/conductor/worker/events/conductor_event.rb +40 -0
- data/lib/conductor/worker/events/global_dispatcher.rb +37 -0
- data/lib/conductor/worker/events/http_events.rb +25 -0
- data/lib/conductor/worker/events/listener_registry.rb +40 -0
- data/lib/conductor/worker/events/listeners.rb +34 -0
- data/lib/conductor/worker/events/sync_event_dispatcher.rb +78 -0
- data/lib/conductor/worker/events/task_runner_events.rb +271 -0
- data/lib/conductor/worker/events/workflow_events.rb +49 -0
- data/lib/conductor/worker/fiber_executor.rb +532 -0
- data/lib/conductor/worker/ractor_task_runner.rb +501 -0
- data/lib/conductor/worker/task_context.rb +114 -0
- data/lib/conductor/worker/task_definition_registrar.rb +322 -0
- data/lib/conductor/worker/task_handler.rb +360 -0
- data/lib/conductor/worker/task_in_progress.rb +60 -0
- data/lib/conductor/worker/task_runner.rb +538 -0
- data/lib/conductor/worker/telemetry/metrics_collector.rb +196 -0
- data/lib/conductor/worker/telemetry/prometheus_backend.rb +224 -0
- data/lib/conductor/worker/worker.rb +355 -0
- data/lib/conductor/worker/worker_config.rb +154 -0
- data/lib/conductor/worker/worker_registry.rb +71 -0
- data/lib/conductor/workflow/dsl/input_ref.rb +37 -0
- data/lib/conductor/workflow/dsl/output_ref.rb +44 -0
- data/lib/conductor/workflow/dsl/parallel_builder.rb +49 -0
- data/lib/conductor/workflow/dsl/switch_builder.rb +74 -0
- data/lib/conductor/workflow/dsl/task_ref.rb +178 -0
- data/lib/conductor/workflow/dsl/workflow_builder.rb +1016 -0
- data/lib/conductor/workflow/dsl/workflow_definition.rb +150 -0
- data/lib/conductor/workflow/llm/chat_message.rb +47 -0
- data/lib/conductor/workflow/llm/embedding_model.rb +19 -0
- data/lib/conductor/workflow/llm/tool_call.rb +43 -0
- data/lib/conductor/workflow/llm/tool_spec.rb +46 -0
- data/lib/conductor/workflow/task_type.rb +68 -0
- data/lib/conductor/workflow/timeout_policy.rb +31 -0
- data/lib/conductor/workflow/workflow_executor.rb +373 -0
- data/lib/conductor.rb +192 -0
- metadata +359 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Workflow
|
|
5
|
+
module Dsl
|
|
6
|
+
# WorkflowDefinition wraps a WorkflowBuilder and provides methods
|
|
7
|
+
# for registering and executing workflows.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# workflow = Conductor.workflow :my_workflow do
|
|
11
|
+
# simple :task1
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# workflow.register(overwrite: true)
|
|
15
|
+
# result = workflow.execute(input: { foo: 'bar' })
|
|
16
|
+
#
|
|
17
|
+
class WorkflowDefinition
|
|
18
|
+
attr_reader :builder
|
|
19
|
+
|
|
20
|
+
# @param builder [WorkflowBuilder] The workflow builder
|
|
21
|
+
# @param executor [WorkflowExecutor, nil] Optional workflow executor
|
|
22
|
+
def initialize(builder, executor: nil)
|
|
23
|
+
@builder = builder
|
|
24
|
+
@executor = executor
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Get the workflow name
|
|
28
|
+
# @return [String] Workflow name
|
|
29
|
+
def name
|
|
30
|
+
@builder.name
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Get the workflow version
|
|
34
|
+
# @return [Integer, nil] Workflow version
|
|
35
|
+
def version
|
|
36
|
+
@builder.version
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Convert to WorkflowDef model
|
|
40
|
+
# @return [Conductor::Http::Models::WorkflowDef] Workflow definition
|
|
41
|
+
def to_workflow_def
|
|
42
|
+
@builder.to_workflow_def
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Register this workflow with Conductor
|
|
46
|
+
# @param overwrite [Boolean] Overwrite existing workflow definition (default: false)
|
|
47
|
+
# @return [Object] API response
|
|
48
|
+
# @raise [RuntimeError] If no executor is configured
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# workflow.register(overwrite: true)
|
|
52
|
+
def register(overwrite: false)
|
|
53
|
+
raise 'Executor required for registration. Pass executor: option to Conductor.workflow' unless @executor
|
|
54
|
+
|
|
55
|
+
@executor.register_workflow(self, overwrite: overwrite)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Execute this workflow and wait for completion
|
|
59
|
+
# @param input [Hash] Workflow input parameters (default: {})
|
|
60
|
+
# @param wait_for_seconds [Integer] Maximum time to wait for completion (default: 30)
|
|
61
|
+
# @param correlation_id [String, nil] Correlation ID for tracking
|
|
62
|
+
# @param domain [String, nil] Task domain for all tasks
|
|
63
|
+
# @param wait_until_task_ref [String, nil] Wait until specific task completes
|
|
64
|
+
# @param request_id [String, nil] Unique request ID for idempotency
|
|
65
|
+
# @return [WorkflowRun] Workflow execution result
|
|
66
|
+
# @raise [RuntimeError] If no executor is configured
|
|
67
|
+
#
|
|
68
|
+
# @example
|
|
69
|
+
# result = workflow.execute(input: { user_id: 123 })
|
|
70
|
+
# puts result.status
|
|
71
|
+
def execute(input: {}, wait_for_seconds: 30, correlation_id: nil, domain: nil,
|
|
72
|
+
wait_until_task_ref: nil, request_id: nil)
|
|
73
|
+
raise 'Executor required for execution. Pass executor: option to Conductor.workflow' unless @executor
|
|
74
|
+
|
|
75
|
+
@executor.execute(
|
|
76
|
+
@builder.name,
|
|
77
|
+
input: input,
|
|
78
|
+
version: @builder.version,
|
|
79
|
+
wait_for_seconds: wait_for_seconds,
|
|
80
|
+
correlation_id: correlation_id,
|
|
81
|
+
domain: domain,
|
|
82
|
+
wait_until_task_ref: wait_until_task_ref,
|
|
83
|
+
request_id: request_id
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Execute this workflow (alias for execute)
|
|
88
|
+
# @param input [Hash] Workflow input parameters
|
|
89
|
+
# @return [WorkflowRun] Workflow execution result
|
|
90
|
+
#
|
|
91
|
+
# @example
|
|
92
|
+
# result = workflow.call(user_id: 123, email: 'user@example.com')
|
|
93
|
+
def call(**input)
|
|
94
|
+
execute(input: input)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Start this workflow asynchronously (returns immediately with workflow ID)
|
|
98
|
+
# @param input [Hash] Workflow input parameters (default: {})
|
|
99
|
+
# @param correlation_id [String, nil] Correlation ID for tracking
|
|
100
|
+
# @param domain [String, nil] Task domain for all tasks
|
|
101
|
+
# @return [String] Workflow ID
|
|
102
|
+
# @raise [RuntimeError] If no executor is configured
|
|
103
|
+
#
|
|
104
|
+
# @example
|
|
105
|
+
# workflow_id = workflow.start(input: { user_id: 123 })
|
|
106
|
+
def start(input: {}, correlation_id: nil, domain: nil)
|
|
107
|
+
raise 'Executor required for starting workflow. Pass executor: option to Conductor.workflow' unless @executor
|
|
108
|
+
|
|
109
|
+
request = Conductor::Http::Models::StartWorkflowRequest.new(
|
|
110
|
+
name: @builder.name,
|
|
111
|
+
version: @builder.version,
|
|
112
|
+
input: input,
|
|
113
|
+
correlation_id: correlation_id
|
|
114
|
+
)
|
|
115
|
+
request.task_to_domain = { '*' => domain } if domain
|
|
116
|
+
|
|
117
|
+
@executor.start_workflow(request)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Get the workflow status
|
|
121
|
+
# @param workflow_id [String] The workflow execution ID
|
|
122
|
+
# @param include_tasks [Boolean] Include task details (default: true)
|
|
123
|
+
# @return [Workflow] Workflow execution details
|
|
124
|
+
# @raise [RuntimeError] If no executor is configured
|
|
125
|
+
#
|
|
126
|
+
# @example
|
|
127
|
+
# workflow_id = workflow.start(input: { user_id: 123 })
|
|
128
|
+
# status = workflow.status(workflow_id)
|
|
129
|
+
def status(workflow_id, include_tasks: true)
|
|
130
|
+
raise 'Executor required for checking status. Pass executor: option to Conductor.workflow' unless @executor
|
|
131
|
+
|
|
132
|
+
@executor.get_workflow(workflow_id, include_tasks: include_tasks)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Inspect the workflow definition
|
|
136
|
+
# @return [String] Human-readable representation
|
|
137
|
+
def inspect
|
|
138
|
+
"#<Conductor::Workflow::Dsl::WorkflowDefinition name=#{@builder.name.inspect} " \
|
|
139
|
+
"version=#{@builder.version.inspect} tasks=#{@builder.tasks.size}>"
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Convert to string
|
|
143
|
+
# @return [String] Workflow name and version
|
|
144
|
+
def to_s
|
|
145
|
+
"#{@builder.name}:#{@builder.version || 'latest'}"
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Workflow
|
|
5
|
+
module Llm
|
|
6
|
+
# Role constants for ChatMessage
|
|
7
|
+
module Role
|
|
8
|
+
USER = 'user'
|
|
9
|
+
ASSISTANT = 'assistant'
|
|
10
|
+
SYSTEM = 'system'
|
|
11
|
+
TOOL_CALL = 'tool_call'
|
|
12
|
+
TOOL = 'tool'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# ChatMessage represents a single message in an LLM chat conversation
|
|
16
|
+
class ChatMessage
|
|
17
|
+
attr_accessor :role, :message, :media, :mime_type, :tool_calls
|
|
18
|
+
|
|
19
|
+
# @param role [String] The role (use Role constants)
|
|
20
|
+
# @param message [String] The message content
|
|
21
|
+
# @param media [Array<String>, nil] Optional media URLs
|
|
22
|
+
# @param mime_type [String, nil] Optional MIME type for media
|
|
23
|
+
# @param tool_calls [Array<ToolCall>, nil] Optional tool calls
|
|
24
|
+
def initialize(role:, message:, media: nil, mime_type: nil, tool_calls: nil)
|
|
25
|
+
@role = role
|
|
26
|
+
@message = message
|
|
27
|
+
@media = media
|
|
28
|
+
@mime_type = mime_type
|
|
29
|
+
@tool_calls = tool_calls
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Convert to hash for serialization
|
|
33
|
+
# @return [Hash] The message as a hash with camelCase keys
|
|
34
|
+
def to_h
|
|
35
|
+
result = {
|
|
36
|
+
'role' => @role,
|
|
37
|
+
'message' => @message
|
|
38
|
+
}
|
|
39
|
+
result['media'] = @media if @media && !@media.empty?
|
|
40
|
+
result['mimeType'] = @mime_type if @mime_type
|
|
41
|
+
result['toolCalls'] = @tool_calls.map(&:to_h) if @tool_calls && !@tool_calls.empty?
|
|
42
|
+
result
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Workflow
|
|
5
|
+
module Llm
|
|
6
|
+
# EmbeddingModel encapsulates the provider and model name for embeddings
|
|
7
|
+
class EmbeddingModel
|
|
8
|
+
attr_reader :provider, :model
|
|
9
|
+
|
|
10
|
+
# @param provider [String] The embedding provider name (e.g. 'openai')
|
|
11
|
+
# @param model [String] The model name (e.g. 'text-embedding-ada-002')
|
|
12
|
+
def initialize(provider:, model:)
|
|
13
|
+
@provider = provider
|
|
14
|
+
@model = model
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Workflow
|
|
5
|
+
module Llm
|
|
6
|
+
# ToolCall represents a tool invocation in an LLM conversation
|
|
7
|
+
class ToolCall
|
|
8
|
+
attr_accessor :name, :task_reference_name, :integration_names, :type,
|
|
9
|
+
:input_parameters, :output
|
|
10
|
+
|
|
11
|
+
# @param name [String] Tool name
|
|
12
|
+
# @param task_reference_name [String, nil] Task reference name
|
|
13
|
+
# @param integration_names [Hash<String,String>, nil] Integration name mappings
|
|
14
|
+
# @param type [String] Tool type (default: 'SIMPLE')
|
|
15
|
+
# @param input_parameters [Hash, nil] Input parameters for the tool
|
|
16
|
+
# @param output [Hash, nil] Expected output
|
|
17
|
+
def initialize(name:, task_reference_name: nil, integration_names: nil,
|
|
18
|
+
type: 'SIMPLE', input_parameters: nil, output: nil)
|
|
19
|
+
@name = name
|
|
20
|
+
@task_reference_name = task_reference_name
|
|
21
|
+
@integration_names = integration_names
|
|
22
|
+
@type = type
|
|
23
|
+
@input_parameters = input_parameters
|
|
24
|
+
@output = output
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Convert to hash for serialization
|
|
28
|
+
# @return [Hash] The tool call as a hash with camelCase keys
|
|
29
|
+
def to_h
|
|
30
|
+
result = {
|
|
31
|
+
'name' => @name,
|
|
32
|
+
'type' => @type
|
|
33
|
+
}
|
|
34
|
+
result['taskReferenceName'] = @task_reference_name if @task_reference_name
|
|
35
|
+
result['integrationNames'] = @integration_names if @integration_names
|
|
36
|
+
result['inputParameters'] = @input_parameters if @input_parameters
|
|
37
|
+
result['output'] = @output if @output
|
|
38
|
+
result
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Workflow
|
|
5
|
+
module Llm
|
|
6
|
+
# ToolSpec defines a tool specification for LLM function calling
|
|
7
|
+
class ToolSpec
|
|
8
|
+
attr_accessor :name, :type, :description, :config_params,
|
|
9
|
+
:integration_names, :input_schema, :output_schema
|
|
10
|
+
|
|
11
|
+
# @param name [String] Tool name
|
|
12
|
+
# @param type [String] Tool type (default: 'SIMPLE')
|
|
13
|
+
# @param description [String, nil] Tool description
|
|
14
|
+
# @param config_params [Hash, nil] Configuration parameters
|
|
15
|
+
# @param integration_names [Hash<String,String>, nil] Integration name mappings
|
|
16
|
+
# @param input_schema [Hash, nil] JSON schema for inputs
|
|
17
|
+
# @param output_schema [Hash, nil] JSON schema for outputs
|
|
18
|
+
def initialize(name:, type: 'SIMPLE', description: nil, config_params: nil,
|
|
19
|
+
integration_names: nil, input_schema: nil, output_schema: nil)
|
|
20
|
+
@name = name
|
|
21
|
+
@type = type
|
|
22
|
+
@description = description
|
|
23
|
+
@config_params = config_params
|
|
24
|
+
@integration_names = integration_names
|
|
25
|
+
@input_schema = input_schema
|
|
26
|
+
@output_schema = output_schema
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Convert to hash for serialization
|
|
30
|
+
# @return [Hash] The tool spec as a hash with camelCase keys
|
|
31
|
+
def to_h
|
|
32
|
+
result = {
|
|
33
|
+
'name' => @name,
|
|
34
|
+
'type' => @type
|
|
35
|
+
}
|
|
36
|
+
result['description'] = @description if @description
|
|
37
|
+
result['configParams'] = @config_params if @config_params
|
|
38
|
+
result['integrationNames'] = @integration_names if @integration_names
|
|
39
|
+
result['inputSchema'] = @input_schema if @input_schema
|
|
40
|
+
result['outputSchema'] = @output_schema if @output_schema
|
|
41
|
+
result
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Workflow
|
|
5
|
+
# Task type constants for Conductor workflow tasks
|
|
6
|
+
# These match the server-side task types
|
|
7
|
+
module TaskType
|
|
8
|
+
SIMPLE = 'SIMPLE'
|
|
9
|
+
DYNAMIC = 'DYNAMIC'
|
|
10
|
+
FORK_JOIN = 'FORK_JOIN'
|
|
11
|
+
FORK_JOIN_DYNAMIC = 'FORK_JOIN_DYNAMIC'
|
|
12
|
+
DECISION = 'DECISION'
|
|
13
|
+
SWITCH = 'SWITCH'
|
|
14
|
+
JOIN = 'JOIN'
|
|
15
|
+
DO_WHILE = 'DO_WHILE'
|
|
16
|
+
SUB_WORKFLOW = 'SUB_WORKFLOW'
|
|
17
|
+
START_WORKFLOW = 'START_WORKFLOW'
|
|
18
|
+
EVENT = 'EVENT'
|
|
19
|
+
WAIT = 'WAIT'
|
|
20
|
+
WAIT_FOR_WEBHOOK = 'WAIT_FOR_WEBHOOK'
|
|
21
|
+
HUMAN = 'HUMAN'
|
|
22
|
+
USER_DEFINED = 'USER_DEFINED'
|
|
23
|
+
HTTP = 'HTTP'
|
|
24
|
+
HTTP_POLL = 'HTTP_POLL'
|
|
25
|
+
LAMBDA = 'LAMBDA'
|
|
26
|
+
INLINE = 'INLINE'
|
|
27
|
+
EXCLUSIVE_JOIN = 'EXCLUSIVE_JOIN'
|
|
28
|
+
TERMINATE = 'TERMINATE'
|
|
29
|
+
KAFKA_PUBLISH = 'KAFKA_PUBLISH'
|
|
30
|
+
JSON_JQ_TRANSFORM = 'JSON_JQ_TRANSFORM'
|
|
31
|
+
SET_VARIABLE = 'SET_VARIABLE'
|
|
32
|
+
GET_DOCUMENT = 'GET_DOCUMENT'
|
|
33
|
+
|
|
34
|
+
# LLM Task Types
|
|
35
|
+
LLM_GENERATE_EMBEDDINGS = 'LLM_GENERATE_EMBEDDINGS'
|
|
36
|
+
LLM_GET_EMBEDDINGS = 'LLM_GET_EMBEDDINGS'
|
|
37
|
+
LLM_TEXT_COMPLETE = 'LLM_TEXT_COMPLETE'
|
|
38
|
+
LLM_CHAT_COMPLETE = 'LLM_CHAT_COMPLETE'
|
|
39
|
+
LLM_INDEX_TEXT = 'LLM_INDEX_TEXT'
|
|
40
|
+
LLM_SEARCH_INDEX = 'LLM_SEARCH_INDEX'
|
|
41
|
+
GENERATE_IMAGE = 'GENERATE_IMAGE'
|
|
42
|
+
GENERATE_AUDIO = 'GENERATE_AUDIO'
|
|
43
|
+
LLM_STORE_EMBEDDINGS = 'LLM_STORE_EMBEDDINGS'
|
|
44
|
+
LLM_SEARCH_EMBEDDINGS = 'LLM_SEARCH_EMBEDDINGS'
|
|
45
|
+
LIST_MCP_TOOLS = 'LIST_MCP_TOOLS'
|
|
46
|
+
CALL_MCP_TOOL = 'CALL_MCP_TOOL'
|
|
47
|
+
|
|
48
|
+
# All valid task types
|
|
49
|
+
ALL_TYPES = [
|
|
50
|
+
SIMPLE, DYNAMIC, FORK_JOIN, FORK_JOIN_DYNAMIC, DECISION, SWITCH, JOIN,
|
|
51
|
+
DO_WHILE, SUB_WORKFLOW, START_WORKFLOW, EVENT, WAIT, WAIT_FOR_WEBHOOK,
|
|
52
|
+
HUMAN, USER_DEFINED, HTTP, HTTP_POLL, LAMBDA, INLINE, EXCLUSIVE_JOIN,
|
|
53
|
+
TERMINATE, KAFKA_PUBLISH, JSON_JQ_TRANSFORM, SET_VARIABLE, GET_DOCUMENT,
|
|
54
|
+
LLM_GENERATE_EMBEDDINGS, LLM_GET_EMBEDDINGS, LLM_TEXT_COMPLETE,
|
|
55
|
+
LLM_CHAT_COMPLETE, LLM_INDEX_TEXT, LLM_SEARCH_INDEX, GENERATE_IMAGE,
|
|
56
|
+
GENERATE_AUDIO, LLM_STORE_EMBEDDINGS, LLM_SEARCH_EMBEDDINGS,
|
|
57
|
+
LIST_MCP_TOOLS, CALL_MCP_TOOL
|
|
58
|
+
].freeze
|
|
59
|
+
|
|
60
|
+
# Check if a task type is valid
|
|
61
|
+
# @param type [String] The task type to check
|
|
62
|
+
# @return [Boolean] true if valid
|
|
63
|
+
def self.valid?(type)
|
|
64
|
+
ALL_TYPES.include?(type)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Workflow
|
|
5
|
+
# Timeout policy for workflows and tasks
|
|
6
|
+
module TimeoutPolicy
|
|
7
|
+
# Workflow times out and is marked as TIMED_OUT
|
|
8
|
+
TIME_OUT_WORKFLOW = 'TIME_OUT_WF'
|
|
9
|
+
|
|
10
|
+
# Only send an alert, workflow continues
|
|
11
|
+
ALERT_ONLY = 'ALERT_ONLY'
|
|
12
|
+
|
|
13
|
+
# All valid timeout policies
|
|
14
|
+
ALL_POLICIES = [TIME_OUT_WORKFLOW, ALERT_ONLY].freeze
|
|
15
|
+
|
|
16
|
+
# Check if a timeout policy is valid
|
|
17
|
+
# @param policy [String] The policy to check
|
|
18
|
+
# @return [Boolean] true if valid
|
|
19
|
+
def self.valid?(policy)
|
|
20
|
+
ALL_POLICIES.include?(policy)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Evaluator types for switch tasks and expressions
|
|
25
|
+
module EvaluatorType
|
|
26
|
+
JAVASCRIPT = 'javascript'
|
|
27
|
+
ECMASCRIPT = 'graaljs'
|
|
28
|
+
VALUE_PARAM = 'value-param'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|