@agentproto/catalog-sync 0.6.0 → 0.6.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/dist/bin.mjs CHANGED
@@ -1015,8 +1015,28 @@ var voiceMinimax = defineGenerator({
1015
1015
  };
1016
1016
  }
1017
1017
  });
1018
-
1019
- // src/generators/image-replicate.ts
1018
+ var ReplicateModelSchema = z.object({
1019
+ owner: z.string(),
1020
+ name: z.string(),
1021
+ description: z.string().nullable(),
1022
+ visibility: z.string(),
1023
+ run_count: z.number(),
1024
+ cover_image_url: z.string().nullable(),
1025
+ latest_version: z.object({
1026
+ id: z.string(),
1027
+ created_at: z.string(),
1028
+ openapi_schema: z.any()
1029
+ })
1030
+ }).passthrough();
1031
+ var ReplicateSnapshotSchema = z.object({
1032
+ // DRF-paginated shape (live API)
1033
+ results: z.array(ReplicateModelSchema).optional(),
1034
+ next: z.string().nullable().optional(),
1035
+ previous: z.string().nullable().optional(),
1036
+ // Hand-authored fixture shape (committed snapshot)
1037
+ _meta: z.record(z.string(), z.unknown()).optional(),
1038
+ models: z.array(ReplicateModelSchema).optional()
1039
+ }).passthrough();
1020
1040
  var PRICING = {
1021
1041
  "nano-banana-pro": { costPerImage: 0.15, costTier: "high", baseCost: 0.15, creditCost: 10 },
1022
1042
  "nano-banana-2": { costPerImage: 0.06, costTier: "medium", baseCost: 0.06, creditCost: 5 },
@@ -1230,14 +1250,14 @@ function mapModel(raw) {
1230
1250
  ...pricing.creditCost !== void 0 ? { creditCost: pricing.creditCost } : {},
1231
1251
  ...pricing.overrideCreditCost !== void 0 ? { overrideCreditCost: pricing.overrideCreditCost } : {}
1232
1252
  },
1233
- description: raw.description,
1253
+ description: raw.description ?? "",
1234
1254
  agentVisible: AGENT_VISIBLE.has(raw.name),
1235
1255
  ...spec.triggerWord ? { triggerWord: spec.triggerWord } : {}
1236
1256
  };
1237
1257
  }
1238
1258
  var REPLICATE_SOURCE = {
1239
1259
  id: "image-replicate",
1240
- url: "https://api.replicate.com/v1/models?query=image+generation",
1260
+ url: "https://api.replicate.com/v1/collections/text-to-image",
1241
1261
  headers: { Authorization: "Bearer env:REPLICATE_API_TOKEN" }
1242
1262
  };
1243
1263
  var imageReplicate = defineGenerator({
@@ -1245,8 +1265,22 @@ var imageReplicate = defineGenerator({
1245
1265
  modality: "image",
1246
1266
  sources: [REPLICATE_SOURCE],
1247
1267
  async generate(ctx) {
1248
- const data = await ctx.fetchSource(REPLICATE_SOURCE);
1249
- const entries = data.models.map(mapModel);
1268
+ const raw = await ctx.fetchSource(REPLICATE_SOURCE);
1269
+ const data = ReplicateSnapshotSchema.parse(raw);
1270
+ const models = data.results ?? data.models;
1271
+ if (!models) {
1272
+ throw new Error(
1273
+ "Replicate snapshot has neither `results` nor `models` array \u2014 invalid shape"
1274
+ );
1275
+ }
1276
+ const curatedModels = models.filter((m) => MODEL_SPECS[m.name]);
1277
+ if (curatedModels.length === 0) {
1278
+ const sampleNames = [...AGENT_VISIBLE].slice(0, 3).join(", ");
1279
+ throw new Error(
1280
+ `image:replicate: none of the curated models (${sampleNames}\u2026) present in source payload (${models.length} entries) \u2014 API shape or roster drift`
1281
+ );
1282
+ }
1283
+ const entries = curatedModels.map(mapModel);
1250
1284
  const lines = [
1251
1285
  "// Generated by @agentproto/catalog-sync generator image:replicate",
1252
1286
  "// DO NOT EDIT MANUALLY \u2014 regenerate with catalog-sync",
@@ -1420,6 +1454,13 @@ async function runGenerators(gens, opts) {
1420
1454
  ...src.body !== void 0 ? { body: JSON.stringify(src.body) } : {}
1421
1455
  });
1422
1456
  if (!res.ok) {
1457
+ if (existing !== void 0) {
1458
+ process.stderr.write(
1459
+ `catalog-sync: skipping refresh of "${src.id}" \u2014 fetch ${src.url} failed: ${res.status} ${res.statusText}; reusing committed snapshot.
1460
+ `
1461
+ );
1462
+ return JSON.parse(existing);
1463
+ }
1423
1464
  throw new Error(
1424
1465
  `catalog-sync: fetch ${src.url} failed: ${res.status} ${res.statusText}`
1425
1466
  );