Explicit I/O mapping between node and bound action #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivation
Today a hero_logic node and its bound hero_proc action share input/output shape by name. If both sides agree (node input
prompt→ action inputprompt), life is easy — and as of 7453ebd the node'sinput_schemaauto-populates from the action on bind, so the common case needs zero configuration.But users legitimately want more:
user_prompt; action expectsprompt. Today you have to make them match — a leaky abstraction.mode = "concise") so the workflow user doesn't have to enter it.All of these are currently impossible without inserting an intermediate hero_proc action just to shuffle fields.
Proposal
Add two optional, ordered mapping tables to
NodeConfig:Source expression grammar (v1, conservative):
inputs.<name>/inputs.<nested.path>— read from the node's own input object at run-time.outputs.<name>— read from the action's parsed output (only valid inaction_output_mappings).literal:<value>— a constant string. For JSON values (numbers, objects),literal:prefix can be dropped in favour of aliteral_json:<json>form if we need it.These are the same tokens the engine's existing
{{inputs.X}}/{{outputs.X}}interpolation grammar already understands, so we can reusehero_proc_lib::template::resolve_path(or an equivalent in hero_logic).Defaulting / back-compat
action_input_mappingsis empty, the engine passesinputstojob.create1:1 (current behaviour).action_output_mappingsis empty, the action's parsed output IS the node's output (current behaviour).target=name,source=inputs.nameoroutputs.name). Users can then rename/rewire without starting from a blank slate.Engine changes
crates/hero_logic/src/engine/node_executors.rs::execute_action:job.create, ifaction_input_mappingsis non-empty, build theinputsJSON by evaluating eachsourceagainst the node's context (inputs.X,outputs.X,literal:…). Otherwise passinput_dataas today.action_output_mappingsis non-empty, build a new output object by evaluating each mapping against the combined(action_outputs, node_inputs)context; that becomesNodeRun.output_data. Otherwise, keep the raw action output as today.UI changes (hero_logic_ui)
action_input_mappings+action_output_mappings.[target dropdown or input] ← [source expression]. Source can be edited as free text or via a picker that offersinputs.*from the node,outputs.*from the action, orliteral:….Reset to identitybutton rebuilds mappings from the action'sinput_schema.Non-goals (v1)
data_mappings); keep those separate for now.Implementation checklist
NodeConfigincrates/hero_logic/schemas/logic/logic.oschema: addaction_input_mappings: [Mapping],action_output_mappings: [Mapping], plus theMappingtype.template_loader.rs.execute_action.workflow_editor.js: on action bind, prefill both tables with identity rows from the action's declared schemas.hero_logic_graph.js: render the Mappings subsection inside the action column.inputs.*,outputs.*,literal:…).References
7453ebdhero_proc_lib::template(see hero_proc#47).data_mappingsfor cross-node field routing (existing, unaffected by this proposal).