@pixerate/editor 0.24.0 → 0.25.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.
Files changed (133) hide show
  1. package/README.md +71 -1
  2. package/THIRD_PARTY_NOTICES.md +29 -0
  3. package/dist/agent/index.cjs +10 -9
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +1 -1
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +4 -3
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/canvas/index.cjs +3173 -340
  10. package/dist/canvas/index.cjs.map +1 -1
  11. package/dist/canvas/index.d.cts +617 -4
  12. package/dist/canvas/index.d.ts +617 -4
  13. package/dist/canvas/index.js +3105 -272
  14. package/dist/canvas/index.js.map +1 -1
  15. package/dist/chunk-4BVP64JJ.cjs +1406 -0
  16. package/dist/chunk-4BVP64JJ.cjs.map +1 -0
  17. package/dist/{chunk-XNORY7M6.cjs → chunk-7WISYZFO.cjs} +105 -50
  18. package/dist/chunk-7WISYZFO.cjs.map +1 -0
  19. package/dist/{chunk-OLZJXL4R.cjs → chunk-AL6JMGWW.cjs} +59 -25
  20. package/dist/chunk-AL6JMGWW.cjs.map +1 -0
  21. package/dist/chunk-BVP3TSLH.cjs +69 -0
  22. package/dist/chunk-BVP3TSLH.cjs.map +1 -0
  23. package/dist/{chunk-MCSJFWAO.cjs → chunk-C7P22VIP.cjs} +670 -96
  24. package/dist/chunk-C7P22VIP.cjs.map +1 -0
  25. package/dist/{chunk-PGNZKFQS.js → chunk-ECCCYKGL.js} +76 -21
  26. package/dist/chunk-ECCCYKGL.js.map +1 -0
  27. package/dist/{chunk-3CN2WD3X.js → chunk-FH6F67DN.js} +646 -72
  28. package/dist/chunk-FH6F67DN.js.map +1 -0
  29. package/dist/chunk-HRMEDT2L.js +1406 -0
  30. package/dist/chunk-HRMEDT2L.js.map +1 -0
  31. package/dist/{chunk-ITBSKI26.js → chunk-IXHSYOVY.js} +941 -9
  32. package/dist/chunk-IXHSYOVY.js.map +1 -0
  33. package/dist/{chunk-FODNLX5N.js → chunk-NAXVVS5I.js} +38 -4
  34. package/dist/chunk-NAXVVS5I.js.map +1 -0
  35. package/dist/chunk-O5RYH2PG.js +69 -0
  36. package/dist/chunk-O5RYH2PG.js.map +1 -0
  37. package/dist/{chunk-SBCZ6RN5.cjs → chunk-PO6A6QQH.cjs} +1039 -107
  38. package/dist/chunk-PO6A6QQH.cjs.map +1 -0
  39. package/dist/{chunk-3LV6RRPH.js → chunk-QGYDWPRM.js} +2 -2
  40. package/dist/{chunk-U5KWZU4X.js → chunk-RR7F5GUM.js} +2632 -129
  41. package/dist/chunk-RR7F5GUM.js.map +1 -0
  42. package/dist/{chunk-5S3Z4PPF.js → chunk-UAKDG62Z.js} +232 -25
  43. package/dist/chunk-UAKDG62Z.js.map +1 -0
  44. package/dist/{chunk-SML64VJG.cjs → chunk-V3CHHWOE.cjs} +4 -4
  45. package/dist/{chunk-SML64VJG.cjs.map → chunk-V3CHHWOE.cjs.map} +1 -1
  46. package/dist/chunk-WSQKHXW7.cjs +5726 -0
  47. package/dist/chunk-WSQKHXW7.cjs.map +1 -0
  48. package/dist/{chunk-D27YFC46.cjs → chunk-X4N4WUKB.cjs} +267 -60
  49. package/dist/chunk-X4N4WUKB.cjs.map +1 -0
  50. package/dist/commands/index.cjs +74 -1
  51. package/dist/commands/index.cjs.map +1 -1
  52. package/dist/commands/index.d.cts +34 -1
  53. package/dist/commands/index.d.ts +34 -1
  54. package/dist/commands/index.js +73 -0
  55. package/dist/commands/index.js.map +1 -1
  56. package/dist/compare/index.cjs +3 -3
  57. package/dist/compare/index.d.cts +1 -1
  58. package/dist/compare/index.d.ts +1 -1
  59. package/dist/compare/index.js +2 -2
  60. package/dist/controller-BIJiNoVs.d.cts +1842 -0
  61. package/dist/controller-BIJiNoVs.d.ts +1842 -0
  62. package/dist/{documents-BQjzJNe2.d.ts → documents-CHT1U5Vs.d.ts} +10 -0
  63. package/dist/{documents-KRTPhvst.d.cts → documents-Gp7wb0Me.d.cts} +10 -0
  64. package/dist/extensions/index.cjs +53 -6
  65. package/dist/extensions/index.cjs.map +1 -1
  66. package/dist/extensions/index.d.cts +12 -4
  67. package/dist/extensions/index.d.ts +12 -4
  68. package/dist/extensions/index.js +53 -6
  69. package/dist/generation/index.cjs +1013 -69
  70. package/dist/generation/index.cjs.map +1 -1
  71. package/dist/generation/index.d.cts +474 -13
  72. package/dist/generation/index.d.ts +474 -13
  73. package/dist/generation/index.js +976 -32
  74. package/dist/generation/index.js.map +1 -1
  75. package/dist/image-editor/index.cjs +3385 -1275
  76. package/dist/image-editor/index.cjs.map +1 -1
  77. package/dist/image-editor/index.d.cts +693 -128
  78. package/dist/image-editor/index.d.ts +693 -128
  79. package/dist/image-editor/index.js +3325 -1215
  80. package/dist/image-editor/index.js.map +1 -1
  81. package/dist/{index-fJrlkJCd.d.ts → index-7a6bHTLy.d.ts} +494 -5
  82. package/dist/{index-BhJBSm2d.d.cts → index-Csd5qI8u.d.cts} +494 -5
  83. package/dist/index.cjs +1491 -45
  84. package/dist/index.cjs.map +1 -1
  85. package/dist/index.d.cts +110 -19
  86. package/dist/index.d.ts +110 -19
  87. package/dist/index.js +1464 -18
  88. package/dist/index.js.map +1 -1
  89. package/dist/mention-text-CDnCFd3c.d.cts +53 -0
  90. package/dist/mention-text-CDnCFd3c.d.ts +53 -0
  91. package/dist/model-C1zApQM8.d.cts +219 -0
  92. package/dist/model-C1zApQM8.d.ts +219 -0
  93. package/dist/persistence/index.d.cts +3 -120
  94. package/dist/persistence/index.d.ts +3 -120
  95. package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.cts} +12 -1
  96. package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.ts} +12 -1
  97. package/dist/serializers/index.cjs +12 -4
  98. package/dist/serializers/index.cjs.map +1 -1
  99. package/dist/serializers/index.d.cts +39 -12
  100. package/dist/serializers/index.d.ts +39 -12
  101. package/dist/serializers/index.js +12 -4
  102. package/dist/spreadsheet/index.cjs +127 -3
  103. package/dist/spreadsheet/index.cjs.map +1 -1
  104. package/dist/spreadsheet/index.d.cts +431 -11
  105. package/dist/spreadsheet/index.d.ts +431 -11
  106. package/dist/spreadsheet/index.js +127 -3
  107. package/dist/storage-BpFfspHm.d.cts +120 -0
  108. package/dist/storage-BpFfspHm.d.ts +120 -0
  109. package/dist/tokens/index.cjs +115 -0
  110. package/dist/tokens/index.cjs.map +1 -0
  111. package/dist/tokens/index.d.cts +212 -0
  112. package/dist/tokens/index.d.ts +212 -0
  113. package/dist/tokens/index.js +115 -0
  114. package/dist/tokens/index.js.map +1 -0
  115. package/dist/{track-changes-BK5sVf4_.d.cts → track-changes-D_VAPELi.d.cts} +95 -11
  116. package/dist/{track-changes-CDjCrwKe.d.ts → track-changes-Db_fGEvx.d.ts} +95 -11
  117. package/package.json +6 -1
  118. package/dist/chunk-3CN2WD3X.js.map +0 -1
  119. package/dist/chunk-5S3Z4PPF.js.map +0 -1
  120. package/dist/chunk-D27YFC46.cjs.map +0 -1
  121. package/dist/chunk-FODNLX5N.js.map +0 -1
  122. package/dist/chunk-ITBSKI26.js.map +0 -1
  123. package/dist/chunk-MA2F5KHF.cjs +0 -3223
  124. package/dist/chunk-MA2F5KHF.cjs.map +0 -1
  125. package/dist/chunk-MCSJFWAO.cjs.map +0 -1
  126. package/dist/chunk-OLZJXL4R.cjs.map +0 -1
  127. package/dist/chunk-PGNZKFQS.js.map +0 -1
  128. package/dist/chunk-SBCZ6RN5.cjs.map +0 -1
  129. package/dist/chunk-U5KWZU4X.js.map +0 -1
  130. package/dist/chunk-XNORY7M6.cjs.map +0 -1
  131. package/dist/controller-BhLLAoi8.d.cts +0 -1000
  132. package/dist/controller-BhLLAoi8.d.ts +0 -1000
  133. /package/dist/{chunk-3LV6RRPH.js.map → chunk-QGYDWPRM.js.map} +0 -0
@@ -4,6 +4,8 @@ import { A as AgentToolProvider } from '../registry-DnzpgY27.cjs';
4
4
  export { a as AgentTool, d as McpToolDefinition, e as McpToolResult } from '../registry-DnzpgY27.cjs';
5
5
  import { S as SourceMapSegment } from '../sourcemap-C8AH3MBQ.cjs';
6
6
  import { T as Template, P as PromptValues } from '../tokens-D7yXvUU6.cjs';
7
+ import { S as StorageAdapter } from '../storage-BpFfspHm.cjs';
8
+ export { a as MentionRoleSyntax, T as TextMention, f as findTextMentions, b as formatMentionText, s as setMentionRoleInText } from '../mention-text-CDnCFd3c.cjs';
7
9
 
8
10
  /**
9
11
  * Declarative descriptions of generative models (what a model accepts) and of
@@ -12,12 +14,45 @@ import { T as Template, P as PromptValues } from '../tokens-D7yXvUU6.cjs';
12
14
  * turned into JSON Schema for agents.
13
15
  */
14
16
  type GenerationMediaKind = 'image' | 'video' | 'audio' | 'text';
15
- /** What a reference input is used for. */
16
- type ReferenceRole = 'start_frame' | 'end_frame' | 'style_ref' | 'character_ref' | 'background_ref' | 'mask' | 'image_ref' | 'video_ref' | 'audio_ref';
17
- /** Every reference role, in a stable display order. */
18
- declare const REFERENCE_ROLES: readonly ReferenceRole[];
17
+ /** The reference roles this library knows by name (labels, aliases, schema order). */
18
+ type BuiltinReferenceRole = 'start_frame' | 'end_frame' | 'style_ref' | 'character_ref' | 'background_ref' | 'mask' | 'image_ref' | 'video_ref' | 'audio_ref';
19
+ /**
20
+ * What a reference input (an asset) is used for. The built-in roles are
21
+ * listed in {@link REFERENCE_ROLES}; models may declare any other role name
22
+ * (e.g. `subject`, `pose`) in `references.roles`, which makes it valid for
23
+ * that model. Role names match {@link REFERENCE_ROLE_NAME_REGEX}.
24
+ */
25
+ type ReferenceRole = BuiltinReferenceRole | (string & {});
26
+ /** Valid role names: a letter, then letters, digits, `_` or `-`, not ending in `_` or `-`. */
27
+ declare const REFERENCE_ROLE_NAME_REGEX: RegExp;
28
+ /** True for a string usable as a role name. */
29
+ declare function isReferenceRoleName(value: unknown): value is ReferenceRole;
30
+ /** Every built-in reference role, in a stable display order. */
31
+ declare const REFERENCE_ROLES: readonly BuiltinReferenceRole[];
19
32
  /** Human-readable default labels for reference roles. */
20
- declare const REFERENCE_ROLE_LABELS: Readonly<Record<ReferenceRole, string>>;
33
+ declare const REFERENCE_ROLE_LABELS: Readonly<Record<BuiltinReferenceRole, string>>;
34
+ /**
35
+ * Friendly role names accepted wherever a role is written by hand (asset
36
+ * mentions such as `@fox:style`, agent calls). A model that declares the
37
+ * alias itself (e.g. its own `style` role) keeps it; otherwise the alias maps
38
+ * to the built-in role. Keys are lower case.
39
+ */
40
+ declare const REFERENCE_ROLE_ALIASES: Readonly<Record<string, BuiltinReferenceRole>>;
41
+ /** Display label of a role: the model's label, the built-in label, or the name made readable. */
42
+ declare function referenceRoleLabel(role: ReferenceRole, caps?: ModelCapabilities): string;
43
+ /**
44
+ * Canonical role for a hand-written name: the name itself when the model
45
+ * declares it (or, without a model, when it is built in), else its alias
46
+ * ({@link REFERENCE_ROLE_ALIASES}, case-insensitive), else the trimmed name.
47
+ */
48
+ declare function normalizeReferenceRole(role: string, caps?: ModelCapabilities): ReferenceRole;
49
+ /**
50
+ * Whether `mediaType` (a MIME type such as `image/png`, or a media kind such
51
+ * as `image`) matches one of `accepts` (`image`, `image/*`, `image/png`).
52
+ * An empty or missing `accepts` accepts everything; an unknown media type
53
+ * only matches a missing `accepts`.
54
+ */
55
+ declare function mediaTypeMatches(mediaType: string | undefined, accepts: readonly string[] | undefined): boolean;
21
56
  /** A choice from a fixed list. `options` order matters (low → high where it applies). */
22
57
  interface EnumCapability<T extends string | number = string> {
23
58
  options: readonly T[];
@@ -65,6 +100,12 @@ interface ReferenceRoleCapability {
65
100
  min?: number;
66
101
  label?: string;
67
102
  description?: string;
103
+ /**
104
+ * Media accepted for this role: kinds (`image`), wildcards (`image/*`) or
105
+ * MIME types (`image/png`). Absent: anything. References whose
106
+ * `mediaType` does not match are dropped or rejected by the planner.
107
+ */
108
+ accepts?: readonly string[];
68
109
  }
69
110
  interface ReferenceCapability {
70
111
  /** Supported roles and their per-role limits. Roles not listed are unsupported. */
@@ -146,6 +187,10 @@ interface GenerationReference {
146
187
  id: string;
147
188
  role: ReferenceRole;
148
189
  url?: string;
190
+ /** MIME type or media kind, checked against the role's `accepts`. */
191
+ mediaType?: string;
192
+ /** Content hash of the asset when it was referenced (used by generation records). */
193
+ contentHash?: string;
149
194
  }
150
195
  type GenerationMode = 'generate' | 'edit' | 'inpaint';
151
196
  type GenerationParamValue = string | number | boolean;
@@ -172,7 +217,10 @@ declare const GENERATION_REQUEST_FIELDS: readonly ["model", "prompt", "negativeP
172
217
  declare function textFieldCapability(value: boolean | TextFieldCapability | undefined): TextFieldCapability | null;
173
218
  /** Seed limits normalized from `boolean | SeedCapability`. */
174
219
  declare function seedCapability(value: boolean | SeedCapability | undefined): SeedCapability | null;
175
- /** Supported reference roles of a model in {@link REFERENCE_ROLES} order. */
220
+ /**
221
+ * Supported reference roles of a model: built-in roles in
222
+ * {@link REFERENCE_ROLES} order, then custom roles in declaration order.
223
+ */
176
224
  declare function supportedReferenceRoles(caps: ModelCapabilities): ReferenceRole[];
177
225
  /** Supported generation modes of a model. */
178
226
  declare function supportedModes(caps: ModelCapabilities): GenerationMode[];
@@ -243,6 +291,27 @@ interface PlanOptions {
243
291
  fillDefaults?: boolean;
244
292
  /** Override whether references with unsupported roles may be dropped (default: `nearest` and `downgrade` only). */
245
293
  dropUnsupportedReferences?: boolean;
294
+ /**
295
+ * Assets mentioned in the prompt (e.g. from `extractMentions(text, { details: true, roles: true })`
296
+ * joined with your asset library). They are appended to `request.references`
297
+ * and validated per role like any other reference. A mention without a role
298
+ * gets `defaultMentionRole`, or the first role of the model that accepts its
299
+ * media type (reported as `defaulted`).
300
+ */
301
+ mentions?: readonly PlanAssetMention[];
302
+ /** Role for mentions that have none (see `mentions`). */
303
+ defaultMentionRole?: ReferenceRole;
304
+ }
305
+ /** An asset mention handed to the planner (see {@link PlanOptions.mentions}). */
306
+ interface PlanAssetMention {
307
+ /** Asset id. */
308
+ id: string;
309
+ role?: ReferenceRole | null;
310
+ mediaType?: string;
311
+ contentHash?: string;
312
+ url?: string;
313
+ /** The mention text, used in messages (default: the id). */
314
+ label?: string;
246
315
  }
247
316
  /** Numeric rank of an aspect ratio such as `16:9` (log of width / height). */
248
317
  declare function aspectRatioRank(value: string): number | undefined;
@@ -407,12 +476,6 @@ declare function createProvenance(options: CreateProvenanceOptions): GenerationP
407
476
  declare function serializeProvenance(provenance: GenerationProvenance): string;
408
477
  /** Parses and checks serialized provenance. Throws {@link ProvenanceParseError}. */
409
478
  declare function parseProvenance(input: string | unknown): GenerationProvenance;
410
- /**
411
- * A request that reproduces the recorded generation exactly: the planned
412
- * settings, model, seed and references that were sent, with the prompt as
413
- * resolved at the time (not re-resolved against today's templates).
414
- */
415
- declare function recreateRequest(provenance: GenerationProvenance): GenerationRequest;
416
479
  /**
417
480
  * Re-resolves the raw prompt against the pinned template bodies and values,
418
481
  * e.g. to check a record or to open it in an editor with its source map.
@@ -528,6 +591,8 @@ interface ReferenceSlot {
528
591
  description?: string;
529
592
  min: number;
530
593
  max: number;
594
+ /** Media accepted for this role (see `ReferenceRoleCapability.accepts`). */
595
+ accepts?: string[];
531
596
  references: GenerationReference[];
532
597
  /** More references of this role fit (per role and in total). */
533
598
  canAdd: boolean;
@@ -551,4 +616,400 @@ declare function addReference(request: GenerationRequest, reference: GenerationR
551
616
  /** Returns a copy of `request` without the reference `id` in `role`. */
552
617
  declare function removeReference(request: GenerationRequest, role: ReferenceRole, id: string): GenerationRequest;
553
618
 
554
- export { AgentToolProvider, type BatchResolver, type BatchResolverOptions, type BooleanParamSpec, type CapabilityOverlay, type CapabilityPresentation, type CountCapability, type CreateProvenanceOptions, type DurationCapability, type EnumCapability, type EnumParamSpec, type EstimateContext, type ExtraParamSpec, GENERATION_REQUEST_FIELDS, type GenerateContext, type GenerationControl, type GenerationControlOption, type GenerationMediaKind, type GenerationMode, type GenerationParamValue, type GenerationPlan, type GenerationProvenance, type GenerationReference, type GenerationRequest, type GenerationToolProvider, type GenerationToolProviderOptions, type JobProgressEstimate, type JobProgressInput, JsonSchema, MAX_PENDING_PERCENT, type ModelCapabilities, type NumberParamSpec, PROVENANCE_FORMAT, PROVENANCE_VERSION, type PinnedTemplate, type PlanAdjustment, type PlanAdjustmentKind, type PlanError, type PlanOptions, type PlanStrategy, type PromptCapability, ProvenanceParseError, QUALITY_LADDER, REFERENCE_ROLES, REFERENCE_ROLE_LABELS, type ReferenceCapability, type ReferenceRole, type ReferenceRoleCapability, type ReferenceSlot, type SeedCapability, type TextFieldCapability, type TimingCapability, addReference, aspectRatioRank, capabilitiesToJsonSchema, createBatchResolver, createGenerationToolProvider, createProvenance, estimateJobProgress, expectedDurationFor, formatRemaining, getGenerationControls, getReferenceSlots, getRequestValue, mergeCapabilities, parseControlValue, parseProvenance, pinnedTemplatesToTemplates, planGenerationRequest, qualityRank, recreateRequest, removeReference, replayProvenancePrompt, resolutionMegapixels, resolutionRank, seedCapability, serializeProvenance, setRequestValue, snapToOption, supportedModes, supportedReferenceRoles, textFieldCapability };
619
+ /**
620
+ * Stable JSON: object keys sorted, `undefined` members left out, so equal
621
+ * values always give the same string regardless of key order.
622
+ */
623
+ declare function stableStringify(value: unknown): string;
624
+ /**
625
+ * A short, stable, synchronous content hash (two independent 32-bit FNV-1a
626
+ * lanes over the UTF-16 code units, 16 hex digits, prefixed with `h1-`).
627
+ * It detects changes; it is not cryptographic, so do not use it to
628
+ * authenticate content.
629
+ */
630
+ declare function hashText(text: string): string;
631
+ /** {@link hashText} of the {@link stableStringify} form of `value`. */
632
+ declare function hashValue(value: unknown): string;
633
+ /**
634
+ * Hash of what a model accepts. Presentation fields (`name`, `description`,
635
+ * `badges`, `icon`, `group`) and `timing` are left out, so renaming a model or
636
+ * changing its progress estimate is not reported as a capability change.
637
+ */
638
+ declare function hashCapabilities(caps: ModelCapabilities): string;
639
+
640
+ /** A role a model accepts for asset mentions / references, for pickers. */
641
+ interface AssetRoleOption {
642
+ role: ReferenceRole;
643
+ label: string;
644
+ description?: string;
645
+ min: number;
646
+ max: number;
647
+ accepts?: string[];
648
+ }
649
+ /** What the host knows about an asset (for planning, records and drift checks). */
650
+ interface AssetInfo {
651
+ id: string;
652
+ label?: string;
653
+ /** MIME type or media kind (`image/png`, `image`). */
654
+ mediaType?: string;
655
+ /** Content hash; a change is reported as `asset-changed` drift. */
656
+ contentHash?: string;
657
+ url?: string;
658
+ }
659
+ /** Assets by id: a lookup function, a map, or a list. */
660
+ type AssetLookup = ((id: string) => AssetInfo | null | undefined) | ReadonlyMap<string, AssetInfo> | readonly AssetInfo[];
661
+ /** Normalizes an {@link AssetLookup} to a function. */
662
+ declare function toAssetResolver(lookup: AssetLookup | undefined): ((id: string) => AssetInfo | undefined) | undefined;
663
+ /** The roles a model accepts, with labels, limits and accepted media (inpainting adds `mask`). */
664
+ declare function getAssetRoleOptions(caps: ModelCapabilities): AssetRoleOption[];
665
+ type AssetMentionIssueCode = 'missing-role' | 'unsupported-role' | 'renamed-role' | 'media-mismatch' | 'too-many';
666
+ interface AssetMentionIssue {
667
+ /** Index of the mention in the input. */
668
+ index: number;
669
+ id: string;
670
+ role?: ReferenceRole;
671
+ code: AssetMentionIssueCode;
672
+ /** `error` blocks generation under the `error` strategy; `warning` is fixed by planning. */
673
+ severity: 'error' | 'warning';
674
+ message: string;
675
+ /** The role the planner will use instead (`renamed-role`). */
676
+ suggestion?: ReferenceRole;
677
+ }
678
+ interface AssetMentionValidation {
679
+ ok: boolean;
680
+ issues: AssetMentionIssue[];
681
+ /** Mentions per (canonical) role. */
682
+ counts: Record<string, number>;
683
+ /** Roles below their `min`. */
684
+ missing: {
685
+ role: ReferenceRole;
686
+ min: number;
687
+ count: number;
688
+ }[];
689
+ }
690
+ /**
691
+ * Checks asset mentions against what a model accepts, per mention, for UI
692
+ * feedback (badges, popovers). Mirrors the planner: aliases (`style` →
693
+ * `style_ref`) are accepted with a `renamed-role` warning, unsupported roles,
694
+ * media types the role does not accept and mentions beyond a role's `max`
695
+ * are reported, and roles below their `min` are listed in `missing`.
696
+ */
697
+ declare function validateAssetMentions(mentions: readonly PlanAssetMention[], caps: ModelCapabilities, options?: {
698
+ assets?: AssetLookup;
699
+ }): AssetMentionValidation;
700
+ /**
701
+ * Joins mentions (`{ handle, role }`, e.g. from `extractMentions(text, { details: true, roles: true })`)
702
+ * with your assets: each handle is looked up by id, then by label
703
+ * (case-insensitive). Mentions that are not assets are left out.
704
+ */
705
+ declare function resolveAssetMentions(mentions: readonly {
706
+ handle: string;
707
+ role?: string | null;
708
+ }[], assets: readonly AssetInfo[]): PlanAssetMention[];
709
+ /** Built-in roles as picker options, for when no model is selected. */
710
+ declare function defaultAssetRoleOptions(): AssetRoleOption[];
711
+ /** An asset mention prepared for display as a chip. */
712
+ interface AssetMentionChip {
713
+ /** Position among the chips. */
714
+ index: number;
715
+ /** Offset of the `@` in the text, when known (for `setMentionRoleInText`). */
716
+ start?: number;
717
+ handle: string;
718
+ asset: AssetInfo;
719
+ role?: ReferenceRole;
720
+ /** Display label of the role (the model's, else built-in). */
721
+ roleLabel?: string;
722
+ /** Problems with this mention for the model (`validateAssetMentions`). */
723
+ issues: AssetMentionIssue[];
724
+ }
725
+ /**
726
+ * Chips for the asset mentions among `mentions` (e.g. `findTextMentions(text)`
727
+ * from `@pixerate/editor/serializers`): each mention whose handle is an asset
728
+ * id or label, with its role label and the problems the model has with it.
729
+ */
730
+ declare function describeAssetMentions(mentions: readonly {
731
+ handle: string;
732
+ role?: string | null;
733
+ start?: number;
734
+ }[], assets: readonly AssetInfo[], caps?: ModelCapabilities): AssetMentionChip[];
735
+
736
+ declare const GENERATION_RECORD_FORMAT = "pixerate.generation-record";
737
+ declare const GENERATION_RECORD_VERSION = 1;
738
+ /** How a record came about. */
739
+ type GenerationRecordKind = 'generate' | 'recreate' | 'variation';
740
+ /** A template the generation used, with a hash of the exact body. */
741
+ interface RecordedTemplate {
742
+ name: string;
743
+ templateId?: string;
744
+ versionId?: string;
745
+ version?: string | number;
746
+ /** {@link hashText} of the body that was used. */
747
+ hash: string;
748
+ }
749
+ /** An asset the generation used, by role, with its content hash at the time. */
750
+ interface RecordedAsset {
751
+ id: string;
752
+ role: ReferenceRole;
753
+ contentHash?: string;
754
+ mediaType?: string;
755
+ url?: string;
756
+ }
757
+ /**
758
+ * Everything needed to reproduce one generation. The prompt, templates,
759
+ * values, resolved prompt, source map, planned request and adjustments live
760
+ * in `provenance` (see `createProvenance`); the record adds hashes for
761
+ * change detection, the user's original settings, assets and lineage.
762
+ */
763
+ interface GenerationRecord {
764
+ format: typeof GENERATION_RECORD_FORMAT;
765
+ version: typeof GENERATION_RECORD_VERSION;
766
+ id: string;
767
+ /** The record this one was recreated or varied from. */
768
+ parentId?: string;
769
+ kind: GenerationRecordKind;
770
+ provenance: GenerationProvenance;
771
+ /** One entry per template in `provenance.templates`, same order. */
772
+ templates: RecordedTemplate[];
773
+ /** {@link hashText} of `provenance.resolvedPrompt`. */
774
+ promptHash: string;
775
+ /** {@link hashCapabilities} of the model when the record was made (absent when only an id was known). */
776
+ capabilityHash?: string;
777
+ /** The request as the user set it, before planning (snapping, clamping, dropping). */
778
+ settings: GenerationRequest;
779
+ /** Strategy the request was planned with. */
780
+ strategy: PlanStrategy;
781
+ /** Seed used: the one the provider reported, else the planned one. */
782
+ seed?: number;
783
+ assets: RecordedAsset[];
784
+ /** Asset mentions that were planned as references (kept apart from `settings`). */
785
+ mentions?: PlanAssetMention[];
786
+ /** ISO timestamp (same as `provenance.createdAt`). */
787
+ createdAt: string;
788
+ updatedAt?: string;
789
+ }
790
+ interface CreateGenerationRecordOptions extends Omit<CreateProvenanceOptions, 'model' | 'plan' | 'request' | 'adjustments'> {
791
+ /** The model (needed for the capability hash and for planning when `plan` is absent). */
792
+ model: ModelCapabilities | string;
793
+ /** The user's settings before planning. */
794
+ request?: GenerationRequest;
795
+ /** The plan that was sent. Without it the request is planned here (needs capabilities). */
796
+ plan?: GenerationPlan;
797
+ /** Strategy for planning here, and recorded for recreating (default: the plan's, else `nearest`). */
798
+ strategy?: PlanStrategy;
799
+ /** Asset mentions to plan as references (see `PlanOptions.mentions`). */
800
+ mentions?: readonly PlanAssetMention[];
801
+ /** Fills in content hashes and media types of referenced assets. */
802
+ assets?: AssetLookup;
803
+ /** Seed the provider actually used, when it differs from the planned one (e.g. random). */
804
+ seed?: number;
805
+ id?: string;
806
+ parentId?: string;
807
+ kind?: GenerationRecordKind;
808
+ }
809
+ /** A unique record id (`crypto.randomUUID` when available). */
810
+ declare function createGenerationRecordId(): string;
811
+ /**
812
+ * Records a generation so it can be listed, explained and recreated. Builds
813
+ * the provenance (pinned template bodies, values, resolved prompt and source
814
+ * map, planned request, adjustments) and adds a hash per template body, the
815
+ * capability hash of the model, the user's original settings, the seed, the
816
+ * referenced assets with their roles and content hashes, and the parent
817
+ * record. Plans the request when no `plan` is given and `model` is a
818
+ * capability object.
819
+ */
820
+ declare function createGenerationRecord(options: CreateGenerationRecordOptions): GenerationRecord;
821
+ /** Returns a copy of `record` with outputs and completion time added (e.g. when the job finishes). */
822
+ declare function completeGenerationRecord(record: GenerationRecord, update: {
823
+ outputIds?: string[];
824
+ completedAt?: Date | number | string;
825
+ seed?: number;
826
+ meta?: Record<string, unknown>;
827
+ }): GenerationRecord;
828
+ /** Versioned JSON for storage. */
829
+ declare function serializeGenerationRecord(record: GenerationRecord): string;
830
+ /** Parses and checks a serialized record. Throws `ProvenanceParseError`. */
831
+ declare function parseGenerationRecord(input: string | unknown): GenerationRecord;
832
+ /** True for a {@link GenerationRecord} (as opposed to bare provenance). */
833
+ declare function isGenerationRecord(value: unknown): value is GenerationRecord;
834
+ /**
835
+ * `exact`: the same resolved prompt (pinned template bodies), the planned
836
+ * settings that were sent, the same seed. `latest`: the raw prompt resolved
837
+ * against today's templates (latest versions) and the user's original
838
+ * settings planned against today's capabilities, with the same seed.
839
+ */
840
+ type RecreateMode = 'exact' | 'latest';
841
+ type DriftType = 'template-changed' | 'template-missing' | 'prompt-changed' | 'model-missing' | 'model-changed' | 'setting-unsupported' | 'setting-changed' | 'asset-missing' | 'asset-changed';
842
+ interface DriftItem {
843
+ type: DriftType;
844
+ /** `error` items make `ok` false (the request cannot reproduce the record). */
845
+ severity: 'info' | 'warning' | 'error';
846
+ message: string;
847
+ /** Template name (template drift). */
848
+ template?: string;
849
+ /** Request path, e.g. `resolution`, `params.guidance`, `references` (setting drift). */
850
+ field?: string;
851
+ /** Asset id and role (asset drift). */
852
+ assetId?: string;
853
+ role?: ReferenceRole;
854
+ modelId?: string;
855
+ /** Recorded and current value, version or hash. */
856
+ from?: unknown;
857
+ to?: unknown;
858
+ /** Whether the change is in the returned request (`latest` mode), or only reported (`exact`). */
859
+ applied?: boolean;
860
+ }
861
+ interface RecreateOptions {
862
+ /** Current templates (to detect edits, and to resolve in `latest` mode). */
863
+ templates?: readonly Template[];
864
+ /** Current model capabilities: one model, or a list to find the record's model in. */
865
+ capabilities?: ModelCapabilities | readonly ModelCapabilities[];
866
+ /** Default `exact`. */
867
+ mode?: RecreateMode;
868
+ /** Current assets, to report missing or changed assets. */
869
+ assets?: AssetLookup;
870
+ /** Planning strategy (default: the record's). */
871
+ strategy?: PlanStrategy;
872
+ }
873
+ interface RecreateResult {
874
+ mode: RecreateMode;
875
+ /** No `error` drift and (when capabilities were given) the plan has no errors. */
876
+ ok: boolean;
877
+ /** The request to send (re-planned when capabilities were given). */
878
+ request: GenerationRequest;
879
+ /** The plan against current capabilities (absent without capabilities or when the model is gone). */
880
+ plan?: GenerationPlan;
881
+ rawPrompt: string;
882
+ resolvedPrompt: string;
883
+ sourceMap: SourceMapSegment[];
884
+ values: PromptValues | null;
885
+ /** Templates and bindings the prompt was resolved with. */
886
+ templates: Template[];
887
+ bindings: Record<string, string>;
888
+ drift: DriftItem[];
889
+ /** The record this request comes from. */
890
+ parentId: string;
891
+ kind: Exclude<GenerationRecordKind, 'generate'>;
892
+ /** Options for {@link createGenerationRecord} once the new generation has run. */
893
+ recordOptions: CreateGenerationRecordOptions;
894
+ }
895
+ /** Changes for {@link variationRequest}. */
896
+ interface VariationOverrides {
897
+ /** New seed, `null` for none, or absent for a random one different from the record's. */
898
+ seed?: number | null;
899
+ /** Values merged over the recorded ones. */
900
+ values?: PromptValues;
901
+ /** Settings merged over the recreated request (`params` are merged too). */
902
+ settings?: Partial<GenerationRequest>;
903
+ /** A different raw prompt. */
904
+ rawPrompt?: string;
905
+ /** Random source in [0, 1) for the seed (default `Math.random`). */
906
+ random?: () => number;
907
+ }
908
+ /**
909
+ * Rebuilds the request of a recorded generation.
910
+ *
911
+ * - With a {@link GenerationRecord}: returns a {@link RecreateResult} with the
912
+ * re-planned request and a drift report: templates edited or deleted since,
913
+ * model capabilities changed or the model gone, settings no longer
914
+ * supported (or, in `latest` mode, planned differently), assets missing or
915
+ * changed. `mode: 'exact'` (default) reproduces the recorded prompt and
916
+ * settings; `mode: 'latest'` uses current templates and re-plans the
917
+ * original settings. Template edits are always reported; only `latest`
918
+ * applies them.
919
+ * - With bare {@link GenerationProvenance} (the original API): returns the
920
+ * planned request that was sent, with the prompt as resolved at the time.
921
+ */
922
+ declare function recreateRequest(provenance: GenerationProvenance): GenerationRequest;
923
+ declare function recreateRequest(record: GenerationRecord, options?: RecreateOptions): RecreateResult;
924
+ /**
925
+ * A request for a variation of a recorded generation: the same prompt,
926
+ * settings and assets (as {@link recreateRequest} would rebuild them, `exact`
927
+ * mode by default) with a new seed (random within the model's range unless
928
+ * given) and any overrides. Setting drift is not reported for the fields you
929
+ * change; template, model and asset drift are.
930
+ */
931
+ declare function variationRequest(record: GenerationRecord, overrides?: VariationOverrides, options?: RecreateOptions): RecreateResult;
932
+ /** Short display labels for drift types (history panels, badges). */
933
+ declare const DRIFT_TYPE_LABELS: Readonly<Record<DriftType, string>>;
934
+ /** Drift items that block an exact reproduction (`severity: 'error'`). */
935
+ declare function blockingDrift(drift: readonly DriftItem[]): DriftItem[];
936
+
937
+ /** What the store indexes per record (kept in one index entry, so lists need no record reads). */
938
+ interface GenerationRecordSummary {
939
+ id: string;
940
+ modelId: string;
941
+ kind: GenerationRecordKind;
942
+ parentId?: string;
943
+ createdAt: string;
944
+ /** Template names and ids used. */
945
+ templates: string[];
946
+ templateIds: string[];
947
+ /** Asset ids and roles used. */
948
+ assets: string[];
949
+ roles: ReferenceRole[];
950
+ /** First 160 characters of the resolved prompt, for lists. */
951
+ preview: string;
952
+ }
953
+ interface GenerationRecordFilter {
954
+ /** Model id(s). */
955
+ model?: string | readonly string[];
956
+ /** Template name or id. */
957
+ template?: string;
958
+ /** Asset id. */
959
+ asset?: string;
960
+ role?: ReferenceRole;
961
+ kind?: GenerationRecordKind;
962
+ parentId?: string;
963
+ /** Created at or after / before (exclusive). */
964
+ since?: Date | number | string;
965
+ until?: Date | number | string;
966
+ /** Case-insensitive text in the prompt preview. */
967
+ text?: string;
968
+ offset?: number;
969
+ limit?: number;
970
+ }
971
+ interface PruneOptions {
972
+ /** Keep at most this many records (newest first). */
973
+ maxRecords?: number;
974
+ /** Remove records created before this time. */
975
+ olderThan?: Date | number | string;
976
+ /** Records for which this returns `true` are never removed (they still count toward `maxRecords`). */
977
+ keep?: (summary: GenerationRecordSummary) => boolean;
978
+ }
979
+ interface GenerationRecordStoreOptions {
980
+ storage: Pick<StorageAdapter, 'get' | 'set' | 'remove'>;
981
+ /** Key prefix (default `pixerate.generation-records`). */
982
+ namespace?: string;
983
+ /** Prune to this many records after every `put`. */
984
+ maxRecords?: number;
985
+ }
986
+ interface GenerationRecordStore {
987
+ /** Adds or replaces a record. */
988
+ put(record: GenerationRecord): Promise<void>;
989
+ get(id: string): Promise<GenerationRecord | null>;
990
+ /** Records matching `filter`, newest first. Unreadable records are skipped. */
991
+ list(filter?: GenerationRecordFilter): Promise<GenerationRecord[]>;
992
+ /** Index entries matching `filter`, newest first (no record reads). */
993
+ summaries(filter?: GenerationRecordFilter): Promise<GenerationRecordSummary[]>;
994
+ remove(id: string): Promise<boolean>;
995
+ /** Removes records by count and age; returns the removed ids. */
996
+ prune(options: PruneOptions): Promise<string[]>;
997
+ clear(): Promise<void>;
998
+ /** Called after every change. Returns an unsubscribe function. */
999
+ subscribe(listener: () => void): () => void;
1000
+ }
1001
+ /** The index entry for a record. */
1002
+ declare function summarizeGenerationRecord(record: GenerationRecord): GenerationRecordSummary;
1003
+ /** True when `summary` matches every condition of `filter` (ignores `offset` / `limit`). */
1004
+ declare function matchesRecordFilter(summary: GenerationRecordSummary, filter?: GenerationRecordFilter): boolean;
1005
+ /**
1006
+ * Persists generation records on a key/value `StorageAdapter`
1007
+ * (`createMemoryStorage`, `createLocalStorageAdapter`, `createIndexedDbAdapter`,
1008
+ * `createOpfsAdapter`). Each record is stored under its own key and a single
1009
+ * index entry holds the summaries used for listing and filtering. Operations
1010
+ * run one at a time, so concurrent `put`s do not lose index entries. The index
1011
+ * is cached after the first read: use one store per storage namespace.
1012
+ */
1013
+ declare function createGenerationRecordStore(options: GenerationRecordStoreOptions): GenerationRecordStore;
1014
+
1015
+ export { AgentToolProvider, type AssetInfo, type AssetLookup, type AssetMentionChip, type AssetMentionIssue, type AssetMentionIssueCode, type AssetMentionValidation, type AssetRoleOption, type BatchResolver, type BatchResolverOptions, type BooleanParamSpec, type BuiltinReferenceRole, type CapabilityOverlay, type CapabilityPresentation, type CountCapability, type CreateGenerationRecordOptions, type CreateProvenanceOptions, DRIFT_TYPE_LABELS, type DriftItem, type DriftType, type DurationCapability, type EnumCapability, type EnumParamSpec, type EstimateContext, type ExtraParamSpec, GENERATION_RECORD_FORMAT, GENERATION_RECORD_VERSION, GENERATION_REQUEST_FIELDS, type GenerateContext, type GenerationControl, type GenerationControlOption, type GenerationMediaKind, type GenerationMode, type GenerationParamValue, type GenerationPlan, type GenerationProvenance, type GenerationRecord, type GenerationRecordFilter, type GenerationRecordKind, type GenerationRecordStore, type GenerationRecordStoreOptions, type GenerationRecordSummary, type GenerationReference, type GenerationRequest, type GenerationToolProvider, type GenerationToolProviderOptions, type JobProgressEstimate, type JobProgressInput, JsonSchema, MAX_PENDING_PERCENT, type ModelCapabilities, type NumberParamSpec, PROVENANCE_FORMAT, PROVENANCE_VERSION, type PinnedTemplate, type PlanAdjustment, type PlanAdjustmentKind, type PlanAssetMention, type PlanError, type PlanOptions, type PlanStrategy, type PromptCapability, ProvenanceParseError, type PruneOptions, QUALITY_LADDER, REFERENCE_ROLES, REFERENCE_ROLE_ALIASES, REFERENCE_ROLE_LABELS, REFERENCE_ROLE_NAME_REGEX, type RecordedAsset, type RecordedTemplate, type RecreateMode, type RecreateOptions, type RecreateResult, type ReferenceCapability, type ReferenceRole, type ReferenceRoleCapability, type ReferenceSlot, type SeedCapability, type TextFieldCapability, type TimingCapability, type VariationOverrides, addReference, aspectRatioRank, blockingDrift, capabilitiesToJsonSchema, completeGenerationRecord, createBatchResolver, createGenerationRecord, createGenerationRecordId, createGenerationRecordStore, createGenerationToolProvider, createProvenance, defaultAssetRoleOptions, describeAssetMentions, estimateJobProgress, expectedDurationFor, formatRemaining, getAssetRoleOptions, getGenerationControls, getReferenceSlots, getRequestValue, hashCapabilities, hashText, hashValue, isGenerationRecord, isReferenceRoleName, matchesRecordFilter, mediaTypeMatches, mergeCapabilities, normalizeReferenceRole, parseControlValue, parseGenerationRecord, parseProvenance, pinnedTemplatesToTemplates, planGenerationRequest, qualityRank, recreateRequest, referenceRoleLabel, removeReference, replayProvenancePrompt, resolutionMegapixels, resolutionRank, resolveAssetMentions, seedCapability, serializeGenerationRecord, serializeProvenance, setRequestValue, snapToOption, stableStringify, summarizeGenerationRecord, supportedModes, supportedReferenceRoles, textFieldCapability, toAssetResolver, validateAssetMentions, variationRequest };