bleam 0.0.11 → 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 +2314 -2173
- package/dist/ai.d.cts +227 -322
- package/dist/ai.d.ts +227 -322
- package/dist/ai.js +2309 -2159
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- 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.d.cts +1 -1
- package/dist/files.d.ts +1 -1
- package/dist/files.js +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- 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-CHc4xEs_.d.ts → ui-D7bRLYee.d.ts} +7 -7
- package/dist/ui.d.ts +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 +2 -2
- package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +46 -46
- package/templates/native/ios/Podfile.lock +173 -173
- package/templates/native/modules/bleam-runtime/ios/AIModule.swift +35 -357
- package/templates/text-generation/app/index.tsx +81 -50
- package/templates/updates/README.md +1 -1
- package/dist/schema-Bo5Jvqus.js +0 -90
- package/dist/schema-CYh6n8GS.d.ts +0 -58
- package/dist/schema-oeOrd3i1.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/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/{files-4ZEoAWiv.d.ts → files-DwA7pzr3.d.cts} +0 -0
- /package/dist/{files-Dt5mbzLq.d.cts → files-VrkQlKIT.d.ts} +0 -0
package/dist/ai.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { s as FileRef } from "./files-Dt5mbzLq.cjs";
|
|
1
|
+
import "./files-DwA7pzr3.cjs";
|
|
3
2
|
|
|
4
3
|
//#region src/ai/bonsai.d.ts
|
|
5
4
|
type BonsaiTextModelId = 'ternary-bonsai-1.7b' | 'ternary-bonsai-4b' | 'ternary-bonsai-8b' | 'ternary-bonsai-27b';
|
|
@@ -26,6 +25,189 @@ declare const bonsaiTextModelCatalog: readonly BonsaiTextModelMetadata[];
|
|
|
26
25
|
declare function bonsai<const Id extends BonsaiTextModelId>(id: Id): BonsaiTextModel<Id>;
|
|
27
26
|
declare function bonsai<const Id extends BonsaiImageModelId>(id: Id): BonsaiImageModel<Id>;
|
|
28
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
|
|
195
|
+
//#region src/ai/errors.d.ts
|
|
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';
|
|
197
|
+
type ImageGenerationStage = 'download' | 'tokenize' | 'encode' | 'denoise' | 'decode' | 'write';
|
|
198
|
+
type ImageGenerationErrorDetails = {
|
|
199
|
+
stage: ImageGenerationStage;
|
|
200
|
+
};
|
|
201
|
+
declare class AIError extends Error {
|
|
202
|
+
readonly code: AIErrorCode;
|
|
203
|
+
readonly cause?: unknown | undefined;
|
|
204
|
+
constructor(code: AIErrorCode, message: string, cause?: unknown | undefined);
|
|
205
|
+
}
|
|
206
|
+
declare class ImageGenerationError extends AIError {
|
|
207
|
+
readonly stage: ImageGenerationStage;
|
|
208
|
+
constructor(stage: ImageGenerationStage, message: string, cause?: unknown);
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
29
211
|
//#region src/ai/image-models.d.ts
|
|
30
212
|
type FluxImageModelId = 'flux2-klein-4b-8bit-abliterated';
|
|
31
213
|
type ImageModelId = FluxImageModelId | 'ternary-bonsai-image-4b';
|
|
@@ -214,23 +396,35 @@ type GenerateImageResult = {
|
|
|
214
396
|
type GenerateImagesOptions = GenerateImageOptions & {
|
|
215
397
|
count: number;
|
|
216
398
|
};
|
|
217
|
-
type
|
|
218
|
-
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 = {
|
|
219
412
|
id: string;
|
|
220
|
-
|
|
413
|
+
kind: 'image';
|
|
414
|
+
status: JobStatus;
|
|
415
|
+
request: ImageJobRequest;
|
|
416
|
+
attempt: number;
|
|
221
417
|
createdAt: string;
|
|
418
|
+
updatedAt: string;
|
|
222
419
|
startedAt?: string;
|
|
223
420
|
completedAt?: string;
|
|
224
421
|
progress?: ImagegenProgress;
|
|
225
422
|
result?: GenerateImageResult;
|
|
226
|
-
error?:
|
|
423
|
+
error?: JobError;
|
|
227
424
|
};
|
|
228
|
-
type
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
cancel(): boolean;
|
|
232
|
-
getSnapshot(): ImageGenerationJobSnapshot;
|
|
233
|
-
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;
|
|
234
428
|
};
|
|
235
429
|
type GenerateImageMetadata = {
|
|
236
430
|
model: ImageModelId;
|
|
@@ -280,138 +474,6 @@ declare const imageModelManifests: readonly [FluxImageModelManifest, ImageModelM
|
|
|
280
474
|
declare function imageModelManifest(model: ImageModelId): ImageModelManifest | FluxImageModelManifest | undefined;
|
|
281
475
|
declare function fluxImageModelPaths(path: string, manifest?: ImageModelManifest): FluxImageModelPaths;
|
|
282
476
|
//#endregion
|
|
283
|
-
//#region src/ai/shape.d.ts
|
|
284
|
-
type PrimitiveToken = 'string' | 'number' | 'boolean';
|
|
285
|
-
type ShapeArray = readonly [ShapeDefinition];
|
|
286
|
-
type ShapeObject = {
|
|
287
|
-
readonly [key: string]: ShapeDefinition;
|
|
288
|
-
};
|
|
289
|
-
type ShapeDefinition = PrimitiveToken | ShapeObject | ShapeArray;
|
|
290
|
-
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;
|
|
291
|
-
type InferShape<Definition extends ShapeObject> = { [Key in keyof Definition]: InferShapeValue<Definition[Key]> };
|
|
292
|
-
type BridgeSchema = {
|
|
293
|
-
type: PrimitiveToken;
|
|
294
|
-
} | {
|
|
295
|
-
type: 'array';
|
|
296
|
-
items: BridgeSchema;
|
|
297
|
-
} | {
|
|
298
|
-
type: 'object';
|
|
299
|
-
properties: Record<string, BridgeSchema>;
|
|
300
|
-
required: string[];
|
|
301
|
-
};
|
|
302
|
-
type StructuredInput = {
|
|
303
|
-
value: unknown;
|
|
304
|
-
shape: BleamAIShape<unknown, unknown> | StandardSchema;
|
|
305
|
-
};
|
|
306
|
-
type StructuredSchema = BleamAIShape<unknown, unknown> | StandardSchema;
|
|
307
|
-
type BridgeStructuredSchema = StandardSchema & {
|
|
308
|
-
toJSONSchema(): BridgeSchema;
|
|
309
|
-
};
|
|
310
|
-
interface BleamAIShape<Input, Output$1> extends StandardSchema<Input, Output$1> {
|
|
311
|
-
parse(value: unknown): Output$1;
|
|
312
|
-
safeParse(value: unknown): SchemaResult<Output$1>;
|
|
313
|
-
toJSONSchema(): BridgeSchema;
|
|
314
|
-
}
|
|
315
|
-
type InferShapeOutput<Value extends BleamAIShape<unknown, unknown>> = Value extends BleamAIShape<unknown, infer Output> ? Output : never;
|
|
316
|
-
declare function shape<Definition extends ShapeObject>(definition: Definition): BleamAIShape<InferShape<Definition>, InferShape<Definition>>;
|
|
317
|
-
type GenerateResult<Output$1 extends StructuredSchema | undefined> = Output$1 extends BleamAIShape<unknown, infer ShapeOutput> ? ShapeOutput : Output$1 extends StandardSchema ? InferOutput<Output$1> : string;
|
|
318
|
-
//#endregion
|
|
319
|
-
//#region src/ai/native.d.ts
|
|
320
|
-
type ModelAvailabilityResult = {
|
|
321
|
-
available: boolean;
|
|
322
|
-
reason?: 'device_not_eligible' | 'apple_intelligence_not_enabled' | 'model_not_ready' | 'not_installed' | 'invalid_model' | 'unknown';
|
|
323
|
-
};
|
|
324
|
-
//#endregion
|
|
325
|
-
//#region src/ai/bonsai-generation.d.ts
|
|
326
|
-
type TextMessage = Readonly<{
|
|
327
|
-
role: 'system' | 'user' | 'assistant';
|
|
328
|
-
content: string;
|
|
329
|
-
}>;
|
|
330
|
-
//#endregion
|
|
331
|
-
//#region src/ai/bonsai-text.d.ts
|
|
332
|
-
declare const bonsaiTextModelFiles: readonly ["config.json", "tokenizer.json", "tokenizer_config.json", "chat_template.jinja", "model.safetensors", "model.safetensors.index.json"];
|
|
333
|
-
type BonsaiTextModelFile = (typeof bonsaiTextModelFiles)[number];
|
|
334
|
-
type PrepareBonsaiTextModelProgress = Readonly<{
|
|
335
|
-
model: BonsaiTextModelId;
|
|
336
|
-
file: BonsaiTextModelFile;
|
|
337
|
-
index: number;
|
|
338
|
-
total: number;
|
|
339
|
-
bytesWritten: number;
|
|
340
|
-
totalBytes?: number;
|
|
341
|
-
fraction?: number;
|
|
342
|
-
modelBytesWritten: number;
|
|
343
|
-
estimatedModelBytes: number;
|
|
344
|
-
modelFraction: number;
|
|
345
|
-
}>;
|
|
346
|
-
type PrepareBonsaiTextModelOptions = Readonly<{
|
|
347
|
-
accessToken?: string;
|
|
348
|
-
directory?: string;
|
|
349
|
-
signal?: AbortSignal;
|
|
350
|
-
onProgress?: (progress: PrepareBonsaiTextModelProgress) => void;
|
|
351
|
-
}>;
|
|
352
|
-
type PreparedBonsaiTextModel = Readonly<{
|
|
353
|
-
model: BonsaiTextModel;
|
|
354
|
-
path: string;
|
|
355
|
-
}>;
|
|
356
|
-
type BonsaiTextModelState = Readonly<{
|
|
357
|
-
model: BonsaiTextModel;
|
|
358
|
-
metadata: BonsaiTextModelMetadata;
|
|
359
|
-
path: string;
|
|
360
|
-
installed: boolean;
|
|
361
|
-
verified: boolean;
|
|
362
|
-
bytesPresent: number;
|
|
363
|
-
estimatedTotalBytes: number;
|
|
364
|
-
missingFiles: readonly string[];
|
|
365
|
-
invalidFiles: readonly string[];
|
|
366
|
-
}>;
|
|
367
|
-
type ModelInput = BonsaiTextModelId | BonsaiTextModel;
|
|
368
|
-
declare function prepareBonsaiTextModel(model: ModelInput, options?: PrepareBonsaiTextModelOptions): Promise<PreparedBonsaiTextModel>;
|
|
369
|
-
declare function verifyBonsaiTextModel(model: ModelInput, options?: Readonly<{
|
|
370
|
-
path?: string;
|
|
371
|
-
}>): Promise<Readonly<{
|
|
372
|
-
model: BonsaiTextModel;
|
|
373
|
-
metadata: BonsaiTextModelMetadata;
|
|
374
|
-
path: string;
|
|
375
|
-
installed: boolean;
|
|
376
|
-
verified: boolean;
|
|
377
|
-
bytesPresent: number;
|
|
378
|
-
estimatedTotalBytes: number;
|
|
379
|
-
missingFiles: readonly string[];
|
|
380
|
-
invalidFiles: readonly string[];
|
|
381
|
-
}>>;
|
|
382
|
-
declare function listBonsaiTextModels(options?: Readonly<{
|
|
383
|
-
directory?: string;
|
|
384
|
-
}>): Promise<Readonly<{
|
|
385
|
-
model: BonsaiTextModel;
|
|
386
|
-
metadata: BonsaiTextModelMetadata;
|
|
387
|
-
path: string;
|
|
388
|
-
installed: boolean;
|
|
389
|
-
verified: boolean;
|
|
390
|
-
bytesPresent: number;
|
|
391
|
-
estimatedTotalBytes: number;
|
|
392
|
-
missingFiles: readonly string[];
|
|
393
|
-
invalidFiles: readonly string[];
|
|
394
|
-
}>[]>;
|
|
395
|
-
declare function deleteBonsaiTextModel(model: ModelInput, options?: Readonly<{
|
|
396
|
-
path?: string;
|
|
397
|
-
}>): Promise<void>;
|
|
398
|
-
//#endregion
|
|
399
|
-
//#region src/ai/errors.d.ts
|
|
400
|
-
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';
|
|
401
|
-
type ImageGenerationStage = 'download' | 'tokenize' | 'encode' | 'denoise' | 'decode' | 'write';
|
|
402
|
-
type ImageGenerationErrorDetails = {
|
|
403
|
-
stage: ImageGenerationStage;
|
|
404
|
-
};
|
|
405
|
-
declare class AIError extends Error {
|
|
406
|
-
readonly code: AIErrorCode;
|
|
407
|
-
readonly cause?: unknown | undefined;
|
|
408
|
-
constructor(code: AIErrorCode, message: string, cause?: unknown | undefined);
|
|
409
|
-
}
|
|
410
|
-
declare class ImageGenerationError extends AIError {
|
|
411
|
-
readonly stage: ImageGenerationStage;
|
|
412
|
-
constructor(stage: ImageGenerationStage, message: string, cause?: unknown);
|
|
413
|
-
}
|
|
414
|
-
//#endregion
|
|
415
477
|
//#region src/ai/image.d.ts
|
|
416
478
|
declare const defaultImageLongSide = 1152;
|
|
417
479
|
declare function normalizeImageSize(size: ImageSize, maxLongSide?: number | false): ImageSize;
|
|
@@ -437,18 +499,23 @@ declare function listImageLoRAs(loras: ImageLoRADefinition[]): Promise<ImageLoRA
|
|
|
437
499
|
declare function deleteImageLoRA(lora: string | ImageLoRADefinition): Promise<void>;
|
|
438
500
|
declare function generateImage(options: GenerateImageOptions): Promise<GenerateImageResult>;
|
|
439
501
|
declare function generateImages(options: GenerateImagesOptions): Promise<GenerateImageResult[]>;
|
|
440
|
-
declare function
|
|
441
|
-
declare
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
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[];
|
|
452
519
|
//#endregion
|
|
453
520
|
//#region src/ai/image-composer.d.ts
|
|
454
521
|
type ImageComposerMode = 'text' | 'subject' | 'edit' | 'outpaint';
|
|
@@ -456,7 +523,9 @@ type ImageComposerSize = {
|
|
|
456
523
|
width: number;
|
|
457
524
|
height: number;
|
|
458
525
|
};
|
|
459
|
-
type ImageComposerImage =
|
|
526
|
+
type ImageComposerImage = {
|
|
527
|
+
path: string;
|
|
528
|
+
uri: string;
|
|
460
529
|
size: ImageComposerSize;
|
|
461
530
|
};
|
|
462
531
|
type ImageComposerRect = {
|
|
@@ -485,75 +554,6 @@ type ImageGenerationRequestInput = {
|
|
|
485
554
|
source: ImageComposerImage | null;
|
|
486
555
|
rect: ImageComposerRect | null;
|
|
487
556
|
};
|
|
488
|
-
type ImageComposerOptions = {
|
|
489
|
-
initialMode?: ImageComposerMode;
|
|
490
|
-
maxRefs?: number;
|
|
491
|
-
inputRoot?: string;
|
|
492
|
-
};
|
|
493
|
-
type TextComposerState = {
|
|
494
|
-
refs: ImageComposerImage[];
|
|
495
|
-
isPicking: boolean;
|
|
496
|
-
error: Error | null;
|
|
497
|
-
};
|
|
498
|
-
type SubjectComposerState = TextComposerState & {
|
|
499
|
-
subject: ImageComposerImage | null;
|
|
500
|
-
};
|
|
501
|
-
type EditComposerState = TextComposerState & {
|
|
502
|
-
source: ImageComposerImage | null;
|
|
503
|
-
};
|
|
504
|
-
type OutpaintComposerState = {
|
|
505
|
-
source: ImageComposerImage | null;
|
|
506
|
-
rect: ImageComposerRect | null;
|
|
507
|
-
isPicking: boolean;
|
|
508
|
-
error: Error | null;
|
|
509
|
-
};
|
|
510
|
-
type TextImageComposer = TextComposerState & {
|
|
511
|
-
mode: 'text';
|
|
512
|
-
pickRefs(): Promise<void>;
|
|
513
|
-
removeRef(index: number): void;
|
|
514
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
515
|
-
clear(): void;
|
|
516
|
-
};
|
|
517
|
-
type SubjectImageComposer = SubjectComposerState & {
|
|
518
|
-
mode: 'subject';
|
|
519
|
-
pickSubject(): Promise<void>;
|
|
520
|
-
removeSubject(): void;
|
|
521
|
-
pickRefs(): Promise<void>;
|
|
522
|
-
removeRef(index: number): void;
|
|
523
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
524
|
-
clear(): void;
|
|
525
|
-
};
|
|
526
|
-
type EditImageComposer = EditComposerState & {
|
|
527
|
-
mode: 'edit';
|
|
528
|
-
pickSource(): Promise<void>;
|
|
529
|
-
removeSource(): void;
|
|
530
|
-
pickRefs(): Promise<void>;
|
|
531
|
-
removeRef(index: number): void;
|
|
532
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
533
|
-
clear(): void;
|
|
534
|
-
};
|
|
535
|
-
type OutpaintImageComposer = OutpaintComposerState & {
|
|
536
|
-
mode: 'outpaint';
|
|
537
|
-
pickSource(): Promise<void>;
|
|
538
|
-
removeSource(): void;
|
|
539
|
-
setRect(rect: ImageComposerRect | null): void;
|
|
540
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
541
|
-
clear(): void;
|
|
542
|
-
};
|
|
543
|
-
type ImageComposer = TextImageComposer | SubjectImageComposer | EditImageComposer | OutpaintImageComposer;
|
|
544
|
-
type ImageComposerController = {
|
|
545
|
-
mode: ImageComposerMode;
|
|
546
|
-
setMode(mode: ImageComposerMode): void;
|
|
547
|
-
active: ImageComposer;
|
|
548
|
-
text: TextImageComposer;
|
|
549
|
-
subject: SubjectImageComposer;
|
|
550
|
-
edit: EditImageComposer;
|
|
551
|
-
outpaint: OutpaintImageComposer;
|
|
552
|
-
isPicking: boolean;
|
|
553
|
-
error: Error | null;
|
|
554
|
-
request(prompt: string): ImageGenerationRequestInput;
|
|
555
|
-
clear(): void;
|
|
556
|
-
};
|
|
557
557
|
declare function roundImageDimension(value: number): number;
|
|
558
558
|
declare function imageSizeForAspectRatio(size: ImageComposerSize, maxSide?: number): ImageComposerSize;
|
|
559
559
|
declare function roundedImageSize(size: ImageComposerSize): ImageComposerSize;
|
|
@@ -564,100 +564,5 @@ declare function rectForSourceScale(sourceSize: ImageComposerSize, scale: number
|
|
|
564
564
|
}): ImageComposerRect;
|
|
565
565
|
declare function initialOutpaintRect(sourceSize: ImageComposerSize): ImageComposerRect;
|
|
566
566
|
declare function buildImageGenerationRequest(input: ImageGenerationRequestInput, options?: Pick<GenerateImageOptions, 'signal' | 'onModelProgress' | 'onProgress' | 'model' | 'path' | 'tokenizer' | 'accessToken' | 'concurrency' | 'loras'>): GenerateImageOptions;
|
|
567
|
-
declare function useImageComposer(options?: ImageComposerOptions): ImageComposerController;
|
|
568
|
-
declare function useImageComposer(mode: 'text', options?: ImageComposerOptions): TextImageComposer;
|
|
569
|
-
declare function useImageComposer(mode: 'subject', options?: ImageComposerOptions): SubjectImageComposer;
|
|
570
|
-
declare function useImageComposer(mode: 'edit', options?: ImageComposerOptions): EditImageComposer;
|
|
571
|
-
declare function useImageComposer(mode: 'outpaint', options?: ImageComposerOptions): OutpaintImageComposer;
|
|
572
|
-
declare function useImageGeneration(): {
|
|
573
|
-
run: (input: ImageGenerationRequestInput, options?: Pick<GenerateImageOptions, "loras">) => Promise<GenerateImageResult | null>;
|
|
574
|
-
cancel: () => void;
|
|
575
|
-
clear: () => void;
|
|
576
|
-
imageUri: string | null;
|
|
577
|
-
result: GenerateImageResult | null;
|
|
578
|
-
progress: number;
|
|
579
|
-
status: string;
|
|
580
|
-
isGenerating: boolean;
|
|
581
|
-
error: Error | null;
|
|
582
|
-
};
|
|
583
|
-
declare function useImageModel(): {
|
|
584
|
-
installed: boolean;
|
|
585
|
-
verified: boolean;
|
|
586
|
-
missingFiles: string[];
|
|
587
|
-
bytesPresent: number;
|
|
588
|
-
totalBytes: number;
|
|
589
|
-
check: () => Promise<ImageModelState | null>;
|
|
590
|
-
checking: boolean;
|
|
591
|
-
state: ImageModelState | null;
|
|
592
|
-
error: Error | null;
|
|
593
|
-
};
|
|
594
|
-
//#endregion
|
|
595
|
-
//#region src/ai/text.d.ts
|
|
596
|
-
type AITool<Input extends BridgeStructuredSchema = BridgeStructuredSchema> = {
|
|
597
|
-
name: string;
|
|
598
|
-
description: string;
|
|
599
|
-
input: Input;
|
|
600
|
-
execute(input: InferToolInput<Input>): unknown | Promise<unknown>;
|
|
601
|
-
};
|
|
602
|
-
type InferToolInput<Input extends BridgeStructuredSchema> = Input extends {
|
|
603
|
-
readonly '~standard': {
|
|
604
|
-
readonly types?: {
|
|
605
|
-
readonly output: infer Output;
|
|
606
|
-
};
|
|
607
|
-
};
|
|
608
|
-
} ? Output : unknown;
|
|
609
|
-
type FoundationGenerateOptions<Output$1 extends BridgeStructuredSchema | undefined = undefined> = {
|
|
610
|
-
model?: never;
|
|
611
|
-
system?: string;
|
|
612
|
-
prompt?: string;
|
|
613
|
-
input?: string | StructuredInput;
|
|
614
|
-
messages?: never;
|
|
615
|
-
output?: Output$1;
|
|
616
|
-
temperature?: number;
|
|
617
|
-
maxTokens?: number;
|
|
618
|
-
tools?: readonly AITool[];
|
|
619
|
-
signal?: AbortSignal;
|
|
620
|
-
};
|
|
621
|
-
type BonsaiGenerateOptions = {
|
|
622
|
-
model: BonsaiTextModel;
|
|
623
|
-
path?: string;
|
|
624
|
-
system?: string;
|
|
625
|
-
prompt?: string;
|
|
626
|
-
messages?: readonly TextMessage[];
|
|
627
|
-
input?: never;
|
|
628
|
-
output?: never;
|
|
629
|
-
tools?: never;
|
|
630
|
-
temperature?: number;
|
|
631
|
-
maxTokens?: number;
|
|
632
|
-
seed?: number;
|
|
633
|
-
signal?: AbortSignal;
|
|
634
|
-
};
|
|
635
|
-
type GenerateOptions<Output$1 extends BridgeStructuredSchema | undefined = undefined> = FoundationGenerateOptions<Output$1> | BonsaiGenerateOptions;
|
|
636
|
-
type StreamOptions = Omit<FoundationGenerateOptions<undefined>, 'output'> | BonsaiGenerateOptions;
|
|
637
|
-
type ModelAvailability = ModelAvailabilityResult;
|
|
638
|
-
declare function isAvailable(model?: BonsaiTextModel, options?: Readonly<{
|
|
639
|
-
path?: string;
|
|
640
|
-
}>): Promise<boolean>;
|
|
641
|
-
declare function availability(model?: BonsaiTextModel, options?: Readonly<{
|
|
642
|
-
path?: string;
|
|
643
|
-
}>): Promise<ModelAvailability>;
|
|
644
|
-
declare function generate(options: BonsaiGenerateOptions): Promise<string>;
|
|
645
|
-
declare function generate<Output$1 extends BridgeStructuredSchema | undefined = undefined>(options: FoundationGenerateOptions<Output$1>): Promise<GenerateResult<Output$1>>;
|
|
646
|
-
declare function stream(options: StreamOptions): AsyncGenerator<string>;
|
|
647
|
-
//#endregion
|
|
648
|
-
//#region src/ai/text-hook.d.ts
|
|
649
|
-
type TextGenerationState = {
|
|
650
|
-
text: string;
|
|
651
|
-
isGenerating: boolean;
|
|
652
|
-
error: Error | null;
|
|
653
|
-
};
|
|
654
|
-
declare function useTextGeneration(): {
|
|
655
|
-
run: (options: StreamOptions) => Promise<string | null>;
|
|
656
|
-
cancel: () => void;
|
|
657
|
-
clear: () => void;
|
|
658
|
-
text: string;
|
|
659
|
-
isGenerating: boolean;
|
|
660
|
-
error: Error | null;
|
|
661
|
-
};
|
|
662
567
|
//#endregion
|
|
663
|
-
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 };
|