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
@@ -1,4 +1,4 @@
1
- export type ArtifactFormat = 'bleam-ota-zip-v1' | 'bleam-macos-app-zip-v1'
1
+ export type ArtifactFormat = 'bleam-ota-zip-v1'
2
2
 
3
3
  export interface StoredArtifact {
4
4
  format: ArtifactFormat
@@ -11,43 +11,24 @@ export interface ResolvedArtifact extends StoredArtifact {
11
11
  url: string
12
12
  }
13
13
 
14
- interface ReleaseFields {
14
+ export interface OtaRelease {
15
15
  schemaVersion: 1
16
+ kind: 'ota'
16
17
  bundleIdentifier: string
17
18
  teamIdentifier: string
18
19
  channel: 'stable'
19
20
  releaseId: string
20
- publishedAt: string
21
- }
22
-
23
- export interface OtaRelease extends ReleaseFields {
24
- kind: 'ota'
25
21
  bundleVersion: string
26
22
  runtimeVersion: string
27
23
  artifact: StoredArtifact & { format: 'bleam-ota-zip-v1' }
24
+ publishedAt: string
28
25
  }
29
26
 
30
- export interface PlatformRelease extends ReleaseFields {
31
- kind: 'platform'
32
- appVersion: string
33
- buildNumber: string
34
- bleamPlatformVersion: string
35
- platformFingerprint?: string
36
- redeploy: boolean
37
- target: {
38
- os: 'macos'
39
- architecture: 'arm64'
40
- installLocation: 'user-applications'
41
- minimumMacOSVersion: string
42
- }
43
- artifact: StoredArtifact & { format: 'bleam-macos-app-zip-v1' }
44
- }
45
-
46
- export type StoredRelease = OtaRelease | PlatformRelease
27
+ export type StoredRelease = OtaRelease
47
28
 
48
- export type ResolvedRelease =
49
- | (Omit<OtaRelease, 'artifact'> & { artifact: ResolvedArtifact })
50
- | (Omit<PlatformRelease, 'artifact'> & { artifact: ResolvedArtifact })
29
+ export type ResolvedRelease = Omit<OtaRelease, 'artifact'> & {
30
+ artifact: ResolvedArtifact
31
+ }
51
32
 
52
33
  export interface DownloadRecord {
53
34
  schemaVersion: 1
@@ -104,23 +85,6 @@ function version(value: unknown, field: string): string {
104
85
  return result
105
86
  }
106
87
 
107
- function numericString(value: unknown, field: string): string {
108
- const result = string(value, field)
109
- if (!/^\d+$/.test(result)) {
110
- return invalid(field, 'must contain only decimal digits')
111
- }
112
- return result
113
- }
114
-
115
- function optionalSha256(value: unknown, field: string): string | undefined {
116
- if (value === undefined) return undefined
117
- const result = string(value, field)
118
- if (!/^[a-f0-9]{64}$/.test(result)) {
119
- return invalid(field, 'must be a lowercase SHA-256 hex digest')
120
- }
121
- return result
122
- }
123
-
124
88
  function publishedAt(value: unknown): string {
125
89
  const result = string(value, 'publishedAt')
126
90
  if (
@@ -140,44 +104,6 @@ export function isRuntimeVersion(value: string): boolean {
140
104
  return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(value)
141
105
  }
142
106
 
143
- export function compareRuntimeVersions(left: string, right: string) {
144
- const parse = (value: string) => {
145
- const match = /^(\d+)\.(\d+)\.(\d+)(?:-([^+]+))?(?:\+.*)?$/.exec(value)
146
- if (!match) return invalid('runtimeVersion', 'must be a semantic version')
147
- return {
148
- core: match.slice(1, 4).map(Number),
149
- prerelease: match[4]?.split('.'),
150
- }
151
- }
152
- const a = parse(left)
153
- const b = parse(right)
154
- for (let index = 0; index < a.core.length; index += 1) {
155
- if (a.core[index] !== b.core[index]) {
156
- return (a.core[index] ?? 0) < (b.core[index] ?? 0) ? -1 : 1
157
- }
158
- }
159
- if (!a.prerelease && !b.prerelease) return 0
160
- if (!a.prerelease) return 1
161
- if (!b.prerelease) return -1
162
- const length = Math.max(a.prerelease.length, b.prerelease.length)
163
- for (let index = 0; index < length; index += 1) {
164
- const aPart = a.prerelease[index]
165
- const bPart = b.prerelease[index]
166
- if (aPart === undefined) return -1
167
- if (bPart === undefined) return 1
168
- if (aPart === bPart) continue
169
- const aNumber = /^\d+$/.test(aPart) ? Number(aPart) : undefined
170
- const bNumber = /^\d+$/.test(bPart) ? Number(bPart) : undefined
171
- if (aNumber !== undefined && bNumber !== undefined) {
172
- return aNumber < bNumber ? -1 : 1
173
- }
174
- if (aNumber !== undefined) return -1
175
- if (bNumber !== undefined) return 1
176
- return aPart < bPart ? -1 : 1
177
- }
178
- return 0
179
- }
180
-
181
107
  export function isDownloadId(value: string): boolean {
182
108
  return /^[a-z][a-z0-9_-]{2,127}$/.test(value)
183
109
  }
@@ -209,11 +135,9 @@ function teamIdentifier(value: unknown): string {
209
135
  return result
210
136
  }
211
137
 
212
- function artifact(value: unknown, kind: StoredRelease['kind']): StoredArtifact {
138
+ function artifact(value: unknown): StoredArtifact {
213
139
  const input = record(value, 'artifact')
214
- const expectedFormat =
215
- kind === 'ota' ? 'bleam-ota-zip-v1' : 'bleam-macos-app-zip-v1'
216
- exactString(input.format, 'artifact.format', expectedFormat)
140
+ exactString(input.format, 'artifact.format', 'bleam-ota-zip-v1')
217
141
 
218
142
  const downloadId = string(input.downloadId, 'artifact.downloadId')
219
143
  if (!isDownloadId(downloadId)) {
@@ -229,113 +153,34 @@ function artifact(value: unknown, kind: StoredRelease['kind']): StoredArtifact {
229
153
  }
230
154
 
231
155
  return {
232
- format: expectedFormat,
156
+ format: 'bleam-ota-zip-v1',
233
157
  downloadId,
234
158
  sizeBytes: positiveInteger(input.sizeBytes, 'artifact.sizeBytes'),
235
159
  sha256,
236
160
  }
237
161
  }
238
162
 
239
- function releaseFields(input: Record<string, unknown>): ReleaseFields {
163
+ export function parseStoredRelease(value: unknown): StoredRelease {
164
+ const input = record(value, 'manifest')
240
165
  if (input.schemaVersion !== 1) {
241
166
  return invalid('schemaVersion', 'must be 1')
242
167
  }
243
-
168
+ exactString(input.kind, 'kind', 'ota')
244
169
  exactString(input.channel, 'channel', 'stable')
245
170
  return {
246
171
  schemaVersion: 1,
172
+ kind: 'ota',
247
173
  bundleIdentifier: bundleIdentifier(input.bundleIdentifier),
248
174
  teamIdentifier: teamIdentifier(input.teamIdentifier),
249
175
  channel: 'stable',
250
176
  releaseId: releaseId(input.releaseId),
177
+ bundleVersion: string(input.bundleVersion, 'bundleVersion'),
178
+ runtimeVersion: version(input.runtimeVersion, 'runtimeVersion'),
179
+ artifact: artifact(input.artifact),
251
180
  publishedAt: publishedAt(input.publishedAt),
252
181
  }
253
182
  }
254
183
 
255
- export function parseStoredRelease(value: unknown): StoredRelease {
256
- const input = record(value, 'manifest')
257
- const kind = string(input.kind, 'kind')
258
- const fields = releaseFields(input)
259
-
260
- if (kind === 'ota') {
261
- const parsedArtifact = artifact(input.artifact, kind)
262
- return {
263
- ...fields,
264
- kind,
265
- bundleVersion: string(input.bundleVersion, 'bundleVersion'),
266
- runtimeVersion: version(input.runtimeVersion, 'runtimeVersion'),
267
- artifact: {
268
- ...parsedArtifact,
269
- format: 'bleam-ota-zip-v1',
270
- },
271
- }
272
- }
273
-
274
- if (kind === 'platform') {
275
- const target = record(input.target, 'target')
276
- exactString(target.os, 'target.os', 'macos')
277
- exactString(target.architecture, 'target.architecture', 'arm64')
278
- exactString(
279
- target.installLocation,
280
- 'target.installLocation',
281
- 'user-applications',
282
- )
283
- const minimumMacOSVersion = string(
284
- target.minimumMacOSVersion,
285
- 'target.minimumMacOSVersion',
286
- )
287
- if (!/^\d+(?:\.\d+){0,2}$/.test(minimumMacOSVersion)) {
288
- return invalid(
289
- 'target.minimumMacOSVersion',
290
- 'must be a macOS version number',
291
- )
292
- }
293
-
294
- const parsedArtifact = artifact(input.artifact, kind)
295
- return {
296
- ...fields,
297
- kind,
298
- appVersion: version(input.appVersion, 'appVersion'),
299
- buildNumber: numericString(input.buildNumber, 'buildNumber'),
300
- bleamPlatformVersion: version(
301
- input.bleamPlatformVersion,
302
- 'bleamPlatformVersion',
303
- ),
304
- platformFingerprint: optionalSha256(
305
- input.platformFingerprint,
306
- 'platformFingerprint',
307
- ),
308
- redeploy: input.redeploy === true,
309
- target: {
310
- os: 'macos',
311
- architecture: 'arm64',
312
- installLocation: 'user-applications',
313
- minimumMacOSVersion,
314
- },
315
- artifact: {
316
- ...parsedArtifact,
317
- format: 'bleam-macos-app-zip-v1',
318
- },
319
- }
320
- }
321
-
322
- return invalid('kind', 'must be "ota" or "platform"')
323
- }
324
-
325
- export function parsePublishedRelease(value: unknown): StoredRelease {
326
- const release = parseStoredRelease(value)
327
- if (release.kind !== 'platform') return release
328
-
329
- const input = record(value, 'manifest')
330
- if (release.platformFingerprint === undefined) {
331
- return invalid('platformFingerprint', 'is required')
332
- }
333
- if (typeof input.redeploy !== 'boolean') {
334
- return invalid('redeploy', 'must be a boolean')
335
- }
336
- return release
337
- }
338
-
339
184
  export function parseDownloadRecord(value: unknown): DownloadRecord {
340
185
  const input = record(value, 'download record')
341
186
  if (input.schemaVersion !== 1) {