@okrlinkhub/agent-factory 0.2.1 → 0.2.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.
@@ -99,7 +99,7 @@ async function runReconcileWorkerPool(
99
99
  ) {
100
100
  const nowMs = args.nowMs ?? Date.now();
101
101
  const scaling = args.scalingPolicy ?? DEFAULT_CONFIG.scaling;
102
- const providerConfig = args.providerConfig ?? DEFAULT_CONFIG.provider;
102
+ const providerConfig = ensureProviderConfig(args.providerConfig ?? DEFAULT_CONFIG.provider);
103
103
  const flyApiToken =
104
104
  args.flyApiToken ??
105
105
  (await ctx.runQuery(internal.queue.getActiveSecretPlaintext, {
@@ -304,7 +304,7 @@ async function runEnforceIdleShutdowns(
304
304
  },
305
305
  ) {
306
306
  const nowMs = args.nowMs ?? Date.now();
307
- const providerConfig = args.providerConfig ?? DEFAULT_CONFIG.provider;
307
+ const providerConfig = ensureProviderConfig(args.providerConfig ?? DEFAULT_CONFIG.provider);
308
308
  const flyApiToken =
309
309
  args.flyApiToken ??
310
310
  (await ctx.runQuery(internal.queue.getActiveSecretPlaintext, {
@@ -431,6 +431,27 @@ function resolveProvider(kind: string, flyApiToken: string): WorkerProvider {
431
431
  }
432
432
  }
433
433
 
434
+ function ensureProviderConfig(providerConfig: typeof DEFAULT_CONFIG.provider) {
435
+ const requiredFields: Array<
436
+ "appName" | "organizationSlug" | "image" | "region" | "volumeName" | "volumePath"
437
+ > = [
438
+ "appName",
439
+ "organizationSlug",
440
+ "image",
441
+ "region",
442
+ "volumeName",
443
+ "volumePath",
444
+ ];
445
+ for (const field of requiredFields) {
446
+ if (!providerConfig[field]?.trim()) {
447
+ throw new Error(
448
+ `Missing providerConfig.${field}. Pass providerConfig explicitly when starting/reconciling workers.`,
449
+ );
450
+ }
451
+ }
452
+ return providerConfig;
453
+ }
454
+
434
455
  function clamp(value: number, min: number, max: number): number {
435
456
  return Math.max(min, Math.min(max, value));
436
457
  }