@okrlinkhub/agent-factory 3.0.1 → 3.0.3
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/README.md +185 -31
- package/dist/client/index.d.ts +11 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +16 -0
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +2 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +60 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/flyCleanup.d.ts +32 -0
- package/dist/component/flyCleanup.d.ts.map +1 -0
- package/dist/component/flyCleanup.js +272 -0
- package/dist/component/flyCleanup.js.map +1 -0
- package/dist/component/lib.d.ts +1 -0
- package/dist/component/lib.d.ts.map +1 -1
- package/dist/component/lib.js +1 -0
- package/dist/component/lib.js.map +1 -1
- package/dist/component/providers/fly.d.ts +23 -2
- package/dist/component/providers/fly.d.ts.map +1 -1
- package/dist/component/providers/fly.js +15 -3
- package/dist/component/providers/fly.js.map +1 -1
- package/dist/component/pushing.d.ts +4 -4
- package/dist/component/queue.d.ts +32 -16
- package/dist/component/queue.d.ts.map +1 -1
- package/dist/component/queue.js +44 -2
- package/dist/component/queue.js.map +1 -1
- package/dist/component/scheduler.d.ts +8 -8
- package/dist/component/scheduler.d.ts.map +1 -1
- package/dist/component/scheduler.js +59 -12
- package/dist/component/scheduler.js.map +1 -1
- package/dist/component/schema.d.ts +30 -28
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +1 -0
- package/dist/component/schema.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +16 -0
- package/src/component/_generated/api.ts +2 -0
- package/src/component/_generated/component.ts +72 -0
- package/src/component/flyCleanup.ts +386 -0
- package/src/component/lib.test.ts +280 -4
- package/src/component/lib.ts +1 -0
- package/src/component/providers/fly.ts +39 -5
- package/src/component/queue.ts +55 -2
- package/src/component/scheduler.ts +100 -16
- package/src/component/schema.ts +1 -0
|
@@ -11,7 +11,6 @@ type PreparedTelegramAttachment = {
|
|
|
11
11
|
downloadUrl?: string;
|
|
12
12
|
};
|
|
13
13
|
export declare const enqueueMessage: import("convex/server").RegisteredMutation<"public", {
|
|
14
|
-
nowMs?: number | undefined;
|
|
15
14
|
providerConfig?: {
|
|
16
15
|
appName: string;
|
|
17
16
|
kind: "fly" | "runpod" | "ecs";
|
|
@@ -22,6 +21,7 @@ export declare const enqueueMessage: import("convex/server").RegisteredMutation<
|
|
|
22
21
|
volumePath: string;
|
|
23
22
|
volumeSizeGb: number;
|
|
24
23
|
} | undefined;
|
|
24
|
+
nowMs?: number | undefined;
|
|
25
25
|
maxAttempts?: number | undefined;
|
|
26
26
|
priority?: number | undefined;
|
|
27
27
|
scheduledFor?: number | undefined;
|
|
@@ -34,8 +34,8 @@ export declare const enqueueMessage: import("convex/server").RegisteredMutation<
|
|
|
34
34
|
fileName?: string | undefined;
|
|
35
35
|
mimeType?: string | undefined;
|
|
36
36
|
downloadUrl?: string | undefined;
|
|
37
|
-
status: "expired" | "ready";
|
|
38
37
|
storageId: import("convex/values").GenericId<"_storage">;
|
|
38
|
+
status: "expired" | "ready";
|
|
39
39
|
kind: "photo" | "video" | "audio" | "voice" | "document";
|
|
40
40
|
telegramFileId: string;
|
|
41
41
|
expiresAt: number;
|
|
@@ -98,6 +98,13 @@ export declare const getWorkerSpawnOpenClawEnv: import("convex/server").Register
|
|
|
98
98
|
OPENCLAW_SERVICE_KEY?: string;
|
|
99
99
|
OPENCLAW_LINKING_SHARED_SECRET?: string;
|
|
100
100
|
}>>;
|
|
101
|
+
export declare const getActiveConversationsForScheduler: import("convex/server").RegisteredQuery<"internal", {
|
|
102
|
+
nowMs?: number | undefined;
|
|
103
|
+
limit?: number | undefined;
|
|
104
|
+
}, Promise<{
|
|
105
|
+
conversationId: string;
|
|
106
|
+
agentKey: string;
|
|
107
|
+
}[]>>;
|
|
101
108
|
export declare const getProviderRuntimeConfig: import("convex/server").RegisteredQuery<"internal", {}, Promise<{
|
|
102
109
|
appName: string;
|
|
103
110
|
kind: "fly" | "runpod" | "ecs";
|
|
@@ -207,9 +214,9 @@ export declare const deployGlobalSkill: import("convex/server").RegisteredMutati
|
|
|
207
214
|
releaseChannel: "stable" | "canary";
|
|
208
215
|
}>>;
|
|
209
216
|
export declare const listGlobalSkills: import("convex/server").RegisteredQuery<"public", {
|
|
210
|
-
status?: "active" | "disabled" | undefined;
|
|
211
217
|
limit?: number | undefined;
|
|
212
218
|
releaseChannel?: "stable" | "canary" | undefined;
|
|
219
|
+
status?: "active" | "disabled" | undefined;
|
|
213
220
|
}, Promise<{
|
|
214
221
|
skillId: any;
|
|
215
222
|
slug: string;
|
|
@@ -255,8 +262,8 @@ export declare const getWorkerGlobalSkillsManifest: import("convex/server").Regi
|
|
|
255
262
|
export declare const setGlobalSkillStatus: import("convex/server").RegisteredMutation<"public", {
|
|
256
263
|
nowMs?: number | undefined;
|
|
257
264
|
actor?: string | undefined;
|
|
258
|
-
status: "active" | "disabled";
|
|
259
265
|
slug: string;
|
|
266
|
+
status: "active" | "disabled";
|
|
260
267
|
}, Promise<{
|
|
261
268
|
updated: boolean;
|
|
262
269
|
slug: string;
|
|
@@ -297,8 +304,8 @@ export declare const claimNextJob: import("convex/server").RegisteredMutation<"p
|
|
|
297
304
|
fileName?: string | undefined;
|
|
298
305
|
mimeType?: string | undefined;
|
|
299
306
|
downloadUrl?: string | undefined;
|
|
300
|
-
status: "expired" | "ready";
|
|
301
307
|
storageId: import("convex/values").GenericId<"_storage">;
|
|
308
|
+
status: "expired" | "ready";
|
|
302
309
|
kind: "photo" | "video" | "audio" | "voice" | "document";
|
|
303
310
|
telegramFileId: string;
|
|
304
311
|
expiresAt: number;
|
|
@@ -317,7 +324,6 @@ export declare const heartbeatJob: import("convex/server").RegisteredMutation<"p
|
|
|
317
324
|
leaseId: string;
|
|
318
325
|
}, Promise<boolean>>;
|
|
319
326
|
export declare const completeJob: import("convex/server").RegisteredMutation<"public", {
|
|
320
|
-
nowMs?: number | undefined;
|
|
321
327
|
providerConfig?: {
|
|
322
328
|
appName: string;
|
|
323
329
|
kind: "fly" | "runpod" | "ecs";
|
|
@@ -328,12 +334,12 @@ export declare const completeJob: import("convex/server").RegisteredMutation<"pu
|
|
|
328
334
|
volumePath: string;
|
|
329
335
|
volumeSizeGb: number;
|
|
330
336
|
} | undefined;
|
|
337
|
+
nowMs?: number | undefined;
|
|
331
338
|
messageId: import("convex/values").GenericId<"messageQueue">;
|
|
332
339
|
workerId: string;
|
|
333
340
|
leaseId: string;
|
|
334
341
|
}, Promise<boolean>>;
|
|
335
342
|
export declare const failJob: import("convex/server").RegisteredMutation<"public", {
|
|
336
|
-
nowMs?: number | undefined;
|
|
337
343
|
providerConfig?: {
|
|
338
344
|
appName: string;
|
|
339
345
|
kind: "fly" | "runpod" | "ecs";
|
|
@@ -344,6 +350,7 @@ export declare const failJob: import("convex/server").RegisteredMutation<"public
|
|
|
344
350
|
volumePath: string;
|
|
345
351
|
volumeSizeGb: number;
|
|
346
352
|
} | undefined;
|
|
353
|
+
nowMs?: number | undefined;
|
|
347
354
|
messageId: import("convex/values").GenericId<"messageQueue">;
|
|
348
355
|
workerId: string;
|
|
349
356
|
leaseId: string;
|
|
@@ -446,8 +453,8 @@ export declare const listQueueItemsForConversation: import("convex/server").Regi
|
|
|
446
453
|
fileName?: string | undefined;
|
|
447
454
|
mimeType?: string | undefined;
|
|
448
455
|
downloadUrl?: string | undefined;
|
|
449
|
-
status: "expired" | "ready";
|
|
450
456
|
storageId: import("convex/values").GenericId<"_storage">;
|
|
457
|
+
status: "expired" | "ready";
|
|
451
458
|
kind: "photo" | "video" | "audio" | "voice" | "document";
|
|
452
459
|
telegramFileId: string;
|
|
453
460
|
expiresAt: number;
|
|
@@ -482,8 +489,8 @@ export declare const listQueueItemsForUserAgent: import("convex/server").Registe
|
|
|
482
489
|
fileName?: string | undefined;
|
|
483
490
|
mimeType?: string | undefined;
|
|
484
491
|
downloadUrl?: string | undefined;
|
|
485
|
-
status: "expired" | "ready";
|
|
486
492
|
storageId: import("convex/values").GenericId<"_storage">;
|
|
493
|
+
status: "expired" | "ready";
|
|
487
494
|
kind: "photo" | "video" | "audio" | "voice" | "document";
|
|
488
495
|
telegramFileId: string;
|
|
489
496
|
expiresAt: number;
|
|
@@ -529,8 +536,8 @@ export declare const getConversationViewForUserAgent: import("convex/server").Re
|
|
|
529
536
|
fileName?: string | undefined;
|
|
530
537
|
mimeType?: string | undefined;
|
|
531
538
|
downloadUrl?: string | undefined;
|
|
532
|
-
status: "expired" | "ready";
|
|
533
539
|
storageId: import("convex/values").GenericId<"_storage">;
|
|
540
|
+
status: "expired" | "ready";
|
|
534
541
|
kind: "photo" | "video" | "audio" | "voice" | "document";
|
|
535
542
|
telegramFileId: string;
|
|
536
543
|
expiresAt: number;
|
|
@@ -548,8 +555,6 @@ export declare const getConversationViewForUserAgent: import("convex/server").Re
|
|
|
548
555
|
lastAssistantMessageAt: number | null;
|
|
549
556
|
}>>;
|
|
550
557
|
export declare const sendMessageToUserAgent: import("convex/server").RegisteredMutation<"public", {
|
|
551
|
-
metadata?: Record<string, string> | undefined;
|
|
552
|
-
nowMs?: number | undefined;
|
|
553
558
|
providerConfig?: {
|
|
554
559
|
appName: string;
|
|
555
560
|
kind: "fly" | "runpod" | "ecs";
|
|
@@ -560,13 +565,13 @@ export declare const sendMessageToUserAgent: import("convex/server").RegisteredM
|
|
|
560
565
|
volumePath: string;
|
|
561
566
|
volumeSizeGb: number;
|
|
562
567
|
} | undefined;
|
|
568
|
+
metadata?: Record<string, string> | undefined;
|
|
569
|
+
nowMs?: number | undefined;
|
|
563
570
|
agentKey: string;
|
|
564
571
|
consumerUserId: string;
|
|
565
572
|
content: string;
|
|
566
573
|
}, Promise<import("convex/values").GenericId<"messageQueue">>>;
|
|
567
574
|
export declare const sendMessageTemplateToUserAgent: import("convex/server").RegisteredMutation<"public", {
|
|
568
|
-
metadata?: Record<string, string> | undefined;
|
|
569
|
-
nowMs?: number | undefined;
|
|
570
575
|
providerConfig?: {
|
|
571
576
|
appName: string;
|
|
572
577
|
kind: "fly" | "runpod" | "ecs";
|
|
@@ -577,6 +582,8 @@ export declare const sendMessageTemplateToUserAgent: import("convex/server").Reg
|
|
|
577
582
|
volumePath: string;
|
|
578
583
|
volumeSizeGb: number;
|
|
579
584
|
} | undefined;
|
|
585
|
+
metadata?: Record<string, string> | undefined;
|
|
586
|
+
nowMs?: number | undefined;
|
|
580
587
|
agentKey: string;
|
|
581
588
|
consumerUserId: string;
|
|
582
589
|
templateId: import("convex/values").GenericId<"messageTemplates">;
|
|
@@ -654,14 +661,22 @@ export declare const listJobsByStatus: import("convex/server").RegisteredQuery<"
|
|
|
654
661
|
export declare const upsertWorkerState: import("convex/server").RegisteredMutation<"internal", {
|
|
655
662
|
nowMs?: number | undefined;
|
|
656
663
|
appName?: string | undefined;
|
|
664
|
+
volumeId?: string | undefined;
|
|
657
665
|
region?: string | undefined;
|
|
658
666
|
machineId?: string | undefined;
|
|
659
667
|
scheduledShutdownAt?: number | undefined;
|
|
660
668
|
stoppedAt?: number | undefined;
|
|
669
|
+
assignment?: {
|
|
670
|
+
agentKey: string;
|
|
671
|
+
conversationId: string;
|
|
672
|
+
leaseId: string;
|
|
673
|
+
assignedAt: number;
|
|
674
|
+
} | null | undefined;
|
|
661
675
|
clearLastSnapshotId?: boolean | undefined;
|
|
662
676
|
clearMachineRef?: boolean | undefined;
|
|
663
|
-
|
|
677
|
+
clearVolumeId?: boolean | undefined;
|
|
664
678
|
workerId: string;
|
|
679
|
+
status: "active" | "draining" | "stopping" | "stopped";
|
|
665
680
|
provider: string;
|
|
666
681
|
load: number;
|
|
667
682
|
}, Promise<null>>;
|
|
@@ -692,8 +707,8 @@ export declare const finalizeDataSnapshotUpload: import("convex/server").Registe
|
|
|
692
707
|
}, Promise<boolean>>;
|
|
693
708
|
export declare const failDataSnapshotUpload: import("convex/server").RegisteredMutation<"public", {
|
|
694
709
|
nowMs?: number | undefined;
|
|
695
|
-
error: string;
|
|
696
710
|
workerId: string;
|
|
711
|
+
error: string;
|
|
697
712
|
snapshotId: import("convex/values").GenericId<"dataSnapshots">;
|
|
698
713
|
}, Promise<boolean>>;
|
|
699
714
|
export declare const getLatestDataSnapshotForRestore: import("convex/server").RegisteredQuery<"public", {
|
|
@@ -726,6 +741,7 @@ export declare const listWorkersForScheduler: import("convex/server").Registered
|
|
|
726
741
|
machineId: string | null;
|
|
727
742
|
appName: string | null;
|
|
728
743
|
region: string | null;
|
|
744
|
+
volumeId: string | null;
|
|
729
745
|
}[]>>;
|
|
730
746
|
export declare const expireOldDataSnapshots: import("convex/server").RegisteredMutation<"internal", {
|
|
731
747
|
nowMs?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/component/queue.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/component/queue.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AA0OpD,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IACzD,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;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CAAsC;;;mBA+BjD,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;qBAyB/C,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;KAsC3B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;iBAmF5B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;GA6ChC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;GA+BpC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;oBAmCrC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;oBAmBjC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;UA+C1C,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;KAqClC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;mBAoBjC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;mBAyCvC,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;GAsCzB,CAAC"}
|
package/dist/component/queue.js
CHANGED
|
@@ -121,6 +121,10 @@ const workerSpawnOpenClawEnvValidator = v.object({
|
|
|
121
121
|
OPENCLAW_SERVICE_KEY: v.optional(v.string()),
|
|
122
122
|
OPENCLAW_LINKING_SHARED_SECRET: v.optional(v.string()),
|
|
123
123
|
});
|
|
124
|
+
const schedulerConversationTargetValidator = v.object({
|
|
125
|
+
conversationId: v.string(),
|
|
126
|
+
agentKey: v.string(),
|
|
127
|
+
});
|
|
124
128
|
const messageRuntimeConfigValidator = v.object({
|
|
125
129
|
systemPrompt: v.optional(v.string()),
|
|
126
130
|
telegramAttachmentRetentionMs: v.optional(v.number()),
|
|
@@ -361,6 +365,37 @@ export const getWorkerSpawnOpenClawEnv = internalQuery({
|
|
|
361
365
|
return env;
|
|
362
366
|
},
|
|
363
367
|
});
|
|
368
|
+
export const getActiveConversationsForScheduler = internalQuery({
|
|
369
|
+
args: {
|
|
370
|
+
nowMs: v.optional(v.number()),
|
|
371
|
+
limit: v.optional(v.number()),
|
|
372
|
+
},
|
|
373
|
+
returns: v.array(schedulerConversationTargetValidator),
|
|
374
|
+
handler: async (ctx, args) => {
|
|
375
|
+
const nowMs = args.nowMs ?? Date.now();
|
|
376
|
+
const limit = Math.max(1, args.limit ?? 1000);
|
|
377
|
+
const queuedJobs = await ctx.db
|
|
378
|
+
.query("messageQueue")
|
|
379
|
+
.withIndex("by_status_and_scheduledFor", (q) => q.eq("status", "queued").lte("scheduledFor", nowMs))
|
|
380
|
+
.take(limit);
|
|
381
|
+
const processingJobs = await ctx.db
|
|
382
|
+
.query("messageQueue")
|
|
383
|
+
.withIndex("by_status_and_leaseExpiresAt", (q) => q.eq("status", "processing").gt("leaseExpiresAt", nowMs))
|
|
384
|
+
.take(limit);
|
|
385
|
+
const conversations = new Map();
|
|
386
|
+
for (const job of [...queuedJobs, ...processingJobs]) {
|
|
387
|
+
const key = `${job.agentKey}::${job.conversationId}`;
|
|
388
|
+
if (!conversations.has(key)) {
|
|
389
|
+
conversations.set(key, {
|
|
390
|
+
conversationId: job.conversationId,
|
|
391
|
+
agentKey: job.agentKey,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return Array.from(conversations.values()).sort((left, right) => left.agentKey.localeCompare(right.agentKey) ||
|
|
396
|
+
left.conversationId.localeCompare(right.conversationId));
|
|
397
|
+
},
|
|
398
|
+
});
|
|
364
399
|
export const getProviderRuntimeConfig = internalQuery({
|
|
365
400
|
args: {},
|
|
366
401
|
returns: v.union(v.null(), providerConfigValidator),
|
|
@@ -1867,8 +1902,11 @@ export const upsertWorkerState = internalMutation({
|
|
|
1867
1902
|
machineId: v.optional(v.string()),
|
|
1868
1903
|
appName: v.optional(v.string()),
|
|
1869
1904
|
region: v.optional(v.string()),
|
|
1905
|
+
volumeId: v.optional(v.string()),
|
|
1906
|
+
assignment: v.optional(v.union(v.null(), workerAssignmentValidator)),
|
|
1870
1907
|
clearLastSnapshotId: v.optional(v.boolean()),
|
|
1871
1908
|
clearMachineRef: v.optional(v.boolean()),
|
|
1909
|
+
clearVolumeId: v.optional(v.boolean()),
|
|
1872
1910
|
},
|
|
1873
1911
|
returns: v.null(),
|
|
1874
1912
|
handler: async (ctx, args) => {
|
|
@@ -1888,7 +1926,8 @@ export const upsertWorkerState = internalMutation({
|
|
|
1888
1926
|
stoppedAt: args.status === "stopped" || args.status === "stopping"
|
|
1889
1927
|
? (args.stoppedAt ?? nowMs)
|
|
1890
1928
|
: undefined,
|
|
1891
|
-
|
|
1929
|
+
volumeId: args.volumeId,
|
|
1930
|
+
assignment: args.assignment ?? undefined,
|
|
1892
1931
|
machineRef: args.machineId && args.appName
|
|
1893
1932
|
? {
|
|
1894
1933
|
appName: args.appName,
|
|
@@ -1912,7 +1951,8 @@ export const upsertWorkerState = internalMutation({
|
|
|
1912
1951
|
? (args.stoppedAt ?? worker.stoppedAt ?? nowMs)
|
|
1913
1952
|
: undefined,
|
|
1914
1953
|
lastSnapshotId: args.clearLastSnapshotId ? undefined : worker.lastSnapshotId,
|
|
1915
|
-
|
|
1954
|
+
volumeId: args.clearVolumeId ? undefined : (args.volumeId ?? worker.volumeId),
|
|
1955
|
+
assignment: args.assignment === undefined ? worker.assignment : (args.assignment ?? undefined),
|
|
1916
1956
|
machineRef: args.clearMachineRef
|
|
1917
1957
|
? undefined
|
|
1918
1958
|
: args.machineId && args.appName
|
|
@@ -2115,6 +2155,7 @@ export const listWorkersForScheduler = internalQuery({
|
|
|
2115
2155
|
machineId: v.union(v.null(), v.string()),
|
|
2116
2156
|
appName: v.union(v.null(), v.string()),
|
|
2117
2157
|
region: v.union(v.null(), v.string()),
|
|
2158
|
+
volumeId: v.union(v.null(), v.string()),
|
|
2118
2159
|
})),
|
|
2119
2160
|
handler: async (ctx) => {
|
|
2120
2161
|
const rows = await ctx.db.query("workers").collect();
|
|
@@ -2131,6 +2172,7 @@ export const listWorkersForScheduler = internalQuery({
|
|
|
2131
2172
|
machineId: worker.machineRef?.machineId ?? null,
|
|
2132
2173
|
appName: worker.machineRef?.appName ?? null,
|
|
2133
2174
|
region: worker.machineRef?.region ?? null,
|
|
2175
|
+
volumeId: worker.volumeId ?? null,
|
|
2134
2176
|
}));
|
|
2135
2177
|
},
|
|
2136
2178
|
});
|