@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/index.mjs CHANGED
@@ -180,6 +180,13 @@ async function runGenerators(gens, opts) {
180
180
  ...src.body !== void 0 ? { body: JSON.stringify(src.body) } : {}
181
181
  });
182
182
  if (!res.ok) {
183
+ if (existing !== void 0) {
184
+ process.stderr.write(
185
+ `catalog-sync: skipping refresh of "${src.id}" \u2014 fetch ${src.url} failed: ${res.status} ${res.statusText}; reusing committed snapshot.
186
+ `
187
+ );
188
+ return JSON.parse(existing);
189
+ }
183
190
  throw new Error(
184
191
  `catalog-sync: fetch ${src.url} failed: ${res.status} ${res.statusText}`
185
192
  );
@@ -972,8 +979,28 @@ var voiceMinimax = defineGenerator({
972
979
  };
973
980
  }
974
981
  });
975
-
976
- // src/generators/image-replicate.ts
982
+ var ReplicateModelSchema = z.object({
983
+ owner: z.string(),
984
+ name: z.string(),
985
+ description: z.string().nullable(),
986
+ visibility: z.string(),
987
+ run_count: z.number(),
988
+ cover_image_url: z.string().nullable(),
989
+ latest_version: z.object({
990
+ id: z.string(),
991
+ created_at: z.string(),
992
+ openapi_schema: z.any()
993
+ })
994
+ }).passthrough();
995
+ var ReplicateSnapshotSchema = z.object({
996
+ // DRF-paginated shape (live API)
997
+ results: z.array(ReplicateModelSchema).optional(),
998
+ next: z.string().nullable().optional(),
999
+ previous: z.string().nullable().optional(),
1000
+ // Hand-authored fixture shape (committed snapshot)
1001
+ _meta: z.record(z.string(), z.unknown()).optional(),
1002
+ models: z.array(ReplicateModelSchema).optional()
1003
+ }).passthrough();
977
1004
  var PRICING = {
978
1005
  "nano-banana-pro": { costPerImage: 0.15, costTier: "high", baseCost: 0.15, creditCost: 10 },
979
1006
  "nano-banana-2": { costPerImage: 0.06, costTier: "medium", baseCost: 0.06, creditCost: 5 },
@@ -1187,14 +1214,14 @@ function mapModel(raw) {
1187
1214
  ...pricing.creditCost !== void 0 ? { creditCost: pricing.creditCost } : {},
1188
1215
  ...pricing.overrideCreditCost !== void 0 ? { overrideCreditCost: pricing.overrideCreditCost } : {}
1189
1216
  },
1190
- description: raw.description,
1217
+ description: raw.description ?? "",
1191
1218
  agentVisible: AGENT_VISIBLE.has(raw.name),
1192
1219
  ...spec.triggerWord ? { triggerWord: spec.triggerWord } : {}
1193
1220
  };
1194
1221
  }
1195
1222
  var REPLICATE_SOURCE = {
1196
1223
  id: "image-replicate",
1197
- url: "https://api.replicate.com/v1/models?query=image+generation",
1224
+ url: "https://api.replicate.com/v1/collections/text-to-image",
1198
1225
  headers: { Authorization: "Bearer env:REPLICATE_API_TOKEN" }
1199
1226
  };
1200
1227
  var imageReplicate = defineGenerator({
@@ -1202,8 +1229,22 @@ var imageReplicate = defineGenerator({
1202
1229
  modality: "image",
1203
1230
  sources: [REPLICATE_SOURCE],
1204
1231
  async generate(ctx) {
1205
- const data = await ctx.fetchSource(REPLICATE_SOURCE);
1206
- const entries = data.models.map(mapModel);
1232
+ const raw = await ctx.fetchSource(REPLICATE_SOURCE);
1233
+ const data = ReplicateSnapshotSchema.parse(raw);
1234
+ const models = data.results ?? data.models;
1235
+ if (!models) {
1236
+ throw new Error(
1237
+ "Replicate snapshot has neither `results` nor `models` array \u2014 invalid shape"
1238
+ );
1239
+ }
1240
+ const curatedModels = models.filter((m) => MODEL_SPECS[m.name]);
1241
+ if (curatedModels.length === 0) {
1242
+ const sampleNames = [...AGENT_VISIBLE].slice(0, 3).join(", ");
1243
+ throw new Error(
1244
+ `image:replicate: none of the curated models (${sampleNames}\u2026) present in source payload (${models.length} entries) \u2014 API shape or roster drift`
1245
+ );
1246
+ }
1247
+ const entries = curatedModels.map(mapModel);
1207
1248
  const lines = [
1208
1249
  "// Generated by @agentproto/catalog-sync generator image:replicate",
1209
1250
  "// DO NOT EDIT MANUALLY \u2014 regenerate with catalog-sync",