tide-commander 1.32.2 → 1.35.0
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.
- package/dist/assets/{BossLogsModal-2lqGyuCD.js → BossLogsModal-B_dgVF7L.js} +1 -1
- package/dist/assets/{BossSpawnModal-CR-ofDeB.js → BossSpawnModal-CSO1bYxA.js} +1 -1
- package/dist/assets/{ControlsModal-DQ8QVshA.js → ControlsModal-WMTTqbca.js} +1 -1
- package/dist/assets/{DockerLogsModal-D6yQTHy7.js → DockerLogsModal-THzhLHch.js} +1 -1
- package/dist/assets/{EmbeddedEditor-wechGxGl.js → EmbeddedEditor-DWLKJYav.js} +1 -1
- package/dist/assets/GmailOAuthSetup-DN9ceaS6.js +270 -0
- package/dist/assets/{GoogleOAuthSetup-BcpJEydM.js → GoogleOAuthSetup-bVST2EOB.js} +1 -1
- package/dist/assets/{IframeModal-E2E7NR08.js → IframeModal-BELsjvgi.js} +1 -1
- package/dist/assets/{IntegrationsPanel-CrS2QOFR.js → IntegrationsPanel-DwDr4BRt.js} +2 -2
- package/dist/assets/{LogViewerModal-BpIPZeFr.js → LogViewerModal-CMe04PO5.js} +1 -1
- package/dist/assets/MonitoringModal-CqSalNeY.js +1 -0
- package/dist/assets/{PM2LogsModal-CDk_2mi1.js → PM2LogsModal-CCmCDxVt.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-BmgBrk9J.js → RestoreArchivedAreaModal-IfzPidIv.js} +1 -1
- package/dist/assets/{SaveSnapshotModal-DWta9pcx.js → SaveSnapshotModal-DUhrVD5l.js} +1 -1
- package/dist/assets/{Scene2DCanvas-C3CcFsjU.js → Scene2DCanvas-Bl5DUC7w.js} +1 -1
- package/dist/assets/{SceneManager-mFUakRNl.js → SceneManager-BGO9tiaI.js} +1 -1
- package/dist/assets/{SkillsPanel-Br3h8GNh.js → SkillsPanel-CPFOI4Tl.js} +1 -1
- package/dist/assets/{SnapshotManager-CPYWfnPR.js → SnapshotManager-Cbu0tJBz.js} +1 -1
- package/dist/assets/{SpawnModal-DSDirR0j.js → SpawnModal-BqDbsYLY.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-Daz67phV.js → SubordinateAssignmentModal-DOqkhL_L.js} +1 -1
- package/dist/assets/{SupervisorPanel-DoAl5e8W.js → SupervisorPanel-BvX-dlk_.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-CVIHbqDt.js → TriggerManagerPanel-RUVFmKmf.js} +1 -1
- package/dist/assets/WorkflowEditorPanel-CwZpEqzM.js +42 -0
- package/dist/assets/browser-ponyfill-DZOWXZ4K.js +2 -0
- package/dist/assets/camera-D_KeL_pz.js +1 -0
- package/dist/assets/{index-I-I3pPPW.js → index-B-wV06cR.js} +1 -1
- package/dist/assets/index-BFguOWBW.js +2 -0
- package/dist/assets/{index-uXOqPsuU.js → index-C7gqY2AA.js} +1 -1
- package/dist/assets/{index-CE_GbjZ6.js → index-CiD1Rwaq.js} +1 -1
- package/dist/assets/index-D4nfDvz4.js +49 -0
- package/dist/assets/{index-CvMf5n2v.js → index-DDPUtz8-.js} +1 -1
- package/dist/assets/{index-Chrxgrys.js → index-EH8IBvSU.js} +1 -1
- package/dist/assets/{index-DWVQ48nQ.js → index-H0PzHVFw.js} +1 -1
- package/dist/assets/main-Cjm0d8dZ.js +152 -0
- package/dist/assets/main-DqC9_fF4.css +1 -0
- package/dist/assets/{prism-cpp-CcQnz8LL.js → prism-cpp-CK2Ly5dS.js} +1 -1
- package/dist/assets/{prism-csharp-DFIAaw4Y.js → prism-csharp-ByDDDiWW.js} +1 -1
- package/dist/assets/{prism-elixir-jP4m4T-8.js → prism-elixir-df27OMMQ.js} +1 -1
- package/dist/assets/{prism-haskell-BrMZM7_F.js → prism-haskell-Ce8aBmia.js} +1 -1
- package/dist/assets/{prism-java-BEsh8u4L.js → prism-java-CK6tws4L.js} +1 -1
- package/dist/assets/{prism-perl-ecHKp0bZ.js → prism-perl-UZfqnD51.js} +1 -1
- package/dist/assets/{prism-php-Ch-kk89U.js → prism-php-Dt9698bA.js} +1 -1
- package/dist/assets/{prism-ruby-zNpGDk6v.js → prism-ruby-CQBUuZIF.js} +1 -1
- package/dist/assets/{prism-scss-BeuXx0O0.js → prism-scss-CeN16CFC.js} +1 -1
- package/dist/assets/{vendor-react-uS-d4TUT.js → vendor-react--Eh9ivFN.js} +2 -2
- package/dist/assets/{web-IWJRtE3-.js → web-D1vWYL8u.js} +1 -1
- package/dist/assets/{web-DdRt5c0R.js → web-DUq3Undh.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/src/packages/server/data/builtin-skills/boss-instructions.js +57 -66
- package/dist/src/packages/server/data/builtin-skills/index.js +2 -0
- package/dist/src/packages/server/data/builtin-skills/workflow-builder.js +253 -0
- package/dist/src/packages/server/data/builtin-skills/workflow-designer.js +157 -0
- package/dist/src/packages/server/data/event-queries.js +24 -0
- package/dist/src/packages/server/data/migrations/002_workflow_agent_binding.sql +14 -0
- package/dist/src/packages/server/data/migrations/003_matcher_executions.sql +19 -0
- package/dist/src/packages/server/data/migrations/004_matcher_message_source.sql +8 -0
- package/dist/src/packages/server/integrations/gmail/gmail-client.js +75 -15
- package/dist/src/packages/server/integrations/gmail/gmail-config.js +32 -2
- package/dist/src/packages/server/integrations/gmail/gmail-routes.js +5 -0
- package/dist/src/packages/server/integrations/gmail/index.js +23 -1
- package/dist/src/packages/server/integrations/jira/jira-client.js +11 -5
- package/dist/src/packages/server/integrations/jira/jira-routes.js +20 -3
- package/dist/src/packages/server/integrations/jira/jira-skill.js +110 -58
- package/dist/src/packages/server/routes/trigger-routes.js +22 -0
- package/dist/src/packages/server/routes/workflow-routes.js +86 -2
- package/dist/src/packages/server/services/boss-message-service.js +1 -1
- package/dist/src/packages/server/services/llm-matcher-service.js +50 -81
- package/dist/src/packages/server/services/trigger-service.js +195 -6
- package/dist/src/packages/server/services/workflow-executor.js +230 -0
- package/dist/src/packages/server/services/workflow-service.js +59 -13
- package/package.json +7 -7
- package/dist/assets/GmailOAuthSetup-B2GDjROU.js +0 -222
- package/dist/assets/MonitoringModal-CIF9MUm9.js +0 -1
- package/dist/assets/WorkflowEditorPanel-C4BRfmDM.js +0 -42
- package/dist/assets/browser-ponyfill-DIm4hKhx.js +0 -2
- package/dist/assets/camera-8crtHeRa.js +0 -1
- package/dist/assets/index--PCy0J0f.js +0 -49
- package/dist/assets/index-DOzx4Y9b.js +0 -2
- package/dist/assets/main-DQpuQfqS.css +0 -1
- package/dist/assets/main-DahZb6P4.js +0 -152
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Builder - Built-in Skill Definition
|
|
3
|
+
* Provides agents with runtime context when executing workflow states.
|
|
4
|
+
* The generateWorkflowExecutorPrompt() function creates a prompt that tells
|
|
5
|
+
* an agent what workflow it's in, what state it's executing, what variables
|
|
6
|
+
* are available, and how to update variables / signal completion.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Generate a prompt for an agent executing a workflow state.
|
|
10
|
+
* This gives the agent full context about the workflow instance,
|
|
11
|
+
* current state, available variables, and API endpoints.
|
|
12
|
+
*/
|
|
13
|
+
export function generateWorkflowExecutorPrompt(params) {
|
|
14
|
+
const { authToken, port, instanceId, workflowName, currentStateId, currentStateName, currentStateType, promptTemplate, variables, skills, agentId, allStates, transitions, } = params;
|
|
15
|
+
const variablesList = Object.entries(variables)
|
|
16
|
+
.map(([k, v]) => `- **${k}**: ${v !== undefined && v !== null ? JSON.stringify(v) : '(not set)'}`)
|
|
17
|
+
.join('\n');
|
|
18
|
+
const statesList = allStates
|
|
19
|
+
.map((s) => `- ${s.name} (${s.id}) [${s.type}]${s.id === currentStateId ? ' ← YOU ARE HERE' : ''}`)
|
|
20
|
+
.join('\n');
|
|
21
|
+
const transitionsList = transitions
|
|
22
|
+
.map((t) => `- "${t.name}" → ${t.targetStateId} (on ${t.conditionType})`)
|
|
23
|
+
.join('\n');
|
|
24
|
+
const skillsList = skills.length > 0
|
|
25
|
+
? skills.map((s) => `- ${s}`).join('\n')
|
|
26
|
+
: '- (none assigned)';
|
|
27
|
+
return `# Workflow Executor Context
|
|
28
|
+
|
|
29
|
+
You are executing a step in an active workflow instance.
|
|
30
|
+
|
|
31
|
+
## Workflow: ${workflowName}
|
|
32
|
+
**Instance ID:** ${instanceId}
|
|
33
|
+
**Current State:** ${currentStateName} (${currentStateId}) [${currentStateType}]
|
|
34
|
+
**Agent:** ${agentId}
|
|
35
|
+
|
|
36
|
+
## Your Task
|
|
37
|
+
|
|
38
|
+
${promptTemplate}
|
|
39
|
+
|
|
40
|
+
## Available Variables
|
|
41
|
+
|
|
42
|
+
${variablesList}
|
|
43
|
+
|
|
44
|
+
## Workflow States
|
|
45
|
+
|
|
46
|
+
${statesList}
|
|
47
|
+
|
|
48
|
+
## Transitions from Current State
|
|
49
|
+
|
|
50
|
+
${transitionsList}
|
|
51
|
+
|
|
52
|
+
## Assigned Skills
|
|
53
|
+
|
|
54
|
+
${skillsList}
|
|
55
|
+
|
|
56
|
+
## How to Update Workflow Variables
|
|
57
|
+
|
|
58
|
+
When your task produces results, update the workflow variables so downstream states can use them:
|
|
59
|
+
|
|
60
|
+
\`\`\`bash
|
|
61
|
+
curl -s -X PATCH "http://localhost:${port}/api/workflows/instances/${instanceId}/variables" \\
|
|
62
|
+
-H "Content-Type: application/json" \\
|
|
63
|
+
-H "X-Auth-Token: ${authToken}" \\
|
|
64
|
+
-d '{ "variables": { "variable_name": "value" }, "changedBy": "agent:${agentId}" }'
|
|
65
|
+
\`\`\`
|
|
66
|
+
|
|
67
|
+
## How to Check Available Transitions
|
|
68
|
+
|
|
69
|
+
Before transitioning, check which transitions are available from the current state:
|
|
70
|
+
|
|
71
|
+
\`\`\`bash
|
|
72
|
+
curl -s -H "X-Auth-Token: ${authToken}" "http://localhost:${port}/api/workflows/instances/${instanceId}/available-transitions"
|
|
73
|
+
\`\`\`
|
|
74
|
+
|
|
75
|
+
Returns: \`{ "transitions": [{ "id": "...", "name": "...", "targetStateId": "...", "targetStateName": "...", "conditionType": "..." }] }\`
|
|
76
|
+
|
|
77
|
+
## How to Transition to the Next State
|
|
78
|
+
|
|
79
|
+
When your task is done, explicitly transition the workflow to the next state. Choose the appropriate target state from the available transitions above:
|
|
80
|
+
|
|
81
|
+
\`\`\`bash
|
|
82
|
+
curl -s -X PUT "http://localhost:${port}/api/workflows/instances/${instanceId}/transition" \\
|
|
83
|
+
-H "Content-Type: application/json" \\
|
|
84
|
+
-H "X-Auth-Token: ${authToken}" \\
|
|
85
|
+
-d '{ "targetStateId": "TARGET_STATE_ID", "reason": "Brief explanation of why this transition" }'
|
|
86
|
+
\`\`\`
|
|
87
|
+
|
|
88
|
+
## How to Signal Task Completion (Legacy)
|
|
89
|
+
|
|
90
|
+
Alternatively, signal completion via an event (the workflow engine matches the event to a transition):
|
|
91
|
+
|
|
92
|
+
\`\`\`bash
|
|
93
|
+
curl -s -X POST "http://localhost:${port}/api/workflows/instances/${instanceId}/event" \\
|
|
94
|
+
-H "Content-Type: application/json" \\
|
|
95
|
+
-H "X-Auth-Token: ${authToken}" \\
|
|
96
|
+
-d '{ "eventType": "agent_complete", "data": { "agentResponse": "Brief summary of what you did" } }'
|
|
97
|
+
\`\`\`
|
|
98
|
+
|
|
99
|
+
## Important Rules
|
|
100
|
+
|
|
101
|
+
1. **Always update variables BEFORE transitioning** — downstream states need your results
|
|
102
|
+
2. **Always transition or signal completion** — the workflow waits for you to move it forward
|
|
103
|
+
3. **Check available transitions** to know which target states are valid
|
|
104
|
+
4. **Use the skills assigned** to accomplish your task (listed above)
|
|
105
|
+
5. **Reference variables** using their current values shown above
|
|
106
|
+
6. **Do not modify states or transitions** — only update variables and drive transitions
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
export const workflowBuilder = {
|
|
110
|
+
slug: 'workflow-builder',
|
|
111
|
+
name: 'Workflow Builder',
|
|
112
|
+
description: 'Runtime context and API reference for agents executing workflow states',
|
|
113
|
+
allowedTools: ['Bash(curl:*)'],
|
|
114
|
+
content: `# Workflow Builder — Agent Execution Guide
|
|
115
|
+
|
|
116
|
+
When you are assigned a workflow state task, you receive context about the workflow instance,
|
|
117
|
+
your current state, available variables, and the API endpoints to interact with the workflow engine.
|
|
118
|
+
|
|
119
|
+
## Workflow Execution Lifecycle
|
|
120
|
+
|
|
121
|
+
1. The workflow engine enters your state and sends you a prompt
|
|
122
|
+
2. You execute your task using the assigned skills
|
|
123
|
+
3. You update workflow variables with your results
|
|
124
|
+
4. You signal completion so the workflow transitions to the next state
|
|
125
|
+
|
|
126
|
+
## Update Variables
|
|
127
|
+
|
|
128
|
+
Store your results in workflow variables so downstream states can use them:
|
|
129
|
+
|
|
130
|
+
\`\`\`bash
|
|
131
|
+
curl -s -X PATCH "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/variables" \\
|
|
132
|
+
-H "Content-Type: application/json" \\
|
|
133
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}" \\
|
|
134
|
+
-d '{ "variables": { "result_key": "result_value" }, "changedBy": "agent:YOUR_AGENT_ID" }'
|
|
135
|
+
\`\`\`
|
|
136
|
+
|
|
137
|
+
## Check Available Transitions
|
|
138
|
+
|
|
139
|
+
Before transitioning, see which next states are valid:
|
|
140
|
+
|
|
141
|
+
\`\`\`bash
|
|
142
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/available-transitions"
|
|
143
|
+
\`\`\`
|
|
144
|
+
|
|
145
|
+
Returns a list of transitions with id, name, targetStateId, targetStateName, and conditionType.
|
|
146
|
+
|
|
147
|
+
## Transition to Next State
|
|
148
|
+
|
|
149
|
+
After finishing your task, explicitly move the workflow to the next state:
|
|
150
|
+
|
|
151
|
+
\`\`\`bash
|
|
152
|
+
curl -s -X PUT "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/transition" \\
|
|
153
|
+
-H "Content-Type: application/json" \\
|
|
154
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}" \\
|
|
155
|
+
-d '{ "targetStateId": "TARGET_STATE_ID", "reason": "Why this transition was chosen" }'
|
|
156
|
+
\`\`\`
|
|
157
|
+
|
|
158
|
+
## Signal Completion (Legacy)
|
|
159
|
+
|
|
160
|
+
Alternatively, signal the workflow engine with an event:
|
|
161
|
+
|
|
162
|
+
\`\`\`bash
|
|
163
|
+
curl -s -X POST "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/event" \\
|
|
164
|
+
-H "Content-Type: application/json" \\
|
|
165
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}" \\
|
|
166
|
+
-d '{ "eventType": "agent_complete", "data": { "agentResponse": "Summary of what was done" } }'
|
|
167
|
+
\`\`\`
|
|
168
|
+
|
|
169
|
+
## Read Current Variables
|
|
170
|
+
|
|
171
|
+
Check the current state of all workflow variables:
|
|
172
|
+
|
|
173
|
+
\`\`\`bash
|
|
174
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID"
|
|
175
|
+
\`\`\`
|
|
176
|
+
|
|
177
|
+
## Read Instance Timeline
|
|
178
|
+
|
|
179
|
+
See execution history and previous state transitions:
|
|
180
|
+
|
|
181
|
+
\`\`\`bash
|
|
182
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/timeline"
|
|
183
|
+
\`\`\`
|
|
184
|
+
|
|
185
|
+
## Read Step Logs
|
|
186
|
+
|
|
187
|
+
See what previous agents did in earlier states:
|
|
188
|
+
|
|
189
|
+
\`\`\`bash
|
|
190
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/steps"
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
## Variable Interpolation
|
|
194
|
+
|
|
195
|
+
In prompt templates, variables are referenced with double braces: \`{{variable_name}}\`.
|
|
196
|
+
The workflow engine substitutes these before sending you the prompt.
|
|
197
|
+
|
|
198
|
+
## Common Patterns
|
|
199
|
+
|
|
200
|
+
### Pattern: Collect and Store
|
|
201
|
+
1. Use a skill (e.g. slack-messaging) to gather information
|
|
202
|
+
2. Update variables with the collected data
|
|
203
|
+
3. Check available transitions, then transition to the next state
|
|
204
|
+
|
|
205
|
+
### Pattern: Generate and Forward
|
|
206
|
+
1. Use a skill (e.g. document-generator) to create output
|
|
207
|
+
2. Store the output reference (filename, URL) in variables
|
|
208
|
+
3. Transition to the next state so it can use the output
|
|
209
|
+
|
|
210
|
+
### Pattern: Notify and Complete
|
|
211
|
+
1. Use a skill (e.g. email-gmail, slack-messaging) to send a notification
|
|
212
|
+
2. Store confirmation details in variables
|
|
213
|
+
3. Transition to the next state
|
|
214
|
+
|
|
215
|
+
### Pattern: Decision Point
|
|
216
|
+
1. Evaluate current variables or task results
|
|
217
|
+
2. Check available transitions for the different paths
|
|
218
|
+
3. Choose the appropriate transition based on your decision
|
|
219
|
+
|
|
220
|
+
## Execution Rules
|
|
221
|
+
|
|
222
|
+
1. **Always update variables BEFORE transitioning** — downstream states depend on your output
|
|
223
|
+
2. **Always transition explicitly** — check available transitions, then PUT the target state
|
|
224
|
+
3. **Use only assigned skills** — the workflow definition specifies which skills you should use
|
|
225
|
+
4. **Do not skip steps** — execute the full task described in your prompt
|
|
226
|
+
5. **Handle errors gracefully** — if a skill fails, transition to an error state or include error details
|
|
227
|
+
6. **Be concise** — the reason in your transition should summarize what you did and why
|
|
228
|
+
|
|
229
|
+
## Error Handling
|
|
230
|
+
|
|
231
|
+
If your task fails, check available transitions for an error/failure path and transition there:
|
|
232
|
+
|
|
233
|
+
\`\`\`bash
|
|
234
|
+
# Check for error transitions
|
|
235
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/available-transitions"
|
|
236
|
+
|
|
237
|
+
# Transition to the error state
|
|
238
|
+
curl -s -X PUT "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/transition" \\
|
|
239
|
+
-H "Content-Type: application/json" \\
|
|
240
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}" \\
|
|
241
|
+
-d '{ "targetStateId": "ERROR_STATE_ID", "reason": "FAILED: reason for failure" }'
|
|
242
|
+
\`\`\`
|
|
243
|
+
|
|
244
|
+
If no error transition exists, use the event-based completion as fallback:
|
|
245
|
+
|
|
246
|
+
\`\`\`bash
|
|
247
|
+
curl -s -X POST "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/event" \\
|
|
248
|
+
-H "Content-Type: application/json" \\
|
|
249
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}" \\
|
|
250
|
+
-d '{ "eventType": "agent_complete", "data": { "agentResponse": "FAILED: reason for failure", "error": true } }'
|
|
251
|
+
\`\`\`
|
|
252
|
+
`,
|
|
253
|
+
};
|
|
@@ -168,6 +168,161 @@ curl -s -X POST "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/e
|
|
|
168
168
|
| \`helix\` | DNA-like double spiral |
|
|
169
169
|
| \`clockwork\` | Mechanical gears and cogs |
|
|
170
170
|
|
|
171
|
+
## Get Instance Details
|
|
172
|
+
|
|
173
|
+
\`\`\`bash
|
|
174
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID"
|
|
175
|
+
\`\`\`
|
|
176
|
+
|
|
177
|
+
Response includes current state, variables, status, and execution progress.
|
|
178
|
+
|
|
179
|
+
## List All Instances (with filtering)
|
|
180
|
+
|
|
181
|
+
\`\`\`bash
|
|
182
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances?workflowDefId=WORKFLOW_ID&status=running&limit=50"
|
|
183
|
+
\`\`\`
|
|
184
|
+
|
|
185
|
+
Filters available: \`workflowDefId\`, \`status\` (running, paused, completed, failed, cancelled), \`limit\`, \`offset\`
|
|
186
|
+
|
|
187
|
+
## Pause a Running Instance
|
|
188
|
+
|
|
189
|
+
Stop a workflow instance temporarily. All timers are suspended, state is preserved.
|
|
190
|
+
|
|
191
|
+
\`\`\`bash
|
|
192
|
+
curl -s -X PATCH "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/pause" \\
|
|
193
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}"
|
|
194
|
+
\`\`\`
|
|
195
|
+
|
|
196
|
+
## Resume a Paused Instance
|
|
197
|
+
|
|
198
|
+
Continue a paused workflow from where it left off.
|
|
199
|
+
|
|
200
|
+
\`\`\`bash
|
|
201
|
+
curl -s -X PATCH "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/resume" \\
|
|
202
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}"
|
|
203
|
+
\`\`\`
|
|
204
|
+
|
|
205
|
+
## Cancel a Running Instance
|
|
206
|
+
|
|
207
|
+
Terminate a workflow instance and mark it as cancelled.
|
|
208
|
+
|
|
209
|
+
\`\`\`bash
|
|
210
|
+
curl -s -X PATCH "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/cancel" \\
|
|
211
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}"
|
|
212
|
+
\`\`\`
|
|
213
|
+
|
|
214
|
+
## Get Instance Execution Timeline
|
|
215
|
+
|
|
216
|
+
View a chronological trace of state transitions, including timestamps and conditions that triggered each transition.
|
|
217
|
+
|
|
218
|
+
\`\`\`bash
|
|
219
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/timeline"
|
|
220
|
+
\`\`\`
|
|
221
|
+
|
|
222
|
+
## Get Instance Steps
|
|
223
|
+
|
|
224
|
+
View detailed information about each state execution: agent assignments, outcomes, variable changes.
|
|
225
|
+
|
|
226
|
+
\`\`\`bash
|
|
227
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/steps"
|
|
228
|
+
\`\`\`
|
|
229
|
+
|
|
230
|
+
## Get Variable Change History
|
|
231
|
+
|
|
232
|
+
Track all changes to a specific workflow variable (or all variables).
|
|
233
|
+
|
|
234
|
+
\`\`\`bash
|
|
235
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/variables?variableName=release_name"
|
|
236
|
+
\`\`\`
|
|
237
|
+
|
|
238
|
+
Omit \`variableName\` to see history of all variables.
|
|
239
|
+
|
|
240
|
+
## Get Instance Reasoning Trace
|
|
241
|
+
|
|
242
|
+
View the decision-making logic and Claude reasoning for each workflow step (if available).
|
|
243
|
+
|
|
244
|
+
\`\`\`bash
|
|
245
|
+
curl -s -H "X-Auth-Token: {{AUTH_TOKEN}}" "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/reasoning"
|
|
246
|
+
\`\`\`
|
|
247
|
+
|
|
248
|
+
## Trigger Manual Transition
|
|
249
|
+
|
|
250
|
+
Force a workflow to transition via a specific transition ID. Useful for manual approvals or overrides.
|
|
251
|
+
|
|
252
|
+
\`\`\`bash
|
|
253
|
+
curl -s -X POST "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/transition" \\
|
|
254
|
+
-H "Content-Type: application/json" \\
|
|
255
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}" \\
|
|
256
|
+
-d '{ "transitionId": "t1" }'
|
|
257
|
+
\`\`\`
|
|
258
|
+
|
|
259
|
+
## Get Conversational Explanation of Workflow
|
|
260
|
+
|
|
261
|
+
Ask Claude AI questions about a workflow definition, execution trace, or design.
|
|
262
|
+
|
|
263
|
+
\`\`\`bash
|
|
264
|
+
curl -s -X POST "http://localhost:{{PORT}}/api/workflows/WORKFLOW_ID/chat" \\
|
|
265
|
+
-H "Content-Type: application/json" \\
|
|
266
|
+
-H "X-Auth-Token: {{AUTH_TOKEN}}" \\
|
|
267
|
+
-d '{
|
|
268
|
+
"message": "Why did the workflow transition to the error state?",
|
|
269
|
+
"scope": {
|
|
270
|
+
"type": "instance",
|
|
271
|
+
"instanceId": "INSTANCE_ID"
|
|
272
|
+
},
|
|
273
|
+
"conversationHistory": []
|
|
274
|
+
}'
|
|
275
|
+
\`\`\`
|
|
276
|
+
|
|
277
|
+
Scope types: \`definition\`, \`instance\`
|
|
278
|
+
|
|
279
|
+
## Troubleshooting Common Issues
|
|
280
|
+
|
|
281
|
+
### Workflow Stuck in a State
|
|
282
|
+
|
|
283
|
+
1. Get timeline to see last state: \`GET /instances/INSTANCE_ID/timeline\`
|
|
284
|
+
2. Check variable history: \`GET /instances/INSTANCE_ID/variables\`
|
|
285
|
+
3. Pause the instance: \`PATCH /instances/INSTANCE_ID/pause\`
|
|
286
|
+
4. Fix any issues manually or via variable update
|
|
287
|
+
5. Resume: \`PATCH /instances/INSTANCE_ID/resume\`
|
|
288
|
+
6. Or manually transition: \`POST /instances/INSTANCE_ID/transition\` with correct transitionId
|
|
289
|
+
|
|
290
|
+
### Agent Task Not Completing
|
|
291
|
+
|
|
292
|
+
1. Get steps to see agent's task: \`GET /instances/INSTANCE_ID/steps\`
|
|
293
|
+
2. Check reasoning trace: \`GET /instances/INSTANCE_ID/reasoning\`
|
|
294
|
+
3. Pause the instance while debugging
|
|
295
|
+
4. Contact the assigned agent or check agent logs
|
|
296
|
+
5. Manually transition once resolved
|
|
297
|
+
|
|
298
|
+
### Variable Not Updating
|
|
299
|
+
|
|
300
|
+
1. Check variable history: \`GET /instances/INSTANCE_ID/variables?variableName=YOUR_VAR\`
|
|
301
|
+
2. Use PATCH /variables endpoint to set correct value if needed
|
|
302
|
+
3. Verify agents in action states are using correct variable names in prompts
|
|
303
|
+
4. Use {{variable_name}} syntax (double braces) in promptTemplate
|
|
304
|
+
|
|
305
|
+
### Timeout Issues
|
|
306
|
+
|
|
307
|
+
- If a wait state is timing out incorrectly, check the \`afterMs\` value in the wait action config
|
|
308
|
+
- Get timeline to confirm timeout fired: \`GET /instances/INSTANCE_ID/timeline\`
|
|
309
|
+
- Pause and manually transition if needed
|
|
310
|
+
|
|
311
|
+
## Instance Lifecycle State Diagram
|
|
312
|
+
|
|
313
|
+
A workflow instance flows through these states:
|
|
314
|
+
|
|
315
|
+
\`\`\`
|
|
316
|
+
idle → running ──→ completed
|
|
317
|
+
↓ ↑
|
|
318
|
+
paused─┘
|
|
319
|
+
↓
|
|
320
|
+
cancelled
|
|
321
|
+
|
|
322
|
+
↓
|
|
323
|
+
failed ← (if agent/trigger error)
|
|
324
|
+
\`\`\`
|
|
325
|
+
|
|
171
326
|
## Design Guidelines
|
|
172
327
|
|
|
173
328
|
1. **State naming**: Use descriptive, action-oriented names ("Collect Requirements", "Generate Report")
|
|
@@ -176,5 +331,7 @@ curl -s -X POST "http://localhost:{{PORT}}/api/workflows/instances/INSTANCE_ID/e
|
|
|
176
331
|
4. **Skills**: Assign only the skills each state needs (slack-messaging, email-gmail, jira-service-desk, document-generator, google-calendar)
|
|
177
332
|
5. **Error handling**: Add timeout transitions on wait states. Consider error/escalation states
|
|
178
333
|
6. **Position**: Place workflow models near related buildings/agents in the work area
|
|
334
|
+
7. **Monitoring**: Use the chat API and timeline queries during development to understand execution flow
|
|
335
|
+
8. **Debugging**: When instances get stuck, use pause/resume and manual transitions as escape hatches
|
|
179
336
|
`,
|
|
180
337
|
};
|
|
@@ -388,6 +388,9 @@ function workflowRowToInstance(row) {
|
|
|
388
388
|
activeTriggerIds: fromJson(row.active_trigger_ids) ?? [],
|
|
389
389
|
activeTimers: fromJson(row.active_timers) ?? [],
|
|
390
390
|
error: row.error ?? undefined,
|
|
391
|
+
agentId: row.agent_id ?? undefined,
|
|
392
|
+
triggerId: row.trigger_id ?? undefined,
|
|
393
|
+
triggerData: fromJson(row.trigger_data_json) ?? undefined,
|
|
391
394
|
createdAt: row.created_at,
|
|
392
395
|
updatedAt: row.updated_at,
|
|
393
396
|
completedAt: row.completed_at ?? undefined,
|
|
@@ -404,6 +407,9 @@ export function insertWorkflowInstance(instance) {
|
|
|
404
407
|
active_trigger_ids: JSON.stringify(instance.activeTriggerIds),
|
|
405
408
|
active_timers: JSON.stringify(instance.activeTimers),
|
|
406
409
|
error: instance.error ?? null,
|
|
410
|
+
agent_id: instance.agentId ?? null,
|
|
411
|
+
trigger_id: instance.triggerId ?? null,
|
|
412
|
+
trigger_data_json: instance.triggerData ? JSON.stringify(instance.triggerData) : null,
|
|
407
413
|
created_at: instance.createdAt,
|
|
408
414
|
updated_at: instance.updatedAt,
|
|
409
415
|
completed_at: instance.completedAt ?? null,
|
|
@@ -436,6 +442,18 @@ export function updateWorkflowInstance(id, updates) {
|
|
|
436
442
|
setClauses.push('error = ?');
|
|
437
443
|
params.push(updates.error);
|
|
438
444
|
}
|
|
445
|
+
if (updates.agentId !== undefined) {
|
|
446
|
+
setClauses.push('agent_id = ?');
|
|
447
|
+
params.push(updates.agentId);
|
|
448
|
+
}
|
|
449
|
+
if (updates.triggerId !== undefined) {
|
|
450
|
+
setClauses.push('trigger_id = ?');
|
|
451
|
+
params.push(updates.triggerId);
|
|
452
|
+
}
|
|
453
|
+
if (updates.triggerData !== undefined) {
|
|
454
|
+
setClauses.push('trigger_data_json = ?');
|
|
455
|
+
params.push(JSON.stringify(updates.triggerData));
|
|
456
|
+
}
|
|
439
457
|
if (updates.updatedAt !== undefined) {
|
|
440
458
|
setClauses.push('updated_at = ?');
|
|
441
459
|
params.push(updates.updatedAt);
|
|
@@ -504,6 +522,7 @@ function stepLogRowToModel(row) {
|
|
|
504
522
|
promptSent: row.prompt_sent ?? undefined,
|
|
505
523
|
agentResponse: row.agent_response ?? undefined,
|
|
506
524
|
agentReasoning: row.agent_reasoning ?? undefined,
|
|
525
|
+
agentSummary: row.agent_summary ?? undefined,
|
|
507
526
|
triggerId: row.trigger_id ?? undefined,
|
|
508
527
|
triggerPayload: fromJson(row.trigger_payload),
|
|
509
528
|
variablesBefore: fromJson(row.variables_before),
|
|
@@ -528,6 +547,7 @@ export function insertStepLog(step) {
|
|
|
528
547
|
prompt_sent: step.promptSent ?? null,
|
|
529
548
|
agent_response: step.agentResponse ?? null,
|
|
530
549
|
agent_reasoning: step.agentReasoning ?? null,
|
|
550
|
+
agent_summary: step.agentSummary ?? null,
|
|
531
551
|
trigger_id: step.triggerId ?? null,
|
|
532
552
|
trigger_payload: toJson(step.triggerPayload),
|
|
533
553
|
variables_before: toJson(step.variablesBefore),
|
|
@@ -550,6 +570,10 @@ export function updateStepLog(id, updates) {
|
|
|
550
570
|
setClauses.push('agent_reasoning = ?');
|
|
551
571
|
params.push(updates.agentReasoning);
|
|
552
572
|
}
|
|
573
|
+
if (updates.agentSummary !== undefined) {
|
|
574
|
+
setClauses.push('agent_summary = ?');
|
|
575
|
+
params.push(updates.agentSummary);
|
|
576
|
+
}
|
|
553
577
|
if (updates.variablesAfter !== undefined) {
|
|
554
578
|
setClauses.push('variables_after = ?');
|
|
555
579
|
params.push(toJson(updates.variablesAfter));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- Migration 002: Workflow-as-Agent Architecture
|
|
2
|
+
-- Adds agent binding, trigger correlation, and agent summary fields
|
|
3
|
+
|
|
4
|
+
-- ─── workflow_instances: add agent_id and trigger correlation ───
|
|
5
|
+
|
|
6
|
+
ALTER TABLE workflow_instances ADD COLUMN agent_id TEXT;
|
|
7
|
+
ALTER TABLE workflow_instances ADD COLUMN trigger_id TEXT;
|
|
8
|
+
ALTER TABLE workflow_instances ADD COLUMN trigger_data_json TEXT;
|
|
9
|
+
|
|
10
|
+
CREATE INDEX idx_workflow_instances_agent ON workflow_instances(agent_id);
|
|
11
|
+
|
|
12
|
+
-- ─── workflow_step_log: add agent_summary ───
|
|
13
|
+
|
|
14
|
+
ALTER TABLE workflow_step_log ADD COLUMN agent_summary TEXT;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- Migration 003: Matcher Executions
|
|
2
|
+
-- Debugging layer for trigger matcher pipeline visibility
|
|
3
|
+
|
|
4
|
+
CREATE TABLE matcher_executions (
|
|
5
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
6
|
+
trigger_event_id INTEGER,
|
|
7
|
+
trigger_id TEXT NOT NULL,
|
|
8
|
+
matcher_type TEXT NOT NULL,
|
|
9
|
+
matcher_name TEXT NOT NULL,
|
|
10
|
+
executed_at INTEGER NOT NULL,
|
|
11
|
+
matched INTEGER NOT NULL DEFAULT 0,
|
|
12
|
+
confidence REAL,
|
|
13
|
+
reason TEXT,
|
|
14
|
+
result_json TEXT,
|
|
15
|
+
FOREIGN KEY (trigger_event_id) REFERENCES trigger_events(id)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE INDEX idx_matcher_executions_event ON matcher_executions(trigger_event_id);
|
|
19
|
+
CREATE INDEX idx_matcher_executions_trigger ON matcher_executions(trigger_id);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
-- Migration 004: Matcher Message Source
|
|
2
|
+
-- Adds source tracking to matcher_executions for per-message visibility
|
|
3
|
+
|
|
4
|
+
ALTER TABLE matcher_executions ADD COLUMN source_type TEXT;
|
|
5
|
+
ALTER TABLE matcher_executions ADD COLUMN source_id TEXT;
|
|
6
|
+
ALTER TABLE matcher_executions ADD COLUMN source_timestamp INTEGER;
|
|
7
|
+
|
|
8
|
+
CREATE INDEX idx_matcher_executions_source ON matcher_executions(source_type, source_id);
|