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/cli.cjs CHANGED
@@ -97,8 +97,6 @@ Commands:
97
97
  Build and install a standalone macOS app
98
98
  publish ota [dir] [--service-url <url>]
99
99
  Publish an OTA update to the local update service
100
- publish platform [dir] [--service-url <url>] [--redeploy]
101
- Build and publish a platform update locally
102
100
  doctor [dir] Check the local Bleam environment
103
101
  typecheck [dir] Typecheck project files
104
102
  check [dir] [--write] Format, lint, and organize imports
@@ -133,13 +131,6 @@ function parsePublishOtaOptions(argv) {
133
131
  serviceUrl: url.origin
134
132
  };
135
133
  }
136
- function parsePublishPlatformOptions(argv) {
137
- const redeploy = argv.includes("--redeploy");
138
- return {
139
- ...parsePublishOtaOptions(argv.filter((argument) => argument !== "--redeploy")),
140
- redeploy
141
- };
142
- }
143
134
  function invocationRoot() {
144
135
  const pwd = process.env.PWD;
145
136
  return pwd && node_path.default.isAbsolute(pwd) ? pwd : process.cwd();
@@ -198,7 +189,7 @@ function parseDevOptions(argv) {
198
189
  function parseNewOptions(argv) {
199
190
  const root = invocationRoot();
200
191
  let projectRoot;
201
- let template = "basic";
192
+ let template = "text-generation";
202
193
  for (let index = 0; index < argv.length; index += 1) {
203
194
  const arg = argv[index];
204
195
  if (arg === "--help" || arg === "-h") {
@@ -227,6 +218,7 @@ const projectTemplates = [
227
218
  "basic",
228
219
  "state",
229
220
  "foundation-models",
221
+ "text-generation",
230
222
  "image-generation"
231
223
  ];
232
224
  function projectTemplate(value) {
@@ -729,27 +721,6 @@ function prepareNativeIcon(nativeRoot, iconPath) {
729
721
  }
730
722
  }, null, 2)}\n`);
731
723
  }
732
- function platformInputFingerprint(config) {
733
- const iconSha256 = config.iconPath ? sha256(config.iconPath) : null;
734
- return (0, node_crypto.createHash)("sha256").update(JSON.stringify({
735
- schemaVersion: 1,
736
- bleamPlatformVersion: config.runtimeVersion,
737
- name: config.name,
738
- appVersion: config.version ?? "1.0.0",
739
- buildNumber: config.buildNumber,
740
- bundleIdentifier: config.bundleIdentifier,
741
- teamIdentifier: config.teamId,
742
- appGroups: config.appGroups,
743
- appearance: config.appearance,
744
- iconSha256,
745
- updateServiceUrl: process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl,
746
- target: {
747
- os: "macos",
748
- architecture: "arm64",
749
- minimumMacOSVersion: "14.0"
750
- }
751
- })).digest("hex");
752
- }
753
724
  function patchNativeProject(nativeRoot, config) {
754
725
  const projectPath = node_path.default.join(nativeRoot, "ios", "Bleam.xcodeproj", "project.pbxproj");
755
726
  const infoPlistPath = node_path.default.join(nativeRoot, "ios", "Bleam", "Info.plist");
@@ -763,7 +734,6 @@ function patchNativeProject(nativeRoot, config) {
763
734
  const version = xcodeSettingValue(config.version ?? "1.0.0");
764
735
  const buildNumber = xcodeSettingValue(config.buildNumber);
765
736
  const primaryAppGroup = config.appGroups[0];
766
- const fingerprint = platformInputFingerprint(config);
767
737
  let project = (0, node_fs.readFileSync)(projectPath, "utf8");
768
738
  project = project.replace(/PRODUCT_BUNDLE_IDENTIFIER = ([^;]+);/g, (_, current) => {
769
739
  return `PRODUCT_BUNDLE_IDENTIFIER = ${current.endsWith(".GenerationService") ? generationBundleIdentifier : bundleIdentifier};`;
@@ -781,7 +751,6 @@ function patchNativeProject(nativeRoot, config) {
781
751
  infoPlist = replacePlistString(infoPlist, "CFBundleDisplayName", config.name);
782
752
  infoPlist = replacePlistString(infoPlist, "CFBundleShortVersionString", config.version ?? "1.0.0");
783
753
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamRuntimeVersion", config.runtimeVersion);
784
- infoPlist = replaceOrInsertPlistString(infoPlist, "BleamPlatformFingerprint", fingerprint);
785
754
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamTeamIdentifier", config.teamId ?? "");
786
755
  const updateServiceUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl;
787
756
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamUpdateServiceURL", updateServiceUrl);
@@ -1065,147 +1034,6 @@ async function publishOta(options) {
1065
1034
  console.log(`Published OTA update ${releaseId}`);
1066
1035
  console.log(`${options.serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier)}/ota/${runtimeVersion}`);
1067
1036
  }
1068
- function compareVersions(left, right) {
1069
- const parse = (value) => {
1070
- const match = /^(\d+)\.(\d+)\.(\d+)(?:-([^+]+))?(?:\+.*)?$/.exec(value);
1071
- if (!match) throw new Error(`Invalid Bleam platform version: ${value}`);
1072
- return {
1073
- core: match.slice(1, 4).map(Number),
1074
- prerelease: match[4]?.split(".")
1075
- };
1076
- };
1077
- const a = parse(left);
1078
- const b = parse(right);
1079
- for (let index = 0; index < a.core.length; index += 1) if (a.core[index] !== b.core[index]) return (a.core[index] ?? 0) < (b.core[index] ?? 0) ? -1 : 1;
1080
- if (!a.prerelease && !b.prerelease) return 0;
1081
- if (!a.prerelease) return 1;
1082
- if (!b.prerelease) return -1;
1083
- const length = Math.max(a.prerelease.length, b.prerelease.length);
1084
- for (let index = 0; index < length; index += 1) {
1085
- const aPart = a.prerelease[index];
1086
- const bPart = b.prerelease[index];
1087
- if (aPart === void 0) return -1;
1088
- if (bPart === void 0) return 1;
1089
- if (aPart === bPart) continue;
1090
- const aNumber = /^\d+$/.test(aPart) ? Number(aPart) : void 0;
1091
- const bNumber = /^\d+$/.test(bPart) ? Number(bPart) : void 0;
1092
- if (aNumber !== void 0 && bNumber !== void 0) return aNumber < bNumber ? -1 : 1;
1093
- if (aNumber !== void 0) return -1;
1094
- if (bNumber !== void 0) return 1;
1095
- return aPart < bPart ? -1 : 1;
1096
- }
1097
- return 0;
1098
- }
1099
- function platformPublicationReason(active, target, redeploy) {
1100
- if (active && compareVersions(target.bleamPlatformVersion, active.bleamPlatformVersion) < 0) throw new Error(`Cannot publish older Bleam platform ${target.bleamPlatformVersion} over ${active.bleamPlatformVersion}. Rollback requires a separate release operation.`);
1101
- const unchanged = active?.platformFingerprint === target.platformFingerprint;
1102
- if (unchanged && !redeploy) throw new Error("Platform inputs are unchanged. Developer code and ordinary assets must be published with bleam publish ota. Use --redeploy only to intentionally republish identical platform inputs.");
1103
- if (!unchanged && redeploy) throw new Error("--redeploy requires an existing release with the same platform fingerprint; publish normally because platform inputs changed.");
1104
- if (unchanged) return "redeploy";
1105
- if (!active) return "first-release";
1106
- if (!active.platformFingerprint) return "legacy-migration";
1107
- if (active.bleamPlatformVersion !== target.bleamPlatformVersion) return "runtime-upgrade";
1108
- return "signed-input-change";
1109
- }
1110
- async function activePlatformRelease(serviceUrl, config) {
1111
- const response = await fetch(`${serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier ?? "")}/platform/macos-arm64`, { cache: "no-store" });
1112
- if (response.status === 404) return void 0;
1113
- if (!response.ok) throw new Error(`Could not resolve the active platform release: ${response.status} ${await response.text()}`);
1114
- const release = await response.json();
1115
- if (release.kind !== "platform" || release.bundleIdentifier !== config.bundleIdentifier || release.teamIdentifier !== config.teamId || typeof release.bleamPlatformVersion !== "string" || release.platformFingerprint !== void 0 && (typeof release.platformFingerprint !== "string" || !/^[a-f0-9]{64}$/.test(release.platformFingerprint))) throw new Error("The active platform release is invalid for this app");
1116
- return {
1117
- bleamPlatformVersion: release.bleamPlatformVersion,
1118
- platformFingerprint: release.platformFingerprint
1119
- };
1120
- }
1121
- async function publishPlatform(options) {
1122
- const config = readProjectConfig(options);
1123
- if (!config.bundleIdentifier) throw missingBuildFieldError("bundleIdentifier");
1124
- if (!config.teamId) throw missingBuildFieldError("teamId");
1125
- const fingerprint = platformInputFingerprint(config);
1126
- const active = await activePlatformRelease(options.serviceUrl, config);
1127
- console.log(`Bleam platform: ${active?.bleamPlatformVersion ?? "none"} -> ${config.runtimeVersion}`);
1128
- console.log(`Platform fingerprint: ${active?.platformFingerprint ?? "none"} -> ${fingerprint}`);
1129
- const reason = platformPublicationReason(active, {
1130
- bleamPlatformVersion: config.runtimeVersion,
1131
- platformFingerprint: fingerprint
1132
- }, options.redeploy);
1133
- if (reason === "redeploy") console.log("Redeploying unchanged platform inputs by explicit request");
1134
- else if (reason === "first-release") console.log("Publishing the first platform release for this app");
1135
- else if (reason === "legacy-migration") console.log("Migrating the active legacy release to platform fingerprints");
1136
- else if (reason === "runtime-upgrade") console.log("Publishing a Bleam platform runtime upgrade");
1137
- else console.log("Publishing changed signed app metadata or resources");
1138
- const archivePath = await buildNativeArchives({
1139
- projectRoot: options.projectRoot,
1140
- output: node_path.default.join(options.projectRoot, "dist"),
1141
- configuration: "Release",
1142
- clean: false
1143
- });
1144
- const products = node_path.default.join(archivePath, "Products", "Applications");
1145
- const appName = (0, node_fs.readdirSync)(products).find((name) => name.endsWith(".app"));
1146
- if (!appName) throw new Error(`Archive does not contain a macOS app: ${archivePath}`);
1147
- const outputRoot = node_path.default.join(options.projectRoot, ".bleam", "publish", "platform");
1148
- const stagingRoot = node_path.default.join(outputRoot, "app");
1149
- const artifactPath = node_path.default.join(outputRoot, "platform.zip");
1150
- (0, node_fs.rmSync)(outputRoot, {
1151
- recursive: true,
1152
- force: true
1153
- });
1154
- (0, node_fs.mkdirSync)(stagingRoot, { recursive: true });
1155
- (0, node_child_process.execFileSync)("ditto", [node_path.default.join(products, appName), node_path.default.join(stagingRoot, appName)]);
1156
- runInheritedCommand("zip", [
1157
- "-q",
1158
- "-r",
1159
- "-y",
1160
- artifactPath,
1161
- "app"
1162
- ], outputRoot);
1163
- const sizeBytes = (0, node_fs.readFileSync)(artifactPath).byteLength;
1164
- const digest = sha256(artifactPath);
1165
- const releaseId = `platform_${Date.now().toString(36)}_${digest.slice(0, 12)}`;
1166
- const release = platformRelease(config, releaseId, sizeBytes, digest, options.redeploy);
1167
- const response = await fetch(`${options.serviceUrl}/v1/local/releases/platform`, {
1168
- method: "POST",
1169
- headers: { "content-type": "application/json" },
1170
- body: JSON.stringify({
1171
- release,
1172
- artifactBase64: (0, node_fs.readFileSync)(artifactPath).toString("base64")
1173
- })
1174
- });
1175
- if (!response.ok) throw new Error(`Local platform publication failed: ${response.status} ${await response.text()}`);
1176
- console.log(`Published platform update ${releaseId}`);
1177
- console.log(`${options.serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier)}/platform/macos-arm64`);
1178
- }
1179
- function platformRelease(config, releaseId, sizeBytes, digest, redeploy = false) {
1180
- if (!config.bundleIdentifier) throw missingBuildFieldError("bundleIdentifier");
1181
- if (!config.teamId) throw missingBuildFieldError("teamId");
1182
- return {
1183
- schemaVersion: 1,
1184
- kind: "platform",
1185
- bundleIdentifier: config.bundleIdentifier,
1186
- teamIdentifier: config.teamId,
1187
- channel: "stable",
1188
- releaseId,
1189
- appVersion: config.version ?? "1.0.0",
1190
- buildNumber: config.buildNumber,
1191
- bleamPlatformVersion: config.runtimeVersion,
1192
- platformFingerprint: platformInputFingerprint(config),
1193
- redeploy,
1194
- target: {
1195
- os: "macos",
1196
- architecture: "arm64",
1197
- installLocation: "user-applications",
1198
- minimumMacOSVersion: "14.0"
1199
- },
1200
- artifact: {
1201
- format: "bleam-macos-app-zip-v1",
1202
- downloadId: releaseId,
1203
- sizeBytes,
1204
- sha256: digest
1205
- },
1206
- publishedAt: (/* @__PURE__ */ new Date()).toISOString()
1207
- };
1208
- }
1209
1037
  function runtimeCacheRoot() {
1210
1038
  return node_path.default.join(node_os.default.homedir(), "Library", "Caches", "bleam", "runtimes", runtimeVersion, artifactPlatform());
1211
1039
  }
@@ -2082,11 +1910,7 @@ async function main(argv = process.argv.slice(2)) {
2082
1910
  await publishOta(parsePublishOtaOptions(publishArgs));
2083
1911
  return;
2084
1912
  }
2085
- if (kind === "platform") {
2086
- await publishPlatform(parsePublishPlatformOptions(publishArgs));
2087
- return;
2088
- }
2089
- throw new Error("Usage: bleam publish <ota|platform> [dir] [--service-url <url>] [--redeploy]");
1913
+ throw new Error("Usage: bleam publish ota [dir] [--service-url <url>]");
2090
1914
  }
2091
1915
  if (command === "doctor") {
2092
1916
  runDoctor(parseDoctorOptions(args));
@@ -2131,10 +1955,6 @@ const __test = {
2131
1955
  parseBuildOptions,
2132
1956
  parseNewOptions,
2133
1957
  parsePublishOtaOptions,
2134
- parsePublishPlatformOptions,
2135
- platformInputFingerprint,
2136
- platformPublicationReason,
2137
- platformRelease,
2138
1958
  podInstallInputStamp,
2139
1959
  replaceOrInsertPlistString
2140
1960
  };
package/dist/cli.d.cts CHANGED
@@ -13,9 +13,6 @@ interface PublishOtaOptions {
13
13
  projectRoot: string;
14
14
  serviceUrl: string;
15
15
  }
16
- interface PublishPlatformOptions extends PublishOtaOptions {
17
- redeploy: boolean;
18
- }
19
16
  interface ProjectConfig {
20
17
  name: string;
21
18
  version?: string;
@@ -29,12 +26,11 @@ interface ProjectConfig {
29
26
  iconPath?: string;
30
27
  }
31
28
  declare function parsePublishOtaOptions(argv: string[]): PublishOtaOptions;
32
- declare function parsePublishPlatformOptions(argv: string[]): PublishPlatformOptions;
33
29
  declare function parseNewOptions(argv: string[]): {
34
30
  projectRoot: string;
35
- template: "state" | "basic" | "foundation-models" | "image-generation";
31
+ template: "state" | "basic" | "foundation-models" | "text-generation" | "image-generation";
36
32
  };
37
- declare const projectTemplates: readonly ["basic", "state", "foundation-models", "image-generation"];
33
+ declare const projectTemplates: readonly ["basic", "state", "foundation-models", "text-generation", "image-generation"];
38
34
  type ProjectTemplate = (typeof projectTemplates)[number];
39
35
  declare function parseBuildOptions(argv: string[]): BuildOptions;
40
36
  declare function createProject(options: {
@@ -49,7 +45,6 @@ declare function localUpdateServicePaths(home?: string): {
49
45
  log: string;
50
46
  };
51
47
  declare function replaceOrInsertPlistString(plist: string, key: string, value: string): string;
52
- declare function platformInputFingerprint(config: ProjectConfig): string;
53
48
  declare function createBuildNativeWorkspace(options: BuildOptions, config: ProjectConfig): string;
54
49
  declare function podInstallInputStamp(iosRoot: string): string;
55
50
  declare function hasCurrentPodInstall(iosRoot: string, expectedStamp: string): boolean;
@@ -60,41 +55,6 @@ declare function nativeArchiveArgs(options: {
60
55
  }): string[];
61
56
  declare function installArchivedApp(archivePath: string, applications?: string): string;
62
57
  declare function installedAppPath(appName: string): string;
63
- interface ActivePlatformRelease {
64
- bleamPlatformVersion: string;
65
- platformFingerprint?: string;
66
- }
67
- type PlatformPublicationReason = 'first-release' | 'legacy-migration' | 'runtime-upgrade' | 'signed-input-change' | 'redeploy';
68
- declare function platformPublicationReason(active: ActivePlatformRelease | undefined, target: {
69
- bleamPlatformVersion: string;
70
- platformFingerprint: string;
71
- }, redeploy: boolean): PlatformPublicationReason;
72
- declare function platformRelease(config: ProjectConfig, releaseId: string, sizeBytes: number, digest: string, redeploy?: boolean): {
73
- schemaVersion: number;
74
- kind: string;
75
- bundleIdentifier: string;
76
- teamIdentifier: string;
77
- channel: string;
78
- releaseId: string;
79
- appVersion: string;
80
- buildNumber: string;
81
- bleamPlatformVersion: string;
82
- platformFingerprint: string;
83
- redeploy: boolean;
84
- target: {
85
- os: string;
86
- architecture: string;
87
- installLocation: string;
88
- minimumMacOSVersion: string;
89
- };
90
- artifact: {
91
- format: string;
92
- downloadId: string;
93
- sizeBytes: number;
94
- sha256: string;
95
- };
96
- publishedAt: string;
97
- };
98
58
  declare const __test: {
99
59
  createProject: typeof createProject;
100
60
  createBuildNativeWorkspace: typeof createBuildNativeWorkspace;
@@ -108,10 +68,6 @@ declare const __test: {
108
68
  parseBuildOptions: typeof parseBuildOptions;
109
69
  parseNewOptions: typeof parseNewOptions;
110
70
  parsePublishOtaOptions: typeof parsePublishOtaOptions;
111
- parsePublishPlatformOptions: typeof parsePublishPlatformOptions;
112
- platformInputFingerprint: typeof platformInputFingerprint;
113
- platformPublicationReason: typeof platformPublicationReason;
114
- platformRelease: typeof platformRelease;
115
71
  podInstallInputStamp: typeof podInstallInputStamp;
116
72
  replaceOrInsertPlistString: typeof replaceOrInsertPlistString;
117
73
  };
package/dist/cli.d.ts CHANGED
@@ -13,9 +13,6 @@ interface PublishOtaOptions {
13
13
  projectRoot: string;
14
14
  serviceUrl: string;
15
15
  }
16
- interface PublishPlatformOptions extends PublishOtaOptions {
17
- redeploy: boolean;
18
- }
19
16
  interface ProjectConfig {
20
17
  name: string;
21
18
  version?: string;
@@ -29,12 +26,11 @@ interface ProjectConfig {
29
26
  iconPath?: string;
30
27
  }
31
28
  declare function parsePublishOtaOptions(argv: string[]): PublishOtaOptions;
32
- declare function parsePublishPlatformOptions(argv: string[]): PublishPlatformOptions;
33
29
  declare function parseNewOptions(argv: string[]): {
34
30
  projectRoot: string;
35
- template: "state" | "basic" | "foundation-models" | "image-generation";
31
+ template: "state" | "basic" | "foundation-models" | "text-generation" | "image-generation";
36
32
  };
37
- declare const projectTemplates: readonly ["basic", "state", "foundation-models", "image-generation"];
33
+ declare const projectTemplates: readonly ["basic", "state", "foundation-models", "text-generation", "image-generation"];
38
34
  type ProjectTemplate = (typeof projectTemplates)[number];
39
35
  declare function parseBuildOptions(argv: string[]): BuildOptions;
40
36
  declare function createProject(options: {
@@ -49,7 +45,6 @@ declare function localUpdateServicePaths(home?: string): {
49
45
  log: string;
50
46
  };
51
47
  declare function replaceOrInsertPlistString(plist: string, key: string, value: string): string;
52
- declare function platformInputFingerprint(config: ProjectConfig): string;
53
48
  declare function createBuildNativeWorkspace(options: BuildOptions, config: ProjectConfig): string;
54
49
  declare function podInstallInputStamp(iosRoot: string): string;
55
50
  declare function hasCurrentPodInstall(iosRoot: string, expectedStamp: string): boolean;
@@ -60,41 +55,6 @@ declare function nativeArchiveArgs(options: {
60
55
  }): string[];
61
56
  declare function installArchivedApp(archivePath: string, applications?: string): string;
62
57
  declare function installedAppPath(appName: string): string;
63
- interface ActivePlatformRelease {
64
- bleamPlatformVersion: string;
65
- platformFingerprint?: string;
66
- }
67
- type PlatformPublicationReason = 'first-release' | 'legacy-migration' | 'runtime-upgrade' | 'signed-input-change' | 'redeploy';
68
- declare function platformPublicationReason(active: ActivePlatformRelease | undefined, target: {
69
- bleamPlatformVersion: string;
70
- platformFingerprint: string;
71
- }, redeploy: boolean): PlatformPublicationReason;
72
- declare function platformRelease(config: ProjectConfig, releaseId: string, sizeBytes: number, digest: string, redeploy?: boolean): {
73
- schemaVersion: number;
74
- kind: string;
75
- bundleIdentifier: string;
76
- teamIdentifier: string;
77
- channel: string;
78
- releaseId: string;
79
- appVersion: string;
80
- buildNumber: string;
81
- bleamPlatformVersion: string;
82
- platformFingerprint: string;
83
- redeploy: boolean;
84
- target: {
85
- os: string;
86
- architecture: string;
87
- installLocation: string;
88
- minimumMacOSVersion: string;
89
- };
90
- artifact: {
91
- format: string;
92
- downloadId: string;
93
- sizeBytes: number;
94
- sha256: string;
95
- };
96
- publishedAt: string;
97
- };
98
58
  declare const __test: {
99
59
  createProject: typeof createProject;
100
60
  createBuildNativeWorkspace: typeof createBuildNativeWorkspace;
@@ -108,10 +68,6 @@ declare const __test: {
108
68
  parseBuildOptions: typeof parseBuildOptions;
109
69
  parseNewOptions: typeof parseNewOptions;
110
70
  parsePublishOtaOptions: typeof parsePublishOtaOptions;
111
- parsePublishPlatformOptions: typeof parsePublishPlatformOptions;
112
- platformInputFingerprint: typeof platformInputFingerprint;
113
- platformPublicationReason: typeof platformPublicationReason;
114
- platformRelease: typeof platformRelease;
115
71
  podInstallInputStamp: typeof podInstallInputStamp;
116
72
  replaceOrInsertPlistString: typeof replaceOrInsertPlistString;
117
73
  };
package/dist/cli.js CHANGED
@@ -85,8 +85,6 @@ Commands:
85
85
  Build and install a standalone macOS app
86
86
  publish ota [dir] [--service-url <url>]
87
87
  Publish an OTA update to the local update service
88
- publish platform [dir] [--service-url <url>] [--redeploy]
89
- Build and publish a platform update locally
90
88
  doctor [dir] Check the local Bleam environment
91
89
  typecheck [dir] Typecheck project files
92
90
  check [dir] [--write] Format, lint, and organize imports
@@ -121,13 +119,6 @@ function parsePublishOtaOptions(argv) {
121
119
  serviceUrl: url.origin
122
120
  };
123
121
  }
124
- function parsePublishPlatformOptions(argv) {
125
- const redeploy = argv.includes("--redeploy");
126
- return {
127
- ...parsePublishOtaOptions(argv.filter((argument) => argument !== "--redeploy")),
128
- redeploy
129
- };
130
- }
131
122
  function invocationRoot() {
132
123
  const pwd = process.env.PWD;
133
124
  return pwd && path.isAbsolute(pwd) ? pwd : process.cwd();
@@ -186,7 +177,7 @@ function parseDevOptions(argv) {
186
177
  function parseNewOptions(argv) {
187
178
  const root = invocationRoot();
188
179
  let projectRoot;
189
- let template = "basic";
180
+ let template = "text-generation";
190
181
  for (let index = 0; index < argv.length; index += 1) {
191
182
  const arg = argv[index];
192
183
  if (arg === "--help" || arg === "-h") {
@@ -215,6 +206,7 @@ const projectTemplates = [
215
206
  "basic",
216
207
  "state",
217
208
  "foundation-models",
209
+ "text-generation",
218
210
  "image-generation"
219
211
  ];
220
212
  function projectTemplate(value) {
@@ -717,27 +709,6 @@ function prepareNativeIcon(nativeRoot, iconPath) {
717
709
  }
718
710
  }, null, 2)}\n`);
719
711
  }
720
- function platformInputFingerprint(config) {
721
- const iconSha256 = config.iconPath ? sha256(config.iconPath) : null;
722
- return createHash("sha256").update(JSON.stringify({
723
- schemaVersion: 1,
724
- bleamPlatformVersion: config.runtimeVersion,
725
- name: config.name,
726
- appVersion: config.version ?? "1.0.0",
727
- buildNumber: config.buildNumber,
728
- bundleIdentifier: config.bundleIdentifier,
729
- teamIdentifier: config.teamId,
730
- appGroups: config.appGroups,
731
- appearance: config.appearance,
732
- iconSha256,
733
- updateServiceUrl: process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl,
734
- target: {
735
- os: "macos",
736
- architecture: "arm64",
737
- minimumMacOSVersion: "14.0"
738
- }
739
- })).digest("hex");
740
- }
741
712
  function patchNativeProject(nativeRoot, config) {
742
713
  const projectPath = path.join(nativeRoot, "ios", "Bleam.xcodeproj", "project.pbxproj");
743
714
  const infoPlistPath = path.join(nativeRoot, "ios", "Bleam", "Info.plist");
@@ -751,7 +722,6 @@ function patchNativeProject(nativeRoot, config) {
751
722
  const version = xcodeSettingValue(config.version ?? "1.0.0");
752
723
  const buildNumber = xcodeSettingValue(config.buildNumber);
753
724
  const primaryAppGroup = config.appGroups[0];
754
- const fingerprint = platformInputFingerprint(config);
755
725
  let project = readFileSync(projectPath, "utf8");
756
726
  project = project.replace(/PRODUCT_BUNDLE_IDENTIFIER = ([^;]+);/g, (_, current) => {
757
727
  return `PRODUCT_BUNDLE_IDENTIFIER = ${current.endsWith(".GenerationService") ? generationBundleIdentifier : bundleIdentifier};`;
@@ -769,7 +739,6 @@ function patchNativeProject(nativeRoot, config) {
769
739
  infoPlist = replacePlistString(infoPlist, "CFBundleDisplayName", config.name);
770
740
  infoPlist = replacePlistString(infoPlist, "CFBundleShortVersionString", config.version ?? "1.0.0");
771
741
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamRuntimeVersion", config.runtimeVersion);
772
- infoPlist = replaceOrInsertPlistString(infoPlist, "BleamPlatformFingerprint", fingerprint);
773
742
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamTeamIdentifier", config.teamId ?? "");
774
743
  const updateServiceUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl;
775
744
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamUpdateServiceURL", updateServiceUrl);
@@ -1053,147 +1022,6 @@ async function publishOta(options) {
1053
1022
  console.log(`Published OTA update ${releaseId}`);
1054
1023
  console.log(`${options.serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier)}/ota/${runtimeVersion}`);
1055
1024
  }
1056
- function compareVersions(left, right) {
1057
- const parse = (value) => {
1058
- const match = /^(\d+)\.(\d+)\.(\d+)(?:-([^+]+))?(?:\+.*)?$/.exec(value);
1059
- if (!match) throw new Error(`Invalid Bleam platform version: ${value}`);
1060
- return {
1061
- core: match.slice(1, 4).map(Number),
1062
- prerelease: match[4]?.split(".")
1063
- };
1064
- };
1065
- const a = parse(left);
1066
- const b = parse(right);
1067
- for (let index = 0; index < a.core.length; index += 1) if (a.core[index] !== b.core[index]) return (a.core[index] ?? 0) < (b.core[index] ?? 0) ? -1 : 1;
1068
- if (!a.prerelease && !b.prerelease) return 0;
1069
- if (!a.prerelease) return 1;
1070
- if (!b.prerelease) return -1;
1071
- const length = Math.max(a.prerelease.length, b.prerelease.length);
1072
- for (let index = 0; index < length; index += 1) {
1073
- const aPart = a.prerelease[index];
1074
- const bPart = b.prerelease[index];
1075
- if (aPart === void 0) return -1;
1076
- if (bPart === void 0) return 1;
1077
- if (aPart === bPart) continue;
1078
- const aNumber = /^\d+$/.test(aPart) ? Number(aPart) : void 0;
1079
- const bNumber = /^\d+$/.test(bPart) ? Number(bPart) : void 0;
1080
- if (aNumber !== void 0 && bNumber !== void 0) return aNumber < bNumber ? -1 : 1;
1081
- if (aNumber !== void 0) return -1;
1082
- if (bNumber !== void 0) return 1;
1083
- return aPart < bPart ? -1 : 1;
1084
- }
1085
- return 0;
1086
- }
1087
- function platformPublicationReason(active, target, redeploy) {
1088
- if (active && compareVersions(target.bleamPlatformVersion, active.bleamPlatformVersion) < 0) throw new Error(`Cannot publish older Bleam platform ${target.bleamPlatformVersion} over ${active.bleamPlatformVersion}. Rollback requires a separate release operation.`);
1089
- const unchanged = active?.platformFingerprint === target.platformFingerprint;
1090
- if (unchanged && !redeploy) throw new Error("Platform inputs are unchanged. Developer code and ordinary assets must be published with bleam publish ota. Use --redeploy only to intentionally republish identical platform inputs.");
1091
- if (!unchanged && redeploy) throw new Error("--redeploy requires an existing release with the same platform fingerprint; publish normally because platform inputs changed.");
1092
- if (unchanged) return "redeploy";
1093
- if (!active) return "first-release";
1094
- if (!active.platformFingerprint) return "legacy-migration";
1095
- if (active.bleamPlatformVersion !== target.bleamPlatformVersion) return "runtime-upgrade";
1096
- return "signed-input-change";
1097
- }
1098
- async function activePlatformRelease(serviceUrl, config) {
1099
- const response = await fetch(`${serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier ?? "")}/platform/macos-arm64`, { cache: "no-store" });
1100
- if (response.status === 404) return void 0;
1101
- if (!response.ok) throw new Error(`Could not resolve the active platform release: ${response.status} ${await response.text()}`);
1102
- const release = await response.json();
1103
- if (release.kind !== "platform" || release.bundleIdentifier !== config.bundleIdentifier || release.teamIdentifier !== config.teamId || typeof release.bleamPlatformVersion !== "string" || release.platformFingerprint !== void 0 && (typeof release.platformFingerprint !== "string" || !/^[a-f0-9]{64}$/.test(release.platformFingerprint))) throw new Error("The active platform release is invalid for this app");
1104
- return {
1105
- bleamPlatformVersion: release.bleamPlatformVersion,
1106
- platformFingerprint: release.platformFingerprint
1107
- };
1108
- }
1109
- async function publishPlatform(options) {
1110
- const config = readProjectConfig(options);
1111
- if (!config.bundleIdentifier) throw missingBuildFieldError("bundleIdentifier");
1112
- if (!config.teamId) throw missingBuildFieldError("teamId");
1113
- const fingerprint = platformInputFingerprint(config);
1114
- const active = await activePlatformRelease(options.serviceUrl, config);
1115
- console.log(`Bleam platform: ${active?.bleamPlatformVersion ?? "none"} -> ${config.runtimeVersion}`);
1116
- console.log(`Platform fingerprint: ${active?.platformFingerprint ?? "none"} -> ${fingerprint}`);
1117
- const reason = platformPublicationReason(active, {
1118
- bleamPlatformVersion: config.runtimeVersion,
1119
- platformFingerprint: fingerprint
1120
- }, options.redeploy);
1121
- if (reason === "redeploy") console.log("Redeploying unchanged platform inputs by explicit request");
1122
- else if (reason === "first-release") console.log("Publishing the first platform release for this app");
1123
- else if (reason === "legacy-migration") console.log("Migrating the active legacy release to platform fingerprints");
1124
- else if (reason === "runtime-upgrade") console.log("Publishing a Bleam platform runtime upgrade");
1125
- else console.log("Publishing changed signed app metadata or resources");
1126
- const archivePath = await buildNativeArchives({
1127
- projectRoot: options.projectRoot,
1128
- output: path.join(options.projectRoot, "dist"),
1129
- configuration: "Release",
1130
- clean: false
1131
- });
1132
- const products = path.join(archivePath, "Products", "Applications");
1133
- const appName = readdirSync(products).find((name) => name.endsWith(".app"));
1134
- if (!appName) throw new Error(`Archive does not contain a macOS app: ${archivePath}`);
1135
- const outputRoot = path.join(options.projectRoot, ".bleam", "publish", "platform");
1136
- const stagingRoot = path.join(outputRoot, "app");
1137
- const artifactPath = path.join(outputRoot, "platform.zip");
1138
- rmSync(outputRoot, {
1139
- recursive: true,
1140
- force: true
1141
- });
1142
- mkdirSync(stagingRoot, { recursive: true });
1143
- execFileSync("ditto", [path.join(products, appName), path.join(stagingRoot, appName)]);
1144
- runInheritedCommand("zip", [
1145
- "-q",
1146
- "-r",
1147
- "-y",
1148
- artifactPath,
1149
- "app"
1150
- ], outputRoot);
1151
- const sizeBytes = readFileSync(artifactPath).byteLength;
1152
- const digest = sha256(artifactPath);
1153
- const releaseId = `platform_${Date.now().toString(36)}_${digest.slice(0, 12)}`;
1154
- const release = platformRelease(config, releaseId, sizeBytes, digest, options.redeploy);
1155
- const response = await fetch(`${options.serviceUrl}/v1/local/releases/platform`, {
1156
- method: "POST",
1157
- headers: { "content-type": "application/json" },
1158
- body: JSON.stringify({
1159
- release,
1160
- artifactBase64: readFileSync(artifactPath).toString("base64")
1161
- })
1162
- });
1163
- if (!response.ok) throw new Error(`Local platform publication failed: ${response.status} ${await response.text()}`);
1164
- console.log(`Published platform update ${releaseId}`);
1165
- console.log(`${options.serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier)}/platform/macos-arm64`);
1166
- }
1167
- function platformRelease(config, releaseId, sizeBytes, digest, redeploy = false) {
1168
- if (!config.bundleIdentifier) throw missingBuildFieldError("bundleIdentifier");
1169
- if (!config.teamId) throw missingBuildFieldError("teamId");
1170
- return {
1171
- schemaVersion: 1,
1172
- kind: "platform",
1173
- bundleIdentifier: config.bundleIdentifier,
1174
- teamIdentifier: config.teamId,
1175
- channel: "stable",
1176
- releaseId,
1177
- appVersion: config.version ?? "1.0.0",
1178
- buildNumber: config.buildNumber,
1179
- bleamPlatformVersion: config.runtimeVersion,
1180
- platformFingerprint: platformInputFingerprint(config),
1181
- redeploy,
1182
- target: {
1183
- os: "macos",
1184
- architecture: "arm64",
1185
- installLocation: "user-applications",
1186
- minimumMacOSVersion: "14.0"
1187
- },
1188
- artifact: {
1189
- format: "bleam-macos-app-zip-v1",
1190
- downloadId: releaseId,
1191
- sizeBytes,
1192
- sha256: digest
1193
- },
1194
- publishedAt: (/* @__PURE__ */ new Date()).toISOString()
1195
- };
1196
- }
1197
1025
  function runtimeCacheRoot() {
1198
1026
  return path.join(os.homedir(), "Library", "Caches", "bleam", "runtimes", runtimeVersion, artifactPlatform());
1199
1027
  }
@@ -2070,11 +1898,7 @@ async function main(argv = process.argv.slice(2)) {
2070
1898
  await publishOta(parsePublishOtaOptions(publishArgs));
2071
1899
  return;
2072
1900
  }
2073
- if (kind === "platform") {
2074
- await publishPlatform(parsePublishPlatformOptions(publishArgs));
2075
- return;
2076
- }
2077
- throw new Error("Usage: bleam publish <ota|platform> [dir] [--service-url <url>] [--redeploy]");
1901
+ throw new Error("Usage: bleam publish ota [dir] [--service-url <url>]");
2078
1902
  }
2079
1903
  if (command === "doctor") {
2080
1904
  runDoctor(parseDoctorOptions(args));
@@ -2119,10 +1943,6 @@ const __test = {
2119
1943
  parseBuildOptions,
2120
1944
  parseNewOptions,
2121
1945
  parsePublishOtaOptions,
2122
- parsePublishPlatformOptions,
2123
- platformInputFingerprint,
2124
- platformPublicationReason,
2125
- platformRelease,
2126
1946
  podInstallInputStamp,
2127
1947
  replaceOrInsertPlistString
2128
1948
  };
package/dist/files.d.cts 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-DwA7pzr3.cjs";
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-Dt5mbzLq.cjs";
2
2
  export { CreateDirectoryOptions, DirectoryRef, DownloadOptions, DownloadProgress, DownloadTask, FilePaths, FileRef, FileStat, FileType, PickFileType, PickOptions, RemoveOptions, WriteOptions, files };