agent-avatars 1.0.0-rc.2

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.
@@ -0,0 +1,197 @@
1
+ export type AvatarStyleVersion = "1";
2
+ export type SeedMode = "human" | "raw";
3
+ export type AvatarTheme = "light" | "dark";
4
+ export type VariantChoice<T extends string> = "auto" | T | number;
5
+
6
+ export interface ThemeColors {
7
+ background: string;
8
+ foreground: string;
9
+ }
10
+
11
+ export interface AvatarPaletteInput {
12
+ id?: string;
13
+ light?: ThemeColors | readonly [string, string];
14
+ dark?: ThemeColors | readonly [string, string];
15
+ background?: string;
16
+ foreground?: string;
17
+ }
18
+
19
+ export interface NormalizedPalette {
20
+ id: string;
21
+ light: ThemeColors;
22
+ dark: ThemeColors;
23
+ visualKey?: string;
24
+ }
25
+
26
+ export interface AvatarConstraints {
27
+ minPixels: number;
28
+ maxPixels: number;
29
+ minDensity: number;
30
+ maxDensity: number;
31
+ maxDiagonalConnections: number;
32
+ connectivity: 4 | 8;
33
+ maxHoles: number;
34
+ }
35
+
36
+ export interface AvatarOptions {
37
+ size?: number | `${number}`;
38
+ seedMode?: SeedMode;
39
+ namespace?: string | number;
40
+ namespaceMode?: SeedMode;
41
+ theme?: AvatarTheme;
42
+ minPixels?: number;
43
+ maxPixels?: number;
44
+ minDensity?: number;
45
+ maxDensity?: number;
46
+ maxDiagonalConnections?: number;
47
+ connectivity?: 4 | 8;
48
+ maxHoles?: number;
49
+ palette?: VariantChoice<string> | AvatarPaletteInput;
50
+ palettes?: readonly (AvatarPaletteInput | readonly [string, string])[];
51
+ collisionNonce?: number;
52
+ minimumContrast?: number;
53
+ allowLowContrast?: boolean;
54
+ }
55
+
56
+ export interface HashOptions {
57
+ seedMode?: SeedMode;
58
+ namespace?: string | number;
59
+ namespaceMode?: SeedMode;
60
+ domain?: string;
61
+ }
62
+
63
+ export interface AvatarBounds {
64
+ minX: number;
65
+ minY: number;
66
+ maxX: number;
67
+ maxY: number;
68
+ width: number;
69
+ height: number;
70
+ }
71
+
72
+ export interface AvatarMetrics {
73
+ cellCount: number;
74
+ density: number;
75
+ bounds: AvatarBounds;
76
+ connectedComponents4: number;
77
+ connectedComponents8: number;
78
+ holeCount: number;
79
+ diagonalTouchCount: number;
80
+ diagonalTouchCountIgnoringMirror: number;
81
+ }
82
+
83
+ export interface AvatarValidation extends AvatarMetrics {
84
+ valid: boolean;
85
+ mirrored: boolean;
86
+ constraints: AvatarConstraints;
87
+ }
88
+
89
+ export interface AvatarDescriptor {
90
+ styleVersion: AvatarStyleVersion;
91
+ namespace: string;
92
+ canonicalSeed: string;
93
+ identityKey: string;
94
+ collisionNonce: number;
95
+ hash: number;
96
+ shapeId: string;
97
+ shapeMask: number;
98
+ shapeIndex: number;
99
+ rows: number[];
100
+ grid: boolean[][];
101
+ paletteId: string;
102
+ paletteIndex: number;
103
+ palette: NormalizedPalette;
104
+ theme: AvatarTheme;
105
+ colors: ThemeColors;
106
+ constraints: AvatarConstraints;
107
+ stateSpace: number;
108
+ signature: string;
109
+ metrics: AvatarMetrics;
110
+ }
111
+
112
+ export interface CatalogShape extends AvatarMetrics {
113
+ id: string;
114
+ mask: number;
115
+ rows: number[];
116
+ }
117
+
118
+ export interface CatalogStats {
119
+ styleVersion: AvatarStyleVersion;
120
+ rawSymmetricMasks: 4096;
121
+ validShapes: number;
122
+ availablePalettes: number;
123
+ signatureStates: number;
124
+ constraints: AvatarConstraints;
125
+ }
126
+
127
+ export interface IdentityManifestEntry {
128
+ nonce: number;
129
+ signature: string;
130
+ shapeId: string;
131
+ paletteId: string;
132
+ }
133
+
134
+ export interface IdentityDistinguishabilityPolicy {
135
+ schema: "visual-distance/v1";
136
+ minimumShapeDistance: number;
137
+ minimumPaletteDistance: number;
138
+ mode: "either" | "both";
139
+ }
140
+
141
+ export interface IdentityManifest {
142
+ schema: "deterministic-agent-avatars-manifest/v1";
143
+ styleVersion: AvatarStyleVersion;
144
+ namespaceKey: string;
145
+ optionsKey: string;
146
+ distinguishability?: IdentityDistinguishabilityPolicy;
147
+ entries: Record<string, IdentityManifestEntry>;
148
+ }
149
+
150
+ export interface IdentitySetOptions extends Omit<AvatarOptions, "collisionNonce"> {
151
+ ensureUnique?: boolean;
152
+ includeSvg?: boolean;
153
+ manifest?: IdentityManifest;
154
+ maxAttempts?: number;
155
+ minimumShapeDistance?: number;
156
+ minimumPaletteDistance?: number;
157
+ distanceMode?: "either" | "both";
158
+ }
159
+
160
+ export interface IdentitySetItem<T = unknown> {
161
+ input: T;
162
+ identityKey: string;
163
+ nonce: number;
164
+ signature: string;
165
+ descriptor: AvatarDescriptor;
166
+ svg?: string;
167
+ }
168
+
169
+ export interface IdentitySetResult<T = unknown> {
170
+ items: IdentitySetItem<T>[];
171
+ manifest: IdentityManifest;
172
+ stateSpace: number;
173
+ }
174
+
175
+ export const STYLE_VERSION: AvatarStyleVersion;
176
+ export const GRID_W: 5;
177
+ export const GRID_H: 4;
178
+ export const RAW_SYMMETRIC_MASKS: 4096;
179
+ export const BUILTIN_PALETTES: readonly NormalizedPalette[];
180
+ export function canonicalSeed(value: unknown, mode?: SeedMode): string;
181
+ export function hash32(value: unknown, options?: HashOptions): number;
182
+ export function contrastRatio(first: string, second: string): number;
183
+ export function rowsFromSymmetricMask(mask: number): number[];
184
+ export function symmetricMaskFromRows(rows: readonly number[]): number;
185
+
186
+ export function getAvatarCatalog(options?: AvatarOptions): CatalogShape[];
187
+ export function getCatalogStats(options?: AvatarOptions): CatalogStats;
188
+ export function validateAvatarBitmap(gridOrRows: boolean[][] | number[], options?: AvatarOptions): AvatarValidation;
189
+ export function createAvatarDescriptor(seed: unknown, options?: AvatarOptions): AvatarDescriptor;
190
+
191
+ export function createHashAvatarFromDescriptor(descriptor: AvatarDescriptor, size?: number | `${number}`): string;
192
+ export function createHashAvatar(seed: unknown, size?: number | `${number}`, options?: AvatarOptions): string;
193
+ export function createHashAvatar(seed: unknown, options?: AvatarOptions): string;
194
+ export function avatarDataUri(seed: unknown, size?: number | `${number}`, options?: AvatarOptions): string;
195
+ export function avatarDataUri(seed: unknown, options?: AvatarOptions): string;
196
+
197
+ export function createIdentitySet<T>(seeds: readonly T[], options?: IdentitySetOptions): IdentitySetResult<T>;
@@ -0,0 +1,197 @@
1
+ export type AvatarStyleVersion = "1";
2
+ export type SeedMode = "human" | "raw";
3
+ export type AvatarTheme = "light" | "dark";
4
+ export type VariantChoice<T extends string> = "auto" | T | number;
5
+
6
+ export interface ThemeColors {
7
+ background: string;
8
+ foreground: string;
9
+ }
10
+
11
+ export interface AvatarPaletteInput {
12
+ id?: string;
13
+ light?: ThemeColors | readonly [string, string];
14
+ dark?: ThemeColors | readonly [string, string];
15
+ background?: string;
16
+ foreground?: string;
17
+ }
18
+
19
+ export interface NormalizedPalette {
20
+ id: string;
21
+ light: ThemeColors;
22
+ dark: ThemeColors;
23
+ visualKey?: string;
24
+ }
25
+
26
+ export interface AvatarConstraints {
27
+ minPixels: number;
28
+ maxPixels: number;
29
+ minDensity: number;
30
+ maxDensity: number;
31
+ maxDiagonalConnections: number;
32
+ connectivity: 4 | 8;
33
+ maxHoles: number;
34
+ }
35
+
36
+ export interface AvatarOptions {
37
+ size?: number | `${number}`;
38
+ seedMode?: SeedMode;
39
+ namespace?: string | number;
40
+ namespaceMode?: SeedMode;
41
+ theme?: AvatarTheme;
42
+ minPixels?: number;
43
+ maxPixels?: number;
44
+ minDensity?: number;
45
+ maxDensity?: number;
46
+ maxDiagonalConnections?: number;
47
+ connectivity?: 4 | 8;
48
+ maxHoles?: number;
49
+ palette?: VariantChoice<string> | AvatarPaletteInput;
50
+ palettes?: readonly (AvatarPaletteInput | readonly [string, string])[];
51
+ collisionNonce?: number;
52
+ minimumContrast?: number;
53
+ allowLowContrast?: boolean;
54
+ }
55
+
56
+ export interface HashOptions {
57
+ seedMode?: SeedMode;
58
+ namespace?: string | number;
59
+ namespaceMode?: SeedMode;
60
+ domain?: string;
61
+ }
62
+
63
+ export interface AvatarBounds {
64
+ minX: number;
65
+ minY: number;
66
+ maxX: number;
67
+ maxY: number;
68
+ width: number;
69
+ height: number;
70
+ }
71
+
72
+ export interface AvatarMetrics {
73
+ cellCount: number;
74
+ density: number;
75
+ bounds: AvatarBounds;
76
+ connectedComponents4: number;
77
+ connectedComponents8: number;
78
+ holeCount: number;
79
+ diagonalTouchCount: number;
80
+ diagonalTouchCountIgnoringMirror: number;
81
+ }
82
+
83
+ export interface AvatarValidation extends AvatarMetrics {
84
+ valid: boolean;
85
+ mirrored: boolean;
86
+ constraints: AvatarConstraints;
87
+ }
88
+
89
+ export interface AvatarDescriptor {
90
+ styleVersion: AvatarStyleVersion;
91
+ namespace: string;
92
+ canonicalSeed: string;
93
+ identityKey: string;
94
+ collisionNonce: number;
95
+ hash: number;
96
+ shapeId: string;
97
+ shapeMask: number;
98
+ shapeIndex: number;
99
+ rows: number[];
100
+ grid: boolean[][];
101
+ paletteId: string;
102
+ paletteIndex: number;
103
+ palette: NormalizedPalette;
104
+ theme: AvatarTheme;
105
+ colors: ThemeColors;
106
+ constraints: AvatarConstraints;
107
+ stateSpace: number;
108
+ signature: string;
109
+ metrics: AvatarMetrics;
110
+ }
111
+
112
+ export interface CatalogShape extends AvatarMetrics {
113
+ id: string;
114
+ mask: number;
115
+ rows: number[];
116
+ }
117
+
118
+ export interface CatalogStats {
119
+ styleVersion: AvatarStyleVersion;
120
+ rawSymmetricMasks: 4096;
121
+ validShapes: number;
122
+ availablePalettes: number;
123
+ signatureStates: number;
124
+ constraints: AvatarConstraints;
125
+ }
126
+
127
+ export interface IdentityManifestEntry {
128
+ nonce: number;
129
+ signature: string;
130
+ shapeId: string;
131
+ paletteId: string;
132
+ }
133
+
134
+ export interface IdentityDistinguishabilityPolicy {
135
+ schema: "visual-distance/v1";
136
+ minimumShapeDistance: number;
137
+ minimumPaletteDistance: number;
138
+ mode: "either" | "both";
139
+ }
140
+
141
+ export interface IdentityManifest {
142
+ schema: "deterministic-agent-avatars-manifest/v1";
143
+ styleVersion: AvatarStyleVersion;
144
+ namespaceKey: string;
145
+ optionsKey: string;
146
+ distinguishability?: IdentityDistinguishabilityPolicy;
147
+ entries: Record<string, IdentityManifestEntry>;
148
+ }
149
+
150
+ export interface IdentitySetOptions extends Omit<AvatarOptions, "collisionNonce"> {
151
+ ensureUnique?: boolean;
152
+ includeSvg?: boolean;
153
+ manifest?: IdentityManifest;
154
+ maxAttempts?: number;
155
+ minimumShapeDistance?: number;
156
+ minimumPaletteDistance?: number;
157
+ distanceMode?: "either" | "both";
158
+ }
159
+
160
+ export interface IdentitySetItem<T = unknown> {
161
+ input: T;
162
+ identityKey: string;
163
+ nonce: number;
164
+ signature: string;
165
+ descriptor: AvatarDescriptor;
166
+ svg?: string;
167
+ }
168
+
169
+ export interface IdentitySetResult<T = unknown> {
170
+ items: IdentitySetItem<T>[];
171
+ manifest: IdentityManifest;
172
+ stateSpace: number;
173
+ }
174
+
175
+ export const STYLE_VERSION: AvatarStyleVersion;
176
+ export const GRID_W: 5;
177
+ export const GRID_H: 4;
178
+ export const RAW_SYMMETRIC_MASKS: 4096;
179
+ export const BUILTIN_PALETTES: readonly NormalizedPalette[];
180
+ export function canonicalSeed(value: unknown, mode?: SeedMode): string;
181
+ export function hash32(value: unknown, options?: HashOptions): number;
182
+ export function contrastRatio(first: string, second: string): number;
183
+ export function rowsFromSymmetricMask(mask: number): number[];
184
+ export function symmetricMaskFromRows(rows: readonly number[]): number;
185
+
186
+ export function getAvatarCatalog(options?: AvatarOptions): CatalogShape[];
187
+ export function getCatalogStats(options?: AvatarOptions): CatalogStats;
188
+ export function validateAvatarBitmap(gridOrRows: boolean[][] | number[], options?: AvatarOptions): AvatarValidation;
189
+ export function createAvatarDescriptor(seed: unknown, options?: AvatarOptions): AvatarDescriptor;
190
+
191
+ export function createHashAvatarFromDescriptor(descriptor: AvatarDescriptor, size?: number | `${number}`): string;
192
+ export function createHashAvatar(seed: unknown, size?: number | `${number}`, options?: AvatarOptions): string;
193
+ export function createHashAvatar(seed: unknown, options?: AvatarOptions): string;
194
+ export function avatarDataUri(seed: unknown, size?: number | `${number}`, options?: AvatarOptions): string;
195
+ export function avatarDataUri(seed: unknown, options?: AvatarOptions): string;
196
+
197
+ export function createIdentitySet<T>(seeds: readonly T[], options?: IdentitySetOptions): IdentitySetResult<T>;