@agentforge-io/connectors-higgsfield 1.0.2 → 1.1.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.
package/dist/rules.d.ts CHANGED
@@ -24,6 +24,28 @@ export declare const STUDIO_MODEL: {
24
24
  readonly resolution: "2k";
25
25
  readonly referenceRole: "image_references";
26
26
  };
27
+ /**
28
+ * Fallback generation models for a job the primary model's moderation ended as `nsfw` / `ip_detected` (PDK-HIGGSFIELD-FALLBACK).
29
+ * Model facts from the live Higgsfield catalog (models_explore, 2026-12-02): both take `image_references`.
30
+ * - gpt_image_2_6 (OpenAI, Higgsfield's default for product shots / edits): quality low..max, resolution 1k|2k|4k,
31
+ * background auto|opaque|transparent, aspect ratios incl. 1:1 3:4 4:5 9:16 16:9, up to 16 references.
32
+ * - seedream_5_5 (Bytedance, edits that keep untargeted parts unchanged): resolution up to 4k, up to 10 references.
33
+ * Exact param VALUES (quality enum, resolution strings) are only confirmed by a free `estimate_image_cost`; the platform always
34
+ * quotes before it spends, so a wrong shape fails at the (free) quote, never at the paid call.
35
+ */
36
+ export declare const FALLBACK_MODEL_IDS: readonly ["gpt_image_2_6", "seedream_5_5"];
37
+ export type FallbackModelId = (typeof FALLBACK_MODEL_IDS)[number];
38
+ export interface FallbackModel {
39
+ model: FallbackModelId;
40
+ resolution: string;
41
+ referenceRole: string;
42
+ /** gpt_image_2_6 only. */
43
+ quality?: string;
44
+ }
45
+ export declare const GPT_IMAGE_FALLBACK: FallbackModel;
46
+ export declare const SEEDREAM_FALLBACK: FallbackModel;
47
+ /** Which job verdicts a fallback / cutout retry is offered for. */
48
+ export declare const MODERATION_VERDICTS: readonly ["nsfw", "ip_detected"];
27
49
  export declare const REJECTED_STUDIO_MODELS: readonly ["marketing_studio_2_image"];
28
50
  export type CatalogErrorCode = 'PHOTO_REQUIRED' | 'INVALID_MODE' | 'INVALID_ANGLE';
29
51
  export declare class CatalogRequestError extends Error {
package/dist/rules.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatalogRequestError = exports.REJECTED_STUDIO_MODELS = exports.STUDIO_MODEL = exports.STUDIO_ANGLES = exports.CATALOG_MODES = exports.CATALOG_MASTER = exports.CATALOG_RULES_VERSION = void 0;
3
+ exports.CatalogRequestError = exports.REJECTED_STUDIO_MODELS = exports.MODERATION_VERDICTS = exports.SEEDREAM_FALLBACK = exports.GPT_IMAGE_FALLBACK = exports.FALLBACK_MODEL_IDS = exports.STUDIO_MODEL = exports.STUDIO_ANGLES = exports.CATALOG_MODES = exports.CATALOG_MASTER = exports.CATALOG_RULES_VERSION = void 0;
4
4
  exports.buildStudioPrompt = buildStudioPrompt;
5
5
  exports.assertCatalogRequest = assertCatalogRequest;
6
6
  exports.buildStudioGenerateParams = buildStudioGenerateParams;
@@ -23,6 +23,20 @@ exports.CATALOG_MODES = ['cutout', 'studio'];
23
23
  exports.STUDIO_ANGLES = ['front', 'three_quarter', 'top'];
24
24
  /** marketing_studio_2_image is ad-styled (copy, badges), so it is deliberately not used. */
25
25
  exports.STUDIO_MODEL = { model: 'flux_2', variant: 'pro', resolution: '2k', referenceRole: 'image_references' };
26
+ /**
27
+ * Fallback generation models for a job the primary model's moderation ended as `nsfw` / `ip_detected` (PDK-HIGGSFIELD-FALLBACK).
28
+ * Model facts from the live Higgsfield catalog (models_explore, 2026-12-02): both take `image_references`.
29
+ * - gpt_image_2_6 (OpenAI, Higgsfield's default for product shots / edits): quality low..max, resolution 1k|2k|4k,
30
+ * background auto|opaque|transparent, aspect ratios incl. 1:1 3:4 4:5 9:16 16:9, up to 16 references.
31
+ * - seedream_5_5 (Bytedance, edits that keep untargeted parts unchanged): resolution up to 4k, up to 10 references.
32
+ * Exact param VALUES (quality enum, resolution strings) are only confirmed by a free `estimate_image_cost`; the platform always
33
+ * quotes before it spends, so a wrong shape fails at the (free) quote, never at the paid call.
34
+ */
35
+ exports.FALLBACK_MODEL_IDS = ['gpt_image_2_6', 'seedream_5_5'];
36
+ exports.GPT_IMAGE_FALLBACK = { model: 'gpt_image_2_6', resolution: '2k', referenceRole: 'image_references', quality: 'high' };
37
+ exports.SEEDREAM_FALLBACK = { model: 'seedream_5_5', resolution: '2k', referenceRole: 'image_references' };
38
+ /** Which job verdicts a fallback / cutout retry is offered for. */
39
+ exports.MODERATION_VERDICTS = ['nsfw', 'ip_detected'];
26
40
  exports.REJECTED_STUDIO_MODELS = ['marketing_studio_2_image'];
27
41
  class CatalogRequestError extends Error {
28
42
  constructor(code, message) {
package/dist/skills.d.ts CHANGED
@@ -1,12 +1,38 @@
1
+ import { type FallbackModel } from './rules';
1
2
  /**
2
3
  * Image skills (PDK-HIGGSFIELD §10, D10-D14): server-side, versioned art-direction recipes.
3
4
  * The owner picks a slug (+ the business palette, + an optional short note); the system owns every
4
5
  * word of the prompt. Pure module: no I/O, no network, no spend.
5
6
  */
6
7
  /** Bump on ANY change to a skill's text, model, aspect or the palette / hard-rule wording: jobs record it. */
7
- export declare const SKILLS_RULES_VERSION = "2026-12-01.5";
8
+ export declare const SKILLS_RULES_VERSION = "2026-12-02.1";
8
9
  export declare const SKILL_SLUGS: readonly ["product-cart", "ugc-model", "minimal-poster", "gravity-defying", "hero-offert", "cleanfly"];
9
10
  export type SkillSlug = (typeof SKILL_SLUGS)[number];
11
+ /**
12
+ * The one NON-generative skill (PDK-HIGGSFIELD-FALLBACK): only the background removal of the owner's own photo, as a
13
+ * transparent catalog master. No generative model runs, so a generative model's moderation cannot block it. It is NOT in
14
+ * IMAGE_SKILLS (no prompt, no palette, no model, never part of a batch): the platform runs it as its `cutout` recipe.
15
+ */
16
+ export declare const CUTOUT_SKILL_SLUG: "cutout";
17
+ export declare const CUTOUT_SKILL: {
18
+ readonly slug: "cutout";
19
+ readonly label: {
20
+ readonly es: "Recortar producto";
21
+ readonly en: "Cut out product";
22
+ };
23
+ readonly purpose: {
24
+ readonly es: "Quita el fondo de tu foto real y la deja en PNG transparente, sin generar nada nuevo.";
25
+ readonly en: "Removes the background of your real photo into a transparent PNG, without generating anything new.";
26
+ };
27
+ readonly aspectRatio: "1:1";
28
+ readonly size: {
29
+ readonly width: 2048;
30
+ readonly height: 2048;
31
+ };
32
+ readonly output: "alpha_master";
33
+ readonly generative: false;
34
+ };
35
+ export declare const isCutoutSlug: (slug: unknown) => slug is typeof CUTOUT_SKILL_SLUG;
10
36
  /** alpha_master = the catalog master (generate, remove background, 2048 PNG with alpha). scene = a finished picture. */
11
37
  export type SkillOutput = 'alpha_master' | 'scene';
12
38
  export type PeoplePolicy = 'none' | 'one_person';
@@ -34,6 +60,11 @@ export interface ImageSkill {
34
60
  /** One line, neutral Spanish (tú) / English. */
35
61
  purpose: LocalizedText;
36
62
  model: SkillModel;
63
+ /**
64
+ * Model tried ONLY when the owner explicitly asks to redo a job the primary model's moderation ended as nsfw / ip_detected.
65
+ * Same prompt, same reference, same aspect; never used automatically.
66
+ */
67
+ fallbackModel: FallbackModel;
37
68
  /** Aspect of the STORED result (the platform crops/resizes to `size`). */
38
69
  aspectRatio: AspectRatio;
39
70
  /** Aspect sent to generate_image: always one flux_2 supports (FLUX2_ASPECTS). */
@@ -113,13 +144,66 @@ export declare function buildSkillPrompt(opts: {
113
144
  palette: unknown;
114
145
  note?: unknown;
115
146
  }): string;
116
- /** generate_image params: reference-guided, the skill's aspect, no free text. */
147
+ export type SkillEngine = 'primary' | 'fallback';
148
+ /**
149
+ * generate_image params for a fallback model, per model id (the param names differ). Aspect = the skill's `generateAspect`
150
+ * (1:1, 3:4 and 16:9 are accepted by both fallback models), so the stored crop/resize is identical to the primary's.
151
+ * Throws for a model id this table does not know: no model is ever assumed.
152
+ */
153
+ export declare function buildFallbackGenerateParams(opts: {
154
+ fallback: FallbackModel;
155
+ prompt: string;
156
+ aspect: string;
157
+ referenceMediaId: string;
158
+ }): {
159
+ model: "gpt_image_2_6";
160
+ prompt: string;
161
+ aspect_ratio: string;
162
+ resolution: string;
163
+ quality: string;
164
+ medias: {
165
+ value: string;
166
+ role: string;
167
+ }[];
168
+ } | {
169
+ model: "seedream_5_5";
170
+ prompt: string;
171
+ aspect_ratio: string;
172
+ resolution: string;
173
+ medias: {
174
+ value: string;
175
+ role: string;
176
+ }[];
177
+ quality?: undefined;
178
+ };
179
+ /** generate_image params: reference-guided, the skill's aspect, no free text. `engine: 'fallback'` swaps ONLY the model + its params. */
117
180
  export declare function buildSkillGenerateParams(opts: {
118
181
  skill: ImageSkill | SkillSlug;
119
182
  palette: unknown;
120
183
  note?: unknown;
121
184
  referenceMediaId: string;
185
+ engine?: SkillEngine;
122
186
  }): {
187
+ model: "gpt_image_2_6";
188
+ prompt: string;
189
+ aspect_ratio: string;
190
+ resolution: string;
191
+ quality: string;
192
+ medias: {
193
+ value: string;
194
+ role: string;
195
+ }[];
196
+ } | {
197
+ model: "seedream_5_5";
198
+ prompt: string;
199
+ aspect_ratio: string;
200
+ resolution: string;
201
+ medias: {
202
+ value: string;
203
+ role: string;
204
+ }[];
205
+ quality?: undefined;
206
+ } | {
123
207
  model: string;
124
208
  variant: string;
125
209
  resolution: string;
@@ -131,13 +215,32 @@ export declare function buildSkillGenerateParams(opts: {
131
215
  }[];
132
216
  };
133
217
  /** What a host lists to an owner: no prompt text, no model internals. */
134
- export declare function listImageSkills(): {
135
- slug: "product-cart" | "ugc-model" | "minimal-poster" | "gravity-defying" | "hero-offert" | "cleanfly";
218
+ export declare function listImageSkills(): ({
219
+ slug: string;
136
220
  label: LocalizedText;
137
221
  purpose: LocalizedText;
138
- aspectRatio: AspectRatio;
139
- generateAspect: "1:1" | "3:4" | "16:9" | "4:3" | "9:16";
222
+ aspectRatio: string;
223
+ generateAspect: string;
140
224
  width: number;
141
225
  height: number;
142
226
  output: SkillOutput;
143
- }[];
227
+ generative: boolean;
228
+ hasFallback: boolean;
229
+ } | {
230
+ slug: string;
231
+ label: {
232
+ readonly es: "Recortar producto";
233
+ readonly en: "Cut out product";
234
+ };
235
+ purpose: {
236
+ readonly es: "Quita el fondo de tu foto real y la deja en PNG transparente, sin generar nada nuevo.";
237
+ readonly en: "Removes the background of your real photo into a transparent PNG, without generating anything new.";
238
+ };
239
+ aspectRatio: string;
240
+ generateAspect: string;
241
+ width: 2048;
242
+ height: 2048;
243
+ output: SkillOutput;
244
+ generative: boolean;
245
+ hasFallback: boolean;
246
+ })[];
package/dist/skills.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NOTE_MAX_LENGTH = exports.SkillRequestError = exports.GLOBAL_AVOID = exports.HARD_RULES = exports.IMAGE_SKILLS = exports.FLUX2_ASPECTS = exports.SKILL_SLUGS = exports.SKILLS_RULES_VERSION = void 0;
3
+ exports.NOTE_MAX_LENGTH = exports.SkillRequestError = exports.GLOBAL_AVOID = exports.HARD_RULES = exports.IMAGE_SKILLS = exports.FLUX2_ASPECTS = exports.isCutoutSlug = exports.CUTOUT_SKILL = exports.CUTOUT_SKILL_SLUG = exports.SKILL_SLUGS = exports.SKILLS_RULES_VERSION = void 0;
4
4
  exports.getImageSkill = getImageSkill;
5
5
  exports.normalizeHex = normalizeHex;
6
6
  exports.colorName = colorName;
@@ -12,6 +12,7 @@ exports.sanitizeNote = sanitizeNote;
12
12
  exports.assertNote = assertNote;
13
13
  exports.assertSkillRequest = assertSkillRequest;
14
14
  exports.buildSkillPrompt = buildSkillPrompt;
15
+ exports.buildFallbackGenerateParams = buildFallbackGenerateParams;
15
16
  exports.buildSkillGenerateParams = buildSkillGenerateParams;
16
17
  exports.listImageSkills = listImageSkills;
17
18
  const rules_1 = require("./rules");
@@ -21,7 +22,7 @@ const rules_1 = require("./rules");
21
22
  * word of the prompt. Pure module: no I/O, no network, no spend.
22
23
  */
23
24
  /** Bump on ANY change to a skill's text, model, aspect or the palette / hard-rule wording: jobs record it. */
24
- exports.SKILLS_RULES_VERSION = '2026-12-01.5';
25
+ exports.SKILLS_RULES_VERSION = '2026-12-02.1';
25
26
  exports.SKILL_SLUGS = [
26
27
  'product-cart',
27
28
  'ugc-model',
@@ -30,6 +31,26 @@ exports.SKILL_SLUGS = [
30
31
  'hero-offert',
31
32
  'cleanfly',
32
33
  ];
34
+ /**
35
+ * The one NON-generative skill (PDK-HIGGSFIELD-FALLBACK): only the background removal of the owner's own photo, as a
36
+ * transparent catalog master. No generative model runs, so a generative model's moderation cannot block it. It is NOT in
37
+ * IMAGE_SKILLS (no prompt, no palette, no model, never part of a batch): the platform runs it as its `cutout` recipe.
38
+ */
39
+ exports.CUTOUT_SKILL_SLUG = 'cutout';
40
+ exports.CUTOUT_SKILL = {
41
+ slug: exports.CUTOUT_SKILL_SLUG,
42
+ label: { es: 'Recortar producto', en: 'Cut out product' },
43
+ purpose: {
44
+ es: 'Quita el fondo de tu foto real y la deja en PNG transparente, sin generar nada nuevo.',
45
+ en: 'Removes the background of your real photo into a transparent PNG, without generating anything new.',
46
+ },
47
+ aspectRatio: rules_1.CATALOG_MASTER.aspectRatio,
48
+ size: { width: rules_1.CATALOG_MASTER.width, height: rules_1.CATALOG_MASTER.height },
49
+ output: 'alpha_master',
50
+ generative: false,
51
+ };
52
+ const isCutoutSlug = (slug) => slug === exports.CUTOUT_SKILL_SLUG;
53
+ exports.isCutoutSlug = isCutoutSlug;
33
54
  /**
34
55
  * Aspect ratios flux_2 accepts, checked against the live Higgsfield model catalog (models_explore get flux_2)
35
56
  * on 2026-12-01: aspect_ratios 1:1, 4:3, 3:4, 16:9, 9:16; resolution 1k|2k; variants pro|flex|max; media role
@@ -42,6 +63,7 @@ exports.FLUX2_ASPECTS = ['1:1', '4:3', '3:4', '16:9', '9:16'];
42
63
  * reference, which is the whole point (no invented products). No other model id is assumed.
43
64
  */
44
65
  const MODEL = { ...rules_1.STUDIO_MODEL };
66
+ const FALLBACK = { ...rules_1.GPT_IMAGE_FALLBACK };
45
67
  exports.IMAGE_SKILLS = [
46
68
  {
47
69
  slug: 'product-cart',
@@ -51,6 +73,7 @@ exports.IMAGE_SKILLS = [
51
73
  en: 'Clean product photo on a transparent background, ready for your catalog and cart.',
52
74
  },
53
75
  model: MODEL,
76
+ fallbackModel: FALLBACK,
54
77
  aspectRatio: rules_1.CATALOG_MASTER.aspectRatio,
55
78
  generateAspect: '1:1',
56
79
  size: { width: rules_1.CATALOG_MASTER.width, height: rules_1.CATALOG_MASTER.height },
@@ -78,6 +101,7 @@ exports.IMAGE_SKILLS = [
78
101
  en: 'A person naturally using or holding your real product, with a phone-shot look.',
79
102
  },
80
103
  model: MODEL,
104
+ fallbackModel: FALLBACK,
81
105
  aspectRatio: '4:5',
82
106
  generateAspect: '3:4',
83
107
  size: { width: 1600, height: 2000 },
@@ -114,6 +138,7 @@ exports.IMAGE_SKILLS = [
114
138
  en: 'Minimal editorial composition with plenty of calm space for your copy later.',
115
139
  },
116
140
  model: MODEL,
141
+ fallbackModel: FALLBACK,
117
142
  aspectRatio: '3:4',
118
143
  generateAspect: '3:4',
119
144
  size: { width: 1536, height: 2048 },
@@ -137,6 +162,7 @@ exports.IMAGE_SKILLS = [
137
162
  en: 'Your product levitating with a few of its own parts or ingredients.',
138
163
  },
139
164
  model: MODEL,
165
+ fallbackModel: FALLBACK,
140
166
  aspectRatio: '1:1',
141
167
  generateAspect: '1:1',
142
168
  size: { width: 2048, height: 2048 },
@@ -161,6 +187,7 @@ exports.IMAGE_SKILLS = [
161
187
  en: 'Wide web hero with the product on the right and calm space for your message.',
162
188
  },
163
189
  model: MODEL,
190
+ fallbackModel: FALLBACK,
164
191
  aspectRatio: '16:9',
165
192
  generateAspect: '16:9',
166
193
  size: { width: 2048, height: 1152 },
@@ -187,6 +214,7 @@ exports.IMAGE_SKILLS = [
187
214
  en: 'Tidy top-down flat lay with your product and two or three related items.',
188
215
  },
189
216
  model: MODEL,
217
+ fallbackModel: FALLBACK,
190
218
  aspectRatio: '4:5',
191
219
  generateAspect: '3:4',
192
220
  size: { width: 1600, height: 2000 },
@@ -498,30 +526,67 @@ function buildSkillPrompt(opts) {
498
526
  `Avoid: ${avoid.join(', ')}.`,
499
527
  ].join('\n');
500
528
  }
501
- /** generate_image params: reference-guided, the skill's aspect, no free text. */
529
+ /**
530
+ * generate_image params for a fallback model, per model id (the param names differ). Aspect = the skill's `generateAspect`
531
+ * (1:1, 3:4 and 16:9 are accepted by both fallback models), so the stored crop/resize is identical to the primary's.
532
+ * Throws for a model id this table does not know: no model is ever assumed.
533
+ */
534
+ function buildFallbackGenerateParams(opts) {
535
+ const { fallback: f } = opts;
536
+ const medias = [{ value: opts.referenceMediaId, role: f.referenceRole }];
537
+ switch (f.model) {
538
+ case 'gpt_image_2_6':
539
+ return { model: f.model, prompt: opts.prompt, aspect_ratio: opts.aspect, resolution: f.resolution, quality: f.quality ?? 'high', medias };
540
+ case 'seedream_5_5':
541
+ return { model: f.model, prompt: opts.prompt, aspect_ratio: opts.aspect, resolution: f.resolution, medias };
542
+ default:
543
+ throw new SkillRequestError('INVALID_SKILL', `no param builder for fallback model ${String(f.model)}`);
544
+ }
545
+ }
546
+ /** generate_image params: reference-guided, the skill's aspect, no free text. `engine: 'fallback'` swaps ONLY the model + its params. */
502
547
  function buildSkillGenerateParams(opts) {
503
548
  const skill = typeof opts.skill === 'string' ? getImageSkill(opts.skill) : getImageSkill(opts.skill?.slug);
504
549
  if (!skill)
505
550
  throw new SkillRequestError('INVALID_SKILL', 'unknown skill');
551
+ const prompt = buildSkillPrompt({ skill, palette: opts.palette, note: opts.note });
552
+ if (opts.engine === 'fallback') {
553
+ return buildFallbackGenerateParams({ fallback: skill.fallbackModel, prompt, aspect: skill.generateAspect, referenceMediaId: opts.referenceMediaId });
554
+ }
506
555
  return {
507
556
  model: skill.model.model,
508
557
  variant: skill.model.variant,
509
558
  resolution: skill.model.resolution,
510
- prompt: buildSkillPrompt({ skill, palette: opts.palette, note: opts.note }),
559
+ prompt,
511
560
  aspect_ratio: skill.generateAspect,
512
561
  medias: [{ value: opts.referenceMediaId, role: skill.model.referenceRole }],
513
562
  };
514
563
  }
515
564
  /** What a host lists to an owner: no prompt text, no model internals. */
516
565
  function listImageSkills() {
517
- return exports.IMAGE_SKILLS.map((s) => ({
518
- slug: s.slug,
519
- label: s.label,
520
- purpose: s.purpose,
521
- aspectRatio: s.aspectRatio,
522
- generateAspect: s.generateAspect,
523
- width: s.size.width,
524
- height: s.size.height,
525
- output: s.output,
526
- }));
566
+ return [
567
+ ...exports.IMAGE_SKILLS.map((s) => ({
568
+ slug: s.slug,
569
+ label: s.label,
570
+ purpose: s.purpose,
571
+ aspectRatio: s.aspectRatio,
572
+ generateAspect: s.generateAspect,
573
+ width: s.size.width,
574
+ height: s.size.height,
575
+ output: s.output,
576
+ generative: true,
577
+ hasFallback: true,
578
+ })),
579
+ {
580
+ slug: exports.CUTOUT_SKILL.slug,
581
+ label: exports.CUTOUT_SKILL.label,
582
+ purpose: exports.CUTOUT_SKILL.purpose,
583
+ aspectRatio: exports.CUTOUT_SKILL.aspectRatio,
584
+ generateAspect: exports.CUTOUT_SKILL.aspectRatio,
585
+ width: exports.CUTOUT_SKILL.size.width,
586
+ height: exports.CUTOUT_SKILL.size.height,
587
+ output: exports.CUTOUT_SKILL.output,
588
+ generative: false,
589
+ hasFallback: false,
590
+ },
591
+ ];
527
592
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/connectors-higgsfield",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Higgsfield connector for AgentForge — OAuth public client (CIMD + PKCE) over the Higgsfield MCP server, with a typed MCP client, versioned catalog-photo rules, and read-only agent tools (balance, job status). Nothing here spends credits on its own.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",