bleam 0.0.10 → 0.0.12
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/ai.cjs +1872 -1182
- package/dist/ai.d.cts +267 -234
- package/dist/ai.d.ts +267 -234
- package/dist/ai.js +1859 -1167
- package/dist/cli.cjs +3 -183
- package/dist/cli.d.cts +3 -47
- package/dist/cli.d.ts +3 -47
- package/dist/cli.js +3 -183
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{files-Ds1wT8C2.js → files-BXVkPrPN.js} +6 -1
- package/dist/{files-Bo7h9fik.cjs → files-DxaQ-Nv0.cjs} +11 -0
- package/dist/files.cjs +1 -1
- package/dist/files.js +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/platform.cjs +1 -13
- package/dist/platform.d.cts +1 -28
- package/dist/platform.d.ts +1 -28
- package/dist/platform.js +1 -10
- package/dist/schema-B5BfdswF.js +226 -0
- package/dist/schema-BnVZOXfu.cjs +286 -0
- package/dist/schema-D5eImHxu.d.cts +125 -0
- package/dist/schema-SSjokbtw.d.ts +125 -0
- package/dist/schema.cjs +10 -2
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +2 -2
- package/dist/state-Dh3HLixb.js +874 -0
- package/dist/state-LssDgpff.cjs +973 -0
- package/dist/state.cjs +16 -12
- package/dist/state.d.cts +144 -140
- package/dist/state.d.ts +145 -140
- package/dist/state.js +3 -3
- package/dist/{ui-Bg11tvlc.d.ts → ui-1WepaMS4.d.cts} +1 -1
- package/dist/{ui-Dd7SXdbg.d.cts → ui-D7bRLYee.d.ts} +7 -7
- package/dist/ui.d.cts +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/window.d.cts +1 -1
- package/dist/window.d.ts +1 -1
- package/package.json +3 -1
- package/templates/foundation-models/app/index.tsx +77 -15
- package/templates/image-generation/app/index.tsx +4 -2
- package/templates/native/ios/Bleam/AI/Flux2/Configuration/ModelRegistry.swift +1 -1
- package/templates/native/ios/Bleam/AI/Flux2/Pipeline/FluxImageRunner.swift +7 -2
- package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextGenerator.swift +46 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextModel.swift +107 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextSnapshotValidator.swift +201 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Core/GenerationTypes.swift +85 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Core/ModelCapabilities.swift +21 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Core/TextKVCache.swift +23 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Core/TokenSampler.swift +79 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3CheckpointLoader.swift +161 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Configuration.swift +119 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3InferenceSession.swift +84 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Layers.swift +197 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Model.swift +130 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Checkpoint.swift +102 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Configuration.swift +140 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Model.swift +112 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Session.swift +121 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridCache.swift +42 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridFullAttention.swift +57 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridLayers.swift +58 -0
- package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridLinearAttention.swift +111 -0
- package/templates/native/ios/Bleam/AppDelegate.swift +0 -206
- package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +135 -129
- package/templates/native/ios/GenerationService/BonsaiTextGenerationRunner.swift +103 -0
- package/templates/native/ios/GenerationService/ImageGenerationRunner.swift +19 -7
- package/templates/native/ios/GenerationService/main.swift +174 -48
- package/templates/native/ios/Podfile.lock +173 -173
- package/templates/native/ios/Shared/Generation/GenerationServiceProtocol.swift +3 -0
- package/templates/native/ios/Shared/Generation/GenerationWorkerProtocol.swift +44 -0
- package/templates/native/modules/bleam-runtime/ios/AIModule.swift +239 -341
- package/templates/native/modules/bleam-runtime/ios/GenerationContracts.swift +47 -0
- package/templates/native/modules/bleam-runtime/ios/PlatformModule.swift +0 -191
- package/templates/text-generation/app/index.tsx +124 -0
- package/templates/text-generation/app.config.ts +5 -0
- package/templates/updates/README.md +43 -199
- package/templates/updates/src/index.ts +5 -98
- package/templates/updates/src/schema.ts +18 -173
- package/dist/schema-Bo5Jvqus.js +0 -90
- package/dist/schema-DOOjfXvs.d.ts +0 -58
- package/dist/schema-ENSMX_1t.d.cts +0 -58
- package/dist/schema-rQ13mrpD.cjs +0 -102
- package/dist/state-Bx0VlTlO.cjs +0 -852
- package/dist/state-CAwe-Vw1.js +0 -767
- package/templates/native/ios/PlatformHelper/main.swift +0 -726
- /package/dist/{config-Cms0rvqg.d.ts → config-COcRnn5a.d.cts} +0 -0
- /package/dist/{config-CufOVJV3.d.cts → config-Chi-flpJ.d.ts} +0 -0
package/dist/ai.d.ts
CHANGED
|
@@ -1,6 +1,197 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { h as StandardSchema, p as SchemaResult, s as InferOutput } from "./schema-DOOjfXvs.js";
|
|
1
|
+
import "./files-VrkQlKIT.js";
|
|
3
2
|
|
|
3
|
+
//#region src/ai/bonsai.d.ts
|
|
4
|
+
type BonsaiTextModelId = 'ternary-bonsai-1.7b' | 'ternary-bonsai-4b' | 'ternary-bonsai-8b' | 'ternary-bonsai-27b';
|
|
5
|
+
type BonsaiImageModelId = 'ternary-bonsai-image-4b';
|
|
6
|
+
type BonsaiTextModel<Id extends BonsaiTextModelId = BonsaiTextModelId> = Readonly<{
|
|
7
|
+
provider: 'bonsai';
|
|
8
|
+
kind: 'text';
|
|
9
|
+
id: Id;
|
|
10
|
+
}>;
|
|
11
|
+
type BonsaiImageModel<Id extends BonsaiImageModelId = BonsaiImageModelId> = Readonly<{
|
|
12
|
+
provider: 'bonsai';
|
|
13
|
+
kind: 'image';
|
|
14
|
+
id: Id;
|
|
15
|
+
}>;
|
|
16
|
+
type BonsaiModel = BonsaiTextModel | BonsaiImageModel;
|
|
17
|
+
type BonsaiTextModelMetadata = Readonly<{
|
|
18
|
+
id: BonsaiTextModelId;
|
|
19
|
+
repo: string;
|
|
20
|
+
revision: string;
|
|
21
|
+
estimatedDownloadBytes: number;
|
|
22
|
+
contextLength: number;
|
|
23
|
+
}>;
|
|
24
|
+
declare const bonsaiTextModelCatalog: readonly BonsaiTextModelMetadata[];
|
|
25
|
+
declare function bonsai<const Id extends BonsaiTextModelId>(id: Id): BonsaiTextModel<Id>;
|
|
26
|
+
declare function bonsai<const Id extends BonsaiImageModelId>(id: Id): BonsaiImageModel<Id>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/ai/bonsai-text.d.ts
|
|
29
|
+
declare const bonsaiTextModelFiles: readonly ["config.json", "tokenizer.json", "tokenizer_config.json", "chat_template.jinja", "model.safetensors", "model.safetensors.index.json"];
|
|
30
|
+
type BonsaiTextModelFile = (typeof bonsaiTextModelFiles)[number];
|
|
31
|
+
type PrepareBonsaiTextModelProgress = Readonly<{
|
|
32
|
+
model: BonsaiTextModelId;
|
|
33
|
+
file: BonsaiTextModelFile;
|
|
34
|
+
index: number;
|
|
35
|
+
total: number;
|
|
36
|
+
bytesWritten: number;
|
|
37
|
+
totalBytes?: number;
|
|
38
|
+
fraction?: number;
|
|
39
|
+
modelBytesWritten: number;
|
|
40
|
+
estimatedModelBytes: number;
|
|
41
|
+
modelFraction: number;
|
|
42
|
+
}>;
|
|
43
|
+
type PrepareBonsaiTextModelOptions = Readonly<{
|
|
44
|
+
accessToken?: string;
|
|
45
|
+
directory?: string;
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
onProgress?: (progress: PrepareBonsaiTextModelProgress) => void;
|
|
48
|
+
}>;
|
|
49
|
+
type PreparedBonsaiTextModel = Readonly<{
|
|
50
|
+
model: BonsaiTextModel;
|
|
51
|
+
path: string;
|
|
52
|
+
}>;
|
|
53
|
+
type BonsaiTextModelState = Readonly<{
|
|
54
|
+
model: BonsaiTextModel;
|
|
55
|
+
metadata: BonsaiTextModelMetadata;
|
|
56
|
+
path: string;
|
|
57
|
+
installed: boolean;
|
|
58
|
+
verified: boolean;
|
|
59
|
+
bytesPresent: number;
|
|
60
|
+
estimatedTotalBytes: number;
|
|
61
|
+
missingFiles: readonly string[];
|
|
62
|
+
invalidFiles: readonly string[];
|
|
63
|
+
}>;
|
|
64
|
+
type ModelInput = BonsaiTextModelId | BonsaiTextModel;
|
|
65
|
+
declare function prepareBonsaiTextModel(model: ModelInput, options?: PrepareBonsaiTextModelOptions): Promise<PreparedBonsaiTextModel>;
|
|
66
|
+
declare function verifyBonsaiTextModel(model: ModelInput, options?: Readonly<{
|
|
67
|
+
path?: string;
|
|
68
|
+
}>): Promise<Readonly<{
|
|
69
|
+
model: BonsaiTextModel;
|
|
70
|
+
metadata: BonsaiTextModelMetadata;
|
|
71
|
+
path: string;
|
|
72
|
+
installed: boolean;
|
|
73
|
+
verified: boolean;
|
|
74
|
+
bytesPresent: number;
|
|
75
|
+
estimatedTotalBytes: number;
|
|
76
|
+
missingFiles: readonly string[];
|
|
77
|
+
invalidFiles: readonly string[];
|
|
78
|
+
}>>;
|
|
79
|
+
declare function listBonsaiTextModels(options?: Readonly<{
|
|
80
|
+
directory?: string;
|
|
81
|
+
}>): Promise<Readonly<{
|
|
82
|
+
model: BonsaiTextModel;
|
|
83
|
+
metadata: BonsaiTextModelMetadata;
|
|
84
|
+
path: string;
|
|
85
|
+
installed: boolean;
|
|
86
|
+
verified: boolean;
|
|
87
|
+
bytesPresent: number;
|
|
88
|
+
estimatedTotalBytes: number;
|
|
89
|
+
missingFiles: readonly string[];
|
|
90
|
+
invalidFiles: readonly string[];
|
|
91
|
+
}>[]>;
|
|
92
|
+
declare function deleteBonsaiTextModel(model: ModelInput, options?: Readonly<{
|
|
93
|
+
path?: string;
|
|
94
|
+
}>): Promise<void>;
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/ai/chat-models.d.ts
|
|
97
|
+
type ChatStatus = 'ready' | 'queued' | 'generating' | 'canceling' | 'failed' | 'canceled';
|
|
98
|
+
type AssistantMessageStatus = 'queued' | 'generating' | 'canceling' | 'completed' | 'failed' | 'canceled';
|
|
99
|
+
type ChatError = {
|
|
100
|
+
name: string;
|
|
101
|
+
message: string;
|
|
102
|
+
code?: string;
|
|
103
|
+
stage?: string;
|
|
104
|
+
};
|
|
105
|
+
type Chat = {
|
|
106
|
+
id: string;
|
|
107
|
+
title: string;
|
|
108
|
+
status: ChatStatus;
|
|
109
|
+
createdAt: string;
|
|
110
|
+
updatedAt: string;
|
|
111
|
+
};
|
|
112
|
+
type ChatSummary = Chat;
|
|
113
|
+
type ChatMessageBase = {
|
|
114
|
+
id: string;
|
|
115
|
+
chatId: string;
|
|
116
|
+
content: string;
|
|
117
|
+
sequence: number;
|
|
118
|
+
attempt: number;
|
|
119
|
+
createdAt: string;
|
|
120
|
+
updatedAt: string;
|
|
121
|
+
startedAt?: string;
|
|
122
|
+
completedAt?: string;
|
|
123
|
+
error?: ChatError;
|
|
124
|
+
};
|
|
125
|
+
type UserChatMessage = ChatMessageBase & {
|
|
126
|
+
role: 'user';
|
|
127
|
+
status: 'completed';
|
|
128
|
+
};
|
|
129
|
+
type AssistantChatMessage = ChatMessageBase & {
|
|
130
|
+
role: 'assistant';
|
|
131
|
+
status: AssistantMessageStatus;
|
|
132
|
+
};
|
|
133
|
+
type ChatMessage = UserChatMessage | AssistantChatMessage;
|
|
134
|
+
type FoundationChatGenerationOptions = {
|
|
135
|
+
model?: never;
|
|
136
|
+
path?: never;
|
|
137
|
+
system?: string;
|
|
138
|
+
temperature?: number;
|
|
139
|
+
maxTokens?: number;
|
|
140
|
+
seed?: never;
|
|
141
|
+
};
|
|
142
|
+
type BonsaiChatGenerationOptions = {
|
|
143
|
+
model: BonsaiTextModel;
|
|
144
|
+
path?: string;
|
|
145
|
+
system?: string;
|
|
146
|
+
temperature?: number;
|
|
147
|
+
maxTokens?: number;
|
|
148
|
+
seed?: number;
|
|
149
|
+
};
|
|
150
|
+
type ChatGenerationOptions = FoundationChatGenerationOptions | BonsaiChatGenerationOptions;
|
|
151
|
+
type UseChatOptions = ChatGenerationOptions & {
|
|
152
|
+
onFinish?: (message: AssistantChatMessage) => void;
|
|
153
|
+
onError?: (error: ChatError) => void;
|
|
154
|
+
};
|
|
155
|
+
type ChatRunOptions = {
|
|
156
|
+
signal?: AbortSignal;
|
|
157
|
+
};
|
|
158
|
+
type ChatSendOptions = ChatGenerationOptions & ChatRunOptions;
|
|
159
|
+
type SendChatResult = {
|
|
160
|
+
chatId: string;
|
|
161
|
+
userMessageId: string;
|
|
162
|
+
assistantMessageId: string;
|
|
163
|
+
};
|
|
164
|
+
type UseChatResult = {
|
|
165
|
+
chat: Chat | null;
|
|
166
|
+
messages: readonly ChatMessage[];
|
|
167
|
+
status: ChatStatus | 'not-found';
|
|
168
|
+
error: ChatError | null;
|
|
169
|
+
isGenerating: boolean;
|
|
170
|
+
canSend: boolean;
|
|
171
|
+
canCancel: boolean;
|
|
172
|
+
send(content: string, options?: ChatRunOptions): Promise<SendChatResult>;
|
|
173
|
+
cancel(): Promise<boolean>;
|
|
174
|
+
retry(messageId: string, options?: ChatRunOptions): Promise<SendChatResult>;
|
|
175
|
+
setTitle(title: string): Promise<Chat>;
|
|
176
|
+
remove(): Promise<boolean>;
|
|
177
|
+
};
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/ai/chat.d.ts
|
|
180
|
+
declare const chat: {
|
|
181
|
+
create(input?: {
|
|
182
|
+
title?: string;
|
|
183
|
+
}): Promise<Chat>;
|
|
184
|
+
get(id: string): Promise<Chat | null>;
|
|
185
|
+
list(): Promise<readonly Chat[]>;
|
|
186
|
+
send(id: string, content: string, options?: ChatSendOptions): Promise<SendChatResult>;
|
|
187
|
+
cancel(id: string): Promise<boolean>;
|
|
188
|
+
retry(id: string, messageId: string, options?: ChatSendOptions): Promise<SendChatResult>;
|
|
189
|
+
setTitle(id: string, title: string): Promise<Chat>;
|
|
190
|
+
remove(id: string): Promise<boolean>;
|
|
191
|
+
};
|
|
192
|
+
declare function useChat(id: string, options?: UseChatOptions): UseChatResult;
|
|
193
|
+
declare function useChatList(): readonly ChatSummary[];
|
|
194
|
+
//#endregion
|
|
4
195
|
//#region src/ai/errors.d.ts
|
|
5
196
|
type AIErrorCode = 'unsupported_runtime' | 'unsupported_os' | 'model_unavailable' | 'generation_failed' | 'generation_canceled' | 'concurrent_request' | 'guardrail_violation' | 'unsupported_language_or_locale' | 'rate_limited' | 'tool_failed' | 'image_generation_failed' | 'invalid_message' | 'invalid_schema' | 'invalid_model' | 'validation_failed' | 'context_window_exceeded';
|
|
6
197
|
type ImageGenerationStage = 'download' | 'tokenize' | 'encode' | 'denoise' | 'decode' | 'write';
|
|
@@ -19,19 +210,21 @@ declare class ImageGenerationError extends AIError {
|
|
|
19
210
|
//#endregion
|
|
20
211
|
//#region src/ai/image-models.d.ts
|
|
21
212
|
type FluxImageModelId = 'flux2-klein-4b-8bit-abliterated';
|
|
213
|
+
type ImageModelId = FluxImageModelId | 'ternary-bonsai-image-4b';
|
|
214
|
+
type ImageModel = ImageModelId | BonsaiImageModel;
|
|
22
215
|
type ImageModelCapability = 'text-to-image' | 'image-to-image' | 'inpainting' | 'outpainting' | 'references' | 'lora';
|
|
23
216
|
type ImageModelMetadata = {
|
|
24
217
|
displayName: string;
|
|
25
|
-
family: 'flux2-klein';
|
|
26
|
-
precision: '8-bit';
|
|
218
|
+
family: 'flux2-klein' | 'bonsai-image';
|
|
219
|
+
precision: '8-bit' | '2-bit';
|
|
27
220
|
estimatedMemoryGB: number;
|
|
28
221
|
quality: 'high';
|
|
29
222
|
speed: 'fast';
|
|
30
223
|
capabilities: ImageModelCapability[];
|
|
31
224
|
};
|
|
32
|
-
type
|
|
225
|
+
type ImageModelManifest = {
|
|
33
226
|
formatVersion: 1;
|
|
34
|
-
model:
|
|
227
|
+
model: ImageModelId;
|
|
35
228
|
directory: string;
|
|
36
229
|
metadata: ImageModelMetadata;
|
|
37
230
|
components: {
|
|
@@ -40,6 +233,9 @@ type FluxImageModelManifest = {
|
|
|
40
233
|
vae: FluxModelComponentManifest;
|
|
41
234
|
};
|
|
42
235
|
};
|
|
236
|
+
type FluxImageModelManifest = ImageModelManifest & {
|
|
237
|
+
model: FluxImageModelId;
|
|
238
|
+
};
|
|
43
239
|
type FluxModelComponentManifest = {
|
|
44
240
|
repo: string;
|
|
45
241
|
revision: string;
|
|
@@ -51,13 +247,13 @@ type FluxTokenizedPrompt = {
|
|
|
51
247
|
attentionMask: number[];
|
|
52
248
|
};
|
|
53
249
|
type FluxImageModelPaths = {
|
|
54
|
-
|
|
250
|
+
path: string;
|
|
55
251
|
textEncoderPath: string;
|
|
56
252
|
transformerPath: string;
|
|
57
253
|
vaePath: string;
|
|
58
254
|
};
|
|
59
255
|
type PrepareImageModelProgress = {
|
|
60
|
-
model:
|
|
256
|
+
model: ImageModelId;
|
|
61
257
|
file: string;
|
|
62
258
|
index: number;
|
|
63
259
|
total: number;
|
|
@@ -76,7 +272,8 @@ type PrepareImageLoRAProgress = {
|
|
|
76
272
|
fraction?: number;
|
|
77
273
|
};
|
|
78
274
|
type PrepareImageModelOptions = {
|
|
79
|
-
model?:
|
|
275
|
+
model?: ImageModel;
|
|
276
|
+
directory?: string;
|
|
80
277
|
accessToken?: string;
|
|
81
278
|
concurrency?: number;
|
|
82
279
|
onProgress?: (progress: PrepareImageModelProgress) => void;
|
|
@@ -98,7 +295,7 @@ type ImageLoRASource = {
|
|
|
98
295
|
};
|
|
99
296
|
type ImageLoRAPrecision = 'float16' | 'bfloat16' | 'float32';
|
|
100
297
|
type ImageLoRAMetadata = {
|
|
101
|
-
baseModel?:
|
|
298
|
+
baseModel?: ImageModelId;
|
|
102
299
|
precision?: ImageLoRAPrecision;
|
|
103
300
|
recommendedScale?: number;
|
|
104
301
|
sigmaSchedule?: number[];
|
|
@@ -130,7 +327,7 @@ type ImageLoRAState = PreparedImageLoRA & {
|
|
|
130
327
|
size?: number;
|
|
131
328
|
};
|
|
132
329
|
type PreparedImageModel = FluxImageModelPaths & {
|
|
133
|
-
model:
|
|
330
|
+
model: ImageModelId;
|
|
134
331
|
tokenizer: FluxTokenizer;
|
|
135
332
|
};
|
|
136
333
|
type FluxTokenizer = (input: {
|
|
@@ -175,8 +372,8 @@ type GenerateImageOptions = {
|
|
|
175
372
|
guidance?: number;
|
|
176
373
|
strength?: number;
|
|
177
374
|
seed?: number;
|
|
178
|
-
model?:
|
|
179
|
-
|
|
375
|
+
model?: ImageModel;
|
|
376
|
+
path?: string;
|
|
180
377
|
tokenizer?: FluxTokenizer;
|
|
181
378
|
accessToken?: string;
|
|
182
379
|
concurrency?: number;
|
|
@@ -193,32 +390,44 @@ type GenerateImageResult = {
|
|
|
193
390
|
uri: string;
|
|
194
391
|
width: number;
|
|
195
392
|
height: number;
|
|
196
|
-
model:
|
|
393
|
+
model: ImageModelId;
|
|
197
394
|
metadata: GenerateImageMetadata;
|
|
198
395
|
};
|
|
199
396
|
type GenerateImagesOptions = GenerateImageOptions & {
|
|
200
397
|
count: number;
|
|
201
398
|
};
|
|
202
|
-
type
|
|
203
|
-
type
|
|
399
|
+
type QueueImageOptions = Omit<GenerateImageOptions, 'accessToken' | 'onModelProgress' | 'onProgress' | 'signal' | 'tokenizer'>;
|
|
400
|
+
type ImageJobRequest = Omit<QueueImageOptions, 'model'> & {
|
|
401
|
+
model?: ImageModelId;
|
|
402
|
+
seed: number;
|
|
403
|
+
};
|
|
404
|
+
type JobStatus = 'queued' | 'running' | 'canceling' | 'paused' | 'completed' | 'failed' | 'canceled';
|
|
405
|
+
type JobError = {
|
|
406
|
+
name: string;
|
|
407
|
+
message: string;
|
|
408
|
+
code?: string;
|
|
409
|
+
stage?: string;
|
|
410
|
+
};
|
|
411
|
+
type ImageJob = {
|
|
204
412
|
id: string;
|
|
205
|
-
|
|
413
|
+
kind: 'image';
|
|
414
|
+
status: JobStatus;
|
|
415
|
+
request: ImageJobRequest;
|
|
416
|
+
attempt: number;
|
|
206
417
|
createdAt: string;
|
|
418
|
+
updatedAt: string;
|
|
207
419
|
startedAt?: string;
|
|
208
420
|
completedAt?: string;
|
|
209
421
|
progress?: ImagegenProgress;
|
|
210
422
|
result?: GenerateImageResult;
|
|
211
|
-
error?:
|
|
423
|
+
error?: JobError;
|
|
212
424
|
};
|
|
213
|
-
type
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
cancel(): boolean;
|
|
217
|
-
getSnapshot(): ImageGenerationJobSnapshot;
|
|
218
|
-
subscribe(listener: (snapshot: ImageGenerationJobSnapshot) => void): () => void;
|
|
425
|
+
type Job = ImageJob;
|
|
426
|
+
type JobSummary = Pick<Job, 'attempt' | 'completedAt' | 'createdAt' | 'id' | 'kind' | 'progress' | 'startedAt' | 'status' | 'updatedAt'> & {
|
|
427
|
+
prompt: string;
|
|
219
428
|
};
|
|
220
429
|
type GenerateImageMetadata = {
|
|
221
|
-
model:
|
|
430
|
+
model: ImageModelId;
|
|
222
431
|
width: number;
|
|
223
432
|
height: number;
|
|
224
433
|
steps: number;
|
|
@@ -234,8 +443,8 @@ type GenerateImageMetadata = {
|
|
|
234
443
|
sigmaSchedule?: number[];
|
|
235
444
|
};
|
|
236
445
|
type ImageModelState = {
|
|
237
|
-
model:
|
|
238
|
-
|
|
446
|
+
model: ImageModelId;
|
|
447
|
+
path: string;
|
|
239
448
|
paths: FluxImageModelPaths;
|
|
240
449
|
installed: boolean;
|
|
241
450
|
verified: boolean;
|
|
@@ -260,9 +469,10 @@ type UpscaleImageResult = {
|
|
|
260
469
|
scale: number;
|
|
261
470
|
};
|
|
262
471
|
declare const flux2Klein4B8BitAbliterated: FluxImageModelManifest;
|
|
263
|
-
declare const
|
|
264
|
-
declare
|
|
265
|
-
declare function
|
|
472
|
+
declare const ternaryBonsaiImage4B: ImageModelManifest;
|
|
473
|
+
declare const imageModelManifests: readonly [FluxImageModelManifest, ImageModelManifest];
|
|
474
|
+
declare function imageModelManifest(model: ImageModelId): ImageModelManifest | FluxImageModelManifest | undefined;
|
|
475
|
+
declare function fluxImageModelPaths(path: string, manifest?: ImageModelManifest): FluxImageModelPaths;
|
|
266
476
|
//#endregion
|
|
267
477
|
//#region src/ai/image.d.ts
|
|
268
478
|
declare const defaultImageLongSide = 1152;
|
|
@@ -270,15 +480,15 @@ declare function normalizeImageSize(size: ImageSize, maxLongSide?: number | fals
|
|
|
270
480
|
declare function imageSizeForPreset(aspectRatio: ImageAspectRatio, maxLongSide?: number): ImageSize;
|
|
271
481
|
declare function prepareImageModel(options?: PrepareImageModelOptions): Promise<PreparedImageModel>;
|
|
272
482
|
declare function verifyImageModel(options?: {
|
|
273
|
-
model?:
|
|
274
|
-
|
|
483
|
+
model?: ImageModel;
|
|
484
|
+
path?: string;
|
|
275
485
|
}): Promise<ImageModelState>;
|
|
276
486
|
declare function listImageModels(options?: {
|
|
277
|
-
|
|
487
|
+
directory?: string;
|
|
278
488
|
}): Promise<ImageModelState[]>;
|
|
279
489
|
declare function deleteImageModel(options?: {
|
|
280
|
-
model?:
|
|
281
|
-
|
|
490
|
+
model?: ImageModel;
|
|
491
|
+
path?: string;
|
|
282
492
|
}): Promise<void>;
|
|
283
493
|
declare function imageMemoryTelemetry(): Promise<ImageMemoryTelemetry>;
|
|
284
494
|
declare function unloadImageModel(): Promise<boolean>;
|
|
@@ -289,18 +499,23 @@ declare function listImageLoRAs(loras: ImageLoRADefinition[]): Promise<ImageLoRA
|
|
|
289
499
|
declare function deleteImageLoRA(lora: string | ImageLoRADefinition): Promise<void>;
|
|
290
500
|
declare function generateImage(options: GenerateImageOptions): Promise<GenerateImageResult>;
|
|
291
501
|
declare function generateImages(options: GenerateImagesOptions): Promise<GenerateImageResult[]>;
|
|
292
|
-
declare function
|
|
293
|
-
declare
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
502
|
+
declare function queueImage(options: QueueImageOptions): Promise<ImageJob>;
|
|
503
|
+
declare const image: Readonly<{
|
|
504
|
+
generate: typeof generateImage;
|
|
505
|
+
generateMany: typeof generateImages;
|
|
506
|
+
queue: typeof queueImage;
|
|
507
|
+
upscale: typeof upscaleImage;
|
|
508
|
+
}>;
|
|
509
|
+
declare const jobs: Readonly<{
|
|
510
|
+
get: (id: string) => Promise<ImageJob | undefined>;
|
|
511
|
+
list: () => Promise<JobSummary[]>;
|
|
512
|
+
cancel: (id: string) => Promise<boolean>;
|
|
513
|
+
retry: (id: string) => Promise<boolean>;
|
|
514
|
+
resume: (id: string) => Promise<boolean>;
|
|
515
|
+
remove: (id: string) => Promise<boolean>;
|
|
516
|
+
}>;
|
|
517
|
+
declare function useJob(id: string): ImageJob | undefined;
|
|
518
|
+
declare function useJobList(): JobSummary[];
|
|
304
519
|
//#endregion
|
|
305
520
|
//#region src/ai/image-composer.d.ts
|
|
306
521
|
type ImageComposerMode = 'text' | 'subject' | 'edit' | 'outpaint';
|
|
@@ -308,7 +523,9 @@ type ImageComposerSize = {
|
|
|
308
523
|
width: number;
|
|
309
524
|
height: number;
|
|
310
525
|
};
|
|
311
|
-
type ImageComposerImage =
|
|
526
|
+
type ImageComposerImage = {
|
|
527
|
+
path: string;
|
|
528
|
+
uri: string;
|
|
312
529
|
size: ImageComposerSize;
|
|
313
530
|
};
|
|
314
531
|
type ImageComposerRect = {
|
|
@@ -337,75 +554,6 @@ type ImageGenerationRequestInput = {
|
|
|
337
554
|
source: ImageComposerImage | null;
|
|
338
555
|
rect: ImageComposerRect | null;
|
|
339
556
|
};
|
|
340
|
-
type ImageComposerOptions = {
|
|
341
|
-
initialMode?: ImageComposerMode;
|
|
342
|
-
maxRefs?: number;
|
|
343
|
-
inputRoot?: string;
|
|
344
|
-
};
|
|
345
|
-
type TextComposerState = {
|
|
346
|
-
refs: ImageComposerImage[];
|
|
347
|
-
isPicking: boolean;
|
|
348
|
-
error: Error | null;
|
|
349
|
-
};
|
|
350
|
-
type SubjectComposerState = TextComposerState & {
|
|
351
|
-
subject: ImageComposerImage | null;
|
|
352
|
-
};
|
|
353
|
-
type EditComposerState = TextComposerState & {
|
|
354
|
-
source: ImageComposerImage | null;
|
|
355
|
-
};
|
|
356
|
-
type OutpaintComposerState = {
|
|
357
|
-
source: ImageComposerImage | null;
|
|
358
|
-
rect: ImageComposerRect | null;
|
|
359
|
-
isPicking: boolean;
|
|
360
|
-
error: Error | null;
|
|
361
|
-
};
|
|
362
|
-
type TextImageComposer = TextComposerState & {
|
|
363
|
-
mode: 'text';
|
|
364
|
-
pickRefs(): Promise<void>;
|
|
365
|
-
removeRef(index: number): void;
|
|
366
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
367
|
-
clear(): void;
|
|
368
|
-
};
|
|
369
|
-
type SubjectImageComposer = SubjectComposerState & {
|
|
370
|
-
mode: 'subject';
|
|
371
|
-
pickSubject(): Promise<void>;
|
|
372
|
-
removeSubject(): void;
|
|
373
|
-
pickRefs(): Promise<void>;
|
|
374
|
-
removeRef(index: number): void;
|
|
375
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
376
|
-
clear(): void;
|
|
377
|
-
};
|
|
378
|
-
type EditImageComposer = EditComposerState & {
|
|
379
|
-
mode: 'edit';
|
|
380
|
-
pickSource(): Promise<void>;
|
|
381
|
-
removeSource(): void;
|
|
382
|
-
pickRefs(): Promise<void>;
|
|
383
|
-
removeRef(index: number): void;
|
|
384
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
385
|
-
clear(): void;
|
|
386
|
-
};
|
|
387
|
-
type OutpaintImageComposer = OutpaintComposerState & {
|
|
388
|
-
mode: 'outpaint';
|
|
389
|
-
pickSource(): Promise<void>;
|
|
390
|
-
removeSource(): void;
|
|
391
|
-
setRect(rect: ImageComposerRect | null): void;
|
|
392
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
393
|
-
clear(): void;
|
|
394
|
-
};
|
|
395
|
-
type ImageComposer = TextImageComposer | SubjectImageComposer | EditImageComposer | OutpaintImageComposer;
|
|
396
|
-
type ImageComposerController = {
|
|
397
|
-
mode: ImageComposerMode;
|
|
398
|
-
setMode(mode: ImageComposerMode): void;
|
|
399
|
-
active: ImageComposer;
|
|
400
|
-
text: TextImageComposer;
|
|
401
|
-
subject: SubjectImageComposer;
|
|
402
|
-
edit: EditImageComposer;
|
|
403
|
-
outpaint: OutpaintImageComposer;
|
|
404
|
-
isPicking: boolean;
|
|
405
|
-
error: Error | null;
|
|
406
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
407
|
-
clear(): void;
|
|
408
|
-
};
|
|
409
557
|
declare function roundImageDimension(value: number): number;
|
|
410
558
|
declare function imageSizeForAspectRatio(size: ImageComposerSize, maxSide?: number): ImageComposerSize;
|
|
411
559
|
declare function roundedImageSize(size: ImageComposerSize): ImageComposerSize;
|
|
@@ -415,121 +563,6 @@ declare function rectForSourceScale(sourceSize: ImageComposerSize, scale: number
|
|
|
415
563
|
y: number;
|
|
416
564
|
}): ImageComposerRect;
|
|
417
565
|
declare function initialOutpaintRect(sourceSize: ImageComposerSize): ImageComposerRect;
|
|
418
|
-
declare function buildImageGenerationRequest(input: ImageGenerationRequestInput, options?: Pick<GenerateImageOptions, 'signal' | 'onModelProgress' | 'onProgress' | 'model' | '
|
|
419
|
-
declare function useImageComposer(options?: ImageComposerOptions): ImageComposerController;
|
|
420
|
-
declare function useImageComposer(mode: 'text', options?: ImageComposerOptions): TextImageComposer;
|
|
421
|
-
declare function useImageComposer(mode: 'subject', options?: ImageComposerOptions): SubjectImageComposer;
|
|
422
|
-
declare function useImageComposer(mode: 'edit', options?: ImageComposerOptions): EditImageComposer;
|
|
423
|
-
declare function useImageComposer(mode: 'outpaint', options?: ImageComposerOptions): OutpaintImageComposer;
|
|
424
|
-
declare function useImageGeneration(): {
|
|
425
|
-
run: (input: ImageGenerationRequestInput, options?: Pick<GenerateImageOptions, "loras">) => Promise<GenerateImageResult | null>;
|
|
426
|
-
cancel: () => void;
|
|
427
|
-
clear: () => void;
|
|
428
|
-
imageUri: string | null;
|
|
429
|
-
result: GenerateImageResult | null;
|
|
430
|
-
progress: number;
|
|
431
|
-
status: string;
|
|
432
|
-
isGenerating: boolean;
|
|
433
|
-
error: Error | null;
|
|
434
|
-
};
|
|
435
|
-
declare function useImageModel(): {
|
|
436
|
-
installed: boolean;
|
|
437
|
-
verified: boolean;
|
|
438
|
-
missingFiles: string[];
|
|
439
|
-
bytesPresent: number;
|
|
440
|
-
totalBytes: number;
|
|
441
|
-
check: () => Promise<ImageModelState | null>;
|
|
442
|
-
checking: boolean;
|
|
443
|
-
state: ImageModelState | null;
|
|
444
|
-
error: Error | null;
|
|
445
|
-
};
|
|
446
|
-
//#endregion
|
|
447
|
-
//#region src/ai/shape.d.ts
|
|
448
|
-
type PrimitiveToken = 'string' | 'number' | 'boolean';
|
|
449
|
-
type ShapeArray = readonly [ShapeDefinition];
|
|
450
|
-
type ShapeObject = {
|
|
451
|
-
readonly [key: string]: ShapeDefinition;
|
|
452
|
-
};
|
|
453
|
-
type ShapeDefinition = PrimitiveToken | ShapeObject | ShapeArray;
|
|
454
|
-
type InferShapeValue<Definition extends ShapeDefinition> = Definition extends 'string' ? string : Definition extends 'number' ? number : Definition extends 'boolean' ? boolean : Definition extends readonly [infer Item] ? Item extends ShapeDefinition ? Array<InferShapeValue<Item>> : never : Definition extends ShapeObject ? { [Key in keyof Definition]: InferShapeValue<Definition[Key]> } : never;
|
|
455
|
-
type InferShape<Definition extends ShapeObject> = { [Key in keyof Definition]: InferShapeValue<Definition[Key]> };
|
|
456
|
-
type BridgeSchema = {
|
|
457
|
-
type: PrimitiveToken;
|
|
458
|
-
} | {
|
|
459
|
-
type: 'array';
|
|
460
|
-
items: BridgeSchema;
|
|
461
|
-
} | {
|
|
462
|
-
type: 'object';
|
|
463
|
-
properties: Record<string, BridgeSchema>;
|
|
464
|
-
required: string[];
|
|
465
|
-
};
|
|
466
|
-
type StructuredInput = {
|
|
467
|
-
value: unknown;
|
|
468
|
-
shape: BleamAIShape<unknown, unknown> | StandardSchema;
|
|
469
|
-
};
|
|
470
|
-
type StructuredSchema = BleamAIShape<unknown, unknown> | StandardSchema;
|
|
471
|
-
type BridgeStructuredSchema = StandardSchema & {
|
|
472
|
-
toJSONSchema(): BridgeSchema;
|
|
473
|
-
};
|
|
474
|
-
interface BleamAIShape<Input, Output$1> extends StandardSchema<Input, Output$1> {
|
|
475
|
-
parse(value: unknown): Output$1;
|
|
476
|
-
safeParse(value: unknown): SchemaResult<Output$1>;
|
|
477
|
-
toJSONSchema(): BridgeSchema;
|
|
478
|
-
}
|
|
479
|
-
type InferShapeOutput<Value extends BleamAIShape<unknown, unknown>> = Value extends BleamAIShape<unknown, infer Output> ? Output : never;
|
|
480
|
-
declare function shape<Definition extends ShapeObject>(definition: Definition): BleamAIShape<InferShape<Definition>, InferShape<Definition>>;
|
|
481
|
-
type GenerateResult<Output$1 extends StructuredSchema | undefined> = Output$1 extends BleamAIShape<unknown, infer ShapeOutput> ? ShapeOutput : Output$1 extends StandardSchema ? InferOutput<Output$1> : string;
|
|
482
|
-
//#endregion
|
|
483
|
-
//#region src/ai/native.d.ts
|
|
484
|
-
type ModelAvailabilityResult = {
|
|
485
|
-
available: boolean;
|
|
486
|
-
reason?: 'device_not_eligible' | 'apple_intelligence_not_enabled' | 'model_not_ready' | 'unknown';
|
|
487
|
-
};
|
|
488
|
-
//#endregion
|
|
489
|
-
//#region src/ai/text.d.ts
|
|
490
|
-
type AITool<Input extends BridgeStructuredSchema = BridgeStructuredSchema> = {
|
|
491
|
-
name: string;
|
|
492
|
-
description: string;
|
|
493
|
-
input: Input;
|
|
494
|
-
execute(input: InferToolInput<Input>): unknown | Promise<unknown>;
|
|
495
|
-
};
|
|
496
|
-
type InferToolInput<Input extends BridgeStructuredSchema> = Input extends {
|
|
497
|
-
readonly '~standard': {
|
|
498
|
-
readonly types?: {
|
|
499
|
-
readonly output: infer Output;
|
|
500
|
-
};
|
|
501
|
-
};
|
|
502
|
-
} ? Output : unknown;
|
|
503
|
-
type GenerateOptions<Output$1 extends BridgeStructuredSchema | undefined = undefined> = {
|
|
504
|
-
system?: string;
|
|
505
|
-
prompt?: string;
|
|
506
|
-
input?: string | StructuredInput;
|
|
507
|
-
output?: Output$1;
|
|
508
|
-
temperature?: number;
|
|
509
|
-
maxTokens?: number;
|
|
510
|
-
tools?: readonly AITool[];
|
|
511
|
-
signal?: AbortSignal;
|
|
512
|
-
};
|
|
513
|
-
type StreamOptions = Omit<GenerateOptions<undefined>, 'output'>;
|
|
514
|
-
type ModelAvailability = ModelAvailabilityResult;
|
|
515
|
-
declare function isAvailable(): Promise<boolean>;
|
|
516
|
-
declare function availability(): Promise<ModelAvailability>;
|
|
517
|
-
declare function generate<Output$1 extends BridgeStructuredSchema | undefined = undefined>(options: GenerateOptions<Output$1>): Promise<GenerateResult<Output$1>>;
|
|
518
|
-
declare function stream(options: StreamOptions): AsyncGenerator<string>;
|
|
519
|
-
//#endregion
|
|
520
|
-
//#region src/ai/text-hook.d.ts
|
|
521
|
-
type TextGenerationState = {
|
|
522
|
-
text: string;
|
|
523
|
-
isGenerating: boolean;
|
|
524
|
-
error: Error | null;
|
|
525
|
-
};
|
|
526
|
-
declare function useTextGeneration(): {
|
|
527
|
-
run: (options: StreamOptions) => Promise<string | null>;
|
|
528
|
-
cancel: () => void;
|
|
529
|
-
clear: () => void;
|
|
530
|
-
text: string;
|
|
531
|
-
isGenerating: boolean;
|
|
532
|
-
error: Error | null;
|
|
533
|
-
};
|
|
566
|
+
declare function buildImageGenerationRequest(input: ImageGenerationRequestInput, options?: Pick<GenerateImageOptions, 'signal' | 'onModelProgress' | 'onProgress' | 'model' | 'path' | 'tokenizer' | 'accessToken' | 'concurrency' | 'loras'>): GenerateImageOptions;
|
|
534
567
|
//#endregion
|
|
535
|
-
export { AIError, AIErrorCode,
|
|
568
|
+
export { AIError, AIErrorCode, type AssistantChatMessage, type AssistantMessageStatus, BonsaiImageModel, BonsaiImageModelId, BonsaiModel, BonsaiTextModel, BonsaiTextModelId, BonsaiTextModelMetadata, type Chat, type ChatError, type ChatGenerationOptions, type ChatMessage, type ChatRunOptions, type ChatSendOptions, type ChatStatus, type ChatSummary, FluxImageModelId, FluxImageModelManifest, FluxImageModelPaths, FluxModelComponentManifest, FluxTokenizedPrompt, FluxTokenizer, GenerateImageMetadata, GenerateImageOptions, GenerateImageResult, GenerateImagesOptions, ImageAspectRatio, ImageComposerImage, ImageComposerMode, ImageComposerRect, ImageComposerSize, ImageGenerationError, ImageGenerationErrorDetails, ImageGenerationRequestInput, ImageGenerationStage, ImageJob, ImageJobRequest, ImageLoRADefinition, ImageLoRAMetadata, ImageLoRAPrecision, ImageLoRASource, ImageLoRAState, ImageMaskMode, ImageMemoryTelemetry, ImageModel, ImageModelCapability, ImageModelId, ImageModelManifest, ImageModelMetadata, ImageModelState, ImageOutpaintOptions, ImageOutpaintSourceRect, ImageResizeMode, ImageSize, ImagegenProgress, Job, JobError, JobStatus, JobSummary, PrepareImageLoRAOptions, PrepareImageLoRAProgress, PrepareImageModelOptions, PrepareImageModelProgress, PrepareBonsaiTextModelOptions as PrepareTextModelOptions, PrepareBonsaiTextModelProgress as PrepareTextModelProgress, PreparedImageLoRA, PreparedImageModel, PreparedBonsaiTextModel as PreparedTextModel, QueueImageOptions, type SendChatResult, BonsaiTextModelState as TextModelState, UpscaleImageOptions, UpscaleImageResult, type UseChatOptions, type UseChatResult, type UserChatMessage, bonsai, bonsaiTextModelCatalog, buildImageGenerationRequest, chat, clampOutpaintRect, defaultImageLongSide, deleteImageLoRA, deleteImageModel, deleteBonsaiTextModel as deleteTextModel, flux2Klein4B8BitAbliterated, fluxImageModelPaths, image, imageMemoryTelemetry, imageModelManifest, imageModelManifests, imageSizeForAspectRatio, imageSizeForPreset, initialOutpaintRect, jobs, listImageLoRAs, listImageModels, listBonsaiTextModels as listTextModels, normalizeImageSize, prepareImageLoRA, prepareImageModel, prepareBonsaiTextModel as prepareTextModel, rectForSourceScale, roundImageDimension, roundedImageSize, ternaryBonsaiImage4B, unloadImageModel, useChat, useChatList, useJob, useJobList, verifyImageLoRA, verifyImageModel, verifyBonsaiTextModel as verifyTextModel };
|