15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/trak_flow/mcp/tools/plan_start.rb', line 15
def call(plan_id:, variables: {})
self.class.with_database do |db|
plan = db.find_task!(plan_id)
raise TrakFlow::Error, "#{plan_id} is not a Plan" unless plan.plan?
workflow = Models::Task.new(
title: interpolate_vars(plan.title, variables),
description: interpolate_vars(plan.description, variables),
type: plan.type,
priority: plan.priority,
source_plan_id: plan.id,
ephemeral: false
)
db.create_task(workflow)
workflow.append_trace("INSTANTIATED", "from Plan #{plan.id}")
db.update_task(workflow)
db.find_plan_tasks(plan_id).each do |step|
db.create_child_task(workflow.id, {
title: interpolate_vars(step.title, variables),
description: interpolate_vars(step.description, variables),
type: step.type,
priority: step.priority,
ephemeral: false
})
end
workflow.to_h
end
end
|