bleam 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/ai.cjs +608 -59
  2. package/dist/ai.d.cts +217 -89
  3. package/dist/ai.d.ts +217 -89
  4. package/dist/ai.js +601 -59
  5. package/dist/cli.cjs +3 -183
  6. package/dist/cli.d.cts +2 -46
  7. package/dist/cli.d.ts +2 -46
  8. package/dist/cli.js +3 -183
  9. package/dist/files.d.cts +1 -1
  10. package/dist/files.d.ts +1 -1
  11. package/dist/platform.cjs +1 -13
  12. package/dist/platform.d.cts +1 -28
  13. package/dist/platform.d.ts +1 -28
  14. package/dist/platform.js +1 -10
  15. package/dist/schema.d.cts +1 -1
  16. package/dist/schema.d.ts +1 -1
  17. package/dist/state.d.cts +1 -1
  18. package/dist/state.d.ts +1 -1
  19. package/dist/{ui-Bg11tvlc.d.ts → ui-1WepaMS4.d.cts} +1 -1
  20. package/dist/{ui-Dd7SXdbg.d.cts → ui-CHc4xEs_.d.ts} +7 -7
  21. package/dist/ui.d.cts +1 -1
  22. package/dist/ui.d.ts +1 -1
  23. package/dist/window.d.cts +1 -1
  24. package/dist/window.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/templates/image-generation/app/index.tsx +3 -1
  27. package/templates/native/ios/Bleam/AI/Flux2/Configuration/ModelRegistry.swift +1 -1
  28. package/templates/native/ios/Bleam/AI/Flux2/Pipeline/FluxImageRunner.swift +7 -2
  29. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextGenerator.swift +46 -0
  30. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextModel.swift +107 -0
  31. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextSnapshotValidator.swift +201 -0
  32. package/templates/native/ios/Bleam/AI/TextGeneration/Core/GenerationTypes.swift +85 -0
  33. package/templates/native/ios/Bleam/AI/TextGeneration/Core/ModelCapabilities.swift +21 -0
  34. package/templates/native/ios/Bleam/AI/TextGeneration/Core/TextKVCache.swift +23 -0
  35. package/templates/native/ios/Bleam/AI/TextGeneration/Core/TokenSampler.swift +79 -0
  36. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3CheckpointLoader.swift +161 -0
  37. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Configuration.swift +119 -0
  38. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3InferenceSession.swift +84 -0
  39. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Layers.swift +197 -0
  40. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Model.swift +130 -0
  41. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Checkpoint.swift +102 -0
  42. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Configuration.swift +140 -0
  43. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Model.swift +112 -0
  44. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Session.swift +121 -0
  45. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridCache.swift +42 -0
  46. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridFullAttention.swift +57 -0
  47. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridLayers.swift +58 -0
  48. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridLinearAttention.swift +111 -0
  49. package/templates/native/ios/Bleam/AppDelegate.swift +0 -206
  50. package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +128 -122
  51. package/templates/native/ios/GenerationService/BonsaiTextGenerationRunner.swift +103 -0
  52. package/templates/native/ios/GenerationService/ImageGenerationRunner.swift +19 -7
  53. package/templates/native/ios/GenerationService/main.swift +174 -48
  54. package/templates/native/ios/Shared/Generation/GenerationServiceProtocol.swift +3 -0
  55. package/templates/native/ios/Shared/Generation/GenerationWorkerProtocol.swift +44 -0
  56. package/templates/native/modules/bleam-runtime/ios/AIModule.swift +225 -5
  57. package/templates/native/modules/bleam-runtime/ios/GenerationContracts.swift +47 -0
  58. package/templates/native/modules/bleam-runtime/ios/PlatformModule.swift +0 -191
  59. package/templates/text-generation/app/index.tsx +93 -0
  60. package/templates/text-generation/app.config.ts +5 -0
  61. package/templates/updates/README.md +43 -199
  62. package/templates/updates/src/index.ts +5 -98
  63. package/templates/updates/src/schema.ts +18 -173
  64. package/templates/native/ios/PlatformHelper/main.swift +0 -726
  65. /package/dist/{files-DwA7pzr3.d.cts → files-4ZEoAWiv.d.ts} +0 -0
  66. /package/dist/{files-VrkQlKIT.d.ts → files-Dt5mbzLq.d.cts} +0 -0
  67. /package/dist/{schema-DOOjfXvs.d.ts → schema-CYh6n8GS.d.ts} +0 -0
  68. /package/dist/{schema-ENSMX_1t.d.cts → schema-oeOrd3i1.d.cts} +0 -0
package/dist/files.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as DownloadTask, c as FileStat, d as PickOptions, f as RemoveOptions, i as DownloadProgress, l as FileType, m as files, n as DirectoryRef, o as FilePaths, p as WriteOptions, r as DownloadOptions, s as FileRef, t as CreateDirectoryOptions, u as PickFileType } from "./files-VrkQlKIT.js";
1
+ import { a as DownloadTask, c as FileStat, d as PickOptions, f as RemoveOptions, i as DownloadProgress, l as FileType, m as files, n as DirectoryRef, o as FilePaths, p as WriteOptions, r as DownloadOptions, s as FileRef, t as CreateDirectoryOptions, u as PickFileType } from "./files-4ZEoAWiv.js";
2
2
  export { CreateDirectoryOptions, DirectoryRef, DownloadOptions, DownloadProgress, DownloadTask, FilePaths, FileRef, FileStat, FileType, PickFileType, PickOptions, RemoveOptions, WriteOptions, files };
package/dist/platform.cjs CHANGED
@@ -3,15 +3,6 @@ let expo = require("expo");
3
3
  expo = require_chunk.__toESM(expo);
4
4
 
5
5
  //#region src/platform.ts
6
- function getHelperStatus() {
7
- return (0, expo.requireNativeModule)("Platform").helperStatus();
8
- }
9
- function downloadPlatformUpdate() {
10
- return (0, expo.requireNativeModule)("Platform").downloadPlatformUpdate();
11
- }
12
- function updateAndRelaunch(releaseId) {
13
- return (0, expo.requireNativeModule)("Platform").updateAndRelaunch(releaseId);
14
- }
15
6
  function getPermissionState(capability) {
16
7
  return (0, expo.requireNativeModule)("Platform").permissionState(capability);
17
8
  }
@@ -20,8 +11,5 @@ function getPermissionStates() {
20
11
  }
21
12
 
22
13
  //#endregion
23
- exports.downloadPlatformUpdate = downloadPlatformUpdate;
24
- exports.getHelperStatus = getHelperStatus;
25
14
  exports.getPermissionState = getPermissionState;
26
- exports.getPermissionStates = getPermissionStates;
27
- exports.updateAndRelaunch = updateAndRelaunch;
15
+ exports.getPermissionStates = getPermissionStates;
@@ -1,5 +1,4 @@
1
1
  //#region src/platform.d.ts
2
- type HelperCapability = 'platform-updates';
3
2
  type PermissionCapability = 'camera' | 'microphone' | 'photos' | 'contacts' | 'calendars' | 'reminders' | 'location';
4
3
  type PermissionStatus = 'not-determined' | 'denied' | 'restricted' | 'limited' | 'granted' | 'unsupported';
5
4
  interface PermissionState {
@@ -9,33 +8,7 @@ interface PermissionState {
9
8
  canAskAgain: boolean;
10
9
  expires: 'never';
11
10
  }
12
- interface HelperStatus {
13
- healthy: boolean;
14
- protocolVersion: 1;
15
- helperVersion: string;
16
- platformVersion: string;
17
- capabilities: HelperCapability[];
18
- updatesSupported: boolean;
19
- installPath: string;
20
- reason?: 'reinstall_required';
21
- }
22
- interface PlatformDownload {
23
- releaseId: string;
24
- appVersion: string;
25
- buildNumber: string;
26
- platformVersion: string;
27
- platformFingerprint: string;
28
- redeploy: boolean;
29
- artifactPath: string;
30
- appPath: string;
31
- sizeBytes: number;
32
- sha256: string;
33
- verified: true;
34
- }
35
- declare function getHelperStatus(): Promise<HelperStatus>;
36
- declare function downloadPlatformUpdate(): Promise<PlatformDownload>;
37
- declare function updateAndRelaunch(releaseId: string): Promise<void>;
38
11
  declare function getPermissionState(capability: PermissionCapability): Promise<PermissionState>;
39
12
  declare function getPermissionStates(): Promise<PermissionState[]>;
40
13
  //#endregion
41
- export { HelperCapability, HelperStatus, PermissionCapability, PermissionState, PermissionStatus, PlatformDownload, downloadPlatformUpdate, getHelperStatus, getPermissionState, getPermissionStates, updateAndRelaunch };
14
+ export { PermissionCapability, PermissionState, PermissionStatus, getPermissionState, getPermissionStates };
@@ -1,5 +1,4 @@
1
1
  //#region src/platform.d.ts
2
- type HelperCapability = 'platform-updates';
3
2
  type PermissionCapability = 'camera' | 'microphone' | 'photos' | 'contacts' | 'calendars' | 'reminders' | 'location';
4
3
  type PermissionStatus = 'not-determined' | 'denied' | 'restricted' | 'limited' | 'granted' | 'unsupported';
5
4
  interface PermissionState {
@@ -9,33 +8,7 @@ interface PermissionState {
9
8
  canAskAgain: boolean;
10
9
  expires: 'never';
11
10
  }
12
- interface HelperStatus {
13
- healthy: boolean;
14
- protocolVersion: 1;
15
- helperVersion: string;
16
- platformVersion: string;
17
- capabilities: HelperCapability[];
18
- updatesSupported: boolean;
19
- installPath: string;
20
- reason?: 'reinstall_required';
21
- }
22
- interface PlatformDownload {
23
- releaseId: string;
24
- appVersion: string;
25
- buildNumber: string;
26
- platformVersion: string;
27
- platformFingerprint: string;
28
- redeploy: boolean;
29
- artifactPath: string;
30
- appPath: string;
31
- sizeBytes: number;
32
- sha256: string;
33
- verified: true;
34
- }
35
- declare function getHelperStatus(): Promise<HelperStatus>;
36
- declare function downloadPlatformUpdate(): Promise<PlatformDownload>;
37
- declare function updateAndRelaunch(releaseId: string): Promise<void>;
38
11
  declare function getPermissionState(capability: PermissionCapability): Promise<PermissionState>;
39
12
  declare function getPermissionStates(): Promise<PermissionState[]>;
40
13
  //#endregion
41
- export { HelperCapability, HelperStatus, PermissionCapability, PermissionState, PermissionStatus, PlatformDownload, downloadPlatformUpdate, getHelperStatus, getPermissionState, getPermissionStates, updateAndRelaunch };
14
+ export { PermissionCapability, PermissionState, PermissionStatus, getPermissionState, getPermissionStates };
package/dist/platform.js CHANGED
@@ -1,15 +1,6 @@
1
1
  import { requireNativeModule } from "expo";
2
2
 
3
3
  //#region src/platform.ts
4
- function getHelperStatus() {
5
- return requireNativeModule("Platform").helperStatus();
6
- }
7
- function downloadPlatformUpdate() {
8
- return requireNativeModule("Platform").downloadPlatformUpdate();
9
- }
10
- function updateAndRelaunch(releaseId) {
11
- return requireNativeModule("Platform").updateAndRelaunch(releaseId);
12
- }
13
4
  function getPermissionState(capability) {
14
5
  return requireNativeModule("Platform").permissionState(capability);
15
6
  }
@@ -18,4 +9,4 @@ function getPermissionStates() {
18
9
  }
19
10
 
20
11
  //#endregion
21
- export { downloadPlatformUpdate, getHelperStatus, getPermissionState, getPermissionStates, updateAndRelaunch };
12
+ export { getPermissionState, getPermissionStates };
package/dist/schema.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as FieldValue, c as SchemaError, d as SchemaJSONSchema, f as SchemaOutput, g as schema, h as StandardSchema, i as FieldToken, l as SchemaInput, m as SchemaShape, n as FieldDefault, o as InferInput, p as SchemaResult, r as FieldSchema, s as InferOutput, t as BleamSchema, u as SchemaIssue } from "./schema-ENSMX_1t.cjs";
1
+ import { a as FieldValue, c as SchemaError, d as SchemaJSONSchema, f as SchemaOutput, g as schema, h as StandardSchema, i as FieldToken, l as SchemaInput, m as SchemaShape, n as FieldDefault, o as InferInput, p as SchemaResult, r as FieldSchema, s as InferOutput, t as BleamSchema, u as SchemaIssue } from "./schema-oeOrd3i1.cjs";
2
2
  export { BleamSchema, FieldDefault, FieldSchema, FieldToken, FieldValue, InferInput, InferOutput, SchemaError, SchemaInput, SchemaIssue, SchemaJSONSchema, SchemaOutput, SchemaResult, SchemaShape, StandardSchema, schema };
package/dist/schema.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as FieldValue, c as SchemaError, d as SchemaJSONSchema, f as SchemaOutput, g as schema, h as StandardSchema, i as FieldToken, l as SchemaInput, m as SchemaShape, n as FieldDefault, o as InferInput, p as SchemaResult, r as FieldSchema, s as InferOutput, t as BleamSchema, u as SchemaIssue } from "./schema-DOOjfXvs.js";
1
+ import { a as FieldValue, c as SchemaError, d as SchemaJSONSchema, f as SchemaOutput, g as schema, h as StandardSchema, i as FieldToken, l as SchemaInput, m as SchemaShape, n as FieldDefault, o as InferInput, p as SchemaResult, r as FieldSchema, s as InferOutput, t as BleamSchema, u as SchemaIssue } from "./schema-CYh6n8GS.js";
2
2
  export { BleamSchema, FieldDefault, FieldSchema, FieldToken, FieldValue, InferInput, InferOutput, SchemaError, SchemaInput, SchemaIssue, SchemaJSONSchema, SchemaOutput, SchemaResult, SchemaShape, StandardSchema, schema };
package/dist/state.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-ENSMX_1t.cjs";
1
+ import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-oeOrd3i1.cjs";
2
2
 
3
3
  //#region src/state/atom.d.ts
4
4
  type Listener = () => void;
package/dist/state.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-DOOjfXvs.js";
1
+ import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-CYh6n8GS.js";
2
2
 
3
3
  //#region src/state/atom.d.ts
4
4
  type Listener = () => void;
@@ -1,6 +1,6 @@
1
- import * as _nativescript_react_native27 from "@nativescript/react-native";
2
1
  import { ReactNode } from "react";
3
2
  import { ColorValue, StyleProp, TextStyle, ViewStyle } from "react-native";
3
+ import * as _nativescript_react_native27 from "@nativescript/react-native";
4
4
 
5
5
  //#region src/ui/shared.d.ts
6
6
  type NativeStyle = ViewStyle & TextStyle;
@@ -1,6 +1,6 @@
1
+ import * as _nativescript_react_native25 from "@nativescript/react-native";
1
2
  import { ReactNode } from "react";
2
3
  import { ColorValue, StyleProp, TextStyle, ViewStyle } from "react-native";
3
- import * as _nativescript_react_native31 from "@nativescript/react-native";
4
4
 
5
5
  //#region src/ui/shared.d.ts
6
6
  type NativeStyle = ViewStyle & TextStyle;
@@ -18,7 +18,7 @@ type ButtonProps = {
18
18
  onPress?: () => void;
19
19
  style?: StyleProp<NativeStyle>;
20
20
  };
21
- declare const Button: _nativescript_react_native31.UIKitViewComponent<ButtonProps, UIButton>;
21
+ declare const Button: _nativescript_react_native25.UIKitViewComponent<ButtonProps, UIButton>;
22
22
  //#endregion
23
23
  //#region src/ui/label.d.ts
24
24
  type LabelTone = 'primary' | 'secondary' | 'tertiary';
@@ -29,7 +29,7 @@ type LabelProps = {
29
29
  numberOfLines?: number;
30
30
  style?: StyleProp<NativeStyle>;
31
31
  };
32
- declare const Label: _nativescript_react_native31.UIKitViewComponent<LabelProps, UILabel>;
32
+ declare const Label: _nativescript_react_native25.UIKitViewComponent<LabelProps, UILabel>;
33
33
  //#endregion
34
34
  //#region src/ui/symbol.d.ts
35
35
  type SymbolName = string;
@@ -43,7 +43,7 @@ type SymbolProps = {
43
43
  color?: ColorValue;
44
44
  style?: StyleProp<NativeStyle>;
45
45
  };
46
- declare const Symbol: _nativescript_react_native31.UIKitViewComponent<SymbolProps, UIImageView>;
46
+ declare const Symbol: _nativescript_react_native25.UIKitViewComponent<SymbolProps, UIImageView>;
47
47
  //#endregion
48
48
  //#region src/ui/glass-shared.d.ts
49
49
  type GlassStyle = 'regular' | 'clear' | 'none';
@@ -73,10 +73,10 @@ type GlassContainerProps = {
73
73
  };
74
74
  //#endregion
75
75
  //#region src/ui/glass-view.d.ts
76
- declare const GlassView: _nativescript_react_native31.UIKitViewComponent<GlassViewProps, _nativescript_react_native31.UIKitContainerResult<UIVisualEffectView, UIView>>;
76
+ declare const GlassView: _nativescript_react_native25.UIKitViewComponent<GlassViewProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
77
77
  //#endregion
78
78
  //#region src/ui/glass-container.d.ts
79
- declare const GlassContainer: _nativescript_react_native31.UIKitViewComponent<GlassContainerProps, _nativescript_react_native31.UIKitContainerResult<UIVisualEffectView, UIView>>;
79
+ declare const GlassContainer: _nativescript_react_native25.UIKitViewComponent<GlassContainerProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
80
80
  //#endregion
81
81
  //#region src/ui/blur-view.d.ts
82
82
  type BlurIntensity = 'ultraThin' | 'thin' | 'regular' | 'thick' | 'chrome';
@@ -87,6 +87,6 @@ type BlurViewProps = {
87
87
  intensity?: BlurIntensity;
88
88
  colorScheme?: BlurColorScheme;
89
89
  };
90
- declare const BlurView: _nativescript_react_native31.UIKitViewComponent<BlurViewProps, _nativescript_react_native31.UIKitContainerResult<UIVisualEffectView, UIView>>;
90
+ declare const BlurView: _nativescript_react_native25.UIKitViewComponent<BlurViewProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
91
91
  //#endregion
92
92
  export { ButtonVariant as C, ButtonSize as S, Label as _, GlassContainer as a, Button as b, GlassEffectStyleConfig as c, GlassVisualStyle as d, Symbol as f, SymbolWeight as g, SymbolScale as h, BlurViewProps as i, GlassStyle as l, SymbolProps as m, BlurIntensity as n, GlassView as o, SymbolName as p, BlurView as r, GlassContainerProps as s, BlurColorScheme as t, GlassViewProps as u, LabelProps as v, ButtonProps as x, LabelTone as y };
package/dist/ui.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as ButtonVariant, S as ButtonSize, _ as Label, a as GlassContainer, b as Button, c as GlassEffectStyleConfig, d as GlassVisualStyle, f as Symbol, g as SymbolWeight, h as SymbolScale, i as BlurViewProps, l as GlassStyle, m as SymbolProps, n as BlurIntensity, o as GlassView, p as SymbolName, r as BlurView, s as GlassContainerProps, t as BlurColorScheme, u as GlassViewProps, v as LabelProps, x as ButtonProps, y as LabelTone } from "./ui-Dd7SXdbg.cjs";
1
+ import { C as ButtonVariant, S as ButtonSize, _ as Label, a as GlassContainer, b as Button, c as GlassEffectStyleConfig, d as GlassVisualStyle, f as Symbol, g as SymbolWeight, h as SymbolScale, i as BlurViewProps, l as GlassStyle, m as SymbolProps, n as BlurIntensity, o as GlassView, p as SymbolName, r as BlurView, s as GlassContainerProps, t as BlurColorScheme, u as GlassViewProps, v as LabelProps, x as ButtonProps, y as LabelTone } from "./ui-1WepaMS4.cjs";
2
2
  export { BlurColorScheme, BlurIntensity, BlurView, BlurViewProps, Button, ButtonProps, ButtonSize, ButtonVariant, GlassContainer, GlassContainerProps, GlassEffectStyleConfig, GlassStyle, GlassView, GlassViewProps, GlassVisualStyle, Label, LabelProps, LabelTone, Symbol, SymbolName, SymbolProps, SymbolScale, SymbolWeight };
package/dist/ui.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as ButtonVariant, S as ButtonSize, _ as Label, a as GlassContainer, b as Button, c as GlassEffectStyleConfig, d as GlassVisualStyle, f as Symbol, g as SymbolWeight, h as SymbolScale, i as BlurViewProps, l as GlassStyle, m as SymbolProps, n as BlurIntensity, o as GlassView, p as SymbolName, r as BlurView, s as GlassContainerProps, t as BlurColorScheme, u as GlassViewProps, v as LabelProps, x as ButtonProps, y as LabelTone } from "./ui-Bg11tvlc.js";
1
+ import { C as ButtonVariant, S as ButtonSize, _ as Label, a as GlassContainer, b as Button, c as GlassEffectStyleConfig, d as GlassVisualStyle, f as Symbol, g as SymbolWeight, h as SymbolScale, i as BlurViewProps, l as GlassStyle, m as SymbolProps, n as BlurIntensity, o as GlassView, p as SymbolName, r as BlurView, s as GlassContainerProps, t as BlurColorScheme, u as GlassViewProps, v as LabelProps, x as ButtonProps, y as LabelTone } from "./ui-CHc4xEs_.js";
2
2
  export { BlurColorScheme, BlurIntensity, BlurView, BlurViewProps, Button, ButtonProps, ButtonSize, ButtonVariant, GlassContainer, GlassContainerProps, GlassEffectStyleConfig, GlassStyle, GlassView, GlassViewProps, GlassVisualStyle, Label, LabelProps, LabelTone, Symbol, SymbolName, SymbolProps, SymbolScale, SymbolWeight };
package/dist/window.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { p as SymbolName } from "./ui-Dd7SXdbg.cjs";
1
+ import { p as SymbolName } from "./ui-1WepaMS4.cjs";
2
2
  import * as react3 from "react";
3
3
  import { ComponentType } from "react";
4
4
  import { StyleProp, ViewStyle } from "react-native";
package/dist/window.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { p as SymbolName } from "./ui-Bg11tvlc.js";
1
+ import { p as SymbolName } from "./ui-CHc4xEs_.js";
2
2
  import * as react3 from "react";
3
3
  import { ComponentType } from "react";
4
4
  import { StyleProp, ViewStyle } from "react-native";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bleam",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "packageManager": "yarn@1.22.22",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,4 +1,4 @@
1
- import { generateImage } from 'bleam/ai'
1
+ import { bonsai, generateImage } from 'bleam/ai'
2
2
  import { sx } from 'bleam/styles'
3
3
  import { Button } from 'bleam/ui'
4
4
  import { Window } from 'bleam/window'
@@ -6,6 +6,7 @@ import { useState } from 'react'
6
6
  import { Image, Text, View } from 'react-native'
7
7
 
8
8
  const appName = 'Bleam Basic'
9
+ const model = bonsai('ternary-bonsai-image-4b')
9
10
 
10
11
  export default function App() {
11
12
  const [uri, setUri] = useState<string>()
@@ -15,6 +16,7 @@ export default function App() {
15
16
  setStatus('Generating...')
16
17
  try {
17
18
  const result = await generateImage({
19
+ model,
18
20
  prompt: 'A precise editorial illustration of a small native Mac app',
19
21
  aspectRatio: '1:1',
20
22
  })
@@ -152,7 +152,7 @@ public enum ModelRegistry {
152
152
  case klein4B_bf16 = "klein4b-bf16"
153
153
  case klein4B_8bit = "klein4b-8bit"
154
154
  case klein4B_4bit = "klein4b-4bit"
155
- case bonsaiKlein4B_2bit = "bonsai-klein4b-2bit"
155
+ case bonsaiKlein4B_2bit = "ternary-bonsai-image-4b"
156
156
  case bonsaiKlein4B_1bit = "bonsai-klein4b-1bit"
157
157
  case klein9B_8bit = "klein9b-8bit"
158
158
  case klein9B_4bit = "klein9b-4bit"
@@ -198,12 +198,17 @@ public final class FluxImageRunner: @unchecked Sendable {
198
198
  private static let referenceImageMaxLongSide = 768
199
199
 
200
200
  private let paths: FluxImageRunnerPaths
201
+ private let transformerProfile: Flux2TransformerRepoProfile
201
202
  private let scheduler = FlowMatchEulerScheduler()
202
203
  private var transformer: Flux2Transformer2DModel?
203
204
  private var vae: AutoencoderKLFlux2?
204
205
 
205
- public init(paths: FluxImageRunnerPaths) {
206
+ public init(
207
+ paths: FluxImageRunnerPaths,
208
+ transformerProfile: Flux2TransformerRepoProfile = ModelRegistry.TransformerRepo.moxinOrgKlein4B8bit.profile
209
+ ) {
206
210
  self.paths = paths
211
+ self.transformerProfile = transformerProfile
207
212
  }
208
213
 
209
214
  public func generate(
@@ -1237,7 +1242,7 @@ public final class FluxImageRunner: @unchecked Sendable {
1237
1242
  return transformer
1238
1243
  }
1239
1244
 
1240
- let profile = ModelRegistry.TransformerRepo.moxinOrgKlein4B8bit.profile
1245
+ let profile = transformerProfile
1241
1246
  let configURL = paths.transformer.appendingPathComponent("config.json")
1242
1247
  let config = FileManager.default.fileExists(atPath: configURL.path)
1243
1248
  ? (try? Flux2TransformerConfig.load(from: configURL)) ?? .klein4B
@@ -0,0 +1,46 @@
1
+ import Foundation
2
+ import MLX
3
+
4
+ public enum BonsaiTextGenerator {
5
+ public static func generate(
6
+ profile: BonsaiTextModelProfile,
7
+ modelURL: URL,
8
+ inputIDs: [Int],
9
+ endTokenIDs: Set<Int>? = nil,
10
+ parameters: GenerationParameters? = nil,
11
+ isCancelled: @escaping @Sendable () -> Bool,
12
+ onToken: @escaping @Sendable (Int) -> Bool
13
+ ) async throws -> TokenGenerationResult {
14
+ try BonsaiTextSnapshotValidator.validate(modelURL: modelURL, profile: profile)
15
+ let parameters = parameters ?? profile.defaultGenerationParameters
16
+ let endTokenIDs = endTokenIDs ?? profile.defaultEndTokenIDs
17
+ defer { MLX.Memory.clearCache() }
18
+
19
+ switch profile.backend {
20
+ case .qwen3:
21
+ try Task.checkCancellation()
22
+ let model = try Qwen3CheckpointLoader.load(from: modelURL)
23
+ try Task.checkCancellation()
24
+ return try Qwen3InferenceSession(model: model, endTokenIDs: endTokenIDs).generate(
25
+ inputIDs: inputIDs,
26
+ parameters: parameters,
27
+ isCancelled: { Task.isCancelled || isCancelled() },
28
+ onToken: onToken
29
+ )
30
+ case .qwen35:
31
+ let model = try Qwen35Checkpoint.load(
32
+ from: modelURL,
33
+ expectedQuantization: Qwen35Quantization(groupSize: 128, bits: 2)
34
+ )
35
+ let session = Qwen35Session(model: model)
36
+ defer { session.reset() }
37
+ return try await session.generate(
38
+ inputIDs: inputIDs,
39
+ parameters: parameters,
40
+ endTokenIDs: endTokenIDs,
41
+ isCancelled: { Task.isCancelled || isCancelled() },
42
+ onToken: onToken
43
+ )
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,107 @@
1
+ import Foundation
2
+
3
+ public enum BonsaiTextModelID: String, CaseIterable, Codable, Sendable {
4
+ case ternaryBonsai17B = "ternary-bonsai-1.7b"
5
+ case ternaryBonsai4B = "ternary-bonsai-4b"
6
+ case ternaryBonsai8B = "ternary-bonsai-8b"
7
+ case ternaryBonsai27B = "ternary-bonsai-27b"
8
+ }
9
+
10
+ public enum BonsaiTextBackend: Sendable {
11
+ case qwen3
12
+ case qwen35
13
+ }
14
+
15
+ public struct BonsaiTextModelProfile: Sendable {
16
+ public let id: BonsaiTextModelID
17
+ public let backend: BonsaiTextBackend
18
+ public let vocabularySize: Int
19
+ public let hiddenSize: Int
20
+ public let intermediateSize: Int
21
+ public let hiddenLayerCount: Int
22
+ public let attentionHeadCount: Int
23
+ public let keyValueHeadCount: Int
24
+ public let headDimension: Int
25
+ public let contextLength: Int
26
+ public let defaultEndTokenIDs: Set<Int>
27
+ public let defaultGenerationParameters: GenerationParameters
28
+
29
+ public static func resolve(_ value: String) throws -> Self {
30
+ guard let id = BonsaiTextModelID(rawValue: value) else {
31
+ throw BonsaiTextError.unsupportedModel(value)
32
+ }
33
+ return profile(for: id)
34
+ }
35
+
36
+ public static func profile(for id: BonsaiTextModelID) -> Self {
37
+ switch id {
38
+ case .ternaryBonsai17B:
39
+ return Self(
40
+ id: id, backend: .qwen3, vocabularySize: 151_669, hiddenSize: 2_048,
41
+ intermediateSize: 6_144, hiddenLayerCount: 28, attentionHeadCount: 16,
42
+ keyValueHeadCount: 8, headDimension: 128, contextLength: 32_768,
43
+ defaultEndTokenIDs: [151_643, 151_645],
44
+ defaultGenerationParameters: GenerationParameters(
45
+ maximumNewTokens: 256, temperature: 0.5, topP: 0.85,
46
+ repetitionPenalty: 1, repetitionContextSize: 64
47
+ )
48
+ )
49
+ case .ternaryBonsai4B:
50
+ return Self(
51
+ id: id, backend: .qwen3, vocabularySize: 151_669, hiddenSize: 2_560,
52
+ intermediateSize: 9_728, hiddenLayerCount: 36, attentionHeadCount: 32,
53
+ keyValueHeadCount: 8, headDimension: 128, contextLength: 32_768,
54
+ defaultEndTokenIDs: [151_643, 151_645],
55
+ defaultGenerationParameters: GenerationParameters(
56
+ maximumNewTokens: 256, temperature: 0.5, topP: 0.85,
57
+ repetitionPenalty: 1, repetitionContextSize: 64
58
+ )
59
+ )
60
+ case .ternaryBonsai8B:
61
+ return Self(
62
+ id: id, backend: .qwen3, vocabularySize: 151_669, hiddenSize: 4_096,
63
+ intermediateSize: 12_288, hiddenLayerCount: 36, attentionHeadCount: 32,
64
+ keyValueHeadCount: 8, headDimension: 128, contextLength: 65_536,
65
+ defaultEndTokenIDs: [151_643, 151_645],
66
+ defaultGenerationParameters: GenerationParameters(
67
+ maximumNewTokens: 256, temperature: 0.5, topP: 0.85,
68
+ repetitionPenalty: 1, repetitionContextSize: 64
69
+ )
70
+ )
71
+ case .ternaryBonsai27B:
72
+ return Self(
73
+ id: id, backend: .qwen35, vocabularySize: 248_320, hiddenSize: 5_120,
74
+ intermediateSize: 17_408, hiddenLayerCount: 64, attentionHeadCount: 24,
75
+ keyValueHeadCount: 4, headDimension: 256, contextLength: 262_144,
76
+ defaultEndTokenIDs: [248_044, 248_046],
77
+ defaultGenerationParameters: GenerationParameters(
78
+ maximumNewTokens: 2_048, temperature: 0.7, topP: 0.95, topK: 20,
79
+ repetitionPenalty: 1, repetitionContextSize: 128
80
+ )
81
+ )
82
+ }
83
+ }
84
+ }
85
+
86
+ public enum BonsaiTextError: LocalizedError {
87
+ case unsupportedModel(String)
88
+ case invalidModelPath(String)
89
+ case snapshotMismatch(model: BonsaiTextModelID, detail: String)
90
+ case invalidSeed(Int)
91
+ case invalidGenerationParameters(String)
92
+
93
+ public var errorDescription: String? {
94
+ switch self {
95
+ case .unsupportedModel(let value):
96
+ "Unsupported Bonsai text model: \(value)"
97
+ case .invalidModelPath(let path):
98
+ "Bonsai model path is not a directory: \(path)"
99
+ case .snapshotMismatch(let model, let detail):
100
+ "Snapshot does not match \(model.rawValue): \(detail)"
101
+ case .invalidSeed(let seed):
102
+ "Seed must be nonnegative, got \(seed)"
103
+ case .invalidGenerationParameters(let detail):
104
+ "Invalid generation parameters: \(detail)"
105
+ }
106
+ }
107
+ }