1+ import { ComfyApi } from "../client.js" ;
2+ import { Job , JobsListOptions , JobsListResponse , JobStatus } from "../types/api.js" ;
3+ import { FeatureBase } from "./base.js" ;
4+ /**
5+ * Jobs API feature for unified job management (ComfyUI v0.6.0+).
6+ *
7+ * Provides access to the unified `/api/jobs` endpoints which offer:
8+ * - Consistent job representation across all states (pending, in_progress, completed, failed)
9+ * - Filtering by status and workflow ID
10+ * - Sorting by creation time or execution duration
11+ * - Pagination support
12+ * - Summary fields for efficient list views
13+ *
14+ * @example
15+ * ```typescript
16+ * const api = new ComfyApi("http://localhost:8188");
17+ * await api.init();
18+ *
19+ * // List recent completed jobs
20+ * const { jobs, pagination } = await api.ext.jobs.getJobs({
21+ * status: JobStatus.COMPLETED,
22+ * limit: 10,
23+ * sort_order: "desc"
24+ * });
25+ *
26+ * // Get specific job details
27+ * const job = await api.ext.jobs.getJob("prompt-id-here");
28+ * ```
29+ *
30+ * @since ComfyUI v0.6.0
31+ */
32+ export declare class JobsFeature extends FeatureBase {
33+ constructor ( client : ComfyApi ) ;
34+ /**
35+ * Check if the Jobs API is supported by the connected ComfyUI server.
36+ * The Jobs API was introduced in ComfyUI v0.6.0.
37+ *
38+ * @returns Promise resolving to true if supported, false otherwise
39+ */
40+ checkSupported ( ) : Promise < boolean > ;
41+ /**
42+ * List all jobs with optional filtering, sorting, and pagination.
43+ *
44+ * @param options - Query options for filtering and pagination
45+ * @returns Promise resolving to jobs list with pagination info
46+ *
47+ * @example
48+ * ```typescript
49+ * // Get all pending and in-progress jobs
50+ * const { jobs } = await api.ext.jobs.getJobs({
51+ * status: [JobStatus.PENDING, JobStatus.IN_PROGRESS]
52+ * });
53+ *
54+ * // Get paginated completed jobs sorted by execution time
55+ * const { jobs, pagination } = await api.ext.jobs.getJobs({
56+ * status: JobStatus.COMPLETED,
57+ * sort_by: "execution_duration",
58+ * sort_order: "desc",
59+ * limit: 20,
60+ * offset: 0
61+ * });
62+ *
63+ * // Iterate through pages
64+ * while (pagination.has_more) {
65+ * const next = await api.ext.jobs.getJobs({
66+ * limit: 20,
67+ * offset: pagination.offset + jobs.length
68+ * });
69+ * // process next.jobs...
70+ * }
71+ * ```
72+ */
73+ getJobs ( options ?: JobsListOptions ) : Promise < JobsListResponse > ;
74+ /**
75+ * Get a single job by its ID with full details including outputs.
76+ *
77+ * @param jobId - The job/prompt ID to retrieve
78+ * @returns Promise resolving to the job details, or null if not found
79+ *
80+ * @example
81+ * ```typescript
82+ * const job = await api.ext.jobs.getJob("abc-123-def");
83+ * if (job) {
84+ * console.log(`Job ${job.id}: ${job.status}`);
85+ * if (job.status === JobStatus.COMPLETED) {
86+ * console.log(`Outputs: ${job.outputs_count}`);
87+ * console.log(`Duration: ${job.execution_end_time - job.execution_start_time}ms`);
88+ * }
89+ * }
90+ * ```
91+ */
92+ getJob ( jobId : string ) : Promise < Job | null > ;
93+ /**
94+ * Get jobs filtered by a specific status.
95+ * Convenience method that wraps getJobs().
96+ *
97+ * @param status - The status to filter by
98+ * @param limit - Maximum number of jobs to return (default 100)
99+ * @returns Promise resolving to array of jobs
100+ */
101+ getJobsByStatus ( status : JobStatus , limit ?: number ) : Promise < Job [ ] > ;
102+ /**
103+ * Get currently running jobs.
104+ * Convenience method for getJobsByStatus(JobStatus.IN_PROGRESS).
105+ */
106+ getRunningJobs ( ) : Promise < Job [ ] > ;
107+ /**
108+ * Get pending (queued) jobs.
109+ * Convenience method for getJobsByStatus(JobStatus.PENDING).
110+ */
111+ getPendingJobs ( ) : Promise < Job [ ] > ;
112+ /**
113+ * Get recently completed jobs.
114+ *
115+ * @param limit - Maximum number of jobs to return (default 20)
116+ */
117+ getCompletedJobs ( limit ?: number ) : Promise < Job [ ] > ;
118+ /**
119+ * Get recently failed jobs.
120+ *
121+ * @param limit - Maximum number of jobs to return (default 20)
122+ */
123+ getFailedJobs ( limit ?: number ) : Promise < Job [ ] > ;
124+ /**
125+ * Calculate execution duration for a completed job.
126+ *
127+ * @param job - The job to calculate duration for
128+ * @returns Duration in milliseconds, or null if times are not available
129+ */
130+ getExecutionDuration ( job : Job ) : number | null ;
131+ }
132+ //# sourceMappingURL=jobs.d.ts.map
0 commit comments