@cascade-flow/client 0.2.4 → 0.2.5
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/index.d.ts +112 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +3 -3
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Backend, RunState, WorkflowMetadata, AnalyticsOptions, ErrorAnalysis, RetryAnalysis, SchedulingLatency, StepDuration, WorkflowDuration, WorkerStability, Throughput, QueueDepth, QueueDepthByWorkflow, SuccessRate, AnalyticsSummary, StepEvent, StepState, LogEntry } from "@cascade-flow/backend-interface";
|
|
1
|
+
import type { Backend, RunState, WorkflowMetadata, WorkflowVersion, AnalyticsOptions, ErrorAnalysis, RetryAnalysis, SchedulingLatency, StepDuration, WorkflowDuration, WorkerStability, Throughput, QueueDepth, QueueDepthByWorkflow, SuccessRate, AnalyticsSummary, StepEvent, StepState, LogEntry } from "@cascade-flow/backend-interface";
|
|
2
2
|
import { type AttemptMetadata } from "@cascade-flow/backend-interface";
|
|
3
3
|
import type { PollOptions, ListRunsOptions, RunInfo } from "./types.ts";
|
|
4
4
|
/**
|
|
@@ -84,6 +84,41 @@ export declare class WorkflowClient {
|
|
|
84
84
|
* @param reason - Optional cancellation reason
|
|
85
85
|
*/
|
|
86
86
|
cancel(runId: string, reason?: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Rerun a workflow from a specific step
|
|
89
|
+
*
|
|
90
|
+
* Creates a new run that copies events from the parent run and re-executes
|
|
91
|
+
* the specified step and all steps that depend on it.
|
|
92
|
+
*
|
|
93
|
+
* Uses queue-based execution: the new run is submitted to the queue with
|
|
94
|
+
* copied events, and a worker will pick it up and continue execution.
|
|
95
|
+
*
|
|
96
|
+
* @param parentRunId - The run ID to rerun from
|
|
97
|
+
* @param fromStepId - The step ID to rerun from
|
|
98
|
+
* @param options - Optional rerun configuration
|
|
99
|
+
* @returns New run ID. Use getRun() or waitForCompletion() to track progress.
|
|
100
|
+
* @throws Error if parent run or step not found, or version mismatch
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // Rerun from a specific step
|
|
105
|
+
* const { runId } = await client.rerunFrom({
|
|
106
|
+
* parentRunId: '1234567890',
|
|
107
|
+
* fromStepId: 'process-data'
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* // Wait for completion if needed
|
|
111
|
+
* const output = await client.waitForCompletion(runId);
|
|
112
|
+
* console.log(`Completed: ${runId}`, output);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
rerunFrom(params: {
|
|
116
|
+
parentRunId: string;
|
|
117
|
+
fromStepId: string;
|
|
118
|
+
input?: unknown;
|
|
119
|
+
}): Promise<{
|
|
120
|
+
runId: string;
|
|
121
|
+
}>;
|
|
87
122
|
/**
|
|
88
123
|
* Retry a failed workflow
|
|
89
124
|
*
|
|
@@ -127,6 +162,68 @@ export declare class WorkflowClient {
|
|
|
127
162
|
* @returns JSON Schema object or null if workflow has no input schema
|
|
128
163
|
*/
|
|
129
164
|
getWorkflowSchema(workflowSlug: string): Promise<any | null>;
|
|
165
|
+
/**
|
|
166
|
+
* Get a specific version of a workflow
|
|
167
|
+
*
|
|
168
|
+
* Workflow versions are immutable snapshots that include:
|
|
169
|
+
* - Content hash (versionId)
|
|
170
|
+
* - Step manifest (list of step IDs)
|
|
171
|
+
* - Git information (if available)
|
|
172
|
+
* - Creation timestamp
|
|
173
|
+
*
|
|
174
|
+
* @param workflowSlug - Workflow identifier (directory name)
|
|
175
|
+
* @param versionId - Version identifier (content hash like "sha256:abc123...")
|
|
176
|
+
* @returns Workflow version or null if not found
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const version = await client.getWorkflowVersion('my-workflow', 'sha256:abc123...');
|
|
181
|
+
* console.log(`Version has ${version.totalSteps} steps`);
|
|
182
|
+
* console.log(`Git commit: ${version.git?.commit}`);
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
getWorkflowVersion(workflowSlug: string, versionId: string): Promise<WorkflowVersion | null>;
|
|
186
|
+
/**
|
|
187
|
+
* Get the current (most recent) version of a workflow
|
|
188
|
+
*
|
|
189
|
+
* Returns the latest version that was captured when a workflow was executed.
|
|
190
|
+
* Use this to compare against a specific run's version to detect if the
|
|
191
|
+
* workflow has changed.
|
|
192
|
+
*
|
|
193
|
+
* @param workflowSlug - Workflow identifier (directory name)
|
|
194
|
+
* @returns Current workflow version or null if no versions exist
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const currentVersion = await client.getCurrentWorkflowVersion('my-workflow');
|
|
199
|
+
* if (run.versionId !== currentVersion.versionId) {
|
|
200
|
+
* console.log('Run used an outdated version');
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
getCurrentWorkflowVersion(workflowSlug: string): Promise<WorkflowVersion | null>;
|
|
205
|
+
/**
|
|
206
|
+
* List all versions for a workflow
|
|
207
|
+
*
|
|
208
|
+
* Returns versions in reverse chronological order (newest first).
|
|
209
|
+
* Useful for version history views and analytics.
|
|
210
|
+
*
|
|
211
|
+
* @param workflowSlug - Workflow identifier (directory name)
|
|
212
|
+
* @param options - Optional pagination (limit)
|
|
213
|
+
* @returns Array of workflow versions
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* // Get all versions
|
|
218
|
+
* const versions = await client.listWorkflowVersions('my-workflow');
|
|
219
|
+
*
|
|
220
|
+
* // Get last 10 versions
|
|
221
|
+
* const recent = await client.listWorkflowVersions('my-workflow', { limit: 10 });
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
listWorkflowVersions(workflowSlug: string, options?: {
|
|
225
|
+
limit?: number;
|
|
226
|
+
}): Promise<WorkflowVersion[]>;
|
|
130
227
|
/**
|
|
131
228
|
* Helper to sleep
|
|
132
229
|
*/
|
|
@@ -573,6 +670,7 @@ export declare class WorkflowClient {
|
|
|
573
670
|
runId: string;
|
|
574
671
|
category: "workflow";
|
|
575
672
|
type: "WorkflowResumed";
|
|
673
|
+
versionId: string;
|
|
576
674
|
originalRunId: string;
|
|
577
675
|
resumedSteps: number;
|
|
578
676
|
pendingSteps: number;
|
|
@@ -598,6 +696,18 @@ export declare class WorkflowClient {
|
|
|
598
696
|
previousAttemptNumber: number;
|
|
599
697
|
retriedSteps: string[];
|
|
600
698
|
reason?: string | undefined;
|
|
699
|
+
} | {
|
|
700
|
+
eventId: string;
|
|
701
|
+
timestampUs: number;
|
|
702
|
+
workflowSlug: string;
|
|
703
|
+
runId: string;
|
|
704
|
+
category: "workflow";
|
|
705
|
+
type: "WorkflowRerunFromStep";
|
|
706
|
+
parentRunId: string;
|
|
707
|
+
rerunFromStepId: string;
|
|
708
|
+
rerunStepIds: string[];
|
|
709
|
+
versionId: string;
|
|
710
|
+
parentVersionId: string;
|
|
601
711
|
})[]>;
|
|
602
712
|
/**
|
|
603
713
|
* Get detailed information for a specific step
|
|
@@ -611,5 +721,5 @@ export declare class WorkflowClient {
|
|
|
611
721
|
} | null>;
|
|
612
722
|
}
|
|
613
723
|
export type { PollOptions, ListRunsOptions, RunInfo } from "./types.ts";
|
|
614
|
-
export type { AnalyticsOptions, ErrorAnalysis, RetryAnalysis, SchedulingLatency, StepDuration, WorkflowDuration, WorkerStability, Throughput, QueueDepth, QueueDepthByWorkflow, SuccessRate, AnalyticsSummary, } from "@cascade-flow/backend-interface";
|
|
724
|
+
export type { WorkflowVersion, AnalyticsOptions, ErrorAnalysis, RetryAnalysis, SchedulingLatency, StepDuration, WorkflowDuration, WorkerStability, Throughput, QueueDepth, QueueDepthByWorkflow, SuccessRate, AnalyticsSummary, } from "@cascade-flow/backend-interface";
|
|
615
725
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAEP,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAExE;;;;;;;;;GASG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO;IAEpC;;;;;;;;;;;;;;OAcG;IACG,MAAM,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,EAAE;QACrC,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KACjB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAgB9C;;;;;OAKG;IACG,SAAS,CAAC,KAAK,E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AAO,EAAE,MAAM,YAAY,CAAC;AACxE,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,gBAAgB,GACjB,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,9 @@ class WorkflowClient {
|
|
|
102
102
|
async cancel(runId, reason) {
|
|
103
103
|
await this.backend.cancelRun(runId, reason);
|
|
104
104
|
}
|
|
105
|
+
async rerunFrom(params) {
|
|
106
|
+
return await this.backend.rerunFrom(params);
|
|
107
|
+
}
|
|
105
108
|
async retry(runId, reason) {
|
|
106
109
|
const runState = await this.backend.getRun(runId);
|
|
107
110
|
if (!runState) {
|
|
@@ -152,6 +155,15 @@ class WorkflowClient {
|
|
|
152
155
|
const metadata = await this.backend.getWorkflowMetadata(workflowSlug);
|
|
153
156
|
return metadata?.inputSchemaJSON ?? null;
|
|
154
157
|
}
|
|
158
|
+
async getWorkflowVersion(workflowSlug, versionId) {
|
|
159
|
+
return this.backend.getWorkflowVersion(workflowSlug, versionId);
|
|
160
|
+
}
|
|
161
|
+
async getCurrentWorkflowVersion(workflowSlug) {
|
|
162
|
+
return this.backend.getCurrentWorkflowVersion(workflowSlug);
|
|
163
|
+
}
|
|
164
|
+
async listWorkflowVersions(workflowSlug, options) {
|
|
165
|
+
return this.backend.listWorkflowVersions(workflowSlug, options);
|
|
166
|
+
}
|
|
155
167
|
sleep(ms) {
|
|
156
168
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
157
169
|
}
|
|
@@ -245,4 +257,4 @@ export {
|
|
|
245
257
|
WorkflowClient
|
|
246
258
|
};
|
|
247
259
|
|
|
248
|
-
//# debugId=
|
|
260
|
+
//# debugId=BE3F3634187A2C9E64756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type {\n Backend,\n RunSubmission,\n RunState,\n WorkflowMetadata,\n AnalyticsOptions,\n ErrorAnalysis,\n RetryAnalysis,\n SchedulingLatency,\n StepDuration,\n WorkflowDuration,\n WorkerStability,\n Throughput,\n QueueDepth,\n QueueDepthByWorkflow,\n SuccessRate,\n AnalyticsSummary,\n StepEvent,\n StepState,\n LogEntry,\n} from \"@cascade-flow/backend-interface\";\nimport {\n projectStepState,\n extractLogsFromEvents,\n extractAttemptMetadata,\n ensureErrorMessage,\n type AttemptMetadata,\n} from \"@cascade-flow/backend-interface\";\nimport type { PollOptions, ListRunsOptions, RunInfo } from \"./types.ts\";\n\n/**\n * WorkflowClient - submit and manage workflow runs via queue\n *\n * Features:\n * - Type-safe submission with generic input types\n * - Status checking and polling\n * - Wait for completion with timeout\n * - List and filter runs\n * - Cancellation support\n */\nexport class WorkflowClient {\n constructor(private backend: Backend) {}\n\n /**\n * Submit a workflow run to the queue\n *\n * Generic type TInput provides type safety for workflow input\n *\n * @example\n * ```typescript\n * import type { WorkflowInput } from './workflows/my-workflow/input-schema';\n *\n * const { runId } = await client.submit<WorkflowInput>({\n * workflow: 'my-workflow',\n * input: { userId: \"123\", count: 42 } // Fully typed!\n * });\n * ```\n */\n async submit<TInput = unknown>(params: {\n workflow: string;\n input?: TInput;\n runId?: string;\n availableAt?: number;\n priority?: number;\n timeout?: number;\n idempotencyKey?: string;\n metadata?: Record<string, unknown>;\n tags?: string[];\n }): Promise<{ runId: string; isNew: boolean }> {\n const submission: RunSubmission = {\n workflowSlug: params.workflow,\n input: params.input,\n runId: params.runId,\n availableAt: params.availableAt,\n priority: params.priority,\n timeout: params.timeout,\n idempotencyKey: params.idempotencyKey,\n metadata: params.metadata,\n tags: params.tags,\n };\n\n return this.backend.submitRun(submission);\n }\n\n /**\n * Get the current status of a run\n *\n * @param runId - The run ID to query\n * @returns Run state or null if not found\n */\n async getStatus(runId: string): Promise<RunState | null> {\n return this.backend.getRun(runId);\n }\n\n /**\n * Get detailed run information including output/error\n *\n * @param runId - The run ID to query\n * @returns Extended run info or null if not found\n */\n async getRun(runId: string): Promise<RunInfo | null> {\n const runState = await this.backend.getRun(runId);\n if (!runState) return null;\n\n const info: RunInfo = { ...runState };\n\n // Load output or error if run is completed/failed\n if (runState.status === \"completed\" || runState.status === \"failed\") {\n try {\n // Load workflow events to get output/error\n const events = await this.backend.loadEvents(runState.workflowSlug, runId, {\n category: \"workflow\",\n });\n\n // Find WorkflowCompleted or WorkflowFailed event\n for (const event of events) {\n if (event.category === \"workflow\") {\n if (event.type === \"WorkflowCompleted\") {\n info.output = JSON.parse(event.output);\n } else if (event.type === \"WorkflowFailed\") {\n info.error = event.error;\n }\n }\n }\n } catch (err) {\n // Failed to load output/error, return state only\n }\n }\n\n return info;\n }\n\n /**\n * Wait for a run to complete\n *\n * Polls the backend until the run reaches a terminal state (completed/failed/cancelled)\n *\n * @param runId - The run ID to wait for\n * @param options - Polling options\n * @returns Run info when complete\n * @throws Error if timeout or run fails\n */\n async waitForCompletion<TOutput = unknown>(\n runId: string,\n options: PollOptions = {}\n ): Promise<TOutput> {\n const {\n interval = 1000,\n maxAttempts = 60,\n timeout,\n exponentialBackoff = false,\n maxBackoff = 10000,\n } = options;\n\n const startTime = Date.now();\n const effectiveTimeout = timeout || maxAttempts * interval;\n\n let currentInterval = interval;\n let attempts = 0;\n\n while (true) {\n attempts++;\n\n // Check timeout\n if (Date.now() - startTime > effectiveTimeout) {\n throw new Error(`Timeout waiting for run ${runId} after ${effectiveTimeout}ms`);\n }\n\n // Get run status\n const run = await this.getRun(runId);\n\n if (!run) {\n throw new Error(`Run ${runId} not found`);\n }\n\n // Check if run reached terminal state\n if (run.status === \"completed\") {\n return run.output as TOutput;\n } else if (run.status === \"failed\") {\n // Ensure error message is a string (handle cases where it might be an object)\n const errorMsg = run.error?.message ? ensureErrorMessage(run.error.message) : \"Run failed\";\n throw new Error(`Run ${runId} failed: ${errorMsg}`);\n } else if (run.status === \"cancelled\") {\n throw new Error(`Run ${runId} was cancelled`);\n }\n\n // Sleep before next poll\n await this.sleep(currentInterval);\n\n // Apply exponential backoff if enabled\n if (exponentialBackoff) {\n currentInterval = Math.min(currentInterval * 2, maxBackoff);\n }\n }\n }\n\n /**\n * List runs matching filters\n *\n * @param options - Filter options\n * @returns Array of run states\n */\n async listRuns(options: ListRunsOptions = {}): Promise<RunState[]> {\n const { workflowSlug, status, tags, limit } = options;\n\n // Convert status to array for backend (if provided)\n let statuses: RunState[\"status\"][] | undefined;\n if (status) {\n statuses = Array.isArray(status) ? status : [status];\n }\n\n return this.backend.listRuns({\n workflowSlug,\n status: statuses,\n tags,\n limit,\n });\n }\n\n /**\n * Cancel a run\n *\n * Can cancel runs in pending, claimed, or running status\n *\n * @param runId - The run to cancel\n * @param reason - Optional cancellation reason\n */\n async cancel(runId: string, reason?: string): Promise<void> {\n await this.backend.cancelRun(runId, reason);\n }\n\n /**\n * Retry a failed workflow\n *\n * Retries all failed steps in the workflow, keeping successful steps from the original run.\n * Step attempt numbers are reset to 1 for each retried step.\n *\n * @param runId - The run ID to retry\n * @param reason - Optional reason for retry\n * @returns Retry information including new workflow attempt number\n * @throws Error if run is not in failed status\n */\n async retry(\n runId: string,\n reason?: string\n ): Promise<{\n runId: string;\n workflowAttemptNumber: number;\n retriedSteps: string[];\n }> {\n // Get run state\n const runState = await this.backend.getRun(runId);\n if (!runState) {\n throw new Error(`Run ${runId} not found`);\n }\n\n // Verify run is failed\n if (runState.status !== \"failed\") {\n throw new Error(`Cannot retry run ${runId} - status is ${runState.status}, expected 'failed'`);\n }\n\n const workflowSlug = runState.workflowSlug;\n\n // Get failed steps\n const failedSteps = await this.backend.getFailedSteps(workflowSlug, runId);\n if (failedSteps.length === 0) {\n throw new Error(`No failed steps found in run ${runId}`);\n }\n\n // Calculate new workflow attempt number\n const previousAttemptNumber = runState.workflowAttemptNumber || 1;\n const workflowAttemptNumber = previousAttemptNumber + 1;\n\n const retriedStepIds = failedSteps.map((s) => s.stepId);\n\n // Emit WorkflowRetryStarted event\n await this.backend.saveWorkflowRetryStarted(workflowSlug, runId, {\n workflowAttemptNumber,\n previousAttemptNumber,\n retriedSteps: retriedStepIds,\n reason,\n });\n\n // Schedule each failed step for retry with fresh attempt number\n const now = Date.now() * 1000; // Convert to microseconds\n for (const step of failedSteps) {\n await this.backend.saveStepScheduled(workflowSlug, runId, step.stepId, {\n availableAt: now,\n reason: \"retry\",\n attemptNumber: 1, // Reset to 1 for workflow retry\n retryDelayMs: 0,\n });\n }\n\n return {\n runId,\n workflowAttemptNumber,\n retriedSteps: retriedStepIds,\n };\n }\n\n /**\n * List all available workflows\n *\n * @returns Array of workflow metadata\n */\n async listWorkflows(): Promise<WorkflowMetadata[]> {\n return this.backend.listWorkflowMetadata();\n }\n\n /**\n * Get metadata for a specific workflow\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @returns Workflow metadata or null if not found\n */\n async getWorkflowMetadata(workflowSlug: string): Promise<WorkflowMetadata | null> {\n return this.backend.getWorkflowMetadata(workflowSlug);\n }\n\n /**\n * Get step definitions for a specific workflow\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @returns Array of step definitions or empty array if workflow not found\n */\n async getWorkflowSteps(workflowSlug: string): Promise<any[]> {\n return this.backend.getWorkflowSteps(workflowSlug);\n }\n\n /**\n * Get the JSON Schema for a workflow's input\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @returns JSON Schema object or null if workflow has no input schema\n */\n async getWorkflowSchema(workflowSlug: string): Promise<any | null> {\n const metadata = await this.backend.getWorkflowMetadata(workflowSlug);\n return metadata?.inputSchemaJSON ?? null;\n }\n\n /**\n * Helper to sleep\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n // ============================================================================\n // Analytics Methods\n // ============================================================================\n\n /**\n * Get error analysis for workflows and steps\n *\n * Analyzes failure patterns, error types, and common error messages.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Error analysis data\n *\n * @example\n * ```typescript\n * // Get errors for last 24 hours (default)\n * const errors = await client.getErrorAnalysis();\n *\n * // Get errors for specific workflow\n * const errors = await client.getErrorAnalysis({\n * workflowSlug: 'my-workflow',\n * startUs: Date.now() * 1000 - 7 * 24 * 60 * 60 * 1000 * 1000 // Last 7 days\n * });\n * ```\n */\n async getErrorAnalysis(options?: AnalyticsOptions): Promise<ErrorAnalysis> {\n return this.backend.getErrorAnalysis(options);\n }\n\n /**\n * Get retry analysis metrics\n *\n * Analyzes retry patterns, success rates after retries, and retry effectiveness.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Retry analysis data\n */\n async getRetryAnalysis(options?: AnalyticsOptions): Promise<RetryAnalysis> {\n return this.backend.getRetryAnalysis(options);\n }\n\n /**\n * Get scheduling latency metrics\n *\n * Measures time between step being scheduled and actually starting execution.\n * High latency indicates worker starvation or queue congestion.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Scheduling latency statistics\n *\n * @example\n * ```typescript\n * const latency = await client.getSchedulingLatency({ workflowSlug: 'my-workflow' });\n * console.log(`Average wait time: ${latency.averageUs / 1000}ms`);\n * console.log(`P95 wait time: ${latency.p95Us / 1000}ms`);\n * ```\n */\n async getSchedulingLatency(options?: AnalyticsOptions): Promise<SchedulingLatency> {\n return this.backend.getSchedulingLatency(options);\n }\n\n /**\n * Get step duration metrics\n *\n * Analyzes how long steps take to execute.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Step duration statistics\n */\n async getStepDuration(options?: AnalyticsOptions): Promise<StepDuration> {\n return this.backend.getStepDuration(options);\n }\n\n /**\n * Get workflow duration metrics\n *\n * Analyzes end-to-end workflow execution time (from submission to completion).\n *\n * @param options - Optional filters for time range or workflow\n * @returns Workflow duration statistics\n */\n async getWorkflowDuration(options?: AnalyticsOptions): Promise<WorkflowDuration> {\n return this.backend.getWorkflowDuration(options);\n }\n\n /**\n * Get worker stability metrics\n *\n * Analyzes worker crashes, reclamations, and stale heartbeats.\n *\n * @param options - Optional filters for time range\n * @returns Worker stability data\n */\n async getWorkerStability(options?: AnalyticsOptions): Promise<WorkerStability> {\n return this.backend.getWorkerStability(options);\n }\n\n /**\n * Get throughput metrics\n *\n * Analyzes how many runs/steps are being completed per unit time.\n *\n * @param options - Optional filters for time range or workflow\n * @returns Throughput data\n */\n async getThroughput(options?: AnalyticsOptions): Promise<Throughput> {\n return this.backend.getThroughput(options);\n }\n\n /**\n * Get current queue depth\n *\n * Real-time snapshot of pending/running runs and steps.\n *\n * @param options - Optional filter for workflow\n * @returns Queue depth data\n *\n * @example\n * ```typescript\n * const depth = await client.getQueueDepth();\n * console.log(`Pending runs: ${depth.pendingRuns}`);\n * console.log(`Scheduled steps: ${depth.scheduledSteps}`);\n * ```\n */\n async getQueueDepth(options?: Pick<AnalyticsOptions, \"workflowSlug\">): Promise<QueueDepth> {\n return this.backend.getQueueDepth(options);\n }\n\n /**\n * Get queue depth broken down by workflow\n *\n * Real-time snapshot showing per-workflow queue statistics.\n * Useful for identifying which workflows have pending work.\n *\n * @returns Array of per-workflow queue depth data\n *\n * @example\n * ```typescript\n * const breakdown = await client.getQueueDepthByWorkflow();\n * for (const workflow of breakdown) {\n * console.log(`${workflow.workflowName}: ${workflow.pendingRuns} pending, ${workflow.scheduledSteps} scheduled`);\n * }\n * ```\n */\n async getQueueDepthByWorkflow(): Promise<QueueDepthByWorkflow> {\n return this.backend.getQueueDepthByWorkflow();\n }\n\n /**\n * Get success/failure rate metrics\n *\n * Analyzes overall health of workflows and steps.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Success rate data\n */\n async getSuccessRate(options?: AnalyticsOptions): Promise<SuccessRate> {\n return this.backend.getSuccessRate(options);\n }\n\n /**\n * Get comprehensive analytics summary\n *\n * Combines all analytics metrics into a single response.\n * Useful for dashboard views.\n *\n * @param options - Optional filters for time range or workflow\n * @returns Complete analytics summary\n *\n * @example\n * ```typescript\n * // Get full analytics for last 24 hours\n * const summary = await client.getAnalyticsSummary();\n *\n * // Get analytics for specific workflow over last week\n * const summary = await client.getAnalyticsSummary({\n * workflowSlug: 'my-workflow',\n * startUs: Date.now() * 1000 - 7 * 24 * 60 * 60 * 1000 * 1000\n * });\n * ```\n */\n async getAnalyticsSummary(options?: AnalyticsOptions): Promise<AnalyticsSummary> {\n return this.backend.getAnalyticsSummary(options);\n }\n\n /**\n * Get paginated list of errors grouped by fingerprint\n *\n * @param options - Filtering and pagination options\n * @returns Paginated list of error groups\n *\n * @example\n * ```typescript\n * // Get errors for last 24h\n * const { errors, total } = await client.getErrorsList({\n * timeRange: { start: Date.now() * 1000 - 86400000000, end: Date.now() * 1000 },\n * groupingStrategy: 'exact',\n * limit: 50,\n * offset: 0\n * });\n * ```\n */\n async getErrorsList(options?: {\n timeRange?: { start: number; end: number };\n workflowSlug?: string;\n groupingStrategy?: 'exact' | 'normalized' | 'portable';\n limit?: number;\n offset?: number;\n }): Promise<{\n errors: Array<{\n fingerprint: string;\n errorMessage: string;\n errorName: string;\n sampleStack: string;\n count: number;\n affectedRuns: number;\n firstSeen: number;\n lastSeen: number;\n }>;\n total: number;\n }> {\n return this.backend.getErrorsList(options);\n }\n\n /**\n * Get detailed information about a specific error by fingerprint\n *\n * @param fingerprint - Composite fingerprint (nameHash:messageHash:stackHash)\n * @param groupingStrategy - Which stack hash variant to use\n * @param options - Filtering and pagination options\n * @returns Error details with all occurrences\n *\n * @example\n * ```typescript\n * const detail = await client.getErrorDetail(\n * 'abc123:def456:ghi789',\n * 'exact',\n * { limit: 100, offset: 0 }\n * );\n * ```\n */\n async getErrorDetail(\n fingerprint: string,\n groupingStrategy: 'exact' | 'normalized' | 'portable',\n options?: {\n timeRange?: { start: number; end: number };\n limit?: number;\n offset?: number;\n }\n ): Promise<{\n fingerprint: string;\n errorMessage: string;\n errorName: string;\n sampleStack: string;\n totalCount: number;\n affectedRuns: number;\n firstSeen: number;\n lastSeen: number;\n occurrences: Array<{\n workflowSlug: string;\n runId: string;\n stepId: string;\n attemptNumber: number;\n timestampUs: number;\n }>;\n total: number;\n }> {\n return this.backend.getErrorDetail(fingerprint, groupingStrategy, options);\n }\n\n /**\n * Get the state of all steps for a run\n * Projects step events to compute current state\n */\n async getStepStates(workflowSlug: string, runId: string): Promise<StepState[]> {\n const events = await this.backend.loadEvents(workflowSlug, runId, {\n category: 'step',\n });\n\n // Group events by step ID\n const stepGroups = new Map<string, StepEvent[]>();\n for (const event of events) {\n if (event.category === 'step') {\n if (!stepGroups.has(event.stepId)) {\n stepGroups.set(event.stepId, []);\n }\n stepGroups.get(event.stepId)!.push(event as StepEvent);\n }\n }\n\n // Project each step's state\n const states: StepState[] = [];\n for (const [stepId, stepEvents] of stepGroups) {\n try {\n const state = projectStepState(stepEvents, workflowSlug);\n states.push(state);\n } catch (err) {\n console.error(`Failed to project state for step ${stepId}:`, err);\n }\n }\n\n return states;\n }\n\n /**\n * Get all events for a specific run (both workflow and step events)\n */\n async getRunEvents(workflowSlug: string, runId: string) {\n return this.backend.loadEvents(workflowSlug, runId);\n }\n\n /**\n * Get detailed information for a specific step\n * Includes state, events, and logs\n */\n async getStepDetail(\n workflowSlug: string,\n runId: string,\n stepName: string\n ): Promise<{\n state: StepState;\n events: StepEvent[];\n logs: LogEntry[];\n attempts: AttemptMetadata[];\n } | null> {\n // Load all events for this specific step\n const events = await this.backend.loadEvents(workflowSlug, runId, {\n category: 'step',\n stepId: stepName,\n });\n\n // Filter to only step events\n const stepEvents = events.filter((e): e is StepEvent => e.category === 'step');\n\n if (stepEvents.length === 0) {\n return null;\n }\n\n // Project events to current state\n const state = projectStepState(stepEvents, workflowSlug);\n\n // Extract logs from events\n const logs = extractLogsFromEvents(stepEvents);\n\n // Extract attempt metadata\n const attempts = extractAttemptMetadata(stepEvents);\n\n return {\n state,\n events: stepEvents,\n logs,\n attempts,\n };\n }\n}\n\n// Export types\nexport type { PollOptions, ListRunsOptions, RunInfo } from \"./types.ts\";\nexport type {\n AnalyticsOptions,\n ErrorAnalysis,\n RetryAnalysis,\n SchedulingLatency,\n StepDuration,\n WorkflowDuration,\n WorkerStability,\n Throughput,\n QueueDepth,\n QueueDepthByWorkflow,\n SuccessRate,\n AnalyticsSummary,\n} from \"@cascade-flow/backend-interface\";\n"
|
|
5
|
+
"import type {\n Backend,\n RunSubmission,\n RunState,\n WorkflowMetadata,\n WorkflowVersion,\n AnalyticsOptions,\n ErrorAnalysis,\n RetryAnalysis,\n SchedulingLatency,\n StepDuration,\n WorkflowDuration,\n WorkerStability,\n Throughput,\n QueueDepth,\n QueueDepthByWorkflow,\n SuccessRate,\n AnalyticsSummary,\n StepEvent,\n StepState,\n LogEntry,\n} from \"@cascade-flow/backend-interface\";\nimport {\n projectStepState,\n extractLogsFromEvents,\n extractAttemptMetadata,\n ensureErrorMessage,\n type AttemptMetadata,\n} from \"@cascade-flow/backend-interface\";\nimport type { PollOptions, ListRunsOptions, RunInfo } from \"./types.ts\";\n\n/**\n * WorkflowClient - submit and manage workflow runs via queue\n *\n * Features:\n * - Type-safe submission with generic input types\n * - Status checking and polling\n * - Wait for completion with timeout\n * - List and filter runs\n * - Cancellation support\n */\nexport class WorkflowClient {\n constructor(private backend: Backend) {}\n\n /**\n * Submit a workflow run to the queue\n *\n * Generic type TInput provides type safety for workflow input\n *\n * @example\n * ```typescript\n * import type { WorkflowInput } from './workflows/my-workflow/input-schema';\n *\n * const { runId } = await client.submit<WorkflowInput>({\n * workflow: 'my-workflow',\n * input: { userId: \"123\", count: 42 } // Fully typed!\n * });\n * ```\n */\n async submit<TInput = unknown>(params: {\n workflow: string;\n input?: TInput;\n runId?: string;\n availableAt?: number;\n priority?: number;\n timeout?: number;\n idempotencyKey?: string;\n metadata?: Record<string, unknown>;\n tags?: string[];\n }): Promise<{ runId: string; isNew: boolean }> {\n const submission: RunSubmission = {\n workflowSlug: params.workflow,\n input: params.input,\n runId: params.runId,\n availableAt: params.availableAt,\n priority: params.priority,\n timeout: params.timeout,\n idempotencyKey: params.idempotencyKey,\n metadata: params.metadata,\n tags: params.tags,\n };\n\n return this.backend.submitRun(submission);\n }\n\n /**\n * Get the current status of a run\n *\n * @param runId - The run ID to query\n * @returns Run state or null if not found\n */\n async getStatus(runId: string): Promise<RunState | null> {\n return this.backend.getRun(runId);\n }\n\n /**\n * Get detailed run information including output/error\n *\n * @param runId - The run ID to query\n * @returns Extended run info or null if not found\n */\n async getRun(runId: string): Promise<RunInfo | null> {\n const runState = await this.backend.getRun(runId);\n if (!runState) return null;\n\n const info: RunInfo = { ...runState };\n\n // Load output or error if run is completed/failed\n if (runState.status === \"completed\" || runState.status === \"failed\") {\n try {\n // Load workflow events to get output/error\n const events = await this.backend.loadEvents(runState.workflowSlug, runId, {\n category: \"workflow\",\n });\n\n // Find WorkflowCompleted or WorkflowFailed event\n for (const event of events) {\n if (event.category === \"workflow\") {\n if (event.type === \"WorkflowCompleted\") {\n info.output = JSON.parse(event.output);\n } else if (event.type === \"WorkflowFailed\") {\n info.error = event.error;\n }\n }\n }\n } catch (err) {\n // Failed to load output/error, return state only\n }\n }\n\n return info;\n }\n\n /**\n * Wait for a run to complete\n *\n * Polls the backend until the run reaches a terminal state (completed/failed/cancelled)\n *\n * @param runId - The run ID to wait for\n * @param options - Polling options\n * @returns Run info when complete\n * @throws Error if timeout or run fails\n */\n async waitForCompletion<TOutput = unknown>(\n runId: string,\n options: PollOptions = {}\n ): Promise<TOutput> {\n const {\n interval = 1000,\n maxAttempts = 60,\n timeout,\n exponentialBackoff = false,\n maxBackoff = 10000,\n } = options;\n\n const startTime = Date.now();\n const effectiveTimeout = timeout || maxAttempts * interval;\n\n let currentInterval = interval;\n let attempts = 0;\n\n while (true) {\n attempts++;\n\n // Check timeout\n if (Date.now() - startTime > effectiveTimeout) {\n throw new Error(`Timeout waiting for run ${runId} after ${effectiveTimeout}ms`);\n }\n\n // Get run status\n const run = await this.getRun(runId);\n\n if (!run) {\n throw new Error(`Run ${runId} not found`);\n }\n\n // Check if run reached terminal state\n if (run.status === \"completed\") {\n return run.output as TOutput;\n } else if (run.status === \"failed\") {\n // Ensure error message is a string (handle cases where it might be an object)\n const errorMsg = run.error?.message ? ensureErrorMessage(run.error.message) : \"Run failed\";\n throw new Error(`Run ${runId} failed: ${errorMsg}`);\n } else if (run.status === \"cancelled\") {\n throw new Error(`Run ${runId} was cancelled`);\n }\n\n // Sleep before next poll\n await this.sleep(currentInterval);\n\n // Apply exponential backoff if enabled\n if (exponentialBackoff) {\n currentInterval = Math.min(currentInterval * 2, maxBackoff);\n }\n }\n }\n\n /**\n * List runs matching filters\n *\n * @param options - Filter options\n * @returns Array of run states\n */\n async listRuns(options: ListRunsOptions = {}): Promise<RunState[]> {\n const { workflowSlug, status, tags, limit } = options;\n\n // Convert status to array for backend (if provided)\n let statuses: RunState[\"status\"][] | undefined;\n if (status) {\n statuses = Array.isArray(status) ? status : [status];\n }\n\n return this.backend.listRuns({\n workflowSlug,\n status: statuses,\n tags,\n limit,\n });\n }\n\n /**\n * Cancel a run\n *\n * Can cancel runs in pending, claimed, or running status\n *\n * @param runId - The run to cancel\n * @param reason - Optional cancellation reason\n */\n async cancel(runId: string, reason?: string): Promise<void> {\n await this.backend.cancelRun(runId, reason);\n }\n\n /**\n * Rerun a workflow from a specific step\n *\n * Creates a new run that copies events from the parent run and re-executes\n * the specified step and all steps that depend on it.\n *\n * Uses queue-based execution: the new run is submitted to the queue with\n * copied events, and a worker will pick it up and continue execution.\n *\n * @param parentRunId - The run ID to rerun from\n * @param fromStepId - The step ID to rerun from\n * @param options - Optional rerun configuration\n * @returns New run ID. Use getRun() or waitForCompletion() to track progress.\n * @throws Error if parent run or step not found, or version mismatch\n *\n * @example\n * ```typescript\n * // Rerun from a specific step\n * const { runId } = await client.rerunFrom({\n * parentRunId: '1234567890',\n * fromStepId: 'process-data'\n * });\n *\n * // Wait for completion if needed\n * const output = await client.waitForCompletion(runId);\n * console.log(`Completed: ${runId}`, output);\n * ```\n */\n async rerunFrom(params: {\n parentRunId: string;\n fromStepId: string;\n input?: unknown;\n }): Promise<{\n runId: string;\n }> {\n // Delegate to backend implementation\n return await this.backend.rerunFrom(params);\n }\n\n /**\n * Retry a failed workflow\n *\n * Retries all failed steps in the workflow, keeping successful steps from the original run.\n * Step attempt numbers are reset to 1 for each retried step.\n *\n * @param runId - The run ID to retry\n * @param reason - Optional reason for retry\n * @returns Retry information including new workflow attempt number\n * @throws Error if run is not in failed status\n */\n async retry(\n runId: string,\n reason?: string\n ): Promise<{\n runId: string;\n workflowAttemptNumber: number;\n retriedSteps: string[];\n }> {\n // Get run state\n const runState = await this.backend.getRun(runId);\n if (!runState) {\n throw new Error(`Run ${runId} not found`);\n }\n\n // Verify run is failed\n if (runState.status !== \"failed\") {\n throw new Error(`Cannot retry run ${runId} - status is ${runState.status}, expected 'failed'`);\n }\n\n const workflowSlug = runState.workflowSlug;\n\n // Get failed steps\n const failedSteps = await this.backend.getFailedSteps(workflowSlug, runId);\n if (failedSteps.length === 0) {\n throw new Error(`No failed steps found in run ${runId}`);\n }\n\n // Calculate new workflow attempt number\n const previousAttemptNumber = runState.workflowAttemptNumber || 1;\n const workflowAttemptNumber = previousAttemptNumber + 1;\n\n const retriedStepIds = failedSteps.map((s) => s.stepId);\n\n // Emit WorkflowRetryStarted event\n await this.backend.saveWorkflowRetryStarted(workflowSlug, runId, {\n workflowAttemptNumber,\n previousAttemptNumber,\n retriedSteps: retriedStepIds,\n reason,\n });\n\n // Schedule each failed step for retry with fresh attempt number\n const now = Date.now() * 1000; // Convert to microseconds\n for (const step of failedSteps) {\n await this.backend.saveStepScheduled(workflowSlug, runId, step.stepId, {\n availableAt: now,\n reason: \"retry\",\n attemptNumber: 1, // Reset to 1 for workflow retry\n retryDelayMs: 0,\n });\n }\n\n return {\n runId,\n workflowAttemptNumber,\n retriedSteps: retriedStepIds,\n };\n }\n\n /**\n * List all available workflows\n *\n * @returns Array of workflow metadata\n */\n async listWorkflows(): Promise<WorkflowMetadata[]> {\n return this.backend.listWorkflowMetadata();\n }\n\n /**\n * Get metadata for a specific workflow\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @returns Workflow metadata or null if not found\n */\n async getWorkflowMetadata(workflowSlug: string): Promise<WorkflowMetadata | null> {\n return this.backend.getWorkflowMetadata(workflowSlug);\n }\n\n /**\n * Get step definitions for a specific workflow\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @returns Array of step definitions or empty array if workflow not found\n */\n async getWorkflowSteps(workflowSlug: string): Promise<any[]> {\n return this.backend.getWorkflowSteps(workflowSlug);\n }\n\n /**\n * Get the JSON Schema for a workflow's input\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @returns JSON Schema object or null if workflow has no input schema\n */\n async getWorkflowSchema(workflowSlug: string): Promise<any | null> {\n const metadata = await this.backend.getWorkflowMetadata(workflowSlug);\n return metadata?.inputSchemaJSON ?? null;\n }\n\n // ============================================================================\n // Version Management Methods\n // ============================================================================\n\n /**\n * Get a specific version of a workflow\n *\n * Workflow versions are immutable snapshots that include:\n * - Content hash (versionId)\n * - Step manifest (list of step IDs)\n * - Git information (if available)\n * - Creation timestamp\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @param versionId - Version identifier (content hash like \"sha256:abc123...\")\n * @returns Workflow version or null if not found\n *\n * @example\n * ```typescript\n * const version = await client.getWorkflowVersion('my-workflow', 'sha256:abc123...');\n * console.log(`Version has ${version.totalSteps} steps`);\n * console.log(`Git commit: ${version.git?.commit}`);\n * ```\n */\n async getWorkflowVersion(\n workflowSlug: string,\n versionId: string\n ): Promise<WorkflowVersion | null> {\n return this.backend.getWorkflowVersion(workflowSlug, versionId);\n }\n\n /**\n * Get the current (most recent) version of a workflow\n *\n * Returns the latest version that was captured when a workflow was executed.\n * Use this to compare against a specific run's version to detect if the\n * workflow has changed.\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @returns Current workflow version or null if no versions exist\n *\n * @example\n * ```typescript\n * const currentVersion = await client.getCurrentWorkflowVersion('my-workflow');\n * if (run.versionId !== currentVersion.versionId) {\n * console.log('Run used an outdated version');\n * }\n * ```\n */\n async getCurrentWorkflowVersion(workflowSlug: string): Promise<WorkflowVersion | null> {\n return this.backend.getCurrentWorkflowVersion(workflowSlug);\n }\n\n /**\n * List all versions for a workflow\n *\n * Returns versions in reverse chronological order (newest first).\n * Useful for version history views and analytics.\n *\n * @param workflowSlug - Workflow identifier (directory name)\n * @param options - Optional pagination (limit)\n * @returns Array of workflow versions\n *\n * @example\n * ```typescript\n * // Get all versions\n * const versions = await client.listWorkflowVersions('my-workflow');\n *\n * // Get last 10 versions\n * const recent = await client.listWorkflowVersions('my-workflow', { limit: 10 });\n * ```\n */\n async listWorkflowVersions(\n workflowSlug: string,\n options?: { limit?: number }\n ): Promise<WorkflowVersion[]> {\n return this.backend.listWorkflowVersions(workflowSlug, options);\n }\n\n /**\n * Helper to sleep\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n // ============================================================================\n // Analytics Methods\n // ============================================================================\n\n /**\n * Get error analysis for workflows and steps\n *\n * Analyzes failure patterns, error types, and common error messages.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Error analysis data\n *\n * @example\n * ```typescript\n * // Get errors for last 24 hours (default)\n * const errors = await client.getErrorAnalysis();\n *\n * // Get errors for specific workflow\n * const errors = await client.getErrorAnalysis({\n * workflowSlug: 'my-workflow',\n * startUs: Date.now() * 1000 - 7 * 24 * 60 * 60 * 1000 * 1000 // Last 7 days\n * });\n * ```\n */\n async getErrorAnalysis(options?: AnalyticsOptions): Promise<ErrorAnalysis> {\n return this.backend.getErrorAnalysis(options);\n }\n\n /**\n * Get retry analysis metrics\n *\n * Analyzes retry patterns, success rates after retries, and retry effectiveness.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Retry analysis data\n */\n async getRetryAnalysis(options?: AnalyticsOptions): Promise<RetryAnalysis> {\n return this.backend.getRetryAnalysis(options);\n }\n\n /**\n * Get scheduling latency metrics\n *\n * Measures time between step being scheduled and actually starting execution.\n * High latency indicates worker starvation or queue congestion.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Scheduling latency statistics\n *\n * @example\n * ```typescript\n * const latency = await client.getSchedulingLatency({ workflowSlug: 'my-workflow' });\n * console.log(`Average wait time: ${latency.averageUs / 1000}ms`);\n * console.log(`P95 wait time: ${latency.p95Us / 1000}ms`);\n * ```\n */\n async getSchedulingLatency(options?: AnalyticsOptions): Promise<SchedulingLatency> {\n return this.backend.getSchedulingLatency(options);\n }\n\n /**\n * Get step duration metrics\n *\n * Analyzes how long steps take to execute.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Step duration statistics\n */\n async getStepDuration(options?: AnalyticsOptions): Promise<StepDuration> {\n return this.backend.getStepDuration(options);\n }\n\n /**\n * Get workflow duration metrics\n *\n * Analyzes end-to-end workflow execution time (from submission to completion).\n *\n * @param options - Optional filters for time range or workflow\n * @returns Workflow duration statistics\n */\n async getWorkflowDuration(options?: AnalyticsOptions): Promise<WorkflowDuration> {\n return this.backend.getWorkflowDuration(options);\n }\n\n /**\n * Get worker stability metrics\n *\n * Analyzes worker crashes, reclamations, and stale heartbeats.\n *\n * @param options - Optional filters for time range\n * @returns Worker stability data\n */\n async getWorkerStability(options?: AnalyticsOptions): Promise<WorkerStability> {\n return this.backend.getWorkerStability(options);\n }\n\n /**\n * Get throughput metrics\n *\n * Analyzes how many runs/steps are being completed per unit time.\n *\n * @param options - Optional filters for time range or workflow\n * @returns Throughput data\n */\n async getThroughput(options?: AnalyticsOptions): Promise<Throughput> {\n return this.backend.getThroughput(options);\n }\n\n /**\n * Get current queue depth\n *\n * Real-time snapshot of pending/running runs and steps.\n *\n * @param options - Optional filter for workflow\n * @returns Queue depth data\n *\n * @example\n * ```typescript\n * const depth = await client.getQueueDepth();\n * console.log(`Pending runs: ${depth.pendingRuns}`);\n * console.log(`Scheduled steps: ${depth.scheduledSteps}`);\n * ```\n */\n async getQueueDepth(options?: Pick<AnalyticsOptions, \"workflowSlug\">): Promise<QueueDepth> {\n return this.backend.getQueueDepth(options);\n }\n\n /**\n * Get queue depth broken down by workflow\n *\n * Real-time snapshot showing per-workflow queue statistics.\n * Useful for identifying which workflows have pending work.\n *\n * @returns Array of per-workflow queue depth data\n *\n * @example\n * ```typescript\n * const breakdown = await client.getQueueDepthByWorkflow();\n * for (const workflow of breakdown) {\n * console.log(`${workflow.workflowName}: ${workflow.pendingRuns} pending, ${workflow.scheduledSteps} scheduled`);\n * }\n * ```\n */\n async getQueueDepthByWorkflow(): Promise<QueueDepthByWorkflow> {\n return this.backend.getQueueDepthByWorkflow();\n }\n\n /**\n * Get success/failure rate metrics\n *\n * Analyzes overall health of workflows and steps.\n *\n * @param options - Optional filters for time range, workflow, or step\n * @returns Success rate data\n */\n async getSuccessRate(options?: AnalyticsOptions): Promise<SuccessRate> {\n return this.backend.getSuccessRate(options);\n }\n\n /**\n * Get comprehensive analytics summary\n *\n * Combines all analytics metrics into a single response.\n * Useful for dashboard views.\n *\n * @param options - Optional filters for time range or workflow\n * @returns Complete analytics summary\n *\n * @example\n * ```typescript\n * // Get full analytics for last 24 hours\n * const summary = await client.getAnalyticsSummary();\n *\n * // Get analytics for specific workflow over last week\n * const summary = await client.getAnalyticsSummary({\n * workflowSlug: 'my-workflow',\n * startUs: Date.now() * 1000 - 7 * 24 * 60 * 60 * 1000 * 1000\n * });\n * ```\n */\n async getAnalyticsSummary(options?: AnalyticsOptions): Promise<AnalyticsSummary> {\n return this.backend.getAnalyticsSummary(options);\n }\n\n /**\n * Get paginated list of errors grouped by fingerprint\n *\n * @param options - Filtering and pagination options\n * @returns Paginated list of error groups\n *\n * @example\n * ```typescript\n * // Get errors for last 24h\n * const { errors, total } = await client.getErrorsList({\n * timeRange: { start: Date.now() * 1000 - 86400000000, end: Date.now() * 1000 },\n * groupingStrategy: 'exact',\n * limit: 50,\n * offset: 0\n * });\n * ```\n */\n async getErrorsList(options?: {\n timeRange?: { start: number; end: number };\n workflowSlug?: string;\n groupingStrategy?: 'exact' | 'normalized' | 'portable';\n limit?: number;\n offset?: number;\n }): Promise<{\n errors: Array<{\n fingerprint: string;\n errorMessage: string;\n errorName: string;\n sampleStack: string;\n count: number;\n affectedRuns: number;\n firstSeen: number;\n lastSeen: number;\n }>;\n total: number;\n }> {\n return this.backend.getErrorsList(options);\n }\n\n /**\n * Get detailed information about a specific error by fingerprint\n *\n * @param fingerprint - Composite fingerprint (nameHash:messageHash:stackHash)\n * @param groupingStrategy - Which stack hash variant to use\n * @param options - Filtering and pagination options\n * @returns Error details with all occurrences\n *\n * @example\n * ```typescript\n * const detail = await client.getErrorDetail(\n * 'abc123:def456:ghi789',\n * 'exact',\n * { limit: 100, offset: 0 }\n * );\n * ```\n */\n async getErrorDetail(\n fingerprint: string,\n groupingStrategy: 'exact' | 'normalized' | 'portable',\n options?: {\n timeRange?: { start: number; end: number };\n limit?: number;\n offset?: number;\n }\n ): Promise<{\n fingerprint: string;\n errorMessage: string;\n errorName: string;\n sampleStack: string;\n totalCount: number;\n affectedRuns: number;\n firstSeen: number;\n lastSeen: number;\n occurrences: Array<{\n workflowSlug: string;\n runId: string;\n stepId: string;\n attemptNumber: number;\n timestampUs: number;\n }>;\n total: number;\n }> {\n return this.backend.getErrorDetail(fingerprint, groupingStrategy, options);\n }\n\n /**\n * Get the state of all steps for a run\n * Projects step events to compute current state\n */\n async getStepStates(workflowSlug: string, runId: string): Promise<StepState[]> {\n const events = await this.backend.loadEvents(workflowSlug, runId, {\n category: 'step',\n });\n\n // Group events by step ID\n const stepGroups = new Map<string, StepEvent[]>();\n for (const event of events) {\n if (event.category === 'step') {\n if (!stepGroups.has(event.stepId)) {\n stepGroups.set(event.stepId, []);\n }\n stepGroups.get(event.stepId)!.push(event as StepEvent);\n }\n }\n\n // Project each step's state\n const states: StepState[] = [];\n for (const [stepId, stepEvents] of stepGroups) {\n try {\n const state = projectStepState(stepEvents, workflowSlug);\n states.push(state);\n } catch (err) {\n console.error(`Failed to project state for step ${stepId}:`, err);\n }\n }\n\n return states;\n }\n\n /**\n * Get all events for a specific run (both workflow and step events)\n */\n async getRunEvents(workflowSlug: string, runId: string) {\n return this.backend.loadEvents(workflowSlug, runId);\n }\n\n /**\n * Get detailed information for a specific step\n * Includes state, events, and logs\n */\n async getStepDetail(\n workflowSlug: string,\n runId: string,\n stepName: string\n ): Promise<{\n state: StepState;\n events: StepEvent[];\n logs: LogEntry[];\n attempts: AttemptMetadata[];\n } | null> {\n // Load all events for this specific step\n const events = await this.backend.loadEvents(workflowSlug, runId, {\n category: 'step',\n stepId: stepName,\n });\n\n // Filter to only step events\n const stepEvents = events.filter((e): e is StepEvent => e.category === 'step');\n\n if (stepEvents.length === 0) {\n return null;\n }\n\n // Project events to current state\n const state = projectStepState(stepEvents, workflowSlug);\n\n // Extract logs from events\n const logs = extractLogsFromEvents(stepEvents);\n\n // Extract attempt metadata\n const attempts = extractAttemptMetadata(stepEvents);\n\n return {\n state,\n events: stepEvents,\n logs,\n attempts,\n };\n }\n}\n\n// Export types\nexport type { PollOptions, ListRunsOptions, RunInfo } from \"./types.ts\";\nexport type {\n WorkflowVersion,\n AnalyticsOptions,\n ErrorAnalysis,\n RetryAnalysis,\n SchedulingLatency,\n StepDuration,\n WorkflowDuration,\n WorkerStability,\n Throughput,\n QueueDepth,\n QueueDepthByWorkflow,\n SuccessRate,\n AnalyticsSummary,\n} from \"@cascade-flow/backend-interface\";\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAsBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,MAAM,eAAe;AAAA,EACN;AAAA,EAApB,WAAW,CAAS,SAAkB;AAAA,IAAlB;AAAA;AAAA,OAiBd,OAAwB,CAAC,QAUgB;AAAA,IAC7C,MAAM,aAA4B;AAAA,MAChC,cAAc,OAAO;AAAA,MACrB,OAAO,OAAO;AAAA,MACd,OAAO,OAAO;AAAA,MAC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,cAAsB,OAAe;AAAA,IACtD,OAAO,KAAK,QAAQ,WAAW,cAAc,KAAK;AAAA;AAAA,OAO9C,cAAa,CACjB,cACA,OACA,UAMQ;AAAA,IAER,MAAM,SAAS,MAAM,KAAK,QAAQ,WAAW,cAAc,OAAO;AAAA,MAChE,UAAU;AAAA,MACV,QAAQ;AAAA,IACV,CAAC;AAAA,IAGD,MAAM,aAAa,OAAO,OAAO,CAAC,MAAsB,EAAE,aAAa,MAAM;AAAA,IAE7E,IAAI,WAAW,WAAW,GAAG;AAAA,MAC3B,OAAO;AAAA,IACT;AAAA,IAGA,MAAM,QAAQ,iBAAiB,YAAY,YAAY;AAAA,IAGvD,MAAM,OAAO,sBAAsB,UAAU;AAAA,IAG7C,MAAM,WAAW,uBAAuB,UAAU;AAAA,IAElD,OAAO;AAAA,MACL;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA;AAEJ;",
|
|
8
|
+
"debugId": "BE3F3634187A2C9E64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type ListRunsOptions = {
|
|
|
28
28
|
limit?: number;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
* Extended run information with output
|
|
31
|
+
* Extended run information with output and version
|
|
32
32
|
*/
|
|
33
33
|
export type RunInfo = RunState & {
|
|
34
34
|
output?: any;
|
|
@@ -37,5 +37,6 @@ export type RunInfo = RunState & {
|
|
|
37
37
|
stack?: string;
|
|
38
38
|
name?: string;
|
|
39
39
|
};
|
|
40
|
+
versionId?: string;
|
|
40
41
|
};
|
|
41
42
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,iCAAiC,CAAC;A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,CAAC,EAAE,OAAO,CAAC;IAE7B,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAEnD,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG;IAC/B,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cascade-flow/client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test": "bun test"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@cascade-flow/backend-interface": "0.2.
|
|
21
|
+
"@cascade-flow/backend-interface": "0.2.3",
|
|
22
22
|
"zod": "^4.1.12"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|