@mastra/client-js 1.0.0-beta.15 → 1.0.0-beta.16
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +67 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/run.d.ts +65 -0
- package/dist/resources/run.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add `cancel()` method as an alias for `cancelRun()` in the Run class. The new method provides a more concise API while maintaining backward compatibility. Includes comprehensive documentation about abort signals and how steps can respond to cancellation. ([#11417](https://github.com/mastra-ai/mastra/pull/11417))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`3d93a15`](https://github.com/mastra-ai/mastra/commit/3d93a15796b158c617461c8b98bede476ebb43e2), [`efe406a`](https://github.com/mastra-ai/mastra/commit/efe406a1353c24993280ebc2ed61dd9f65b84b26), [`119e5c6`](https://github.com/mastra-ai/mastra/commit/119e5c65008f3e5cfca954eefc2eb85e3bf40da4), [`74e504a`](https://github.com/mastra-ai/mastra/commit/74e504a3b584eafd2f198001c6a113bbec589fd3), [`e33fdbd`](https://github.com/mastra-ai/mastra/commit/e33fdbd07b33920d81e823122331b0c0bee0bb59), [`929f69c`](https://github.com/mastra-ai/mastra/commit/929f69c3436fa20dd0f0e2f7ebe8270bd82a1529), [`8a73529`](https://github.com/mastra-ai/mastra/commit/8a73529ca01187f604b1f3019d0a725ac63ae55f)]:
|
|
10
|
+
- @mastra/core@1.0.0-beta.16
|
|
11
|
+
|
|
3
12
|
## 1.0.0-beta.15
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -2725,12 +2725,79 @@ var Run = class extends BaseResource {
|
|
|
2725
2725
|
/**
|
|
2726
2726
|
* Cancels a specific workflow run by its ID
|
|
2727
2727
|
* @returns Promise containing a success message
|
|
2728
|
+
* @deprecated Use `cancel()` instead
|
|
2728
2729
|
*/
|
|
2729
2730
|
cancelRun() {
|
|
2730
2731
|
return this.request(`/api/workflows/${this.workflowId}/runs/${this.runId}/cancel`, {
|
|
2731
2732
|
method: "POST"
|
|
2732
2733
|
});
|
|
2733
2734
|
}
|
|
2735
|
+
/**
|
|
2736
|
+
* Cancels a workflow run.
|
|
2737
|
+
*
|
|
2738
|
+
* This method aborts any running steps and updates the workflow status to 'canceled' .
|
|
2739
|
+
* It works for both actively running workflows and suspended/waiting workflows.
|
|
2740
|
+
*
|
|
2741
|
+
* ## How cancellation works
|
|
2742
|
+
*
|
|
2743
|
+
* When called, the workflow will:
|
|
2744
|
+
* 1. **Trigger the abort signal** - Uses the standard Web API AbortSignal to notify running steps
|
|
2745
|
+
* 2. **Prevent subsequent steps** - No further steps will be executed
|
|
2746
|
+
*
|
|
2747
|
+
* ## Abort signal behavior
|
|
2748
|
+
*
|
|
2749
|
+
* Steps that check the `abortSignal` parameter can respond to cancellation:
|
|
2750
|
+
* - Steps can listen to the 'abort' event: `abortSignal.addEventListener('abort', callback)`
|
|
2751
|
+
* - Steps can check if already aborted: `if (abortSignal.aborted) { ... }`
|
|
2752
|
+
* - Useful for canceling timeouts, network requests, or long-running operations
|
|
2753
|
+
*
|
|
2754
|
+
* **Note:** Steps must actively check the abort signal to be canceled mid-execution.
|
|
2755
|
+
* Steps that don't check the signal will run to completion, but subsequent steps won't execute.
|
|
2756
|
+
*
|
|
2757
|
+
* @returns Promise that resolves with `{ message: 'Workflow run canceled' }` when cancellation succeeds
|
|
2758
|
+
* @throws {HTTPException} 400 - If workflow ID or run ID is missing
|
|
2759
|
+
* @throws {HTTPException} 404 - If workflow or workflow run is not found
|
|
2760
|
+
*
|
|
2761
|
+
* @example
|
|
2762
|
+
* ```typescript
|
|
2763
|
+
* const run = await workflow.createRun({ runId: 'run-123' });
|
|
2764
|
+
* await run.cancel();
|
|
2765
|
+
* // Returns: { message: 'Workflow run canceled' }
|
|
2766
|
+
* ```
|
|
2767
|
+
*
|
|
2768
|
+
* @example
|
|
2769
|
+
* ```typescript
|
|
2770
|
+
* // Example of a step that responds to cancellation
|
|
2771
|
+
* const step = createStep({
|
|
2772
|
+
* id: 'long-running-step',
|
|
2773
|
+
* execute: async ({ inputData, abortSignal, abort }) => {
|
|
2774
|
+
* const timeout = new Promise((resolve) => {
|
|
2775
|
+
* const timer = setTimeout(() => resolve('done'), 10000);
|
|
2776
|
+
*
|
|
2777
|
+
* // Clean up if canceled
|
|
2778
|
+
* abortSignal.addEventListener('abort', () => {
|
|
2779
|
+
* clearTimeout(timer);
|
|
2780
|
+
* resolve('canceled');
|
|
2781
|
+
* });
|
|
2782
|
+
* });
|
|
2783
|
+
*
|
|
2784
|
+
* const result = await timeout;
|
|
2785
|
+
*
|
|
2786
|
+
* // Check if aborted after async operation
|
|
2787
|
+
* if (abortSignal.aborted) {
|
|
2788
|
+
* return abort(); // Stop execution
|
|
2789
|
+
* }
|
|
2790
|
+
*
|
|
2791
|
+
* return { result };
|
|
2792
|
+
* }
|
|
2793
|
+
* });
|
|
2794
|
+
* ```
|
|
2795
|
+
*/
|
|
2796
|
+
cancel() {
|
|
2797
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${this.runId}/cancel`, {
|
|
2798
|
+
method: "POST"
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2734
2801
|
/**
|
|
2735
2802
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
2736
2803
|
* @param params - Object containing the inputData, initialState and requestContext
|