Created
July 24, 2025 10:28
-
-
Save jyeshe/9fd9912818ae9def095b3e0b6249097d to your computer and use it in GitHub Desktop.
HyperBEAM PoC for workflow execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Create a wallet | |
Wallet = ar_wallet:new(). | |
Module1 = #{ ~"content-type" => ~"application/lua", ~"body" => | |
<<""" | |
function compute(base, req) | |
base.result = "Hello HyperBEAM 1" | |
return base | |
end | |
""">>}. | |
Module2 = #{ ~"content-type" => ~"application/lua", ~"body" => | |
<<""" | |
function compute(base, req) | |
base.result = "Hello HyperBEAM 2" | |
return base | |
end | |
""">>}. | |
Workflow = #{ | |
~"name" => ~"MyWorkflow", | |
~"steps" => #{ | |
~"start" => #{~"description" => ~"First step", ~"execution-device" => ~"[email protected]", ~"module" => Module1}, | |
~"step2" => #{~"description" => ~"Second step", ~"execution-device" => ~"[email protected]", ~"module" => Module2} | |
}, | |
~"transitions" => #{~"start" => #{~"true" => ~"step2"}} | |
}. | |
{ok, #{~"workflow-id" := WorkflowId}} = hb_ao:resolve(#{device => ~"[email protected]"}, #{~"path" => ~"create", ~"workflow" => Workflow}, #{~"wallet" => Wallet}). | |
{ok, #{~"prepared-id" := PreparedId1}} = hb_ao:resolve(#{device => ~"[email protected]"}, #{~"path" => ~"prepare_start", ~"workflow-id" => WorkflowId, ~"body" => #{}}, #{~"wallet" => Wallet}). | |
{ok, #{~"activity-id" := ActivityId1}} = hb_ao:resolve(#{device => ~"[email protected]"}, #{~"path" => ~"run", ~"workflow-id" => WorkflowId, ~"prepared-id" => PreparedId1}, #{~"wallet" => Wallet}). | |
{ok, #{~"prepared-id" := PreparedId2}} = hb_ao:resolve(#{device => ~"[email protected]"}, #{~"path" => ~"prepare_next", ~"workflow-id" => WorkflowId, ~"prev-activity-id" => ActivityId1}, #{~"wallet" => Wallet}). | |
{ok, #{~"activity-id" := ActivityId2}} = hb_ao:resolve(#{device => ~"[email protected]"}, #{~"path" => ~"run", ~"workflow-id" => WorkflowId, ~"prepared-id" => PreparedId2}, #{~"wallet" => Wallet}). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment