@unstable-dev/unmeshed-mcp 0.1.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.
Files changed (47) hide show
  1. package/README.md +64 -0
  2. package/dist/auth.d.ts +6 -0
  3. package/dist/auth.js +11 -0
  4. package/dist/client.d.ts +46 -0
  5. package/dist/client.js +97 -0
  6. package/dist/config.d.ts +10 -0
  7. package/dist/config.js +31 -0
  8. package/dist/get-docs.d.ts +8 -0
  9. package/dist/get-docs.js +64 -0
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.js +35 -0
  12. package/dist/server.d.ts +4 -0
  13. package/dist/server.js +203 -0
  14. package/knowledge/README.md +16 -0
  15. package/knowledge/SKILL.md +359 -0
  16. package/knowledge/assets/patterns.md +637 -0
  17. package/knowledge/execution/debugging-guide.md +18 -0
  18. package/knowledge/execution/process-run.schema.md +24 -0
  19. package/knowledge/execution/step-run.schema.md +21 -0
  20. package/knowledge/process-definition.schema.md +36 -0
  21. package/knowledge/references/integrations.md +914 -0
  22. package/knowledge/references/steps-knowledge.md +834 -0
  23. package/knowledge/step-definition.schema.md +140 -0
  24. package/knowledge/step-output-paths.md +45 -0
  25. package/knowledge/steps/DECISION_ENGINE.md +248 -0
  26. package/knowledge/steps/DEPENDSON.md +296 -0
  27. package/knowledge/steps/EXIT.md +220 -0
  28. package/knowledge/steps/FAIL.md +198 -0
  29. package/knowledge/steps/FLOW_GATEWAY.md +405 -0
  30. package/knowledge/steps/FOREACH.md +250 -0
  31. package/knowledge/steps/HTTP.md +183 -0
  32. package/knowledge/steps/JAVASCRIPT.md +192 -0
  33. package/knowledge/steps/JQ.md +189 -0
  34. package/knowledge/steps/LIST.md +279 -0
  35. package/knowledge/steps/NOOP.md +165 -0
  36. package/knowledge/steps/PARALLEL.md +366 -0
  37. package/knowledge/steps/PYTHON.md +206 -0
  38. package/knowledge/steps/SEND_RESPONSE.md +301 -0
  39. package/knowledge/steps/SQLITE.md +301 -0
  40. package/knowledge/steps/SUB_PROCESS.md +296 -0
  41. package/knowledge/steps/SWITCH.md +369 -0
  42. package/knowledge/steps/UPDATE_STEP.md +257 -0
  43. package/knowledge/steps/WAIT.md +218 -0
  44. package/knowledge/steps/WHILE.md +328 -0
  45. package/knowledge/steps/WORKER.md +233 -0
  46. package/knowledge/system-prompt.md +274 -0
  47. package/package.json +39 -0
@@ -0,0 +1,257 @@
1
+ # UPDATE_STEP Step Schema
2
+
3
+ `UPDATE_STEP` programmatically updates the status and output of a step in another
4
+ (or the same) running workflow. Use it for cross-workflow coordination, external
5
+ callback completion, human-task completion, or any scenario where one workflow
6
+ needs to unblock or modify a step in another workflow.
7
+
8
+ The step supports multiple matching strategies to locate the target step(s) and
9
+ will optionally poll/wait until the target becomes available.
10
+
11
+ ## Definition Input Schema
12
+
13
+ ```json
14
+ {
15
+ "inputMatchType": "BY_PROCESS_ID_REF",
16
+ "processId": 0,
17
+ "ref": "step_ref_to_update",
18
+ "correlationId": "",
19
+ "requestId": "",
20
+ "completionToken": "",
21
+ "stepId": 0,
22
+ "output": {},
23
+ "stepStatus": "COMPLETED",
24
+ "maxWaitSeconds": 86400,
25
+ "maxProcessContexts": 1,
26
+ "processName": "",
27
+ "allowCompletionWithoutMatch": false
28
+ }
29
+ ```
30
+
31
+ | Field | Type | Required | Default | Description |
32
+ |---|---|---|---|---|
33
+ | `inputMatchType` | string | Yes | — | How to find the target step. See match types below. |
34
+ | `ref` | string | Conditional | — | The step `ref` in the target process to update. Required for all match types except `BY_STEP_ID` and `BY_COMPLETION_TOKEN`. |
35
+ | `processId` | long | Conditional | `0` | Target process runtime ID. Required when `inputMatchType` is `BY_PROCESS_ID_REF`. |
36
+ | `correlationId` | string | Conditional | — | Correlation ID to match. Required when `inputMatchType` is `BY_CORRELATION_ID_REF`. |
37
+ | `requestId` | string | Conditional | — | Request ID to match. Required when `inputMatchType` is `BY_REQUEST_ID_REF`. |
38
+ | `completionToken` | string | Conditional | — | Completion token to match. Required when `inputMatchType` is `BY_COMPLETION_TOKEN`. |
39
+ | `stepId` | long | Conditional | `0` | Direct step ID to update. Required when `inputMatchType` is `BY_STEP_ID`. |
40
+ | `output` | object | No | `{}` | Key-value pairs to merge into the target step's output. |
41
+ | `stepStatus` | string | No | `"COMPLETED"` | Status to set on the target step. Valid values: `COMPLETED`, `FAILED`, `RUNNING`. |
42
+ | `maxWaitSeconds` | long | No | `86400` (24h) | Max time to wait for the target step to become available before failing. |
43
+ | `maxProcessContexts` | int | No | `1` | Max number of matching process contexts to update (for correlation/request ID matching). |
44
+ | `processName` | string | Conditional | — | Process definition name. Required for `BY_CORRELATION_ID_REF` and `BY_REQUEST_ID_REF`. |
45
+ | `allowCompletionWithoutMatch` | boolean | No | `false` | When `true` and `BY_COMPLETION_TOKEN` finds no matches, the step completes successfully instead of failing. |
46
+
47
+ ## Input Match Types
48
+
49
+ | Match Type | Finds target by | Required fields |
50
+ |---|---|---|
51
+ | `BY_PROCESS_ID_REF` | Runtime process ID + step ref | `processId`, `ref` |
52
+ | `BY_CORRELATION_ID_REF` | Correlation ID + step ref | `correlationId`, `ref`, `processName` |
53
+ | `BY_REQUEST_ID_REF` | Request ID + step ref | `requestId`, `ref`, `processName` |
54
+ | `BY_STEP_ID` | Direct step runtime ID | `stepId` |
55
+ | `BY_COMPLETION_TOKEN` | Completion token | `completionToken` |
56
+
57
+ ## Runtime Output Schema
58
+
59
+ ### Successful update
60
+
61
+ ```json
62
+ {
63
+ "__updateStepResults": {
64
+ "593084539:593084557": "Updated to: COMPLETED"
65
+ },
66
+ "__updateStepMetadata": [
67
+ {
68
+ "matchedExecutionStepId": 593084557,
69
+ "matchedExecutionProcessId": 593084539,
70
+ "updatedStatus": "COMPLETED",
71
+ "updatedStepRef": "wait_step_1",
72
+ "matchedExecutionProcessName": "my-workflow",
73
+ "matchedExecutionProcessVersion": 1
74
+ }
75
+ ]
76
+ }
77
+ ```
78
+
79
+ ### No match found (within wait period)
80
+
81
+ ```json
82
+ {
83
+ "__updateStepResults": {},
84
+ "error": "No qualified steps found within the wait period of 86400 seconds."
85
+ }
86
+ ```
87
+
88
+ ### Unqualified steps (already completed/cancelled)
89
+
90
+ ```json
91
+ {
92
+ "__updateStepResults": {
93
+ "593084539:593084557": "Step status not updatable: COMPLETED"
94
+ }
95
+ }
96
+ ```
97
+
98
+ ## Output Access Paths
99
+
100
+ Use:
101
+ - `steps.<ref>.output.__updateStepResults` — map of `"processId:stepId"` → status message for each matched step.
102
+ - `steps.<ref>.output.__updateStepMetadata` — array of metadata objects with details about each updated step.
103
+ - `steps.<ref>.output.__updateStepMetadata[0].matchedExecutionProcessId` — the process ID that was updated.
104
+ - `steps.<ref>.output.__updateStepMetadata[0].matchedExecutionStepId` — the step ID that was updated.
105
+ - `steps.<ref>.output.__updateStepMetadata[0].updatedStatus` — the status set on the target step.
106
+ - `steps.<ref>.output.error` — error message if the update failed.
107
+
108
+ Do not use:
109
+ - `steps.<ref>.output.result` — UPDATE_STEP does not wrap in `result`.
110
+ - `steps.<ref>.output.response` — UPDATE_STEP does not have a `response` wrapper.
111
+
112
+ ## Generation Rules
113
+
114
+ - Use uppercase step type: `"UPDATE_STEP"`.
115
+ - Use `children: []`; UPDATE_STEP is not a container.
116
+ - `inputMatchType` must be one of: `BY_PROCESS_ID_REF`, `BY_CORRELATION_ID_REF`, `BY_REQUEST_ID_REF`, `BY_STEP_ID`, `BY_COMPLETION_TOKEN`.
117
+ - `stepStatus` must be `COMPLETED`, `FAILED`, or `RUNNING`. Defaults to `COMPLETED` if omitted.
118
+ - `output` is optional — use it to inject data into the target step's output (e.g. results from an external callback).
119
+ - `maxWaitSeconds` controls how long the step polls before giving up. Default is 24 hours (86400). The engine polls every 30 seconds.
120
+ - Target steps must be in an updatable status (e.g. `SCHEDULED`, `RUNNING`). Already `COMPLETED`/`FAILED`/`CANCELLED` steps cannot be updated.
121
+ - When using `BY_CORRELATION_ID_REF` or `BY_REQUEST_ID_REF`, `processName` is required to scope the search.
122
+ - `maxProcessContexts` limits how many matching processes are updated (default 1).
123
+ - Do not use UPDATE_STEP to update steps in the same process instance (use `__statePut` or data flow instead).
124
+
125
+ ## Debugging Rules
126
+
127
+ When debugging an UPDATE_STEP:
128
+ - Check `__updateStepResults` to see which steps were updated and which were rejected.
129
+ - If a step shows "Step status not updatable", the target step has already completed or been cancelled.
130
+ - If `error` says "No qualified steps found within the wait period", the target step never became available — verify the target workflow is running and the step ref/IDs are correct.
131
+ - Check `__repeatCount` in the output to see how many polling attempts were made.
132
+ - If using `BY_COMPLETION_TOKEN` with no matches, set `allowCompletionWithoutMatch: true` to avoid failures.
133
+
134
+ Common failures:
135
+ - Wrong `inputMatchType` for the use case.
136
+ - Missing required fields for the chosen match type (e.g. `processId` missing for `BY_PROCESS_ID_REF`).
137
+ - Target step already in a terminal status (`COMPLETED`, `FAILED`, `CANCELLED`).
138
+ - Wrong `ref` or `processName` — these are case-sensitive.
139
+ - Setting `stepStatus` to an invalid value (only `COMPLETED`, `FAILED`, `RUNNING` are accepted).
140
+ - Using `maxWaitSeconds: 0` and the target step isn't ready yet — the step fails immediately.
141
+
142
+ ## Minimal Process Definition Example
143
+
144
+ ### Update by process ID + ref
145
+
146
+ ```json
147
+ {
148
+ "orgId": 1,
149
+ "namespace": "default",
150
+ "name": "update-step-example",
151
+ "version": 1,
152
+ "type": "API_ORCHESTRATION",
153
+ "description": "Complete a waiting step in another workflow.",
154
+ "configuration": null,
155
+ "steps": [
156
+ {
157
+ "orgId": 1,
158
+ "namespace": "default",
159
+ "name": "update_step",
160
+ "type": "UPDATE_STEP",
161
+ "ref": "update_step_1",
162
+ "optional": false,
163
+ "createdBy": "system",
164
+ "updatedBy": "system",
165
+ "description": null,
166
+ "label": null,
167
+ "created": 1700000000000,
168
+ "updated": 1700000000000,
169
+ "configuration": {
170
+ "errorPolicyName": null,
171
+ "useCache": false,
172
+ "cacheKey": null,
173
+ "cacheTimeoutSeconds": 0,
174
+ "stream": false,
175
+ "streamAllStatuses": false,
176
+ "preExecutionScript": null,
177
+ "constructInputFromScript": false,
178
+ "scriptLanguage": null,
179
+ "jqTransformer": null,
180
+ "rateLimitMaxRequests": 0,
181
+ "rateLimitWindowSeconds": 0
182
+ },
183
+ "children": [],
184
+ "input": {
185
+ "inputMatchType": "BY_PROCESS_ID_REF",
186
+ "processId": 593084539,
187
+ "ref": "wait_step_1",
188
+ "output": {
189
+ "callbackResult": "approved",
190
+ "approvedBy": "admin@example.com"
191
+ },
192
+ "stepStatus": "COMPLETED",
193
+ "maxWaitSeconds": 300
194
+ },
195
+ "output": null
196
+ }
197
+ ],
198
+ "defaultInput": null,
199
+ "defaultOutput": null,
200
+ "outputMapping": null,
201
+ "signature": null,
202
+ "metadata": null,
203
+ "tags": null,
204
+ "dependencies": null,
205
+ "dependents": null
206
+ }
207
+ ```
208
+
209
+ ### Update by correlation ID
210
+
211
+ ```json
212
+ {
213
+ "input": {
214
+ "inputMatchType": "BY_CORRELATION_ID_REF",
215
+ "correlationId": "order-12345",
216
+ "processName": "order-processor",
217
+ "ref": "approval_wait",
218
+ "output": { "approved": true },
219
+ "stepStatus": "COMPLETED",
220
+ "maxWaitSeconds": 60,
221
+ "maxProcessContexts": 1
222
+ }
223
+ }
224
+ ```
225
+
226
+ ### Update by completion token
227
+
228
+ ```json
229
+ {
230
+ "input": {
231
+ "inputMatchType": "BY_COMPLETION_TOKEN",
232
+ "completionToken": "tok_abc123",
233
+ "output": { "result": "callback-data" },
234
+ "stepStatus": "COMPLETED",
235
+ "allowCompletionWithoutMatch": false
236
+ }
237
+ }
238
+ ```
239
+
240
+ ## Common Pattern: External Callback Completion
241
+
242
+ A WAIT step in workflow A pauses until an external system calls back.
243
+ Workflow B (triggered by the callback) uses UPDATE_STEP to unblock workflow A:
244
+
245
+ ```
246
+ Workflow A: HTTP (send request) → WAIT (paused, waiting for callback)
247
+
248
+ Workflow B: [triggered by callback] → UPDATE_STEP (completes the WAIT step in A with callback data)
249
+ ```
250
+
251
+ ## Common Pattern: Human Task Approval
252
+
253
+ ```
254
+ Workflow: INTEGRATION (send approval email with link) → WAIT (paused)
255
+
256
+ Approval workflow: [triggered by link click] → UPDATE_STEP (BY_COMPLETION_TOKEN, completes WAIT)
257
+ ```
@@ -0,0 +1,218 @@
1
+ # Wait Step Schema
2
+
3
+ `WAIT` pauses process execution until a specific timestamp. Use it when a
4
+ business process needs to wait between steps, delay retries, or resume after a
5
+ time calculated from runtime data.
6
+
7
+ Wait timing is configured with JavaScript. When the WAIT step starts, Unmeshed
8
+ evaluates the script and uses its returned `waitUntil` value as the resume time.
9
+
10
+ ## Definition Input Schema
11
+
12
+ ```json
13
+ {
14
+ "script": "\n(steps, context) => {\n return {\n \"waitUntil\": steps.__self.startTime + (3 * 1000)\n };\n}\n",
15
+ "completionToken": "",
16
+ "validateUpdate": false,
17
+ "enableTrigger": false
18
+ }
19
+ ```
20
+
21
+ Required:
22
+ - `script`: JavaScript function receiving `(steps, context)`.
23
+ - Script return value must include `waitUntil`.
24
+ - `waitUntil` must be an epoch timestamp in milliseconds.
25
+
26
+ Optional/observed:
27
+ - `completionToken`: string, often `""`.
28
+ - `validateUpdate`: boolean.
29
+ - `enableTrigger`: boolean.
30
+
31
+ ## Runtime Output Schema
32
+
33
+ ```json
34
+ {
35
+ "result": {
36
+ "waitUntil": 1778183695557
37
+ },
38
+ "__waitStartedAt": 1778183692557,
39
+ "logs": []
40
+ }
41
+ ```
42
+
43
+ `schedule` on the executed step record is usually the same timestamp as
44
+ `output.result.waitUntil`.
45
+
46
+ ```json
47
+ {
48
+ "start": 1778183692557,
49
+ "schedule": 1778183695557,
50
+ "output": {
51
+ "result": {
52
+ "waitUntil": 1778183695557
53
+ },
54
+ "__waitStartedAt": 1778183692557,
55
+ "logs": []
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Output Access Paths
61
+
62
+ Use:
63
+ - `steps.<ref>.output.result.waitUntil` for the timestamp when execution resumes.
64
+ - `steps.<ref>.output.__waitStartedAt` for the timestamp when the wait started.
65
+ - `steps.<ref>.output.logs` for captured logs.
66
+ - `steps.__self.startTime` inside the WAIT script for this wait instance's start time.
67
+
68
+ Do not use:
69
+ - `steps.<ref>.output.response`
70
+ - `steps.<ref>.output.statusCode`
71
+ - `steps.<ref>.output.waitUntil`
72
+ - a WAIT script return value without `waitUntil`
73
+
74
+ ## Generation Rules
75
+
76
+ - Use uppercase step type: `"WAIT"`.
77
+ - Put JavaScript code in `input.script`.
78
+ - The script must accept `(steps, context)`.
79
+ - The script must return an object with `waitUntil`.
80
+ - `waitUntil` must be epoch milliseconds, not seconds.
81
+ - Use `steps.__self.startTime` for relative waits because it works inside loops.
82
+ - Use `Date.now()` only when the desired behavior is based on current wall-clock time.
83
+ - Use `completionToken: ""`, `validateUpdate: false`, and `enableTrigger: false` unless the user specifically needs external completion/update behavior.
84
+ - Keep `children: []`; WAIT is not a container.
85
+
86
+ ## Debugging Rules
87
+
88
+ When a WAIT step fails or behaves unexpectedly:
89
+ - Inspect `input.script`.
90
+ - Confirm the script returns `{ waitUntil: <epochMillis> }`.
91
+ - Confirm `waitUntil` is in milliseconds, not seconds.
92
+ - Compare `output.result.waitUntil`, `output.__waitStartedAt`, `start`, and `schedule`.
93
+ - If the process appears stuck, check whether `schedule` is in the future.
94
+ - If a wait ran too long or too short, compute `waitUntil - __waitStartedAt`.
95
+ - If the script uses upstream step data, validate those output paths against the source step type.
96
+
97
+ Common failures:
98
+ - Missing `waitUntil`.
99
+ - Returning seconds instead of milliseconds.
100
+ - Returning a date string instead of epoch milliseconds.
101
+ - Using `steps.<wait_ref>.output.waitUntil` instead of `steps.<wait_ref>.output.result.waitUntil`.
102
+ - Using `steps.__self.start` instead of the observed `steps.__self.startTime` in the wait script.
103
+ - Forgetting that the execution list can show multiple runs/polls for one WAIT step.
104
+
105
+ ## Minimal Process Definition Example
106
+
107
+ ```json
108
+ {
109
+ "orgId": 1,
110
+ "namespace": "default",
111
+ "name": "kebab-case-name",
112
+ "version": 1,
113
+ "type": "API_ORCHESTRATION",
114
+ "description": "Wait for three seconds.",
115
+ "configuration": null,
116
+ "steps": [
117
+ {
118
+ "orgId": 1,
119
+ "namespace": "default",
120
+ "name": "wait",
121
+ "type": "WAIT",
122
+ "ref": "wait_1",
123
+ "optional": false,
124
+ "createdBy": "system",
125
+ "updatedBy": "system",
126
+ "description": null,
127
+ "label": null,
128
+ "created": 1700000000000,
129
+ "updated": 1700000000000,
130
+ "configuration": {
131
+ "errorPolicyName": null,
132
+ "useCache": false,
133
+ "cacheKey": null,
134
+ "cacheTimeoutSeconds": 0,
135
+ "stream": false,
136
+ "streamAllStatuses": false,
137
+ "preExecutionScript": null,
138
+ "constructInputFromScript": false,
139
+ "scriptLanguage": null,
140
+ "jqTransformer": null,
141
+ "rateLimitMaxRequests": 0,
142
+ "rateLimitWindowSeconds": 0
143
+ },
144
+ "children": [],
145
+ "input": {
146
+ "script": "\n(steps, context) => {\n return {\n \"waitUntil\": steps.__self.startTime + (3 * 1000)\n };\n}\n",
147
+ "completionToken": "",
148
+ "validateUpdate": false,
149
+ "enableTrigger": false
150
+ },
151
+ "output": null
152
+ }
153
+ ],
154
+ "defaultInput": null,
155
+ "defaultOutput": null,
156
+ "outputMapping": null,
157
+ "signature": null,
158
+ "metadata": null,
159
+ "tags": null,
160
+ "dependencies": null,
161
+ "dependents": null
162
+ }
163
+ ```
164
+
165
+ ## Minimal Executed Step Example
166
+
167
+ ```json
168
+ {
169
+ "id": 28800021,
170
+ "processId": 28800019,
171
+ "ref": "wait_1",
172
+ "namespace": "default",
173
+ "name": "wait",
174
+ "type": "WAIT",
175
+ "status": "COMPLETED",
176
+ "input": {
177
+ "completionToken": "",
178
+ "enableTrigger": false,
179
+ "__currentExecutionStartTime": 1778183692557,
180
+ "script": "\n(steps, context) => {\n return {\n \"waitUntil\": steps.__self.startTime + (3 * 1000)\n };\n}\n",
181
+ "validateUpdate": false
182
+ },
183
+ "output": {
184
+ "result": {
185
+ "waitUntil": 1778183695557
186
+ },
187
+ "__waitStartedAt": 1778183692557,
188
+ "logs": []
189
+ },
190
+ "start": 1778183692557,
191
+ "schedule": 1778183695557,
192
+ "executionList": [
193
+ {
194
+ "id": 0,
195
+ "scheduled": 1778183695557,
196
+ "polled": 1778183695558,
197
+ "start": 1778183692557,
198
+ "updated": 1778183695601,
199
+ "executor": "server-1",
200
+ "ref": "wait_1",
201
+ "runs": 2,
202
+ "output": {}
203
+ }
204
+ ]
205
+ }
206
+ ```
207
+
208
+ ## Example: Wait Until A Time From Input
209
+
210
+ ```javascript
211
+ (steps, context) => {
212
+ const delayMs = Number(context.input.delayMs || 0);
213
+ return {
214
+ waitUntil: steps.__self.startTime + delayMs
215
+ };
216
+ }
217
+ ```
218
+