workflow.internal
Modules
Module workflow.internal
ballerina/workflow.internal Ballerina library
Functions
registerAgentWorkflow
function registerAgentWorkflow( function() () workflowFunction, string workflowName, map< function() () >? activities) returns boolean|errorRegisters a durable agent's runner workflow with the program runtime, marking the
workflow type as an agent workflow so the adapter injects the native agent context
handle (instead of a workflow:Context) and arms the agent update handler.
This is an internal function: registerDurableAgentRunner routes through it for
object-model agents, and the module's own unit tests use it to register loop-test
agents directly (the compiler plugin does not run on the workflow package itself).
registerConnection
Registers a module-level final client object so that it can be passed as
an argument to activity functions whose parameter type is a client object.
This is an internal function used by the compiler plugin. It is emitted
by the source modifier for every module-level final variable whose type is a
client object and is invoked during module initialization, before
startWorkflowRuntime.
When an activity is called with such a client as one of its arguments, the
native runtime substitutes the value with the marker string
"connection:<name>" for transport, then resolves it back to the registered
client on the activity worker side using the same name.
Parameters
- name string - The Ballerina variable name of the client (used as the lookup key)
- connection object {} - The client object reference to register
registerDurableAgentActivity
function registerDurableAgentActivity(string agentName, string toolName, function() () activity, json meta, map<anydata|object {}>? bindings) returns boolean|errorRegisters an activity capability declaration of a durable agent.
Parameters
- agentName string - The agent's name
- toolName string - The tool name advertised to the model
- activity
function() ()- The@workflow:Activityfunction
- meta json (default ()) - Declaration metadata (description, gating, retry policy)
- bindings map<anydata|object {}>? (default ()) - Arguments fixed at registration, keyed by parameter name; client objects are passed by reference to their module-level variable
registerDurableAgentDecl
function registerDurableAgentDecl(string agentName, ModelProvider model, json systemPrompt, int maxIter, typedesc<anydata>? inputType, typedesc<anydata>? resultType) returns boolean|errorRegisters a durable agent declaration: identity, model, system prompt, and reasoning limit. Must be called before the capability registrations below.
Parameters
- agentName string - The agent's name (its module-level variable name)
- model ModelProvider - The agent's
ai:ModelProvider
- systemPrompt json - The agent's system prompt (
role+instructions)
- maxIter int - Per-turn reasoning iteration cap
- inputType typedesc<anydata>? (default string) - The agent's workflow input type:
string(query text), a data type for a structuredruninput, or()for a no-input agent
- resultType typedesc<anydata>? (default ()) - The agent's declared result type, or
()for the final text response
registerDurableAgentEvent
function registerDurableAgentEvent(string agentName, string eventName, typedesc<anydata> request, typedesc<anydata>? response, string cardinality) returns boolean|errorRegisters an event channel declaration of a durable agent.
Parameters
- agentName string - The agent's name
- eventName string - The channel name
- request typedesc<anydata> - The channel's request type
- response typedesc<anydata>? (default ()) - The channel's response type;
()for one-way channels
- cardinality string (default "MULTI_EVENT") -
"MULTI_EVENT"(default) or"SINGLE_EVENT"
registerDurableAgentHumanTask
function registerDurableAgentHumanTask(string agentName, string taskName, json meta, typedesc<anydata> resultType) returns boolean|errorRegisters a human task capability declaration of a durable agent.
registerDurableAgentPeer
function registerDurableAgentPeer(string agentName, string peerName, string targetAgent, json meta) returns boolean|errorRegisters a peer-agent declaration of an object-model durable agent: the peer is advertised to the agent's model as a delegable tool and runs as a true Temporal child workflow of the agent.
registerDurableAgentRunner
Registers the shared object-model runner as an agent's workflow: the agent gets
its own workflow type (workflow-<agentName>) whose activities are the agent's
declared activity functions plus the built-in agent activities. The runner and
the built-ins are captured natively at workflow-module init, so callers pass
only the agent name — no runner machinery leaks into any public API.
Parameters
- agentName string - The agent's name (its module-level variable name)
registerDurableAgentTool
function registerDurableAgentTool(string agentName, BaseToolKit|ToolConfig|FunctionTool tool, boolean requiresApproval, string|string[]? userRoles) returns boolean|errorRegisters an AI tool of an object-model durable agent: stored on the declaration
(so the runner can advertise it to the model) and published to the agent tool
registry (so the built-in executeAgentTool activity can resolve it).
Parameters
- agentName string - The agent's name (its module-level variable name)
- tool BaseToolKit|ToolConfig|FunctionTool - The tool: an
@ai:AgentToolfunction, anai:ToolConfig, or a toolkit
- requiresApproval boolean (default false) - When
true, aPRE_RUNreview activity gates every call
registerHumanTask
Registers a human task type so that the workflow worker can route child workflows
whose type equals taskName to the built-in human task handler.
This is an internal function intended to be called by the compiler plugin at
module initialization time for every awaitHumanTask call site found in user code,
similar to how registerWorkflow is generated for @Workflow functions.
Parameters
- taskName string - The task name passed to
awaitHumanTask; used directly as the Temporal child workflow type
registerWorkflow
function registerWorkflow( function() () workflowFunction, string workflowName, map< function() () >? activities) returns boolean|errorRegisters a workflow function with the program runtime.
This is an internal function used by the compiler plugin to register workflows at module initialization time. It is not intended to be called directly by users.
startWorkflowRuntime
Starts the workflow runtime after all workflows have been registered.
This is an internal function used by the compiler plugin as the last
generated module-level statement, ensuring that polling only begins after
every registerWorkflow call has executed.
Import
import ballerina/workflow.internal;Metadata
Released date: 1 day ago
Version: 0.8.2
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.13.4
GraalVM compatible: No
Pull count
Total: 3621
Current verison: 17
Weekly downloads
Keywords
workflow
Contributors