cpee-llm 1.0.6 → 1.2.2

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +668 -159
  3. data/README.md +15 -0
  4. data/cpee-llm.gemspec +3 -3
  5. data/lib/cpee/llm/dataflow.rb +3 -3
  6. data/lib/cpee/llm/functions.rb +80 -77
  7. data/lib/cpee/llm/implementation.rb +43 -17
  8. data/lib/cpee/llm/implementation.xml +41 -7
  9. data/lib/cpee/llm/prompts/system/adapt_mermaid.txt +12 -0
  10. data/lib/cpee/llm/prompts/system/adapt_xml_documentation.txt +50 -0
  11. data/lib/cpee/llm/prompts/system/adapt_xml_endpoints.txt +80 -0
  12. data/lib/cpee/llm/prompts/{dataflow.txt → system/dataflow.txt} +13 -25
  13. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/arguments.txt +8 -0
  14. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/color_palette.txt +10 -0
  15. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/description.txt +3 -0
  16. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/documentation.txt +35 -0
  17. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/exclusive_gateway.txt +7 -0
  18. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/finalize.txt +2 -0
  19. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/inclusive_gateway.txt +2 -0
  20. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/loop.txt +7 -0
  21. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/method.txt +6 -0
  22. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/parallel_gateway.txt +6 -0
  23. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/pause.txt +4 -0
  24. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/pause_insertion.txt +3 -0
  25. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/script_task.txt +5 -0
  26. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/sequence.txt +2 -0
  27. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/service_task.txt +20 -0
  28. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/variables.txt +3 -0
  29. data/lib/cpee/llm/prompts/system/fragments/cpee_xml.txt +15 -0
  30. data/lib/cpee/llm/prompts/system/fragments/data_references.txt +14 -0
  31. data/lib/cpee/llm/prompts/system/fragments/endpoint_naming.txt +1 -0
  32. data/lib/cpee/llm/prompts/system/fragments/mermaid/structure_rules.txt +29 -0
  33. data/lib/cpee/llm/prompts/system/fragments/mermaid/syntax.txt +22 -0
  34. data/lib/cpee/llm/prompts/system/fragments/numeric_conversion.txt +5 -0
  35. data/lib/cpee/llm/prompts/system/fragments/service_registry.txt +6 -0
  36. data/lib/cpee/llm/prompts/system/fragments/unmatched_tasks.txt +4 -0
  37. data/lib/cpee/llm/prompts/system/generate_mermaid.txt +40 -0
  38. data/lib/cpee/llm/prompts/system/generate_mermaid_endpoints.txt +82 -0
  39. data/lib/cpee/llm/prompts/system/intent.txt +45 -0
  40. data/lib/cpee/llm/prompts/{validate_xml.txt → system/validate_xml.txt} +15 -0
  41. data/lib/cpee/llm/prompts/user/adapt.txt +8 -0
  42. data/lib/cpee/llm/prompts/user/adapt_xml_endpoints.txt +11 -0
  43. data/lib/cpee/llm/prompts/user/dataflow.txt +9 -0
  44. data/lib/cpee/llm/prompts/user/describe_text.txt +4 -0
  45. data/lib/cpee/llm/prompts/user/generate_mermaid.txt +5 -0
  46. data/lib/cpee/llm/prompts/user/generate_mermaid_endpoints.txt +9 -0
  47. data/lib/cpee/llm/prompts/user/intent.txt +17 -0
  48. data/lib/cpee/llm/prompts/user/validate_xml.txt +5 -0
  49. data/lib/cpee/llm/rubyllm_requests.rb +71 -119
  50. data/server/connect_gemini +1 -1
  51. data/server/connect_gpt +1 -1
  52. data/server/connect_morpheus +1 -1
  53. data/server/{cpee-llm → llm} +5 -4
  54. data/server/plugins.json +51 -0
  55. data/tools/cpee-llm +3 -3
  56. data/tools/cpee-llm-tool +4 -4
  57. metadata +46 -17
  58. data/lib/cpee/llm/prompts/adapt_docxml_description.txt +0 -131
  59. data/lib/cpee/llm/prompts/adapt_xml_endpoints.txt +0 -157
  60. data/lib/cpee/llm/prompts/apply.txt +0 -32
  61. data/lib/cpee/llm/prompts/derive.txt +0 -28
  62. data/lib/cpee/llm/prompts/gemini-request.json +0 -18
  63. data/lib/cpee/llm/prompts/generate1.txt +0 -90
  64. data/lib/cpee/llm/prompts/generate_enpoints.txt +0 -132
  65. data/lib/cpee/llm/prompts/generate_enpoints1.txt +0 -155
  66. data/lib/cpee/llm/prompts/identify.txt +0 -25
  67. data/lib/cpee/llm/prompts/validate_mermaid.xml +0 -74
  68. /data/lib/cpee/llm/prompts/{describe.txt → system/describe_text.txt} +0 -0
  69. /data/server/{cpee-llm.conf → llm.conf} +0 -0
@@ -0,0 +1,80 @@
1
+ You are an expert BPMN 2.0 process model editor for the CPEE XML process description language.
2
+ Your task is to modify an existing CPEE XML process model according to the user's natural-language modification request.
3
+ The user will always provide:
4
+ * an existing valid CPEE XML process model;
5
+ * one or more textual modification requests;
6
+ * a list of available API endpoints (service registry).
7
+
8
+ %%%fragments/service_registry.txt
9
+ The service registry is keyed by service url. Each value lists description, functionality, input and output in this order.
10
+
11
+ Core Objective
12
+ Your task is to produce a modified CPEE XML process model that implements the requested changes.
13
+ Only modify the parts of the process that are explicitly or necessarily affected by the user's request.
14
+ Do not redesign, simplify, optimize, refactor, or rewrite unrelated parts of the model.
15
+ Never remove existing functionality unless explicitly requested.
16
+ Never introduce additional behavior that was not requested.
17
+
18
+ Editing Workflow
19
+ Internally perform the following steps:
20
+ 1. Parse the existing CPEE XML testset.
21
+ 2. Parse the endpoint definitions.
22
+ 3. Parse the workflow contained in the description element.
23
+ 4. Understand the user's requested modifications.
24
+ 5. Determine which workflow elements and endpoint definitions are affected.
25
+ 6. Apply only the requested changes.
26
+ 7. Update data flow if necessary.
27
+ 8. Generate the complete updated CPEE XML testset.
28
+
29
+ CPEE XML Testset Structure
30
+ The input CPEE XML document has the following structure:
31
+ - The root element is <testset>.
32
+ - <endpoints> contains the mapping from endpoint names to service URLs.
33
+ - <dslx> contains the workflow definition.
34
+ - The actual process model is the <description> element inside <dslx>.
35
+
36
+ #Endpoint Handling
37
+ The <endpoints> section defines all available service endpoints.
38
+ Each endpoint consists of the endpoint name (the XML element name), and the corresponding service URL (the element value).
39
+ Service tasks inside the workflow reference endpoints only by endpoint name, for example:
40
+ <call endpoint="measurewaterlevel">
41
+ Endpoint Rules:
42
+ - <call endpoint="..."> always references an endpoint name.
43
+ - URLs are stored only in <endpoints>.
44
+ - Update URLs in <endpoints>; update endpoint attributes only when the endpoint name changes.
45
+ - Do not modify unrelated endpoints.
46
+ %%%fragments/endpoint_naming.txt
47
+
48
+ # Service Registry Usage for Newly Added Tasks
49
+ When the user's modification request introduces one or more new tasks, first determine whether the task exists in the Service Registry.
50
+ If the task exists in the Service Registry:
51
+ - Create a <call> element using the corresponding service specification.
52
+ - Set the endpoint attribute to the endpoint name derived from the task label (see Endpoint Rules).
53
+ - If the endpoint is not already present in the <endpoints> section, add it using the service url from the Service Registry.
54
+ - Define the task according to the service specification.
55
+ - Define the <arguments> section with the required input parameters, assigning values from the existing process context whenever possible.
56
+ - If the service specification defines outputs, generate the appropriate <finalize> code to store the returned values in workflow variables (data.*) for later use.
57
+ - Integrate the task into the existing workflow without modifying unrelated behavior.
58
+ If the task does not exist in the Service Registry:
59
+ %%%fragments/unmatched_tasks.txt
60
+ - A script task is a <manipulate> element (see Script Task below).
61
+ - An unconfigured service task is an empty <call> element without endpoint, used as a placeholder. Leave it unconfigured except for information explicitly requested by the user.
62
+ Always use the Service Registry whenever a matching service specification is available.
63
+
64
+ The CPEE XML model must follow these rules:
65
+ %%%fragments/cpee_xml.txt
66
+
67
+ # Handling Ambiguity
68
+ If the user's request is sufficiently precise, perform the modification directly.
69
+ If multiple valid interpretations exist and the missing information affects the resulting workflow, select the best possible interpretation and perform changes.
70
+
71
+ # Output Requirements
72
+ Return the complete updated CPEE XML process model.
73
+ Preserve the overall document structure (testset, endpoints, dslx, and description).
74
+ Modify only the elements affected by the user's request.
75
+ Return the entire XML document, including unchanged sections.
76
+ Do not explain the modifications.
77
+ Do not summarize the changes.
78
+ Do not output Markdown.
79
+ Do not omit unchanged sections.
80
+ The returned XML must be immediately usable as a valid CPEE process model.
@@ -9,15 +9,8 @@ INPUT DESCRIPTION
9
9
  - gateways
10
10
  Tasks define process steps.
11
11
  Gateways define branching logic based on data produced by tasks.
12
- 2. Service Registry maps each task label to one service specification.
13
- Each service specification includes:
14
- - task id
15
- - task label
16
- - service url
17
- - service description
18
- - service functionality
19
- - input (RelaxNG schema)
20
- - optional output
12
+ 2. Service Registry is keyed by the task id from the process model. Each entry contains the task label from the process model (label) and the matching service.
13
+ %%%fragments/service_registry.txt
21
14
 
22
15
  OUTPUT FORMAT
23
16
  Return a JSON object with exactly two top-level fields:
@@ -32,11 +25,10 @@ For each task in the process model include:
32
25
  - label: original task label from the process model
33
26
 
34
27
  Based on the task types additional information is provided:
35
- (a) Script tasks if no matching service exist, but the step is purely data transformation or computation and no external system interaction is implied
28
+ (a) Script tasks
29
+ %%%fragments/unmatched_tasks.txt
36
30
  - url: is always "script"
37
31
  - script: <ruby code>
38
- The script must be generated in simple Ruby. Example: assign from another variable: data.total = data.amount + data.tax
39
- Script tasks participate in process data flow exactly like service tasks and may create or update data.* variables used by downstream tasks and gateways.
40
32
  (b) Service tasks if a matching service exists in the registry:
41
33
  - url: service endpoint
42
34
  - input: required parameters with concrete values if derivable from process logic
@@ -44,12 +36,13 @@ Based on the task types additional information is provided:
44
36
 
45
37
  INPUT RULES
46
38
  Each input value MUST follow exactly one of the following formats:
47
- 1. Literal value (no change)
39
+ 1. Literal value (no change, no leading !)
48
40
  If the value is constant:
49
41
  "intensity": 90
50
- 2. Value from previous task output
51
- If the value comes from another task’s output:
52
- "sample_id": "data.sample_id"
42
+ 2. Value from previous task output or script
43
+ If the value comes from another task’s output or from a script:
44
+ "sample_id": "!data.sample_id"
45
+ %%%fragments/data_references.txt
53
46
 
54
47
  OUTPUT RULES
55
48
  Include output only if required. Otherwise omit it.
@@ -67,16 +60,11 @@ Value sources
67
60
  (b) Nested field access is used when the required value is located inside a specific key within result.
68
61
  "data.ambient_light_lumens": "result['some_key']"
69
62
  Required conversions
70
- All output values are STRING by default.
71
- If the operation description specifies a numeric type or the semantic meaning implies a numeric type, a conversion MUST be applied.
72
- Type rules:
73
- - If the value is defined as or implied to be a float ALWAYS use .to_f
74
- - If the value is defined as or implied to be an integer ALWAYS use .to_i
63
+ %%%fragments/numeric_conversion.txt
75
64
  Examples:
76
65
  "data.ambient_light_lux": "result.to_f"
77
66
  "data.temperature": "result['value'].to_f"
78
67
  "data.count": "result.to_i"
79
- Do NOT omit a conversion!!!
80
68
 
81
69
  Tasks that are not script or service tasks are ignored!!!
82
70
 
@@ -143,11 +131,11 @@ OUTPUT STRUCTURE EXAMPLE (SCHEMA ONLY)
143
131
  "url": "...",
144
132
  "input": {
145
133
  "param1": "value",
146
- "param2": "data.some_output"
134
+ "param2": "!data.some_output"
147
135
  },
148
136
  "output": {
149
- "data.some_output": "result['dome_key']",
150
- "data.some_output": "result.to_i"
137
+ "data.some_output": "result['some_key']",
138
+ "data.other_output": "result.to_i"
151
139
  }
152
140
  },
153
141
  "task_id": {
@@ -0,0 +1,8 @@
1
+ Service input parameters are stored inside arguments (which in turn are always stored inside parameters, see structure above). Each argument is represented by its own child element.
2
+ <parameters>
3
+ <arguments>
4
+ <min>1</min>
5
+ <max>100</max>
6
+ </arguments>
7
+ </parameters>
8
+ %%%fragments/data_references.txt
@@ -0,0 +1,10 @@
1
+ Use only the following color palette:
2
+ * White — #ffffff
3
+ * Blue — #d4e1f1
4
+ * Green — #d8f0dd
5
+ * Yellow — #ffffcc
6
+ * Purple — #e4c3e4
7
+ * Pink — #f8a8c6
8
+ * Brown — #ded0c5
9
+ * Gray — #deddda
10
+ The same color palette also applies to the color attribute of <description> and to the color attribute of <manipulate>.
@@ -0,0 +1,3 @@
1
+ # CPEE XML Process Model Structure
2
+ The process model itself is contained entirely inside the <description color=""> element. Interpret the XML inside <description> using the following mapping.
3
+ The color attribute controls the color of the whole process model. Individual service task colors can be set (see below).
@@ -0,0 +1,35 @@
1
+ ## Documentation
2
+
3
+ The child documentation may appear inside `<call>` (on the same level as parameters), and can have the following structure:
4
+ ├── ...
5
+ └── documentation
6
+ ├── implementation
7
+ │ └── description
8
+ ├── in
9
+ │ └── description
10
+ └── out
11
+ └── description
12
+
13
+ The documentation element may describe the service implementation as well as its expected inputs and produced outputs.
14
+ The <description> elements contain optional textual information about the task's behavior, including the process variables consumed (<in>), produced (<out>), or implementation-specific details (<implementation>).
15
+ Empty <description> elements indicate that no additional semantic information is provided.
16
+
17
+ If a `<documentation>` element does not exist for a Service Task, append an empty `<documentation>` element. Empty `<documentation>` contains only <in> and <implementation>. Include <out> only in tasks, where output is defined.
18
+
19
+ #Outputs:
20
+ Every new output created by the Service Task must be added to the <out><description> element.
21
+ Output variables must use the workflow variable format:
22
+ data.variable_name = "name of document or document content"
23
+ If the output represents a document, specify whether the variable stores the document name or the document content.
24
+ data.invoice_name = "invoice.pdf" or data.invoice_content = "content of the invoice document"
25
+ Each newly created output must introduce a new data. variable.
26
+
27
+ #Inputs:
28
+ Inputs describe the workflow variables consumed by the Service Task.
29
+ An input can either:
30
+ Use an existing output variable from a previous Service Task, or Introduce a new workflow variable.
31
+ If the input is based on an existing output, use the same data. variable name defined in the output:
32
+ data.invoice_content
33
+ If the input is new and has no previous output source, define a new variable:
34
+ data.customer_information = "content of the invoice"
35
+ Do not create a new variable name when an existing output already contains the required data. Reuse the existing data. variable.
@@ -0,0 +1,7 @@
1
+ ## Exclusive Gateway
2
+ An Exclusive Gateway is represented by <choose eid="..." mode="exclusive">
3
+ Each outgoing branch is represented by <alternative condition="..." eid="e.."> child.
4
+ The branch condition is stored in the **condition attribute**.
5
+ <alternative condition="data.temperature > 30" eid="e1">
6
+ Conditions must be valid Ruby expressions.
7
+ Default branch has no conditions. <otherwise eid="..."/>.
@@ -0,0 +1,2 @@
1
+ Returned service values are processed inside <finalize output="result">, where result is the variable containing the service response.
2
+ result can be a single value or an object. Inside <finalize>, assign result directly (<finalize output="result"> data.temperature = result</finalize>) or extract specific properties (<finalize output="result"> data.temperature = result["temperature"].to_f; data.type = result["celsius"];</finalize>) to store values for later use in the process.
@@ -0,0 +1,2 @@
1
+ ## Inclusive Gateway
2
+ An Inclusive Gateway differs from the Exclusive Gateway only by the attribute mode="inclusive".
@@ -0,0 +1,7 @@
1
+ ## Loop
2
+ A BPMN loop is represented by <loop eid="e.." mode="..." condition="...">
3
+ The loop condition is stored in the **condition attribute**. The loop execution mode is stored in the **mode attribute**.
4
+ pre_test is used for head controlled loops.
5
+ post_test is used for tail controlled loops.
6
+ <loop eid="e1" mode="pre_test" condition="data.counter < 10">
7
+ Loop conditions must be valid Ruby expressions.
@@ -0,0 +1,6 @@
1
+ The <method> field must strictly follow the Service Registry specification.
2
+ If the service specification defines a method, use exactly that value. The value must always be lowercase and enclosed in colons (example: <method>:get</method>).
3
+ Never invent, infer, or assume a method value that is not explicitly defined in the service specification:
4
+ <parameters>
5
+ <method/>
6
+ </parameters>
@@ -0,0 +1,6 @@
1
+ ## Parallel Gateway
2
+ Parallel execution is represented by <parallel eid="e.." wait="-1" cancel="last">
3
+ The attribute wait defines how many branches have to reach the cancel condition before other branches are considered invalid. A normal parallel has always wait="-1".
4
+ The attribute cancel defines the cancel condition, i.e., if the wait rules are evaluated after a branch fully finishes (attribute cancel has the value "last"), or if the wait rules are evaluated after the first task of a branch finishes ((attribute cancel has the value "first").
5
+ An event-based gateway (which is a special case of a parallel) has always wait="1" cancel="last".
6
+ Each concurrent branch is represented by <parallel_branch eid="e..">
@@ -0,0 +1,4 @@
1
+ ##Pause Task
2
+ A pause is represented by a <stop id="a.."> element.
3
+ A <stop> pauses the execution of the process (until it is manually resumed). It does not terminate the process.
4
+ <stop id="a5"/>
@@ -0,0 +1,3 @@
1
+ When the user requests to pause, hold, or stop the process, insert a <stop> element.
2
+ The id attribute must be unique within the process model. The id must follow the same naming convention as the existing element IDs in the process model.
3
+ Insert the <stop> element at the location specified or implied by the user's request. Otherwise, insert the <stop> element as the last element of the process.
@@ -0,0 +1,5 @@
1
+ ## Script Task
2
+ A BPMN Script Task is represented by <manipulate id="..." label="..." color="...">. The executable Ruby code is stored inside the <code> child element:
3
+ <manipulate id="a1" label="Increase Counter"><code>data.counter += 1</code></manipulate>
4
+ The label of the BPMN Script Task is stored in an attribute label in the <manipulate>.
5
+ The color of the BPMN Script Task is stored in an attribute color in the <manipulate>.
@@ -0,0 +1,2 @@
1
+ ## Sequential Flow
2
+ Sequential execution is represented by sibling XML elements appearing in order inside the same parent element.
@@ -0,0 +1,20 @@
1
+ ## Service Task
2
+ A BPMN Service Task is represented by a `<call id="..." endpoint="...">` element.
3
+ The endpoint of the service is stored in the **endpoint attribute**.
4
+ <call endpoint="measurelightingconditions">
5
+ The following child elements may appear inside `<call>`:
6
+ ├── parameters
7
+ │ ├── label
8
+ │ ├── color
9
+ │ ├── method
10
+ │ └── arguments
11
+ ├── code
12
+ │ ├── signal
13
+ │ ├── prepare
14
+ │ ├── finalize
15
+ │ ├── update
16
+ │ └── rescue
17
+ ├── annotations
18
+ └── documentation
19
+
20
+ The parameters element stores task metadata, such as its label and display color. The <label> is the task name. The <color> element defines the display color of the task in hexadecimal RGB format.
@@ -0,0 +1,3 @@
1
+ ## Variables
2
+ Variables are referenced as data.variable_name in code (script tasks, finalize) and in conditions. In service arguments they must be prefixed with !, i.e. !data.variable_name.
3
+ %%%fragments/numeric_conversion.txt
@@ -0,0 +1,15 @@
1
+ %%%fragments/cpee_xml/description.txt
2
+ %%%fragments/cpee_xml/sequence.txt
3
+ %%%fragments/cpee_xml/service_task.txt
4
+ %%%fragments/cpee_xml/color_palette.txt
5
+ %%%fragments/cpee_xml/method.txt
6
+ %%%fragments/cpee_xml/arguments.txt
7
+ %%%fragments/cpee_xml/finalize.txt
8
+ %%%fragments/cpee_xml/script_task.txt
9
+ %%%fragments/cpee_xml/exclusive_gateway.txt
10
+ %%%fragments/cpee_xml/inclusive_gateway.txt
11
+ %%%fragments/cpee_xml/loop.txt
12
+ %%%fragments/cpee_xml/parallel_gateway.txt
13
+ %%%fragments/cpee_xml/pause.txt
14
+ %%%fragments/cpee_xml/pause_insertion.txt
15
+ %%%fragments/cpee_xml/variables.txt
@@ -0,0 +1,14 @@
1
+ If a service argument (input parameter) depends on a previously computed or returned value, i.e. on process data, it must be provided using the !data.some_value syntax. A Ruby expression over process data is also allowed, e.g. !data.minutes * 60.
2
+ The leading ! marks the value as a Ruby expression that is evaluated against the process data at runtime. It is NOT a boolean negation and must never be removed.
3
+ Without the leading ! the value is passed as a literal string, i.e. data.timeout_duration would send the text "data.timeout_duration" instead of its value.
4
+ Use the leading ! ONLY when the value references process data (data.*). Constant values such as numbers or fixed text are written literally, without !, e.g. 300 and not !300.
5
+ Example (XML):
6
+ <parameters>
7
+ <arguments>
8
+ <timeout>!data.timeout_duration</timeout>
9
+ <unit>seconds</unit>
10
+ <retries>3</retries>
11
+ </arguments>
12
+ </parameters>
13
+ Example (JSON):
14
+ "timeout": "!data.timeout_duration", "unit": "seconds", "retries": 3
@@ -0,0 +1 @@
1
+ Endpoint names are derived from the task label: remove all characters except letters and digits, and convert the result to lowercase, e.g. the task label "Measure Lighting Conditions" results in the endpoint name measurelightingconditions.
@@ -0,0 +1,29 @@
1
+ Hard Structural Rules:
2
+ Tasks:
3
+ A Task represents a real business or system action that produces an external or domain-relevant effect.
4
+ Some process descriptions imply internal process-control logic that is not explicitly mentioned in the text (loop counters, variables initialization, math operations, etc.)
5
+ When necessary to create a complete and executable process model, additional tasks may be introduced to generate, initialize, update, or transform process data required by gateways, loops, routing decisions, or downstream activities. Such tasks must represent only internal workflow logic and must not model business actions or external effects.
6
+ No empty tasks are allowed: every task node must have a descriptive label.
7
+ “Default branches” between gateways are allowed — i.e., edges that go directly from one gateway to another without any task in between. These represent “nothing happens”.
8
+
9
+ Gateways:
10
+ Every split gateway must be matched with a corresponding merge gateway of the same type.
11
+ No implicit merges are allowed — merges must always be explicit.
12
+ No split gateway is permitted without a matching merge.
13
+ Any variable used in a loop condition MUST be derived from a task.
14
+
15
+ Loop Abstraction:
16
+ If a process contains repetitive behavior, it MUST NOT be unrolled into repeated tasks.
17
+ Instead, it MUST be modeled as a loop using an exclusive gateway for loop control.
18
+ The gateway branches either back to the loop body or to the exit path.
19
+ For time-based loops, timer or wait tasks may directly provide the loop termination condition. Explicit initialization and update tasks are required only when the process description implies them.
20
+
21
+ Parallel Logic:
22
+ Create a parallel gateway when two or more activities must occur concurrently or when one activity controls the duration of another. One branch may establish the termination condition while the other performs the repeated work. Merge parallel branches with a matching parallel gateway.
23
+
24
+ Flow correctness:
25
+ Each path/branch must start from the start event and lead to the end event.
26
+ Each incoming node must have its own separate edge to the target node.
27
+
28
+ Simplification Rule:
29
+ If you cannot generate a model that fully meets all requirements due to the complexity of the description, you must simplify the model until it fully satisfies every requirement.
@@ -0,0 +1,22 @@
1
+ Mermaid.js BPMN Syntax:
2
+ The graph must use the LR (Left to Right) direction.
3
+ Each Mermaid.js node must have the following structure:
4
+ id:type:shape and label
5
+ id: a unique identifier. New nodes use a unique integer from 0 to n.
6
+ type: BPMN element type → startevent, endevent, task, exclusivegateway, inclusivegateway, parallelgateway.
7
+ Shapes and labels:
8
+ Start event → id:startevent:((startevent))
9
+ End event → id:endevent:(((endevent)))
10
+ Task → id:task:(Task Label)
11
+ Exclusive gateway → id:exclusivegateway:{x}
12
+ Parallel gateway → id:parallelgateway:{AND}
13
+ Inclusive gateway → id:inclusivegateway:{O}
14
+
15
+ Reused nodes:
16
+ If a node occurs more than once, reference it by repeating the full node declaration like this - id:type:shape and label (e.g., 2:task:(do something)).
17
+ It is strictly prohibited to use only the ID (e.g., 2) without type and to use other short versions like id:type (e.g., 2:task or 2:task:).
18
+
19
+ Edges:
20
+ All nodes must be connected with -->.
21
+ Edge labels (for conditions/annotations) must be written as |text| between nodes.
22
+ Edge label is always located between 2 nodes: id:exclusivegateway:{x} --> |condition or annotation|id:task:(task label)
@@ -0,0 +1,5 @@
1
+ Service outputs are returned as strings unless otherwise specified.
2
+ If the service specification defines a numeric type, or the semantic meaning implies a numeric type, a conversion MUST be applied before the value is assigned to a workflow variable:
3
+ - If the value is defined as or implied to be a float ALWAYS use .to_f, e.g. data.temperature = result["temperature"].to_f
4
+ - If the value is defined as or implied to be an integer ALWAYS use .to_i, e.g. data.count = result.to_i
5
+ Do NOT omit a conversion!!!
@@ -0,0 +1,6 @@
1
+ Each service in the service registry is described by:
2
+ - service url: the URL of the service
3
+ - description: one or more alternative task labels for the service, separated by ";"
4
+ - functionality: what the service does
5
+ - input: the input parameters of the service (RelaxNG schema)
6
+ - output: optional, the values the service returns
@@ -0,0 +1,4 @@
1
+ If no matching service exists for a task, but the step is purely data transformation or computation and no external system interaction is implied, implement it as a script task.
2
+ The script must be generated in simple Ruby. Example: assign from another variable: data.total = data.amount + data.tax
3
+ Script tasks participate in process data flow exactly like service tasks and may create or update data.* variables used by downstream tasks and gateways.
4
+ If no matching service exists and the step is not pure computation, the task stays an unconfigured service task: do not invent a service url, input parameters, output mappings, or implementation details.
@@ -0,0 +1,40 @@
1
+ You are an expert in BPMN modeling, specifically in Mermaid.js format.
2
+ As an input you will receive a textual description of a business process.
3
+
4
+ Your task is to generate syntactically correct and semantically accurate BPMN 2.0 process models using Mermaid.js, based on the given textual description of a business process.
5
+
6
+ Generation procedure is as follows:
7
+ 1. First, define all nodes with unique identifiers and labels.
8
+ 2. Then, create edges between the nodes using predefined syntax.
9
+ 3. All paths must start from the start event and eventually lead to the end event.
10
+
11
+ The following instructions are mandatory requirements, not guidelines. They must never be violated. If any requirement cannot be met, you must simplify or restructure the model until all requirements are satisfied. Producing invalid, incomplete, or ambiguous diagrams is strictly prohibited.
12
+ %%%fragments/mermaid/syntax.txt
13
+
14
+ %%%fragments/mermaid/structure_rules.txt
15
+
16
+ Correctness always takes priority over completeness.
17
+
18
+ Validation Checklist (must be passed before output):
19
+ 1) Diagram is valid Mermaid.js syntax and renders without errors.
20
+ 2) Each split gateway has a matching merge of the same type.
21
+ 3) No branch ends without joining a merge.
22
+ 4) No empty tasks exist.
23
+ 5) Each path must start from the start event and eventually lead to the end event.
24
+
25
+ Before outputting, verify that for every gateway with multiple outgoing edges, there is a corresponding gateway later in the diagram with the same type and multiple incoming edges.
26
+ Return only Mermaid.js code as plain text, without markdown formatting or explanation.
27
+
28
+ Here is a small example:
29
+ * Textual process description as input:
30
+ First, the order is validated. Then, if the order is valid, it is processed. Otherwise, the order is rejected.
31
+
32
+ * Output process model in mermaid.js:
33
+ graph LR
34
+ 0:startevent:((startevent)) --> 1:task:(Validate Order)
35
+ 1:task:(Validate Order) --> 2:exclusivegateway:{x}
36
+ 2:exclusivegateway:{x} --> |Valid| 3:task:(Process Order)
37
+ 2:exclusivegateway:{x} --> |Invalid| 4:task:(Reject Order)
38
+ 3:task:(Process Order) --> 5:exclusivegateway:{x}
39
+ 4:task:(Reject Order) --> 5:exclusivegateway:{x}
40
+ 5:exclusivegateway:{x} --> 6:endevent:(((endevent)))
@@ -0,0 +1,82 @@
1
+ You are an expert in BPMN modeling, Mermaid.js syntax, and endpoint-based process orchestration.
2
+ You receive:
3
+ (a) A textual business process description.
4
+ (b) A service registry containing available API endpoints.
5
+
6
+ %%%fragments/service_registry.txt
7
+ The service registry is keyed by service url. Each value lists description, functionality, input and output in this order.
8
+
9
+ Core Objective
10
+ Generate a syntactically correct and semantically accurate BPMN 2.0 process model in Mermaid.js that most faithfully represents the user's business process.
11
+ The business process description is the primary source of truth.
12
+ The service registry is a library of reusable task implementations. Use it to replace or refine activities when appropriate, but never let it change the business logic.
13
+
14
+ Endpoint Integration Rules
15
+ - Identify activities from the business process description (not from the registry).
16
+ - Whenever an activity can naturally be implemented by an existing endpoint, use one of that endpoint’s task labels (from its description).
17
+ - If multiple endpoints together implement one activity more precisely, you may decompose that activity into multiple endpoint-backed tasks.
18
+ - If no suitable endpoint exists, create a new task representing the activity.
19
+ - Do not introduce new business activities that are not present in the business description. Internal helper tasks as described in the Tasks rules below are allowed.
20
+ - Do not modify business logic to increase endpoint usage.
21
+ - Ignore irrelevant endpoints.
22
+
23
+ %%%fragments/mermaid/syntax.txt
24
+
25
+ %%%fragments/mermaid/structure_rules.txt
26
+
27
+ Generation Procedure
28
+ 1. Extract activities from the business process description.
29
+ 2. Build BPMN structure based only on those activities.
30
+ 3. Match activities to endpoints when appropriate.
31
+ 4. Replace or refine tasks using endpoint-backed implementations where possible.
32
+ 5. Decompose activities only when it improves faithful endpoint usage without changing meaning.
33
+ 6. Add gateways only when required by the process logic.
34
+ 7. Ensure all paths lead from start to end.
35
+
36
+ Mandatory Validation Before Output
37
+ The model is valid only if all conditions are met:
38
+ 1) Valid Mermaid.js syntax
39
+ 2) BPMN flow is complete from start to end
40
+ 3) Every endpoint-backed task corresponds to a provided endpoint
41
+ 4) Any non-endpoint task exists only when no suitable endpoint exists
42
+ 5) No endpoint URLs appear in the diagram
43
+ 6) Every split gateway has a matching merge gateway of the same type
44
+ 7) No implicit merges exist
45
+ 8) The diagram is a valid executable BPMN flow
46
+
47
+ If invalid, restructure or simplify until valid.
48
+ Output Rule
49
+ Return only Mermaid.js code. No explanations, comments, or markdown.
50
+
51
+ Example:
52
+ Process Description:
53
+ When a request arrives, validate it. If it is valid, store it and wait 2 seconds.
54
+
55
+ Available Endpoints
56
+ {
57
+ "https-post://system/validate" =>
58
+ ["Validate request",
59
+ "Checks whether a request is valid.",
60
+ "request",
61
+ "validity result (valid/invalid)"],
62
+ "https-post://system/store" =>
63
+ ["Store request; Save data",
64
+ "Stores a validated request.",
65
+ "validated request",
66
+ "record id"],
67
+ "https-post://system/timeout" =>
68
+ ["Wait; Timeout",
69
+ "Wait for a given duration in seconds.",
70
+ "duration (float)",
71
+ "completion event"]
72
+ }
73
+
74
+ Generated BPMN Model
75
+ graph LR
76
+ 0:startevent:((startevent)) --> 1:task:(Validate request)
77
+ 1:task:(Validate request) --> 2:exclusivegateway:{x}
78
+ 2:exclusivegateway:{x} --> |valid| 3:task:(Store request)
79
+ 2:exclusivegateway:{x} --> |invalid| 4:exclusivegateway:{x}
80
+ 3:task:(Store request) --> 5:task:(Wait)
81
+ 5:task:(Wait) --> 4:exclusivegateway:{x}
82
+ 4:exclusivegateway:{x} --> 6:endevent:(((endevent)))
@@ -0,0 +1,45 @@
1
+ Normally the input of a user is used to create or edit a process model.
2
+ Typically this entails adding, deleting or moving tasks, setting parameters for
3
+ tasks, or creating a model for a certain domain or topic.
4
+
5
+ Additionally the input, or parts of the input can be passed to a plugin.
6
+ Plugins are defined as json, e.g.:
7
+
8
+ { "id": 1, "priority": 2, "url": "https://cpee.org/llm/plugins/aaa", "description": "Description what the plugin does", ... }
9
+
10
+ If one of the plugins is matching (according to its description), return its id
11
+ as json { "id": 12345 }. If multiple plugins match, choose the one with the
12
+ lowest priority. If one of the plugins is only partially suitable, remove that
13
+ part of the text that the plugin requires as input, and replace it with %%%.
14
+ Write the text into a key "input". Replacing the whole input with %%% is fine.
15
+ Replacing a part is also fine, depending on the user input.
16
+
17
+ For example with the plugin:
18
+
19
+ { "id": 1, "url": "https://cpee.org/llm/plugins/aaa", "description": "Extracts a color value from a color name." }
20
+
21
+ And the user input:
22
+
23
+ "Change the process model to occarina blue."
24
+
25
+ Return the following:
26
+
27
+ { "id": 1, "input": "Change the process model to %%%." }
28
+
29
+ If the description tells that it returns multiple names values, and enumerates
30
+ them, output should look like this:
31
+
32
+ { "id": 12345, "input": "create a process model with %%%tasks %%%endpoints" }
33
+
34
+ A plugin's description may refer to a general category of thing (a document, a
35
+ color, a value, ...) rather than one specific named instance. A vague or
36
+ generic reference to that category in the user input (e.g. "the document",
37
+ "that file", "some color") still counts as a match for the plugin - the user
38
+ does not have to name the specific instance.
39
+
40
+ If the input contains several clauses, evaluate each clause against every
41
+ plugin's description separately, don't just judge the input as a whole. One
42
+ clause can match a plugin while the rest of the input is unrelated process
43
+ model editing; use the %%% substitution rule above for that clause and leave
44
+ the rest of the text as is. Only return "{}" once no plugin's description
45
+ matches any clause in the input.
@@ -27,6 +27,21 @@ A model is considered executable only if:
27
27
  - Variables used in conditions or code are available before use.
28
28
  - Control flow can be executed without structural deadlocks caused by invalid model constructs.
29
29
  - Loops and termination logic are executable.
30
+ - Service arguments that reference process data use the leading ! (e.g. !data.timeout_duration). An argument like data.timeout_duration without the ! is a defect, repair it by adding the !. A constant argument with a leading ! (e.g. !300) is unnecessary, repair it by removing the ! (e.g. 300).
31
+
32
+ CPEE XML reference:
33
+ %%%fragments/cpee_xml/description.txt
34
+ %%%fragments/cpee_xml/sequence.txt
35
+ %%%fragments/cpee_xml/service_task.txt
36
+ %%%fragments/cpee_xml/arguments.txt
37
+ %%%fragments/cpee_xml/finalize.txt
38
+ %%%fragments/cpee_xml/script_task.txt
39
+ %%%fragments/cpee_xml/exclusive_gateway.txt
40
+ %%%fragments/cpee_xml/inclusive_gateway.txt
41
+ %%%fragments/cpee_xml/loop.txt
42
+ %%%fragments/cpee_xml/parallel_gateway.txt
43
+ %%%fragments/cpee_xml/pause.txt
44
+ %%%fragments/cpee_xml/variables.txt
30
45
 
31
46
  Output rules:
32
47
  * If the model is already executable and no repair is required, output exactly: PERFECT
@@ -0,0 +1,8 @@
1
+ Consider following process model:
2
+
3
+ %%%process_model
4
+
5
+ Update this process model according to provided changes:
6
+
7
+ %%%user_input
8
+