@omnicross/contracts 0.1.10 → 0.2.1
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/health-logging-types.d.cts +7 -0
- package/dist/health-logging-types.d.ts +7 -0
- package/dist/image-generation-types.cjs +63 -0
- package/dist/image-generation-types.d.cts +193 -0
- package/dist/image-generation-types.d.ts +193 -0
- package/dist/image-generation-types.js +37 -0
- package/dist/index.cjs +222 -2
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +209 -1
- package/dist/search-compat.cjs +130 -0
- package/dist/search-compat.d.cts +93 -0
- package/dist/search-compat.d.ts +93 -0
- package/dist/search-compat.js +100 -0
- package/dist/search-types.cjs +102 -0
- package/dist/search-types.d.cts +420 -0
- package/dist/search-types.d.ts +420 -0
- package/dist/search-types.js +74 -0
- package/dist/usage-types.d.cts +2 -0
- package/dist/usage-types.d.ts +2 -0
- package/dist/websearch-types.d.cts +20 -2
- package/dist/websearch-types.d.ts +20 -2
- package/package.json +172 -156
|
@@ -58,11 +58,18 @@ type LogFormat = 'text' | 'json';
|
|
|
58
58
|
* - `format` — `text` (human-readable, legacy shape) | `json` (structured lines).
|
|
59
59
|
* - `file` — OPTIONAL append-only file sink path. A PLAIN config value (NOT a
|
|
60
60
|
* secret — never walked by the at-rest secret encryption).
|
|
61
|
+
* - `maxFileBytes` / `maxFiles` — file-sink rotation (default 8 MB x 5). Only
|
|
62
|
+
* meaningful alongside `file`. An uncapped daemon log is a slow
|
|
63
|
+
* disk-fill, so the cap is a default rather than an opt-in.
|
|
61
64
|
*/
|
|
62
65
|
interface LoggingConfig {
|
|
63
66
|
level?: LogLevel;
|
|
64
67
|
format?: LogFormat;
|
|
65
68
|
file?: string;
|
|
69
|
+
/** Size cap for one generation of the file sink, in bytes. Default 8 MB. */
|
|
70
|
+
maxFileBytes?: number;
|
|
71
|
+
/** Generations kept as `<file>.1` … `<file>.N`. Default 5. */
|
|
72
|
+
maxFiles?: number;
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
export { type HealthReport, type HealthStatus, type LogFormat, type LogLevel, type LoggingConfig, healthHttpStatus };
|
|
@@ -58,11 +58,18 @@ type LogFormat = 'text' | 'json';
|
|
|
58
58
|
* - `format` — `text` (human-readable, legacy shape) | `json` (structured lines).
|
|
59
59
|
* - `file` — OPTIONAL append-only file sink path. A PLAIN config value (NOT a
|
|
60
60
|
* secret — never walked by the at-rest secret encryption).
|
|
61
|
+
* - `maxFileBytes` / `maxFiles` — file-sink rotation (default 8 MB x 5). Only
|
|
62
|
+
* meaningful alongside `file`. An uncapped daemon log is a slow
|
|
63
|
+
* disk-fill, so the cap is a default rather than an opt-in.
|
|
61
64
|
*/
|
|
62
65
|
interface LoggingConfig {
|
|
63
66
|
level?: LogLevel;
|
|
64
67
|
format?: LogFormat;
|
|
65
68
|
file?: string;
|
|
69
|
+
/** Size cap for one generation of the file sink, in bytes. Default 8 MB. */
|
|
70
|
+
maxFileBytes?: number;
|
|
71
|
+
/** Generations kept as `<file>.1` … `<file>.N`. Default 5. */
|
|
72
|
+
maxFiles?: number;
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
export { type HealthReport, type HealthStatus, type LogFormat, type LogLevel, type LoggingConfig, healthHttpStatus };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/image-generation-types.ts
|
|
21
|
+
var image_generation_types_exports = {};
|
|
22
|
+
__export(image_generation_types_exports, {
|
|
23
|
+
IMAGE_CAPABILITY_UNAVAILABLE_REASONS: () => IMAGE_CAPABILITY_UNAVAILABLE_REASONS,
|
|
24
|
+
IMAGE_GENERATION_ERROR_CODES: () => IMAGE_GENERATION_ERROR_CODES
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(image_generation_types_exports);
|
|
27
|
+
var IMAGE_GENERATION_ERROR_CODES = [
|
|
28
|
+
"invalid_image_request",
|
|
29
|
+
"unsupported_model",
|
|
30
|
+
"unsupported_capability",
|
|
31
|
+
"invalid_api_key",
|
|
32
|
+
"upstream_auth_required",
|
|
33
|
+
"image_reference_not_found",
|
|
34
|
+
"image_reference_expired",
|
|
35
|
+
"image_too_large",
|
|
36
|
+
"unsupported_image_type",
|
|
37
|
+
"moderation_blocked",
|
|
38
|
+
"upstream_rate_limited",
|
|
39
|
+
"subscription_usage_limit_reached",
|
|
40
|
+
"image_queue_full",
|
|
41
|
+
"image_queue_timeout",
|
|
42
|
+
"request_cancelled",
|
|
43
|
+
"upstream_protocol_changed",
|
|
44
|
+
"image_generation_failed",
|
|
45
|
+
"image_generation_timeout"
|
|
46
|
+
];
|
|
47
|
+
var IMAGE_CAPABILITY_UNAVAILABLE_REASONS = [
|
|
48
|
+
"missing_evidence",
|
|
49
|
+
"stale_evidence",
|
|
50
|
+
"contradictory_evidence",
|
|
51
|
+
"adapter_unavailable",
|
|
52
|
+
"account_unverified",
|
|
53
|
+
"protocol_unverified",
|
|
54
|
+
"no_common_models",
|
|
55
|
+
"no_common_output_formats",
|
|
56
|
+
"no_common_quality_levels",
|
|
57
|
+
"no_common_moderation_modes"
|
|
58
|
+
];
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
IMAGE_CAPABILITY_UNAVAILABLE_REASONS,
|
|
62
|
+
IMAGE_GENERATION_ERROR_CODES
|
|
63
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral image generation vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* This module intentionally contains no HTTP, filesystem, credential, or
|
|
5
|
+
* ChatGPT/Codex private-wire types. Binary access is supplied by the core
|
|
6
|
+
* image-generation module through an asset type that extends
|
|
7
|
+
* {@link ImageInputAsset} / {@link ImageArtifactMetadata}.
|
|
8
|
+
*/
|
|
9
|
+
declare const imageArtifactIdBrand: unique symbol;
|
|
10
|
+
declare const imageReferenceIdBrand: unique symbol;
|
|
11
|
+
declare const sensitiveProviderReferenceBrand: unique symbol;
|
|
12
|
+
/** A process-generated, non-provider artifact identifier. */
|
|
13
|
+
type ImageArtifactId = string & {
|
|
14
|
+
readonly [imageArtifactIdBrand]: true;
|
|
15
|
+
};
|
|
16
|
+
/** A random public reference ID scoped by the reference store to one tenant. */
|
|
17
|
+
type ImageReferenceId = string & {
|
|
18
|
+
readonly [imageReferenceIdBrand]: true;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* An opaque upstream reference. It is content-sensitive and must never be
|
|
22
|
+
* logged, serialized into telemetry, or exposed as a public file/reference ID.
|
|
23
|
+
*/
|
|
24
|
+
type SensitiveOpaqueImageReference = string & {
|
|
25
|
+
readonly [sensitiveProviderReferenceBrand]: 'sensitive-opaque-image-reference';
|
|
26
|
+
};
|
|
27
|
+
type ImageOutputFormat = 'png' | 'jpeg' | 'webp';
|
|
28
|
+
type ImageQuality = 'auto' | 'low' | 'medium' | 'high';
|
|
29
|
+
type ImageBackground = 'auto' | 'opaque' | 'transparent';
|
|
30
|
+
type ImageModeration = 'auto' | 'low';
|
|
31
|
+
type ImageAction = 'generate' | 'edit';
|
|
32
|
+
/** Truthful provider support for the numeric output_compression request. */
|
|
33
|
+
type ImageOutputCompressionCapability = {
|
|
34
|
+
readonly supported: false;
|
|
35
|
+
} | {
|
|
36
|
+
readonly supported: true;
|
|
37
|
+
readonly formats: readonly ImageOutputFormat[];
|
|
38
|
+
readonly min: number;
|
|
39
|
+
readonly max: number;
|
|
40
|
+
};
|
|
41
|
+
type ImageSize = {
|
|
42
|
+
readonly kind: 'auto';
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: 'pixels';
|
|
45
|
+
readonly width: number;
|
|
46
|
+
readonly height: number;
|
|
47
|
+
};
|
|
48
|
+
interface ImageRequestOptions {
|
|
49
|
+
readonly model: string;
|
|
50
|
+
readonly prompt: string;
|
|
51
|
+
readonly n: number;
|
|
52
|
+
readonly quality: ImageQuality;
|
|
53
|
+
readonly size: ImageSize;
|
|
54
|
+
readonly background: ImageBackground;
|
|
55
|
+
readonly outputFormat: ImageOutputFormat;
|
|
56
|
+
readonly outputCompression?: number;
|
|
57
|
+
readonly moderation: ImageModeration;
|
|
58
|
+
readonly stream: boolean;
|
|
59
|
+
readonly partialImages: number;
|
|
60
|
+
/** Optional irreversible digest created by the protocol frontend. */
|
|
61
|
+
readonly userFingerprint?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Trusted metadata shared by every normalized edit asset. */
|
|
64
|
+
interface ImageInputAsset {
|
|
65
|
+
readonly artifactId: ImageArtifactId;
|
|
66
|
+
readonly mimeType: `image/${string}`;
|
|
67
|
+
readonly byteLength: number;
|
|
68
|
+
readonly width: number;
|
|
69
|
+
readonly height: number;
|
|
70
|
+
readonly hasAlpha?: boolean;
|
|
71
|
+
readonly sha256?: string;
|
|
72
|
+
}
|
|
73
|
+
interface NormalizedImageGenerateRequest extends ImageRequestOptions {
|
|
74
|
+
readonly action: 'generate';
|
|
75
|
+
}
|
|
76
|
+
interface NormalizedImageEditRequest<TAsset extends ImageInputAsset = ImageInputAsset> extends ImageRequestOptions {
|
|
77
|
+
readonly action: 'edit';
|
|
78
|
+
readonly images: readonly TAsset[];
|
|
79
|
+
readonly mask?: TAsset;
|
|
80
|
+
}
|
|
81
|
+
type NormalizedImageRequest<TAsset extends ImageInputAsset = ImageInputAsset> = NormalizedImageGenerateRequest | NormalizedImageEditRequest<TAsset>;
|
|
82
|
+
/** Metadata for a complete, independently decodable image artifact. */
|
|
83
|
+
interface ImageArtifactMetadata extends ImageInputAsset {
|
|
84
|
+
readonly independentlyDecodable: true;
|
|
85
|
+
}
|
|
86
|
+
interface ImageProviderOutput<TArtifact extends ImageArtifactMetadata = ImageArtifactMetadata> {
|
|
87
|
+
readonly artifact: TArtifact;
|
|
88
|
+
/** Sensitive trusted-process state; callers must retain it behind a public ID. */
|
|
89
|
+
readonly providerReference?: SensitiveOpaqueImageReference;
|
|
90
|
+
readonly revisedPrompt?: string;
|
|
91
|
+
}
|
|
92
|
+
/** Image usage is truthful and optional; absent values are never defaulted to zero. */
|
|
93
|
+
interface ImageUsage {
|
|
94
|
+
readonly totalTokens?: number;
|
|
95
|
+
readonly inputTokens?: number;
|
|
96
|
+
readonly outputTokens?: number;
|
|
97
|
+
readonly inputTextTokens?: number;
|
|
98
|
+
readonly inputImageTokens?: number;
|
|
99
|
+
readonly outputImageTokens?: number;
|
|
100
|
+
readonly generatedImages?: number;
|
|
101
|
+
}
|
|
102
|
+
declare const IMAGE_GENERATION_ERROR_CODES: readonly ["invalid_image_request", "unsupported_model", "unsupported_capability", "invalid_api_key", "upstream_auth_required", "image_reference_not_found", "image_reference_expired", "image_too_large", "unsupported_image_type", "moderation_blocked", "upstream_rate_limited", "subscription_usage_limit_reached", "image_queue_full", "image_queue_timeout", "request_cancelled", "upstream_protocol_changed", "image_generation_failed", "image_generation_timeout"];
|
|
103
|
+
type ImageGenerationErrorCode = (typeof IMAGE_GENERATION_ERROR_CODES)[number];
|
|
104
|
+
type ImageRetrySafety = 'before_acceptance' | 'after_acceptance' | 'unknown';
|
|
105
|
+
type ImageModerationStage = 'input' | 'output';
|
|
106
|
+
interface ImageModerationDetails {
|
|
107
|
+
readonly stage?: ImageModerationStage;
|
|
108
|
+
/** Coarse, upstream-verified category names only; no scores are accepted. */
|
|
109
|
+
readonly categories?: readonly string[];
|
|
110
|
+
}
|
|
111
|
+
/** The only serializable error fields allowed across the image module boundary. */
|
|
112
|
+
interface ImageGenerationPublicError {
|
|
113
|
+
readonly type: 'image_generation_error' | 'image_generation_user_error';
|
|
114
|
+
readonly code: ImageGenerationErrorCode;
|
|
115
|
+
readonly message: string;
|
|
116
|
+
readonly param?: string;
|
|
117
|
+
readonly httpStatus?: number;
|
|
118
|
+
readonly retryAfterSeconds?: number;
|
|
119
|
+
readonly retrySafety?: ImageRetrySafety;
|
|
120
|
+
readonly moderationDetails?: ImageModerationDetails;
|
|
121
|
+
}
|
|
122
|
+
type ImageProviderAcceptedEvent = {
|
|
123
|
+
readonly type: 'accepted';
|
|
124
|
+
readonly acceptedAt: number;
|
|
125
|
+
};
|
|
126
|
+
type ImageProviderPartialImageEvent<TArtifact extends ImageArtifactMetadata = ImageArtifactMetadata> = {
|
|
127
|
+
readonly type: 'partial_image';
|
|
128
|
+
readonly outputIndex: number;
|
|
129
|
+
readonly partialImageIndex: number;
|
|
130
|
+
readonly image: ImageProviderOutput<TArtifact>;
|
|
131
|
+
};
|
|
132
|
+
type ImageProviderCompletedEvent<TArtifact extends ImageArtifactMetadata = ImageArtifactMetadata> = {
|
|
133
|
+
readonly type: 'completed';
|
|
134
|
+
readonly images: readonly ImageProviderOutput<TArtifact>[];
|
|
135
|
+
readonly usage?: ImageUsage;
|
|
136
|
+
/** Added by trusted retention, not by a private provider wire. */
|
|
137
|
+
readonly references?: readonly ImageReferenceMetadata[];
|
|
138
|
+
};
|
|
139
|
+
type ImageProviderFailedEvent = {
|
|
140
|
+
readonly type: 'failed';
|
|
141
|
+
readonly error: ImageGenerationPublicError;
|
|
142
|
+
};
|
|
143
|
+
type ImageProviderEvent<TArtifact extends ImageArtifactMetadata = ImageArtifactMetadata> = ImageProviderAcceptedEvent | ImageProviderPartialImageEvent<TArtifact> | ImageProviderCompletedEvent<TArtifact> | ImageProviderFailedEvent;
|
|
144
|
+
type ImageCapabilityLayerKind = 'adapter' | 'account' | 'upstream';
|
|
145
|
+
/** Every property is independently evidenced; omission means unknown. */
|
|
146
|
+
interface ImageCapabilityValues {
|
|
147
|
+
readonly available: boolean;
|
|
148
|
+
readonly models: readonly string[];
|
|
149
|
+
readonly generate: boolean;
|
|
150
|
+
readonly edit: boolean;
|
|
151
|
+
readonly maskEdit: boolean;
|
|
152
|
+
readonly maxInputImages: number;
|
|
153
|
+
readonly maxOutputImages: number;
|
|
154
|
+
readonly streaming: boolean;
|
|
155
|
+
readonly maxPartialImages: number;
|
|
156
|
+
readonly transparentBackground: boolean;
|
|
157
|
+
readonly flexibleSizes: boolean;
|
|
158
|
+
readonly outputFormats: readonly ImageOutputFormat[];
|
|
159
|
+
readonly qualityLevels: readonly ImageQuality[];
|
|
160
|
+
readonly moderationModes: readonly ImageModeration[];
|
|
161
|
+
readonly outputCompression: ImageOutputCompressionCapability;
|
|
162
|
+
readonly responsesTool: boolean;
|
|
163
|
+
readonly multiTurnEdit: boolean;
|
|
164
|
+
readonly supportsFileId: boolean;
|
|
165
|
+
readonly supportsImageUrl: boolean;
|
|
166
|
+
}
|
|
167
|
+
/** Trusted evidence. Sources must be descriptive, never an account identifier. */
|
|
168
|
+
interface ImageCapabilityEvidenceLayer {
|
|
169
|
+
readonly kind: ImageCapabilityLayerKind;
|
|
170
|
+
readonly source: string;
|
|
171
|
+
readonly verifiedAt?: number;
|
|
172
|
+
readonly expiresAt?: number;
|
|
173
|
+
readonly values?: Partial<ImageCapabilityValues>;
|
|
174
|
+
}
|
|
175
|
+
declare const IMAGE_CAPABILITY_UNAVAILABLE_REASONS: readonly ["missing_evidence", "stale_evidence", "contradictory_evidence", "adapter_unavailable", "account_unverified", "protocol_unverified", "no_common_models", "no_common_output_formats", "no_common_quality_levels", "no_common_moderation_modes"];
|
|
176
|
+
type ImageCapabilityUnavailableReason = (typeof IMAGE_CAPABILITY_UNAVAILABLE_REASONS)[number];
|
|
177
|
+
/** Safe resolved snapshot. Raw account/protocol evidence never leaves the provider. */
|
|
178
|
+
interface ImageCapabilities extends ImageCapabilityValues {
|
|
179
|
+
readonly reason?: ImageCapabilityUnavailableReason;
|
|
180
|
+
readonly resolvedAt: number;
|
|
181
|
+
readonly oldestEvidenceAt?: number;
|
|
182
|
+
}
|
|
183
|
+
interface ImageReferenceMetadata {
|
|
184
|
+
readonly referenceId: ImageReferenceId;
|
|
185
|
+
readonly createdAt: number;
|
|
186
|
+
readonly expiresAt: number;
|
|
187
|
+
readonly mimeType: `image/${string}`;
|
|
188
|
+
readonly byteLength: number;
|
|
189
|
+
readonly width: number;
|
|
190
|
+
readonly height: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export { IMAGE_CAPABILITY_UNAVAILABLE_REASONS, IMAGE_GENERATION_ERROR_CODES, type ImageAction, type ImageArtifactId, type ImageArtifactMetadata, type ImageBackground, type ImageCapabilities, type ImageCapabilityEvidenceLayer, type ImageCapabilityLayerKind, type ImageCapabilityUnavailableReason, type ImageCapabilityValues, type ImageGenerationErrorCode, type ImageGenerationPublicError, type ImageInputAsset, type ImageModeration, type ImageModerationDetails, type ImageModerationStage, type ImageOutputCompressionCapability, type ImageOutputFormat, type ImageProviderAcceptedEvent, type ImageProviderCompletedEvent, type ImageProviderEvent, type ImageProviderFailedEvent, type ImageProviderOutput, type ImageProviderPartialImageEvent, type ImageQuality, type ImageReferenceId, type ImageReferenceMetadata, type ImageRequestOptions, type ImageRetrySafety, type ImageSize, type ImageUsage, type NormalizedImageEditRequest, type NormalizedImageGenerateRequest, type NormalizedImageRequest, type SensitiveOpaqueImageReference };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral image generation vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* This module intentionally contains no HTTP, filesystem, credential, or
|
|
5
|
+
* ChatGPT/Codex private-wire types. Binary access is supplied by the core
|
|
6
|
+
* image-generation module through an asset type that extends
|
|
7
|
+
* {@link ImageInputAsset} / {@link ImageArtifactMetadata}.
|
|
8
|
+
*/
|
|
9
|
+
declare const imageArtifactIdBrand: unique symbol;
|
|
10
|
+
declare const imageReferenceIdBrand: unique symbol;
|
|
11
|
+
declare const sensitiveProviderReferenceBrand: unique symbol;
|
|
12
|
+
/** A process-generated, non-provider artifact identifier. */
|
|
13
|
+
type ImageArtifactId = string & {
|
|
14
|
+
readonly [imageArtifactIdBrand]: true;
|
|
15
|
+
};
|
|
16
|
+
/** A random public reference ID scoped by the reference store to one tenant. */
|
|
17
|
+
type ImageReferenceId = string & {
|
|
18
|
+
readonly [imageReferenceIdBrand]: true;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* An opaque upstream reference. It is content-sensitive and must never be
|
|
22
|
+
* logged, serialized into telemetry, or exposed as a public file/reference ID.
|
|
23
|
+
*/
|
|
24
|
+
type SensitiveOpaqueImageReference = string & {
|
|
25
|
+
readonly [sensitiveProviderReferenceBrand]: 'sensitive-opaque-image-reference';
|
|
26
|
+
};
|
|
27
|
+
type ImageOutputFormat = 'png' | 'jpeg' | 'webp';
|
|
28
|
+
type ImageQuality = 'auto' | 'low' | 'medium' | 'high';
|
|
29
|
+
type ImageBackground = 'auto' | 'opaque' | 'transparent';
|
|
30
|
+
type ImageModeration = 'auto' | 'low';
|
|
31
|
+
type ImageAction = 'generate' | 'edit';
|
|
32
|
+
/** Truthful provider support for the numeric output_compression request. */
|
|
33
|
+
type ImageOutputCompressionCapability = {
|
|
34
|
+
readonly supported: false;
|
|
35
|
+
} | {
|
|
36
|
+
readonly supported: true;
|
|
37
|
+
readonly formats: readonly ImageOutputFormat[];
|
|
38
|
+
readonly min: number;
|
|
39
|
+
readonly max: number;
|
|
40
|
+
};
|
|
41
|
+
type ImageSize = {
|
|
42
|
+
readonly kind: 'auto';
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: 'pixels';
|
|
45
|
+
readonly width: number;
|
|
46
|
+
readonly height: number;
|
|
47
|
+
};
|
|
48
|
+
interface ImageRequestOptions {
|
|
49
|
+
readonly model: string;
|
|
50
|
+
readonly prompt: string;
|
|
51
|
+
readonly n: number;
|
|
52
|
+
readonly quality: ImageQuality;
|
|
53
|
+
readonly size: ImageSize;
|
|
54
|
+
readonly background: ImageBackground;
|
|
55
|
+
readonly outputFormat: ImageOutputFormat;
|
|
56
|
+
readonly outputCompression?: number;
|
|
57
|
+
readonly moderation: ImageModeration;
|
|
58
|
+
readonly stream: boolean;
|
|
59
|
+
readonly partialImages: number;
|
|
60
|
+
/** Optional irreversible digest created by the protocol frontend. */
|
|
61
|
+
readonly userFingerprint?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Trusted metadata shared by every normalized edit asset. */
|
|
64
|
+
interface ImageInputAsset {
|
|
65
|
+
readonly artifactId: ImageArtifactId;
|
|
66
|
+
readonly mimeType: `image/${string}`;
|
|
67
|
+
readonly byteLength: number;
|
|
68
|
+
readonly width: number;
|
|
69
|
+
readonly height: number;
|
|
70
|
+
readonly hasAlpha?: boolean;
|
|
71
|
+
readonly sha256?: string;
|
|
72
|
+
}
|
|
73
|
+
interface NormalizedImageGenerateRequest extends ImageRequestOptions {
|
|
74
|
+
readonly action: 'generate';
|
|
75
|
+
}
|
|
76
|
+
interface NormalizedImageEditRequest<TAsset extends ImageInputAsset = ImageInputAsset> extends ImageRequestOptions {
|
|
77
|
+
readonly action: 'edit';
|
|
78
|
+
readonly images: readonly TAsset[];
|
|
79
|
+
readonly mask?: TAsset;
|
|
80
|
+
}
|
|
81
|
+
type NormalizedImageRequest<TAsset extends ImageInputAsset = ImageInputAsset> = NormalizedImageGenerateRequest | NormalizedImageEditRequest<TAsset>;
|
|
82
|
+
/** Metadata for a complete, independently decodable image artifact. */
|
|
83
|
+
interface ImageArtifactMetadata extends ImageInputAsset {
|
|
84
|
+
readonly independentlyDecodable: true;
|
|
85
|
+
}
|
|
86
|
+
interface ImageProviderOutput<TArtifact extends ImageArtifactMetadata = ImageArtifactMetadata> {
|
|
87
|
+
readonly artifact: TArtifact;
|
|
88
|
+
/** Sensitive trusted-process state; callers must retain it behind a public ID. */
|
|
89
|
+
readonly providerReference?: SensitiveOpaqueImageReference;
|
|
90
|
+
readonly revisedPrompt?: string;
|
|
91
|
+
}
|
|
92
|
+
/** Image usage is truthful and optional; absent values are never defaulted to zero. */
|
|
93
|
+
interface ImageUsage {
|
|
94
|
+
readonly totalTokens?: number;
|
|
95
|
+
readonly inputTokens?: number;
|
|
96
|
+
readonly outputTokens?: number;
|
|
97
|
+
readonly inputTextTokens?: number;
|
|
98
|
+
readonly inputImageTokens?: number;
|
|
99
|
+
readonly outputImageTokens?: number;
|
|
100
|
+
readonly generatedImages?: number;
|
|
101
|
+
}
|
|
102
|
+
declare const IMAGE_GENERATION_ERROR_CODES: readonly ["invalid_image_request", "unsupported_model", "unsupported_capability", "invalid_api_key", "upstream_auth_required", "image_reference_not_found", "image_reference_expired", "image_too_large", "unsupported_image_type", "moderation_blocked", "upstream_rate_limited", "subscription_usage_limit_reached", "image_queue_full", "image_queue_timeout", "request_cancelled", "upstream_protocol_changed", "image_generation_failed", "image_generation_timeout"];
|
|
103
|
+
type ImageGenerationErrorCode = (typeof IMAGE_GENERATION_ERROR_CODES)[number];
|
|
104
|
+
type ImageRetrySafety = 'before_acceptance' | 'after_acceptance' | 'unknown';
|
|
105
|
+
type ImageModerationStage = 'input' | 'output';
|
|
106
|
+
interface ImageModerationDetails {
|
|
107
|
+
readonly stage?: ImageModerationStage;
|
|
108
|
+
/** Coarse, upstream-verified category names only; no scores are accepted. */
|
|
109
|
+
readonly categories?: readonly string[];
|
|
110
|
+
}
|
|
111
|
+
/** The only serializable error fields allowed across the image module boundary. */
|
|
112
|
+
interface ImageGenerationPublicError {
|
|
113
|
+
readonly type: 'image_generation_error' | 'image_generation_user_error';
|
|
114
|
+
readonly code: ImageGenerationErrorCode;
|
|
115
|
+
readonly message: string;
|
|
116
|
+
readonly param?: string;
|
|
117
|
+
readonly httpStatus?: number;
|
|
118
|
+
readonly retryAfterSeconds?: number;
|
|
119
|
+
readonly retrySafety?: ImageRetrySafety;
|
|
120
|
+
readonly moderationDetails?: ImageModerationDetails;
|
|
121
|
+
}
|
|
122
|
+
type ImageProviderAcceptedEvent = {
|
|
123
|
+
readonly type: 'accepted';
|
|
124
|
+
readonly acceptedAt: number;
|
|
125
|
+
};
|
|
126
|
+
type ImageProviderPartialImageEvent<TArtifact extends ImageArtifactMetadata = ImageArtifactMetadata> = {
|
|
127
|
+
readonly type: 'partial_image';
|
|
128
|
+
readonly outputIndex: number;
|
|
129
|
+
readonly partialImageIndex: number;
|
|
130
|
+
readonly image: ImageProviderOutput<TArtifact>;
|
|
131
|
+
};
|
|
132
|
+
type ImageProviderCompletedEvent<TArtifact extends ImageArtifactMetadata = ImageArtifactMetadata> = {
|
|
133
|
+
readonly type: 'completed';
|
|
134
|
+
readonly images: readonly ImageProviderOutput<TArtifact>[];
|
|
135
|
+
readonly usage?: ImageUsage;
|
|
136
|
+
/** Added by trusted retention, not by a private provider wire. */
|
|
137
|
+
readonly references?: readonly ImageReferenceMetadata[];
|
|
138
|
+
};
|
|
139
|
+
type ImageProviderFailedEvent = {
|
|
140
|
+
readonly type: 'failed';
|
|
141
|
+
readonly error: ImageGenerationPublicError;
|
|
142
|
+
};
|
|
143
|
+
type ImageProviderEvent<TArtifact extends ImageArtifactMetadata = ImageArtifactMetadata> = ImageProviderAcceptedEvent | ImageProviderPartialImageEvent<TArtifact> | ImageProviderCompletedEvent<TArtifact> | ImageProviderFailedEvent;
|
|
144
|
+
type ImageCapabilityLayerKind = 'adapter' | 'account' | 'upstream';
|
|
145
|
+
/** Every property is independently evidenced; omission means unknown. */
|
|
146
|
+
interface ImageCapabilityValues {
|
|
147
|
+
readonly available: boolean;
|
|
148
|
+
readonly models: readonly string[];
|
|
149
|
+
readonly generate: boolean;
|
|
150
|
+
readonly edit: boolean;
|
|
151
|
+
readonly maskEdit: boolean;
|
|
152
|
+
readonly maxInputImages: number;
|
|
153
|
+
readonly maxOutputImages: number;
|
|
154
|
+
readonly streaming: boolean;
|
|
155
|
+
readonly maxPartialImages: number;
|
|
156
|
+
readonly transparentBackground: boolean;
|
|
157
|
+
readonly flexibleSizes: boolean;
|
|
158
|
+
readonly outputFormats: readonly ImageOutputFormat[];
|
|
159
|
+
readonly qualityLevels: readonly ImageQuality[];
|
|
160
|
+
readonly moderationModes: readonly ImageModeration[];
|
|
161
|
+
readonly outputCompression: ImageOutputCompressionCapability;
|
|
162
|
+
readonly responsesTool: boolean;
|
|
163
|
+
readonly multiTurnEdit: boolean;
|
|
164
|
+
readonly supportsFileId: boolean;
|
|
165
|
+
readonly supportsImageUrl: boolean;
|
|
166
|
+
}
|
|
167
|
+
/** Trusted evidence. Sources must be descriptive, never an account identifier. */
|
|
168
|
+
interface ImageCapabilityEvidenceLayer {
|
|
169
|
+
readonly kind: ImageCapabilityLayerKind;
|
|
170
|
+
readonly source: string;
|
|
171
|
+
readonly verifiedAt?: number;
|
|
172
|
+
readonly expiresAt?: number;
|
|
173
|
+
readonly values?: Partial<ImageCapabilityValues>;
|
|
174
|
+
}
|
|
175
|
+
declare const IMAGE_CAPABILITY_UNAVAILABLE_REASONS: readonly ["missing_evidence", "stale_evidence", "contradictory_evidence", "adapter_unavailable", "account_unverified", "protocol_unverified", "no_common_models", "no_common_output_formats", "no_common_quality_levels", "no_common_moderation_modes"];
|
|
176
|
+
type ImageCapabilityUnavailableReason = (typeof IMAGE_CAPABILITY_UNAVAILABLE_REASONS)[number];
|
|
177
|
+
/** Safe resolved snapshot. Raw account/protocol evidence never leaves the provider. */
|
|
178
|
+
interface ImageCapabilities extends ImageCapabilityValues {
|
|
179
|
+
readonly reason?: ImageCapabilityUnavailableReason;
|
|
180
|
+
readonly resolvedAt: number;
|
|
181
|
+
readonly oldestEvidenceAt?: number;
|
|
182
|
+
}
|
|
183
|
+
interface ImageReferenceMetadata {
|
|
184
|
+
readonly referenceId: ImageReferenceId;
|
|
185
|
+
readonly createdAt: number;
|
|
186
|
+
readonly expiresAt: number;
|
|
187
|
+
readonly mimeType: `image/${string}`;
|
|
188
|
+
readonly byteLength: number;
|
|
189
|
+
readonly width: number;
|
|
190
|
+
readonly height: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export { IMAGE_CAPABILITY_UNAVAILABLE_REASONS, IMAGE_GENERATION_ERROR_CODES, type ImageAction, type ImageArtifactId, type ImageArtifactMetadata, type ImageBackground, type ImageCapabilities, type ImageCapabilityEvidenceLayer, type ImageCapabilityLayerKind, type ImageCapabilityUnavailableReason, type ImageCapabilityValues, type ImageGenerationErrorCode, type ImageGenerationPublicError, type ImageInputAsset, type ImageModeration, type ImageModerationDetails, type ImageModerationStage, type ImageOutputCompressionCapability, type ImageOutputFormat, type ImageProviderAcceptedEvent, type ImageProviderCompletedEvent, type ImageProviderEvent, type ImageProviderFailedEvent, type ImageProviderOutput, type ImageProviderPartialImageEvent, type ImageQuality, type ImageReferenceId, type ImageReferenceMetadata, type ImageRequestOptions, type ImageRetrySafety, type ImageSize, type ImageUsage, type NormalizedImageEditRequest, type NormalizedImageGenerateRequest, type NormalizedImageRequest, type SensitiveOpaqueImageReference };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/image-generation-types.ts
|
|
2
|
+
var IMAGE_GENERATION_ERROR_CODES = [
|
|
3
|
+
"invalid_image_request",
|
|
4
|
+
"unsupported_model",
|
|
5
|
+
"unsupported_capability",
|
|
6
|
+
"invalid_api_key",
|
|
7
|
+
"upstream_auth_required",
|
|
8
|
+
"image_reference_not_found",
|
|
9
|
+
"image_reference_expired",
|
|
10
|
+
"image_too_large",
|
|
11
|
+
"unsupported_image_type",
|
|
12
|
+
"moderation_blocked",
|
|
13
|
+
"upstream_rate_limited",
|
|
14
|
+
"subscription_usage_limit_reached",
|
|
15
|
+
"image_queue_full",
|
|
16
|
+
"image_queue_timeout",
|
|
17
|
+
"request_cancelled",
|
|
18
|
+
"upstream_protocol_changed",
|
|
19
|
+
"image_generation_failed",
|
|
20
|
+
"image_generation_timeout"
|
|
21
|
+
];
|
|
22
|
+
var IMAGE_CAPABILITY_UNAVAILABLE_REASONS = [
|
|
23
|
+
"missing_evidence",
|
|
24
|
+
"stale_evidence",
|
|
25
|
+
"contradictory_evidence",
|
|
26
|
+
"adapter_unavailable",
|
|
27
|
+
"account_unverified",
|
|
28
|
+
"protocol_unverified",
|
|
29
|
+
"no_common_models",
|
|
30
|
+
"no_common_output_formats",
|
|
31
|
+
"no_common_quality_levels",
|
|
32
|
+
"no_common_moderation_modes"
|
|
33
|
+
];
|
|
34
|
+
export {
|
|
35
|
+
IMAGE_CAPABILITY_UNAVAILABLE_REASONS,
|
|
36
|
+
IMAGE_GENERATION_ERROR_CODES
|
|
37
|
+
};
|