@corvohq/client 0.2.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.
@@ -0,0 +1,689 @@
1
+ import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
2
+ import type { Timestamp } from "@bufbuild/protobuf/wkt";
3
+ import type { Message } from "@bufbuild/protobuf";
4
+ /**
5
+ * Describes the file corvo/v1/worker.proto.
6
+ */
7
+ export declare const file_corvo_v1_worker: GenFile;
8
+ /**
9
+ * @generated from message corvo.v1.EnqueueRequest
10
+ */
11
+ export type EnqueueRequest = Message<"corvo.v1.EnqueueRequest"> & {
12
+ /**
13
+ * @generated from field: string queue = 1;
14
+ */
15
+ queue: string;
16
+ /**
17
+ * @generated from field: string payload_json = 2;
18
+ */
19
+ payloadJson: string;
20
+ /**
21
+ * @generated from field: corvo.v1.AgentConfig agent = 3;
22
+ */
23
+ agent?: AgentConfig;
24
+ };
25
+ /**
26
+ * Describes the message corvo.v1.EnqueueRequest.
27
+ * Use `create(EnqueueRequestSchema)` to create a new message.
28
+ */
29
+ export declare const EnqueueRequestSchema: GenMessage<EnqueueRequest>;
30
+ /**
31
+ * @generated from message corvo.v1.EnqueueResponse
32
+ */
33
+ export type EnqueueResponse = Message<"corvo.v1.EnqueueResponse"> & {
34
+ /**
35
+ * @generated from field: string job_id = 1;
36
+ */
37
+ jobId: string;
38
+ /**
39
+ * @generated from field: string status = 2;
40
+ */
41
+ status: string;
42
+ /**
43
+ * @generated from field: bool unique_existing = 3;
44
+ */
45
+ uniqueExisting: boolean;
46
+ };
47
+ /**
48
+ * Describes the message corvo.v1.EnqueueResponse.
49
+ * Use `create(EnqueueResponseSchema)` to create a new message.
50
+ */
51
+ export declare const EnqueueResponseSchema: GenMessage<EnqueueResponse>;
52
+ /**
53
+ * @generated from message corvo.v1.FetchRequest
54
+ */
55
+ export type FetchRequest = Message<"corvo.v1.FetchRequest"> & {
56
+ /**
57
+ * @generated from field: repeated string queues = 1;
58
+ */
59
+ queues: string[];
60
+ /**
61
+ * @generated from field: string worker_id = 2;
62
+ */
63
+ workerId: string;
64
+ /**
65
+ * @generated from field: string hostname = 3;
66
+ */
67
+ hostname: string;
68
+ /**
69
+ * @generated from field: int32 lease_duration = 4;
70
+ */
71
+ leaseDuration: number;
72
+ };
73
+ /**
74
+ * Describes the message corvo.v1.FetchRequest.
75
+ * Use `create(FetchRequestSchema)` to create a new message.
76
+ */
77
+ export declare const FetchRequestSchema: GenMessage<FetchRequest>;
78
+ /**
79
+ * @generated from message corvo.v1.FetchResponse
80
+ */
81
+ export type FetchResponse = Message<"corvo.v1.FetchResponse"> & {
82
+ /**
83
+ * @generated from field: bool found = 1;
84
+ */
85
+ found: boolean;
86
+ /**
87
+ * @generated from field: string job_id = 2;
88
+ */
89
+ jobId: string;
90
+ /**
91
+ * @generated from field: string queue = 3;
92
+ */
93
+ queue: string;
94
+ /**
95
+ * @generated from field: string payload_json = 4;
96
+ */
97
+ payloadJson: string;
98
+ /**
99
+ * @generated from field: int32 attempt = 5;
100
+ */
101
+ attempt: number;
102
+ /**
103
+ * @generated from field: int32 max_retries = 6;
104
+ */
105
+ maxRetries: number;
106
+ /**
107
+ * @generated from field: int32 lease_duration = 7;
108
+ */
109
+ leaseDuration: number;
110
+ /**
111
+ * @generated from field: string checkpoint_json = 8;
112
+ */
113
+ checkpointJson: string;
114
+ /**
115
+ * @generated from field: string tags_json = 9;
116
+ */
117
+ tagsJson: string;
118
+ /**
119
+ * @generated from field: corvo.v1.AgentState agent = 10;
120
+ */
121
+ agent?: AgentState;
122
+ };
123
+ /**
124
+ * Describes the message corvo.v1.FetchResponse.
125
+ * Use `create(FetchResponseSchema)` to create a new message.
126
+ */
127
+ export declare const FetchResponseSchema: GenMessage<FetchResponse>;
128
+ /**
129
+ * @generated from message corvo.v1.FetchBatchRequest
130
+ */
131
+ export type FetchBatchRequest = Message<"corvo.v1.FetchBatchRequest"> & {
132
+ /**
133
+ * @generated from field: repeated string queues = 1;
134
+ */
135
+ queues: string[];
136
+ /**
137
+ * @generated from field: string worker_id = 2;
138
+ */
139
+ workerId: string;
140
+ /**
141
+ * @generated from field: string hostname = 3;
142
+ */
143
+ hostname: string;
144
+ /**
145
+ * @generated from field: int32 lease_duration = 4;
146
+ */
147
+ leaseDuration: number;
148
+ /**
149
+ * @generated from field: int32 count = 5;
150
+ */
151
+ count: number;
152
+ };
153
+ /**
154
+ * Describes the message corvo.v1.FetchBatchRequest.
155
+ * Use `create(FetchBatchRequestSchema)` to create a new message.
156
+ */
157
+ export declare const FetchBatchRequestSchema: GenMessage<FetchBatchRequest>;
158
+ /**
159
+ * @generated from message corvo.v1.FetchBatchJob
160
+ */
161
+ export type FetchBatchJob = Message<"corvo.v1.FetchBatchJob"> & {
162
+ /**
163
+ * @generated from field: string job_id = 1;
164
+ */
165
+ jobId: string;
166
+ /**
167
+ * @generated from field: string queue = 2;
168
+ */
169
+ queue: string;
170
+ /**
171
+ * @generated from field: string payload_json = 3;
172
+ */
173
+ payloadJson: string;
174
+ /**
175
+ * @generated from field: int32 attempt = 4;
176
+ */
177
+ attempt: number;
178
+ /**
179
+ * @generated from field: int32 max_retries = 5;
180
+ */
181
+ maxRetries: number;
182
+ /**
183
+ * @generated from field: int32 lease_duration = 6;
184
+ */
185
+ leaseDuration: number;
186
+ /**
187
+ * @generated from field: string checkpoint_json = 7;
188
+ */
189
+ checkpointJson: string;
190
+ /**
191
+ * @generated from field: string tags_json = 8;
192
+ */
193
+ tagsJson: string;
194
+ /**
195
+ * @generated from field: corvo.v1.AgentState agent = 9;
196
+ */
197
+ agent?: AgentState;
198
+ };
199
+ /**
200
+ * Describes the message corvo.v1.FetchBatchJob.
201
+ * Use `create(FetchBatchJobSchema)` to create a new message.
202
+ */
203
+ export declare const FetchBatchJobSchema: GenMessage<FetchBatchJob>;
204
+ /**
205
+ * @generated from message corvo.v1.FetchBatchResponse
206
+ */
207
+ export type FetchBatchResponse = Message<"corvo.v1.FetchBatchResponse"> & {
208
+ /**
209
+ * @generated from field: repeated corvo.v1.FetchBatchJob jobs = 1;
210
+ */
211
+ jobs: FetchBatchJob[];
212
+ };
213
+ /**
214
+ * Describes the message corvo.v1.FetchBatchResponse.
215
+ * Use `create(FetchBatchResponseSchema)` to create a new message.
216
+ */
217
+ export declare const FetchBatchResponseSchema: GenMessage<FetchBatchResponse>;
218
+ /**
219
+ * @generated from message corvo.v1.UsageReport
220
+ */
221
+ export type UsageReport = Message<"corvo.v1.UsageReport"> & {
222
+ /**
223
+ * @generated from field: int64 input_tokens = 1;
224
+ */
225
+ inputTokens: bigint;
226
+ /**
227
+ * @generated from field: int64 output_tokens = 2;
228
+ */
229
+ outputTokens: bigint;
230
+ /**
231
+ * @generated from field: int64 cache_creation_tokens = 3;
232
+ */
233
+ cacheCreationTokens: bigint;
234
+ /**
235
+ * @generated from field: int64 cache_read_tokens = 4;
236
+ */
237
+ cacheReadTokens: bigint;
238
+ /**
239
+ * @generated from field: string model = 5;
240
+ */
241
+ model: string;
242
+ /**
243
+ * @generated from field: string provider = 6;
244
+ */
245
+ provider: string;
246
+ /**
247
+ * @generated from field: double cost_usd = 7;
248
+ */
249
+ costUsd: number;
250
+ };
251
+ /**
252
+ * Describes the message corvo.v1.UsageReport.
253
+ * Use `create(UsageReportSchema)` to create a new message.
254
+ */
255
+ export declare const UsageReportSchema: GenMessage<UsageReport>;
256
+ /**
257
+ * @generated from message corvo.v1.AckRequest
258
+ */
259
+ export type AckRequest = Message<"corvo.v1.AckRequest"> & {
260
+ /**
261
+ * @generated from field: string job_id = 1;
262
+ */
263
+ jobId: string;
264
+ /**
265
+ * @generated from field: string result_json = 2;
266
+ */
267
+ resultJson: string;
268
+ /**
269
+ * @generated from field: corvo.v1.UsageReport usage = 3;
270
+ */
271
+ usage?: UsageReport;
272
+ /**
273
+ * @generated from field: string checkpoint_json = 4;
274
+ */
275
+ checkpointJson: string;
276
+ /**
277
+ * @generated from field: string agent_status = 5;
278
+ */
279
+ agentStatus: string;
280
+ /**
281
+ * @generated from field: string hold_reason = 6;
282
+ */
283
+ holdReason: string;
284
+ /**
285
+ * @generated from field: string trace_json = 7;
286
+ */
287
+ traceJson: string;
288
+ };
289
+ /**
290
+ * Describes the message corvo.v1.AckRequest.
291
+ * Use `create(AckRequestSchema)` to create a new message.
292
+ */
293
+ export declare const AckRequestSchema: GenMessage<AckRequest>;
294
+ /**
295
+ * @generated from message corvo.v1.AckResponse
296
+ */
297
+ export type AckResponse = Message<"corvo.v1.AckResponse"> & {};
298
+ /**
299
+ * Describes the message corvo.v1.AckResponse.
300
+ * Use `create(AckResponseSchema)` to create a new message.
301
+ */
302
+ export declare const AckResponseSchema: GenMessage<AckResponse>;
303
+ /**
304
+ * @generated from message corvo.v1.AckBatchItem
305
+ */
306
+ export type AckBatchItem = Message<"corvo.v1.AckBatchItem"> & {
307
+ /**
308
+ * @generated from field: string job_id = 1;
309
+ */
310
+ jobId: string;
311
+ /**
312
+ * @generated from field: string result_json = 2;
313
+ */
314
+ resultJson: string;
315
+ /**
316
+ * @generated from field: corvo.v1.UsageReport usage = 3;
317
+ */
318
+ usage?: UsageReport;
319
+ };
320
+ /**
321
+ * Describes the message corvo.v1.AckBatchItem.
322
+ * Use `create(AckBatchItemSchema)` to create a new message.
323
+ */
324
+ export declare const AckBatchItemSchema: GenMessage<AckBatchItem>;
325
+ /**
326
+ * @generated from message corvo.v1.AckBatchRequest
327
+ */
328
+ export type AckBatchRequest = Message<"corvo.v1.AckBatchRequest"> & {
329
+ /**
330
+ * @generated from field: repeated corvo.v1.AckBatchItem items = 1;
331
+ */
332
+ items: AckBatchItem[];
333
+ };
334
+ /**
335
+ * Describes the message corvo.v1.AckBatchRequest.
336
+ * Use `create(AckBatchRequestSchema)` to create a new message.
337
+ */
338
+ export declare const AckBatchRequestSchema: GenMessage<AckBatchRequest>;
339
+ /**
340
+ * @generated from message corvo.v1.AckBatchResponse
341
+ */
342
+ export type AckBatchResponse = Message<"corvo.v1.AckBatchResponse"> & {
343
+ /**
344
+ * @generated from field: int32 acked = 1;
345
+ */
346
+ acked: number;
347
+ };
348
+ /**
349
+ * Describes the message corvo.v1.AckBatchResponse.
350
+ * Use `create(AckBatchResponseSchema)` to create a new message.
351
+ */
352
+ export declare const AckBatchResponseSchema: GenMessage<AckBatchResponse>;
353
+ /**
354
+ * @generated from message corvo.v1.LifecycleStreamRequest
355
+ */
356
+ export type LifecycleStreamRequest = Message<"corvo.v1.LifecycleStreamRequest"> & {
357
+ /**
358
+ * @generated from field: uint64 request_id = 1;
359
+ */
360
+ requestId: bigint;
361
+ /**
362
+ * @generated from field: repeated string queues = 2;
363
+ */
364
+ queues: string[];
365
+ /**
366
+ * @generated from field: string worker_id = 3;
367
+ */
368
+ workerId: string;
369
+ /**
370
+ * @generated from field: string hostname = 4;
371
+ */
372
+ hostname: string;
373
+ /**
374
+ * @generated from field: int32 lease_duration = 5;
375
+ */
376
+ leaseDuration: number;
377
+ /**
378
+ * @generated from field: int32 fetch_count = 6;
379
+ */
380
+ fetchCount: number;
381
+ /**
382
+ * @generated from field: repeated corvo.v1.AckBatchItem acks = 7;
383
+ */
384
+ acks: AckBatchItem[];
385
+ /**
386
+ * @generated from field: repeated corvo.v1.LifecycleEnqueueItem enqueues = 8;
387
+ */
388
+ enqueues: LifecycleEnqueueItem[];
389
+ };
390
+ /**
391
+ * Describes the message corvo.v1.LifecycleStreamRequest.
392
+ * Use `create(LifecycleStreamRequestSchema)` to create a new message.
393
+ */
394
+ export declare const LifecycleStreamRequestSchema: GenMessage<LifecycleStreamRequest>;
395
+ /**
396
+ * @generated from message corvo.v1.LifecycleEnqueueItem
397
+ */
398
+ export type LifecycleEnqueueItem = Message<"corvo.v1.LifecycleEnqueueItem"> & {
399
+ /**
400
+ * @generated from field: string queue = 1;
401
+ */
402
+ queue: string;
403
+ /**
404
+ * @generated from field: string payload_json = 2;
405
+ */
406
+ payloadJson: string;
407
+ /**
408
+ * @generated from field: corvo.v1.AgentConfig agent = 3;
409
+ */
410
+ agent?: AgentConfig;
411
+ };
412
+ /**
413
+ * Describes the message corvo.v1.LifecycleEnqueueItem.
414
+ * Use `create(LifecycleEnqueueItemSchema)` to create a new message.
415
+ */
416
+ export declare const LifecycleEnqueueItemSchema: GenMessage<LifecycleEnqueueItem>;
417
+ /**
418
+ * @generated from message corvo.v1.AgentConfig
419
+ */
420
+ export type AgentConfig = Message<"corvo.v1.AgentConfig"> & {
421
+ /**
422
+ * @generated from field: int32 max_iterations = 1;
423
+ */
424
+ maxIterations: number;
425
+ /**
426
+ * @generated from field: double max_cost_usd = 2;
427
+ */
428
+ maxCostUsd: number;
429
+ /**
430
+ * @generated from field: string iteration_timeout = 3;
431
+ */
432
+ iterationTimeout: string;
433
+ };
434
+ /**
435
+ * Describes the message corvo.v1.AgentConfig.
436
+ * Use `create(AgentConfigSchema)` to create a new message.
437
+ */
438
+ export declare const AgentConfigSchema: GenMessage<AgentConfig>;
439
+ /**
440
+ * @generated from message corvo.v1.AgentState
441
+ */
442
+ export type AgentState = Message<"corvo.v1.AgentState"> & {
443
+ /**
444
+ * @generated from field: int32 max_iterations = 1;
445
+ */
446
+ maxIterations: number;
447
+ /**
448
+ * @generated from field: double max_cost_usd = 2;
449
+ */
450
+ maxCostUsd: number;
451
+ /**
452
+ * @generated from field: string iteration_timeout = 3;
453
+ */
454
+ iterationTimeout: string;
455
+ /**
456
+ * @generated from field: int32 iteration = 4;
457
+ */
458
+ iteration: number;
459
+ /**
460
+ * @generated from field: double total_cost_usd = 5;
461
+ */
462
+ totalCostUsd: number;
463
+ };
464
+ /**
465
+ * Describes the message corvo.v1.AgentState.
466
+ * Use `create(AgentStateSchema)` to create a new message.
467
+ */
468
+ export declare const AgentStateSchema: GenMessage<AgentState>;
469
+ /**
470
+ * @generated from message corvo.v1.LifecycleStreamResponse
471
+ */
472
+ export type LifecycleStreamResponse = Message<"corvo.v1.LifecycleStreamResponse"> & {
473
+ /**
474
+ * @generated from field: uint64 request_id = 1;
475
+ */
476
+ requestId: bigint;
477
+ /**
478
+ * @generated from field: repeated corvo.v1.FetchBatchJob jobs = 2;
479
+ */
480
+ jobs: FetchBatchJob[];
481
+ /**
482
+ * @generated from field: int32 acked = 3;
483
+ */
484
+ acked: number;
485
+ /**
486
+ * @generated from field: string error = 4;
487
+ */
488
+ error: string;
489
+ /**
490
+ * @generated from field: repeated string enqueued_job_ids = 5;
491
+ */
492
+ enqueuedJobIds: string[];
493
+ /**
494
+ * HTTP URL of leader, set when error="NOT_LEADER"
495
+ *
496
+ * @generated from field: string leader_addr = 6;
497
+ */
498
+ leaderAddr: string;
499
+ };
500
+ /**
501
+ * Describes the message corvo.v1.LifecycleStreamResponse.
502
+ * Use `create(LifecycleStreamResponseSchema)` to create a new message.
503
+ */
504
+ export declare const LifecycleStreamResponseSchema: GenMessage<LifecycleStreamResponse>;
505
+ /**
506
+ * @generated from message corvo.v1.FailRequest
507
+ */
508
+ export type FailRequest = Message<"corvo.v1.FailRequest"> & {
509
+ /**
510
+ * @generated from field: string job_id = 1;
511
+ */
512
+ jobId: string;
513
+ /**
514
+ * @generated from field: string error = 2;
515
+ */
516
+ error: string;
517
+ /**
518
+ * @generated from field: string backtrace = 3;
519
+ */
520
+ backtrace: string;
521
+ };
522
+ /**
523
+ * Describes the message corvo.v1.FailRequest.
524
+ * Use `create(FailRequestSchema)` to create a new message.
525
+ */
526
+ export declare const FailRequestSchema: GenMessage<FailRequest>;
527
+ /**
528
+ * @generated from message corvo.v1.FailResponse
529
+ */
530
+ export type FailResponse = Message<"corvo.v1.FailResponse"> & {
531
+ /**
532
+ * @generated from field: string status = 1;
533
+ */
534
+ status: string;
535
+ /**
536
+ * @generated from field: google.protobuf.Timestamp next_attempt_at = 2;
537
+ */
538
+ nextAttemptAt?: Timestamp;
539
+ /**
540
+ * @generated from field: int32 attempts_remaining = 3;
541
+ */
542
+ attemptsRemaining: number;
543
+ };
544
+ /**
545
+ * Describes the message corvo.v1.FailResponse.
546
+ * Use `create(FailResponseSchema)` to create a new message.
547
+ */
548
+ export declare const FailResponseSchema: GenMessage<FailResponse>;
549
+ /**
550
+ * @generated from message corvo.v1.HeartbeatJobUpdate
551
+ */
552
+ export type HeartbeatJobUpdate = Message<"corvo.v1.HeartbeatJobUpdate"> & {
553
+ /**
554
+ * @generated from field: string progress_json = 1;
555
+ */
556
+ progressJson: string;
557
+ /**
558
+ * @generated from field: string checkpoint_json = 2;
559
+ */
560
+ checkpointJson: string;
561
+ /**
562
+ * @generated from field: corvo.v1.UsageReport usage = 3;
563
+ */
564
+ usage?: UsageReport;
565
+ /**
566
+ * @generated from field: string stream_delta = 4;
567
+ */
568
+ streamDelta: string;
569
+ };
570
+ /**
571
+ * Describes the message corvo.v1.HeartbeatJobUpdate.
572
+ * Use `create(HeartbeatJobUpdateSchema)` to create a new message.
573
+ */
574
+ export declare const HeartbeatJobUpdateSchema: GenMessage<HeartbeatJobUpdate>;
575
+ /**
576
+ * @generated from message corvo.v1.HeartbeatRequest
577
+ */
578
+ export type HeartbeatRequest = Message<"corvo.v1.HeartbeatRequest"> & {
579
+ /**
580
+ * @generated from field: map<string, corvo.v1.HeartbeatJobUpdate> jobs = 1;
581
+ */
582
+ jobs: {
583
+ [key: string]: HeartbeatJobUpdate;
584
+ };
585
+ };
586
+ /**
587
+ * Describes the message corvo.v1.HeartbeatRequest.
588
+ * Use `create(HeartbeatRequestSchema)` to create a new message.
589
+ */
590
+ export declare const HeartbeatRequestSchema: GenMessage<HeartbeatRequest>;
591
+ /**
592
+ * @generated from message corvo.v1.HeartbeatJobResponse
593
+ */
594
+ export type HeartbeatJobResponse = Message<"corvo.v1.HeartbeatJobResponse"> & {
595
+ /**
596
+ * @generated from field: string status = 1;
597
+ */
598
+ status: string;
599
+ };
600
+ /**
601
+ * Describes the message corvo.v1.HeartbeatJobResponse.
602
+ * Use `create(HeartbeatJobResponseSchema)` to create a new message.
603
+ */
604
+ export declare const HeartbeatJobResponseSchema: GenMessage<HeartbeatJobResponse>;
605
+ /**
606
+ * @generated from message corvo.v1.HeartbeatResponse
607
+ */
608
+ export type HeartbeatResponse = Message<"corvo.v1.HeartbeatResponse"> & {
609
+ /**
610
+ * @generated from field: map<string, corvo.v1.HeartbeatJobResponse> jobs = 1;
611
+ */
612
+ jobs: {
613
+ [key: string]: HeartbeatJobResponse;
614
+ };
615
+ };
616
+ /**
617
+ * Describes the message corvo.v1.HeartbeatResponse.
618
+ * Use `create(HeartbeatResponseSchema)` to create a new message.
619
+ */
620
+ export declare const HeartbeatResponseSchema: GenMessage<HeartbeatResponse>;
621
+ /**
622
+ * @generated from service corvo.v1.WorkerService
623
+ */
624
+ export declare const WorkerService: GenService<{
625
+ /**
626
+ * @generated from rpc corvo.v1.WorkerService.Enqueue
627
+ */
628
+ enqueue: {
629
+ methodKind: "unary";
630
+ input: typeof EnqueueRequestSchema;
631
+ output: typeof EnqueueResponseSchema;
632
+ };
633
+ /**
634
+ * @generated from rpc corvo.v1.WorkerService.Fetch
635
+ */
636
+ fetch: {
637
+ methodKind: "unary";
638
+ input: typeof FetchRequestSchema;
639
+ output: typeof FetchResponseSchema;
640
+ };
641
+ /**
642
+ * @generated from rpc corvo.v1.WorkerService.FetchBatch
643
+ */
644
+ fetchBatch: {
645
+ methodKind: "unary";
646
+ input: typeof FetchBatchRequestSchema;
647
+ output: typeof FetchBatchResponseSchema;
648
+ };
649
+ /**
650
+ * @generated from rpc corvo.v1.WorkerService.Ack
651
+ */
652
+ ack: {
653
+ methodKind: "unary";
654
+ input: typeof AckRequestSchema;
655
+ output: typeof AckResponseSchema;
656
+ };
657
+ /**
658
+ * @generated from rpc corvo.v1.WorkerService.AckBatch
659
+ */
660
+ ackBatch: {
661
+ methodKind: "unary";
662
+ input: typeof AckBatchRequestSchema;
663
+ output: typeof AckBatchResponseSchema;
664
+ };
665
+ /**
666
+ * @generated from rpc corvo.v1.WorkerService.StreamLifecycle
667
+ */
668
+ streamLifecycle: {
669
+ methodKind: "bidi_streaming";
670
+ input: typeof LifecycleStreamRequestSchema;
671
+ output: typeof LifecycleStreamResponseSchema;
672
+ };
673
+ /**
674
+ * @generated from rpc corvo.v1.WorkerService.Fail
675
+ */
676
+ fail: {
677
+ methodKind: "unary";
678
+ input: typeof FailRequestSchema;
679
+ output: typeof FailResponseSchema;
680
+ };
681
+ /**
682
+ * @generated from rpc corvo.v1.WorkerService.Heartbeat
683
+ */
684
+ heartbeat: {
685
+ methodKind: "unary";
686
+ input: typeof HeartbeatRequestSchema;
687
+ output: typeof HeartbeatResponseSchema;
688
+ };
689
+ }>;
@@ -0,0 +1,133 @@
1
+ // @generated by protoc-gen-es v2.11.0 with parameter "target=ts"
2
+ // @generated from file corvo/v1/worker.proto (package corvo.v1, syntax proto3)
3
+ /* eslint-disable */
4
+ import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
5
+ import { file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt";
6
+ /**
7
+ * Describes the file corvo/v1/worker.proto.
8
+ */
9
+ export const file_corvo_v1_worker = /*@__PURE__*/ fileDesc("ChVjb3J2by92MS93b3JrZXIucHJvdG8SCGNvcnZvLnYxIlsKDkVucXVldWVSZXF1ZXN0Eg0KBXF1ZXVlGAEgASgJEhQKDHBheWxvYWRfanNvbhgCIAEoCRIkCgVhZ2VudBgDIAEoCzIVLmNvcnZvLnYxLkFnZW50Q29uZmlnIkoKD0VucXVldWVSZXNwb25zZRIOCgZqb2JfaWQYASABKAkSDgoGc3RhdHVzGAIgASgJEhcKD3VuaXF1ZV9leGlzdGluZxgDIAEoCCJbCgxGZXRjaFJlcXVlc3QSDgoGcXVldWVzGAEgAygJEhEKCXdvcmtlcl9pZBgCIAEoCRIQCghob3N0bmFtZRgDIAEoCRIWCg5sZWFzZV9kdXJhdGlvbhgEIAEoBSLiAQoNRmV0Y2hSZXNwb25zZRINCgVmb3VuZBgBIAEoCBIOCgZqb2JfaWQYAiABKAkSDQoFcXVldWUYAyABKAkSFAoMcGF5bG9hZF9qc29uGAQgASgJEg8KB2F0dGVtcHQY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cG9uc2U6AjgBMrIECg1Xb3JrZXJTZXJ2aWNlEkAKB0VucXVldWUSGC5jb3J2by52MS5FbnF1ZXVlUmVxdWVzdBoZLmNvcnZvLnYxLkVucXVldWVSZXNwb25zZSIAEjoKBUZldGNoEhYuY29ydm8udjEuRmV0Y2hSZXF1ZXN0GhcuY29ydm8udjEuRmV0Y2hSZXNwb25zZSIAEkkKCkZldGNoQmF0Y2gSGy5jb3J2by52MS5GZXRjaEJhdGNoUmVxdWVzdBocLmNvcnZvLnYxLkZldGNoQmF0Y2hSZXNwb25zZSIAEjQKA0FjaxIULmNvcnZvLnYxLkFja1JlcXVlc3QaFS5jb3J2by52MS5BY2tSZXNwb25zZSIAEkMKCEFja0JhdGNoEhkuY29ydm8udjEuQWNrQmF0Y2hSZXF1ZXN0GhouY29ydm8udjEuQWNrQmF0Y2hSZXNwb25zZSIAElwKD1N0cmVhbUxpZmVjeWNsZRIgLmNvcnZvLnYxLkxpZmVjeWNsZVN0cmVhbVJlcXVlc3QaIS5jb3J2by52MS5MaWZlY3ljbGVTdHJlYW1SZXNwb25zZSIAKAEwARI3CgRGYWlsEhUuY29ydm8udjEuRmFpbFJlcXVlc3QaFi5jb3J2by52MS5GYWlsUmVzcG9uc2UiABJGCglIZWFydGJlYXQSGi5jb3J2by52MS5IZWFydGJlYXRSZXF1ZXN0GhsuY29ydm8udjEuSGVhcnRiZWF0UmVzcG9uc2UiAGIGcHJvdG8z", [file_google_protobuf_timestamp]);
10
+ /**
11
+ * Describes the message corvo.v1.EnqueueRequest.
12
+ * Use `create(EnqueueRequestSchema)` to create a new message.
13
+ */
14
+ export const EnqueueRequestSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 0);
15
+ /**
16
+ * Describes the message corvo.v1.EnqueueResponse.
17
+ * Use `create(EnqueueResponseSchema)` to create a new message.
18
+ */
19
+ export const EnqueueResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 1);
20
+ /**
21
+ * Describes the message corvo.v1.FetchRequest.
22
+ * Use `create(FetchRequestSchema)` to create a new message.
23
+ */
24
+ export const FetchRequestSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 2);
25
+ /**
26
+ * Describes the message corvo.v1.FetchResponse.
27
+ * Use `create(FetchResponseSchema)` to create a new message.
28
+ */
29
+ export const FetchResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 3);
30
+ /**
31
+ * Describes the message corvo.v1.FetchBatchRequest.
32
+ * Use `create(FetchBatchRequestSchema)` to create a new message.
33
+ */
34
+ export const FetchBatchRequestSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 4);
35
+ /**
36
+ * Describes the message corvo.v1.FetchBatchJob.
37
+ * Use `create(FetchBatchJobSchema)` to create a new message.
38
+ */
39
+ export const FetchBatchJobSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 5);
40
+ /**
41
+ * Describes the message corvo.v1.FetchBatchResponse.
42
+ * Use `create(FetchBatchResponseSchema)` to create a new message.
43
+ */
44
+ export const FetchBatchResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 6);
45
+ /**
46
+ * Describes the message corvo.v1.UsageReport.
47
+ * Use `create(UsageReportSchema)` to create a new message.
48
+ */
49
+ export const UsageReportSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 7);
50
+ /**
51
+ * Describes the message corvo.v1.AckRequest.
52
+ * Use `create(AckRequestSchema)` to create a new message.
53
+ */
54
+ export const AckRequestSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 8);
55
+ /**
56
+ * Describes the message corvo.v1.AckResponse.
57
+ * Use `create(AckResponseSchema)` to create a new message.
58
+ */
59
+ export const AckResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 9);
60
+ /**
61
+ * Describes the message corvo.v1.AckBatchItem.
62
+ * Use `create(AckBatchItemSchema)` to create a new message.
63
+ */
64
+ export const AckBatchItemSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 10);
65
+ /**
66
+ * Describes the message corvo.v1.AckBatchRequest.
67
+ * Use `create(AckBatchRequestSchema)` to create a new message.
68
+ */
69
+ export const AckBatchRequestSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 11);
70
+ /**
71
+ * Describes the message corvo.v1.AckBatchResponse.
72
+ * Use `create(AckBatchResponseSchema)` to create a new message.
73
+ */
74
+ export const AckBatchResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 12);
75
+ /**
76
+ * Describes the message corvo.v1.LifecycleStreamRequest.
77
+ * Use `create(LifecycleStreamRequestSchema)` to create a new message.
78
+ */
79
+ export const LifecycleStreamRequestSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 13);
80
+ /**
81
+ * Describes the message corvo.v1.LifecycleEnqueueItem.
82
+ * Use `create(LifecycleEnqueueItemSchema)` to create a new message.
83
+ */
84
+ export const LifecycleEnqueueItemSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 14);
85
+ /**
86
+ * Describes the message corvo.v1.AgentConfig.
87
+ * Use `create(AgentConfigSchema)` to create a new message.
88
+ */
89
+ export const AgentConfigSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 15);
90
+ /**
91
+ * Describes the message corvo.v1.AgentState.
92
+ * Use `create(AgentStateSchema)` to create a new message.
93
+ */
94
+ export const AgentStateSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 16);
95
+ /**
96
+ * Describes the message corvo.v1.LifecycleStreamResponse.
97
+ * Use `create(LifecycleStreamResponseSchema)` to create a new message.
98
+ */
99
+ export const LifecycleStreamResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 17);
100
+ /**
101
+ * Describes the message corvo.v1.FailRequest.
102
+ * Use `create(FailRequestSchema)` to create a new message.
103
+ */
104
+ export const FailRequestSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 18);
105
+ /**
106
+ * Describes the message corvo.v1.FailResponse.
107
+ * Use `create(FailResponseSchema)` to create a new message.
108
+ */
109
+ export const FailResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 19);
110
+ /**
111
+ * Describes the message corvo.v1.HeartbeatJobUpdate.
112
+ * Use `create(HeartbeatJobUpdateSchema)` to create a new message.
113
+ */
114
+ export const HeartbeatJobUpdateSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 20);
115
+ /**
116
+ * Describes the message corvo.v1.HeartbeatRequest.
117
+ * Use `create(HeartbeatRequestSchema)` to create a new message.
118
+ */
119
+ export const HeartbeatRequestSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 21);
120
+ /**
121
+ * Describes the message corvo.v1.HeartbeatJobResponse.
122
+ * Use `create(HeartbeatJobResponseSchema)` to create a new message.
123
+ */
124
+ export const HeartbeatJobResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 22);
125
+ /**
126
+ * Describes the message corvo.v1.HeartbeatResponse.
127
+ * Use `create(HeartbeatResponseSchema)` to create a new message.
128
+ */
129
+ export const HeartbeatResponseSchema = /*@__PURE__*/ messageDesc(file_corvo_v1_worker, 23);
130
+ /**
131
+ * @generated from service corvo.v1.WorkerService
132
+ */
133
+ export const WorkerService = /*@__PURE__*/ serviceDesc(file_corvo_v1_worker, 0);
@@ -0,0 +1,156 @@
1
+ export type EnqueueResult = {
2
+ job_id: string;
3
+ status: string;
4
+ unique_existing?: boolean;
5
+ };
6
+ export type SearchFilter = {
7
+ queue?: string;
8
+ state?: string[];
9
+ priority?: string;
10
+ tags?: Record<string, string>;
11
+ payload_contains?: string;
12
+ payload_jq?: string;
13
+ sort?: string;
14
+ order?: "asc" | "desc";
15
+ limit?: number;
16
+ cursor?: string;
17
+ };
18
+ export type SearchResult<T = Record<string, unknown>> = {
19
+ jobs: T[];
20
+ total: number;
21
+ cursor?: string;
22
+ has_more: boolean;
23
+ };
24
+ export type BulkRequest = {
25
+ job_ids?: string[];
26
+ filter?: SearchFilter;
27
+ action: "retry" | "delete" | "cancel" | "move" | "requeue" | "change_priority" | "hold" | "approve" | "reject";
28
+ move_to_queue?: string;
29
+ priority?: string;
30
+ async?: boolean;
31
+ };
32
+ export type BulkResult = {
33
+ affected: number;
34
+ errors: number;
35
+ duration_ms: number;
36
+ };
37
+ export type BulkAsyncStart = {
38
+ bulk_operation_id: string;
39
+ status: string;
40
+ estimated_total: number;
41
+ progress_url: string;
42
+ };
43
+ export type BulkTask = {
44
+ id: string;
45
+ status: "queued" | "running" | "completed" | "failed";
46
+ action: string;
47
+ total: number;
48
+ processed: number;
49
+ affected: number;
50
+ errors: number;
51
+ error?: string;
52
+ created_at: string;
53
+ updated_at: string;
54
+ finished_at?: string;
55
+ };
56
+ export type BatchJob = {
57
+ queue: string;
58
+ payload: unknown;
59
+ [key: string]: unknown;
60
+ };
61
+ export type BatchConfig = {
62
+ callback_queue: string;
63
+ callback_payload?: unknown;
64
+ };
65
+ export type BatchResult = {
66
+ job_ids: string[];
67
+ batch_id: string;
68
+ };
69
+ export type FetchedJob = {
70
+ job_id: string;
71
+ queue: string;
72
+ payload: unknown;
73
+ attempt: number;
74
+ };
75
+ export type HeartbeatResult = {
76
+ acked: string[];
77
+ unknown: string[];
78
+ canceled: string[];
79
+ };
80
+ export type ChainStep = {
81
+ queue: string;
82
+ payload: unknown;
83
+ };
84
+ export type ChainConfig = {
85
+ steps: ChainStep[];
86
+ on_failure?: "stop" | "continue";
87
+ on_exit?: ChainStep;
88
+ };
89
+ export type EnqueueOptions = {
90
+ queue: string;
91
+ payload: unknown;
92
+ priority?: string;
93
+ unique_key?: string;
94
+ unique_period?: number;
95
+ max_retries?: number;
96
+ scheduled_at?: string;
97
+ tags?: Record<string, string>;
98
+ expire_after?: string;
99
+ retry_backoff?: string;
100
+ retry_base_delay?: string;
101
+ retry_max_delay?: string;
102
+ chain?: ChainConfig;
103
+ };
104
+ export type AuthOptions = {
105
+ headers?: Record<string, string>;
106
+ bearerToken?: string;
107
+ apiKey?: string;
108
+ apiKeyHeader?: string;
109
+ tokenProvider?: () => Promise<string> | string;
110
+ };
111
+ export type ClientOptions = {
112
+ useRpc?: boolean;
113
+ };
114
+ export declare class PayloadTooLargeError extends Error {
115
+ constructor(message: string);
116
+ }
117
+ export declare function isPayloadTooLargeError(err: unknown): err is PayloadTooLargeError;
118
+ export declare class CorvoClient {
119
+ readonly baseURL: string;
120
+ readonly fetchImpl: typeof fetch;
121
+ readonly auth: AuthOptions;
122
+ private readonly useRpc;
123
+ private rpcClient;
124
+ constructor(baseURL: string, fetchImpl?: typeof fetch, auth?: AuthOptions, opts?: ClientOptions);
125
+ private getRpc;
126
+ enqueue(queue: string, payload: unknown, extra?: Record<string, unknown>): Promise<EnqueueResult>;
127
+ enqueueWith(opts: EnqueueOptions): Promise<EnqueueResult>;
128
+ getJob<T = Record<string, unknown>>(id: string): Promise<T>;
129
+ search<T = Record<string, unknown>>(filter: SearchFilter): Promise<SearchResult<T>>;
130
+ bulk(req: BulkRequest): Promise<BulkResult | BulkAsyncStart>;
131
+ bulkStatus(id: string): Promise<BulkTask>;
132
+ fetchBatch(queues: string[], workerID: string, hostname?: string, timeout?: number, count?: number): Promise<{
133
+ jobs: FetchedJob[];
134
+ }>;
135
+ ackBatch(acks: {
136
+ job_id: string;
137
+ result?: Record<string, unknown>;
138
+ }[]): Promise<{
139
+ acked: number;
140
+ }>;
141
+ enqueueBatch(jobs: BatchJob[], batch?: BatchConfig): Promise<BatchResult>;
142
+ fetch(queues: string[], workerID: string, hostname?: string, timeout?: number): Promise<FetchedJob | null>;
143
+ ack(jobID: string, body?: Record<string, unknown>): Promise<{
144
+ status: string;
145
+ }>;
146
+ fail(jobID: string, error: string, backtrace?: string): Promise<{
147
+ status: string;
148
+ }>;
149
+ heartbeat(jobs: Record<string, Record<string, unknown>>): Promise<HeartbeatResult>;
150
+ retryJob(id: string): Promise<void>;
151
+ cancelJob(id: string): Promise<void>;
152
+ moveJob(id: string, targetQueue: string): Promise<void>;
153
+ deleteJob(id: string): Promise<void>;
154
+ private request;
155
+ authHeaders(): Promise<Record<string, string>>;
156
+ }
package/dist/index.js ADDED
@@ -0,0 +1,178 @@
1
+ export class PayloadTooLargeError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = "PayloadTooLargeError";
5
+ }
6
+ }
7
+ export function isPayloadTooLargeError(err) {
8
+ return err instanceof PayloadTooLargeError;
9
+ }
10
+ export class CorvoClient {
11
+ constructor(baseURL, fetchImpl = fetch, auth = {}, opts = {}) {
12
+ this.rpcClient = null;
13
+ this.baseURL = baseURL.replace(/\/$/, "");
14
+ this.fetchImpl = fetchImpl;
15
+ this.auth = auth;
16
+ this.useRpc = opts.useRpc ?? false;
17
+ }
18
+ async getRpc() {
19
+ if (!this.rpcClient) {
20
+ const { ClientRpc } = await import("./rpc.js");
21
+ this.rpcClient = new ClientRpc(this.baseURL, this.auth);
22
+ }
23
+ return this.rpcClient;
24
+ }
25
+ async enqueue(queue, payload, extra = {}) {
26
+ if (this.useRpc && Object.keys(extra).length === 0) {
27
+ const rpc = await this.getRpc();
28
+ return rpc.enqueue(queue, payload);
29
+ }
30
+ return this.request("/api/v1/enqueue", {
31
+ method: "POST",
32
+ body: JSON.stringify({ queue, payload, ...extra }),
33
+ });
34
+ }
35
+ async enqueueWith(opts) {
36
+ return this.request("/api/v1/enqueue", {
37
+ method: "POST",
38
+ body: JSON.stringify(opts),
39
+ });
40
+ }
41
+ async getJob(id) {
42
+ return this.request(`/api/v1/jobs/${encodeURIComponent(id)}`, { method: "GET" });
43
+ }
44
+ async search(filter) {
45
+ return this.request("/api/v1/jobs/search", {
46
+ method: "POST",
47
+ body: JSON.stringify(filter),
48
+ });
49
+ }
50
+ async bulk(req) {
51
+ return this.request("/api/v1/jobs/bulk", {
52
+ method: "POST",
53
+ body: JSON.stringify(req),
54
+ });
55
+ }
56
+ async bulkStatus(id) {
57
+ return this.request(`/api/v1/bulk/${encodeURIComponent(id)}`, { method: "GET" });
58
+ }
59
+ async fetchBatch(queues, workerID, hostname = "corvo-worker", timeout = 30, count = 10) {
60
+ return this.request("/api/v1/fetch/batch", {
61
+ method: "POST",
62
+ body: JSON.stringify({ queues, worker_id: workerID, hostname, timeout, count }),
63
+ });
64
+ }
65
+ async ackBatch(acks) {
66
+ return this.request("/api/v1/ack/batch", {
67
+ method: "POST",
68
+ body: JSON.stringify({ acks }),
69
+ });
70
+ }
71
+ async enqueueBatch(jobs, batch) {
72
+ return this.request("/api/v1/enqueue/batch", {
73
+ method: "POST",
74
+ body: JSON.stringify({ jobs, batch }),
75
+ });
76
+ }
77
+ async fetch(queues, workerID, hostname = "corvo-worker", timeout = 30) {
78
+ const result = await this.request("/api/v1/fetch", {
79
+ method: "POST",
80
+ body: JSON.stringify({ queues, worker_id: workerID, hostname, timeout }),
81
+ });
82
+ if (!result || !result.job_id)
83
+ return null;
84
+ return result;
85
+ }
86
+ async ack(jobID, body = {}) {
87
+ return this.request(`/api/v1/ack/${encodeURIComponent(jobID)}`, {
88
+ method: "POST",
89
+ body: JSON.stringify(body),
90
+ });
91
+ }
92
+ async fail(jobID, error, backtrace) {
93
+ if (this.useRpc) {
94
+ const rpc = await this.getRpc();
95
+ return rpc.fail(jobID, error, backtrace ?? "");
96
+ }
97
+ return this.request(`/api/v1/fail/${encodeURIComponent(jobID)}`, {
98
+ method: "POST",
99
+ body: JSON.stringify({ error, backtrace }),
100
+ });
101
+ }
102
+ async heartbeat(jobs) {
103
+ if (this.useRpc) {
104
+ const rpc = await this.getRpc();
105
+ // HeartbeatResult shape from HTTP differs from proto; adapt here
106
+ const resp = await rpc.heartbeat(jobs);
107
+ return resp;
108
+ }
109
+ return this.request("/api/v1/heartbeat", {
110
+ method: "POST",
111
+ body: JSON.stringify({ jobs }),
112
+ });
113
+ }
114
+ async retryJob(id) {
115
+ await this.request(`/api/v1/jobs/${encodeURIComponent(id)}/retry`, { method: "POST" });
116
+ }
117
+ async cancelJob(id) {
118
+ await this.request(`/api/v1/jobs/${encodeURIComponent(id)}/cancel`, { method: "POST" });
119
+ }
120
+ async moveJob(id, targetQueue) {
121
+ await this.request(`/api/v1/jobs/${encodeURIComponent(id)}/move`, {
122
+ method: "POST",
123
+ body: JSON.stringify({ queue: targetQueue }),
124
+ });
125
+ }
126
+ async deleteJob(id) {
127
+ await this.request(`/api/v1/jobs/${encodeURIComponent(id)}`, { method: "DELETE" });
128
+ }
129
+ async request(path, init) {
130
+ const authHeaders = await this.authHeaders();
131
+ const res = await this.fetchImpl(this.baseURL + path, {
132
+ ...init,
133
+ headers: {
134
+ "content-type": "application/json",
135
+ ...authHeaders,
136
+ ...(init.headers || {}),
137
+ },
138
+ });
139
+ if (!res.ok) {
140
+ let details = `HTTP ${res.status}`;
141
+ let code = "";
142
+ try {
143
+ const body = (await res.json());
144
+ if (body.error)
145
+ details = body.error;
146
+ if (body.code)
147
+ code = body.code;
148
+ }
149
+ catch {
150
+ // ignore decode errors for non-JSON responses
151
+ }
152
+ if (code === "PAYLOAD_TOO_LARGE")
153
+ throw new PayloadTooLargeError(details);
154
+ throw new Error(details);
155
+ }
156
+ if (res.status === 204) {
157
+ return {};
158
+ }
159
+ return (await res.json());
160
+ }
161
+ async authHeaders() {
162
+ const out = {};
163
+ if (this.auth.headers) {
164
+ Object.assign(out, this.auth.headers);
165
+ }
166
+ if (this.auth.apiKey) {
167
+ out[this.auth.apiKeyHeader || "X-API-Key"] = this.auth.apiKey;
168
+ }
169
+ let token = this.auth.bearerToken || "";
170
+ if (this.auth.tokenProvider) {
171
+ token = await this.auth.tokenProvider();
172
+ }
173
+ if (token) {
174
+ out.Authorization = `Bearer ${token}`;
175
+ }
176
+ return out;
177
+ }
178
+ }
package/dist/rpc.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { AuthOptions } from "./index.js";
2
+ export declare class ClientRpc {
3
+ private readonly client;
4
+ constructor(baseUrl: string, auth?: AuthOptions);
5
+ enqueue(queue: string, payload: unknown): Promise<{
6
+ job_id: string;
7
+ status: string;
8
+ unique_existing?: boolean;
9
+ }>;
10
+ fail(jobId: string, error: string, backtrace?: string): Promise<{
11
+ status: string;
12
+ }>;
13
+ heartbeat(jobs: Record<string, Record<string, unknown>>): Promise<{
14
+ jobs: Record<string, {
15
+ status: string;
16
+ }>;
17
+ }>;
18
+ }
package/dist/rpc.js ADDED
@@ -0,0 +1,71 @@
1
+ import { createClient } from "@connectrpc/connect";
2
+ import { createConnectTransport } from "@connectrpc/connect-node";
3
+ import { create } from "@bufbuild/protobuf";
4
+ import { WorkerService, HeartbeatJobUpdateSchema, } from "./gen/corvo/v1/worker_pb.js";
5
+ // ---------------------------------------------------------------------------
6
+ // Auth interceptor
7
+ // ---------------------------------------------------------------------------
8
+ const SDK_NAME = "corvo-typescript";
9
+ const SDK_VERSION = "0.2.0";
10
+ function authInterceptor(auth) {
11
+ return (next) => async (req) => {
12
+ req.header.set("x-corvo-client-name", SDK_NAME);
13
+ req.header.set("x-corvo-client-version", SDK_VERSION);
14
+ if (auth.headers) {
15
+ for (const [k, v] of Object.entries(auth.headers)) {
16
+ req.header.set(k, v);
17
+ }
18
+ }
19
+ if (auth.apiKey) {
20
+ req.header.set(auth.apiKeyHeader || "X-API-Key", auth.apiKey);
21
+ }
22
+ let token = auth.bearerToken || "";
23
+ if (auth.tokenProvider) {
24
+ token = await auth.tokenProvider();
25
+ }
26
+ if (token) {
27
+ req.header.set("authorization", `Bearer ${token}`);
28
+ }
29
+ return next(req);
30
+ };
31
+ }
32
+ export class ClientRpc {
33
+ constructor(baseUrl, auth = {}) {
34
+ const transport = createConnectTransport({
35
+ baseUrl: baseUrl.replace(/\/$/, ""),
36
+ httpVersion: "1.1",
37
+ useBinaryFormat: false,
38
+ interceptors: [authInterceptor(auth)],
39
+ });
40
+ this.client = createClient(WorkerService, transport);
41
+ }
42
+ async enqueue(queue, payload) {
43
+ const payloadJson = JSON.stringify(payload ?? {});
44
+ const resp = await this.client.enqueue({ queue, payloadJson });
45
+ return {
46
+ job_id: resp.jobId,
47
+ status: resp.status,
48
+ unique_existing: resp.uniqueExisting || undefined,
49
+ };
50
+ }
51
+ async fail(jobId, error, backtrace = "") {
52
+ const resp = await this.client.fail({ jobId, error, backtrace });
53
+ return { status: resp.status };
54
+ }
55
+ async heartbeat(jobs) {
56
+ const protoJobs = {};
57
+ for (const [id, update] of Object.entries(jobs)) {
58
+ protoJobs[id] = create(HeartbeatJobUpdateSchema, {
59
+ progressJson: update.progress ? JSON.stringify(update.progress) : "",
60
+ checkpointJson: update.checkpoint ? JSON.stringify(update.checkpoint) : "",
61
+ streamDelta: "",
62
+ });
63
+ }
64
+ const resp = await this.client.heartbeat({ jobs: protoJobs });
65
+ const out = {};
66
+ for (const [id, jr] of Object.entries(resp.jobs)) {
67
+ out[id] = { status: jr.status };
68
+ }
69
+ return { jobs: out };
70
+ }
71
+ }
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@corvohq/client",
3
+ "version": "0.2.0",
4
+ "description": "TypeScript client for Corvo",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": ["dist"],
10
+ "scripts": {
11
+ "build": "tsc -p tsconfig.json"
12
+ },
13
+ "dependencies": {
14
+ "@connectrpc/connect": "^2.1.1",
15
+ "@connectrpc/connect-node": "^2.1.1",
16
+ "@bufbuild/protobuf": "^2.11.0"
17
+ },
18
+ "devDependencies": {
19
+ "typescript": "^5.6.3"
20
+ }
21
+ }