umer-wasim commited on
Commit
796f85b
·
verified ·
1 Parent(s): 4822334

0.1.3: Lightning AI and Cloudflare online, Kaggle API tokens

Browse files
README.md CHANGED
@@ -21,12 +21,12 @@ Ora is a desktop app that makes short videos from text prompts **on your own com
21
 
22
  Nothing is uploaded and no account is needed. The app downloads the models once (pinned revisions, SHA-256 checked) and then works offline.
23
 
24
- ## Models and online GPU (0.1.2)
25
 
26
  - **Video:** Wan2.1 1.3B (Fast/Preview), Wan2.2 5B (Quality, also animates images), Wan2.2 A14B (Pro), LTX-2.3 22B (video with sound, beta), MiniMax H3 (up to 15 s with sound, beta).
27
  - **Images:** Z-Image-Turbo 6B, FLUX.1-schnell 12B, Qwen-Image-2512 20B.
28
  - The app checks the computer and locks models it cannot run, with the reason.
29
- - **Online GPU (beta):** connect your own Kaggle (API token) or Google Colab (one notebook line + connection code) and choose Run on › Online. The worker is [`worker/ora_worker.py`](worker/ora_worker.py); the CUDA engine is in the releases repo.
30
 
31
  ## Install
32
 
 
21
 
22
  Nothing is uploaded and no account is needed. The app downloads the models once (pinned revisions, SHA-256 checked) and then works offline.
23
 
24
+ ## Models and online GPU
25
 
26
  - **Video:** Wan2.1 1.3B (Fast/Preview), Wan2.2 5B (Quality, also animates images), Wan2.2 A14B (Pro), LTX-2.3 22B (video with sound, beta), MiniMax H3 (up to 15 s with sound, beta).
27
  - **Images:** Z-Image-Turbo 6B, FLUX.1-schnell 12B, Qwen-Image-2512 20B.
28
  - The app checks the computer and locks models it cannot run, with the reason.
29
+ - **Online (beta):** connect your own Kaggle (API token), Google Colab or Lightning AI (one line + connection code), or Cloudflare Workers AI (images), and choose Run on › Online. The worker is [`worker/ora_worker.py`](worker/ora_worker.py); the CUDA engine is in the releases repo.
30
 
31
  ## Install
32
 
app/main.cjs CHANGED
@@ -260,9 +260,17 @@ function recordUsage(where, seconds, what) {
260
  u.runs = u.runs.filter(x => Date.parse(x.at) > cutoff);
261
  fs.writeFileSync(USAGE, JSON.stringify(u, null, 2));
262
  }
 
 
 
 
 
263
  function usageSummary() {
264
  const u = readUsage(), week = Date.now() - 7 * 864e5;
265
  const out = {};
 
 
 
266
  for (const where of ['kaggle', 'colab']) {
267
  const runs = u.runs.filter(x => x.where === where);
268
  const last7 = runs.filter(x => Date.parse(x.at) > week).reduce((a, x) => a + x.seconds, 0);
@@ -286,7 +294,9 @@ async function remoteHardware(where) {
286
  const raw = (st && st.gpu) || '';
287
  const m = /^(.*?),\s*(\d+)\s*MiB/.exec(raw);
288
  const name = m ? `${m[1]} · ${Math.round(+m[2] / 1024)} GB` : (raw && !/no NVIDIA/.test(raw) ? raw : 'GPU (shown after the first run)');
289
- return { cpu: where === 'kaggle' ? 'Your Kaggle notebook' : 'Your Colab notebook', cores: 0, ram: 0, gpus: [{ vendor: '', name }], engine: { id: `online-${where}`, gpu: true, args: [] } };
 
 
290
  }
291
 
292
  // Runs sd-cli for one job and streams progress to the renderer. Resolves with { code, cancelled, started }.
@@ -465,7 +475,7 @@ async function prepareImages(input, where) {
465
 
466
  async function finishImages(p, code, started) {
467
  const { id, dir, meta, req } = p;
468
- const images = (await fsp.readdir(dir)).filter(f => /^img_\d+\.png$/.test(f)).sort();
469
  meta.seconds_taken = Math.round((Date.now() - started) / 1000);
470
  if (code !== 0 || images.length === 0) return engineFailed(id, dir, meta, code);
471
  // copy to Pictures/Ora/<project>/ as "01 title.png", "01 title 2.png" … (shot number first, like videos)
@@ -474,8 +484,9 @@ async function finishImages(p, code, started) {
474
  const base = req.project ? `${String(req.project.index).padStart(2, '0')} ${core.folderName(req.project.title, 40)}` : `Ora ${meta.created.slice(0, 10)} ${core.slug(req.prompt, 40)}`;
475
  meta.savedFiles = [];
476
  for (const [i, f] of images.entries()) {
477
- let target = path.join(dirOut, `${base}${i ? ` ${i + 1}` : ''}.png`), n = 2;
478
- while (fs.existsSync(target)) target = path.join(dirOut, `${base}${i ? ` ${i + 1}` : ''} (${n++}).png`);
 
479
  await fsp.copyFile(path.join(dir, f), target);
480
  meta.savedFiles.push(target);
481
  }
@@ -487,6 +498,7 @@ async function finishImages(p, code, started) {
487
 
488
  async function generateImages(input) {
489
  if (job) throw new Error('Something is already being made.');
 
490
  const where = input.runOn === 'colab' ? 'colab' : 'local';
491
  const p = await prepareImages(input, where);
492
  if (where === 'colab') return runOnColab(p, p.run.steps, () => finishImages(p, 0, p.started));
@@ -499,6 +511,50 @@ async function generateImages(input) {
499
  return finishImages(p, code, started);
500
  }
501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  // Kaggle: a whole project in one notebook run (the GPU machine starts once), then each shot is finished in order.
503
  async function runOnKaggle(inputs) {
504
  if (job) throw new Error('Something is already being made.');
@@ -681,15 +737,21 @@ app.whenReady().then(() => {
681
  fs.writeFileSync(USAGE, JSON.stringify(u, null, 2));
682
  return usageSummary();
683
  });
684
- ipcMain.handle('online:colab', (_e, code) => remote.connectColab(code));
 
 
685
  ipcMain.handle('online:kaggleFile', async () => {
686
  const r = await dialog.showOpenDialog(win, { title: 'Choose your kaggle.json', properties: ['openFile'], filters: [{ name: 'Kaggle token', extensions: ['json'] }] });
687
  if (r.canceled || !r.filePaths[0]) return remote.status();
688
  return remote.connectKaggle(await fsp.readFile(r.filePaths[0], 'utf8'));
689
  });
690
- ipcMain.handle('online:disconnect', (_e, which) => remote.disconnect(which === 'kaggle' ? 'kaggle' : 'colab'));
691
- ipcMain.handle('online:open', (_e, which) => shell.openExternal(which === 'kaggle' ? 'https://www.kaggle.com/settings/account' : 'https://colab.research.google.com/#create=true'));
692
- ipcMain.handle('online:workerLine', () => `!curl -fsSL ${remote.workerUrl} -o ora_worker.py && python3 ora_worker.py --serve`);
 
 
 
 
693
  ipcMain.handle('video:save', (_e, id, bytes, ext) => saveEncoded(id, bytes, ext));
694
  ipcMain.handle('video:fail', async (_e, id, message) => {
695
  const dir = insideVideos(id);
@@ -730,6 +792,7 @@ app.whenReady().then(() => {
730
  });
731
  ipcMain.handle('open:models', () => shell.openPath(MODELS));
732
  ipcMain.handle('open:saveDir', async () => { await fsp.mkdir(SAVE_DIR, { recursive: true }); return shell.openPath(SAVE_DIR); });
 
733
 
734
  createWindow();
735
  app.on('activate', () => { if (!BrowserWindow.getAllWindows().length) createWindow(); });
 
260
  u.runs = u.runs.filter(x => Date.parse(x.at) > cutoff);
261
  fs.writeFileSync(USAGE, JSON.stringify(u, null, 2));
262
  }
263
+ function recordNeurons(n) {
264
+ const u = readUsage(), today = new Date().toISOString().slice(0, 10);
265
+ u.cf = { day: today, neurons: (u.cf && u.cf.day === today ? u.cf.neurons : 0) + n };
266
+ fs.writeFileSync(USAGE, JSON.stringify(u, null, 2));
267
+ }
268
  function usageSummary() {
269
  const u = readUsage(), week = Date.now() - 7 * 864e5;
270
  const out = {};
271
+ const today = new Date().toISOString().slice(0, 10); // Cloudflare's free Neurons reset at 00:00 UTC
272
+ const cf = u.cf && u.cf.day === today ? u.cf.neurons : 0;
273
+ out.cloudflare = { today: Math.round(cf), left: Math.max(0, 10000 - cf), perImage: remote.cfNeurons(4) };
274
  for (const where of ['kaggle', 'colab']) {
275
  const runs = u.runs.filter(x => x.where === where);
276
  const last7 = runs.filter(x => Date.parse(x.at) > week).reduce((a, x) => a + x.seconds, 0);
 
294
  const raw = (st && st.gpu) || '';
295
  const m = /^(.*?),\s*(\d+)\s*MiB/.exec(raw);
296
  const name = m ? `${m[1]} · ${Math.round(+m[2] / 1024)} GB` : (raw && !/no NVIDIA/.test(raw) ? raw : 'GPU (shown after the first run)');
297
+ if (where === 'cloudflare') return { cpu: 'Cloudflare Workers AI', cores: 0, ram: 0, gpus: [{ vendor: '', name: 'Cloudflare GPU (FLUX.1-schnell)' }], engine: { id: 'online-cloudflare', gpu: true, args: [] } };
298
+ const label = where === 'kaggle' ? 'Your Kaggle notebook' : (st && st.provider === 'lightning') ? 'Your Lightning AI Studio' : 'Your Colab notebook';
299
+ return { cpu: label, cores: 0, ram: 0, gpus: [{ vendor: '', name }], engine: { id: `online-${where}`, gpu: true, args: [] } };
300
  }
301
 
302
  // Runs sd-cli for one job and streams progress to the renderer. Resolves with { code, cancelled, started }.
 
475
 
476
  async function finishImages(p, code, started) {
477
  const { id, dir, meta, req } = p;
478
+ const images = (await fsp.readdir(dir)).filter(f => /^img_\d+\.(png|jpg)$/.test(f)).sort();
479
  meta.seconds_taken = Math.round((Date.now() - started) / 1000);
480
  if (code !== 0 || images.length === 0) return engineFailed(id, dir, meta, code);
481
  // copy to Pictures/Ora/<project>/ as "01 title.png", "01 title 2.png" … (shot number first, like videos)
 
484
  const base = req.project ? `${String(req.project.index).padStart(2, '0')} ${core.folderName(req.project.title, 40)}` : `Ora ${meta.created.slice(0, 10)} ${core.slug(req.prompt, 40)}`;
485
  meta.savedFiles = [];
486
  for (const [i, f] of images.entries()) {
487
+ const ext = path.extname(f);
488
+ let target = path.join(dirOut, `${base}${i ? ` ${i + 1}` : ''}${ext}`), n = 2;
489
+ while (fs.existsSync(target)) target = path.join(dirOut, `${base}${i ? ` ${i + 1}` : ''} (${n++})${ext}`);
490
  await fsp.copyFile(path.join(dir, f), target);
491
  meta.savedFiles.push(target);
492
  }
 
498
 
499
  async function generateImages(input) {
500
  if (job) throw new Error('Something is already being made.');
501
+ if (input.runOn === 'cloudflare') return imagesOnCloudflare(input);
502
  const where = input.runOn === 'colab' ? 'colab' : 'local';
503
  const p = await prepareImages(input, where);
504
  if (where === 'colab') return runOnColab(p, p.run.steps, () => finishImages(p, 0, p.started));
 
511
  return finishImages(p, code, started);
512
  }
513
 
514
+ // Cloudflare Workers AI: FLUX.1-schnell, 1024x1024 JPEGs, a few seconds each, counted against today's free Neurons.
515
+ async function imagesOnCloudflare(input) {
516
+ const req = { ...input, seed: Number.isInteger(input.seed) ? input.seed : crypto.randomInt(0, 2 ** 31 - 1) };
517
+ const errors = core.validateProject(req.project);
518
+ if (!req.prompt || req.prompt.trim().length < 3) errors.push('Describe the image first.');
519
+ if (!Number.isInteger(req.count) || req.count < 1 || req.count > 4) errors.push('Make 1 to 4 images.');
520
+ if (errors.length) throw new Error(errors.join(' '));
521
+ const steps = 4;
522
+ const usage = usageSummary().cloudflare;
523
+ if (usage.left < remote.cfNeurons(steps) * req.count) throw new Error(`Not enough free Cloudflare Neurons left today (${Math.round(usage.left)} left, ${Math.round(remote.cfNeurons(steps) * req.count)} needed). They reset at 00:00 UTC.`);
524
+ const title = req.project ? req.project.title : req.prompt;
525
+ const id = newId(title, req.project);
526
+ const dir = path.join(VIDEOS, id);
527
+ await fsp.mkdir(dir, { recursive: true });
528
+ const hw = await remoteHardware('cloudflare');
529
+ const meta = {
530
+ id, kind: 'image', created: new Date().toISOString(), status: 'running', prompt: req.prompt, model: 'cf-flux1s', modelLabel: 'FLUX.1-schnell (Cloudflare)',
531
+ shape: 'square', size: 'large', count: req.count, seed: req.seed, width: 1024, height: 1024, steps, engine: 'online-cloudflare', where: 'cloudflare',
532
+ project: req.project ? { folder: req.project.folder, index: req.project.index, total: req.project.total, title: req.project.title } : undefined,
533
+ };
534
+ await writeMeta(dir, meta);
535
+ const started = Date.now();
536
+ job = { id, cancelled: false, child: null };
537
+ send('job:update', { id, stage: 'loading', meta, hardware: hw });
538
+ send('job:update', { id, stage: 'frames', item: 0, progress: { done: 0, total: req.count, secPerStep: 0 }, elapsed: 0 });
539
+ let res;
540
+ try {
541
+ res = await remote.runCloudflare(req.prompt, req.seed, steps, req.count, (done, total) => {
542
+ send('job:update', { id, stage: 'frames', item: done, progress: { done, total, secPerStep: (Date.now() - started) / 1000 / done }, elapsed: Date.now() - started });
543
+ }, () => job && job.cancelled);
544
+ } catch (e) {
545
+ job = null;
546
+ meta.status = 'failed'; meta.error = e.message; await writeMeta(dir, meta);
547
+ send('job:end', { id, error: e.message });
548
+ return;
549
+ }
550
+ const cancelled = job && job.cancelled;
551
+ job = null;
552
+ recordNeurons(res.neurons);
553
+ if (cancelled && !res.images.length) { await fsp.rm(dir, { recursive: true, force: true }); send('job:end', { id, cancelled: true }); return; }
554
+ for (const [i, b] of res.images.entries()) await fsp.writeFile(path.join(dir, `img_${String(i).padStart(2, '0')}.jpg`), b);
555
+ return finishImages({ id, dir, meta, req }, 0, started);
556
+ }
557
+
558
  // Kaggle: a whole project in one notebook run (the GPU machine starts once), then each shot is finished in order.
559
  async function runOnKaggle(inputs) {
560
  if (job) throw new Error('Something is already being made.');
 
737
  fs.writeFileSync(USAGE, JSON.stringify(u, null, 2));
738
  return usageSummary();
739
  });
740
+ ipcMain.handle('online:colab', (_e, code, provider) => remote.connectColab(code, provider));
741
+ ipcMain.handle('online:cloudflare', (_e, account, token) => remote.connectCloudflare(account, token));
742
+ ipcMain.handle('online:kaggleToken', (_e, username, token) => remote.connectKaggle({ username, token }));
743
  ipcMain.handle('online:kaggleFile', async () => {
744
  const r = await dialog.showOpenDialog(win, { title: 'Choose your kaggle.json', properties: ['openFile'], filters: [{ name: 'Kaggle token', extensions: ['json'] }] });
745
  if (r.canceled || !r.filePaths[0]) return remote.status();
746
  return remote.connectKaggle(await fsp.readFile(r.filePaths[0], 'utf8'));
747
  });
748
+ ipcMain.handle('online:disconnect', (_e, which) => remote.disconnect(['kaggle', 'cloudflare'].includes(which) ? which : 'colab'));
749
+ ipcMain.handle('online:open', (_e, which) => shell.openExternal({
750
+ kaggle: 'https://www.kaggle.com/settings/account', colab: 'https://colab.research.google.com/#create=true',
751
+ lightning: 'https://lightning.ai/', cloudflare: 'https://dash.cloudflare.com/?to=/:account/ai/workers-ai',
752
+ }[which] || 'https://colab.research.google.com/'));
753
+ // Colab cells need "!" before a shell command; a Lightning AI Studio terminal does not
754
+ ipcMain.handle('online:workerLine', (_e, where) => `${where === 'lightning' ? '' : '!'}curl -fsSL ${remote.workerUrl} -o ora_worker.py && python3 ora_worker.py --serve`);
755
  ipcMain.handle('video:save', (_e, id, bytes, ext) => saveEncoded(id, bytes, ext));
756
  ipcMain.handle('video:fail', async (_e, id, message) => {
757
  const dir = insideVideos(id);
 
792
  });
793
  ipcMain.handle('open:models', () => shell.openPath(MODELS));
794
  ipcMain.handle('open:saveDir', async () => { await fsp.mkdir(SAVE_DIR, { recursive: true }); return shell.openPath(SAVE_DIR); });
795
+ ipcMain.handle('open:imageDir', async () => { await fsp.mkdir(IMAGE_DIR, { recursive: true }); return shell.openPath(IMAGE_DIR); });
796
 
797
  createWindow();
798
  app.on('activate', () => { if (!BrowserWindow.getAllWindows().length) createWindow(); });
app/package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "devseis-ora",
3
  "productName": "Ora",
4
- "version": "0.1.2",
5
  "description": "Make videos from a prompt on your own computer with Wan2.1 1.3B and Wan2.2 5B.",
6
  "author": {
7
  "name": "Devseis",
 
1
  {
2
  "name": "devseis-ora",
3
  "productName": "Ora",
4
+ "version": "0.1.3",
5
  "description": "Make videos from a prompt on your own computer with Wan2.1 1.3B and Wan2.2 5B.",
6
  "author": {
7
  "name": "Devseis",
app/preload.cjs CHANGED
@@ -19,11 +19,13 @@ contextBridge.exposeInMainWorld('ora', {
19
  runKaggle: jobs => ipcRenderer.invoke('kaggle:run', jobs),
20
  onlineStatus: () => ipcRenderer.invoke('online:status'),
21
  setQuota: (where, hours) => ipcRenderer.invoke('online:setQuota', where, hours),
22
- connectColab: code => ipcRenderer.invoke('online:colab', code),
 
23
  connectKaggle: () => ipcRenderer.invoke('online:kaggleFile'),
 
24
  disconnectOnline: which => ipcRenderer.invoke('online:disconnect', which),
25
  openOnline: which => ipcRenderer.invoke('online:open', which),
26
- workerLine: () => ipcRenderer.invoke('online:workerLine'),
27
  onJobUpdate: on('job:update'),
28
  onJobEnd: on('job:end'),
29
  save: (id, bytes, ext) => ipcRenderer.invoke('video:save', id, bytes, ext),
@@ -35,4 +37,5 @@ contextBridge.exposeInMainWorld('ora', {
35
  setSettings: patch => ipcRenderer.invoke('settings:set', patch),
36
  openModels: () => ipcRenderer.invoke('open:models'),
37
  openSaveDir: () => ipcRenderer.invoke('open:saveDir'),
 
38
  });
 
19
  runKaggle: jobs => ipcRenderer.invoke('kaggle:run', jobs),
20
  onlineStatus: () => ipcRenderer.invoke('online:status'),
21
  setQuota: (where, hours) => ipcRenderer.invoke('online:setQuota', where, hours),
22
+ connectColab: (code, provider) => ipcRenderer.invoke('online:colab', code, provider),
23
+ connectCloudflare: (account, token) => ipcRenderer.invoke('online:cloudflare', account, token),
24
  connectKaggle: () => ipcRenderer.invoke('online:kaggleFile'),
25
+ connectKaggleToken: (username, token) => ipcRenderer.invoke('online:kaggleToken', username, token),
26
  disconnectOnline: which => ipcRenderer.invoke('online:disconnect', which),
27
  openOnline: which => ipcRenderer.invoke('online:open', which),
28
+ workerLine: where => ipcRenderer.invoke('online:workerLine', where),
29
  onJobUpdate: on('job:update'),
30
  onJobEnd: on('job:end'),
31
  save: (id, bytes, ext) => ipcRenderer.invoke('video:save', id, bytes, ext),
 
37
  setSettings: patch => ipcRenderer.invoke('settings:set', patch),
38
  openModels: () => ipcRenderer.invoke('open:models'),
39
  openSaveDir: () => ipcRenderer.invoke('open:saveDir'),
40
+ openImageDir: () => ipcRenderer.invoke('open:imageDir'),
41
  });
app/remote.cjs CHANGED
@@ -27,7 +27,8 @@ function createRemote(dataDir) {
27
  const c = read();
28
  return {
29
  kaggle: c.kaggle ? { connected: true, username: c.kaggle.username, gpu: c.kaggle.gpu || null } : { connected: false },
30
- colab: c.colab ? { connected: true, gpu: c.colab.gpu || null, since: c.colab.since } : { connected: false },
 
31
  };
32
  }
33
 
@@ -60,10 +61,10 @@ function createRemote(dataDir) {
60
  throw e;
61
  } finally { clearTimeout(t); }
62
  }
63
- async function connectColab(code) {
64
  const j = decodeCode(code);
65
  const c = read();
66
- c.colab = { url: j.url, secret: seal(j.secret), since: new Date().toISOString() };
67
  write(c);
68
  try {
69
  const hello = await colabCall('/hello', { timeout: 20000 });
@@ -97,26 +98,36 @@ function createRemote(dataDir) {
97
  }
98
 
99
  // ---- Kaggle ------------------------------------------------------------------------------------------------
 
 
100
  function kaggleAuth() {
101
  const k = read().kaggle;
102
  if (!k) throw new Error('Kaggle is not connected.');
103
- return { username: k.username, header: 'Basic ' + Buffer.from(`${k.username}:${open(k.key)}`).toString('base64') };
 
104
  }
105
  async function kaggleCall(pathname, { method = 'GET', body } = {}) {
106
  const { header } = kaggleAuth();
107
  const res = await net.fetch(KAGGLE + pathname, { method, headers: { Authorization: header, 'Content-Type': 'application/json' }, body: body ? JSON.stringify(body) : undefined });
108
  const text = await res.text();
109
  let j; try { j = JSON.parse(text); } catch { j = { message: text.slice(0, 200) }; }
110
- if (res.status === 401 || res.status === 403) throw new Error('Kaggle did not accept this API token. Create a new token in Kaggle (Settings › API) and choose the new kaggle.json.');
111
  if (!res.ok) throw new Error(`Kaggle: ${j.message || j.error || res.status}`);
112
  return j;
113
  }
114
- async function connectKaggle(jsonText) {
 
115
  let k;
116
- try { k = JSON.parse(jsonText); } catch { throw new Error('That file is not a kaggle.json.'); }
117
- if (!k.username || !k.key) throw new Error('kaggle.json must contain "username" and "key".');
 
 
 
 
 
 
118
  const c = read();
119
- c.kaggle = { username: String(k.username), key: seal(String(k.key)) };
120
  write(c);
121
  try {
122
  await kaggleCall(`/kernels/list?user=${encodeURIComponent(k.username)}&pageSize=1`);
@@ -168,9 +179,49 @@ function createRemote(dataDir) {
168
  return Buffer.from(await res.arrayBuffer());
169
  }
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  function disconnect(which) { const c = read(); delete c[which]; write(c); return status(); }
172
 
173
- return { status, connectColab, connectKaggle, runColab, runKaggle, download, disconnect, workerUrl: WORKER_URL };
174
  }
175
 
176
  module.exports = { createRemote };
 
27
  const c = read();
28
  return {
29
  kaggle: c.kaggle ? { connected: true, username: c.kaggle.username, gpu: c.kaggle.gpu || null } : { connected: false },
30
+ colab: c.colab ? { connected: true, gpu: c.colab.gpu || null, since: c.colab.since, provider: c.colab.provider || 'colab' } : { connected: false },
31
+ cloudflare: c.cloudflare ? { connected: true, account: c.cloudflare.account.slice(0, 6) + '…' } : { connected: false },
32
  };
33
  }
34
 
 
61
  throw e;
62
  } finally { clearTimeout(t); }
63
  }
64
+ async function connectColab(code, provider = 'colab') {
65
  const j = decodeCode(code);
66
  const c = read();
67
+ c.colab = { url: j.url, secret: seal(j.secret), since: new Date().toISOString(), provider: provider === 'lightning' ? 'lightning' : 'colab' };
68
  write(c);
69
  try {
70
  const hello = await colabCall('/hello', { timeout: 20000 });
 
98
  }
99
 
100
  // ---- Kaggle ------------------------------------------------------------------------------------------------
101
+ // Two kinds of Kaggle credentials: the newer API token (KGAT_…, sent as a Bearer token, like Kaggle's own
102
+ // KAGGLE_API_TOKEN) and the older kaggle.json (username + key, Basic auth).
103
  function kaggleAuth() {
104
  const k = read().kaggle;
105
  if (!k) throw new Error('Kaggle is not connected.');
106
+ const header = k.token ? `Bearer ${open(k.token)}` : 'Basic ' + Buffer.from(`${k.username}:${open(k.key)}`).toString('base64');
107
+ return { username: k.username, header };
108
  }
109
  async function kaggleCall(pathname, { method = 'GET', body } = {}) {
110
  const { header } = kaggleAuth();
111
  const res = await net.fetch(KAGGLE + pathname, { method, headers: { Authorization: header, 'Content-Type': 'application/json' }, body: body ? JSON.stringify(body) : undefined });
112
  const text = await res.text();
113
  let j; try { j = JSON.parse(text); } catch { j = { message: text.slice(0, 200) }; }
114
+ if (res.status === 401 || res.status === 403) throw new Error('Kaggle did not accept this API token. Create a new token in Kaggle (Settings › API) and paste it here.');
115
  if (!res.ok) throw new Error(`Kaggle: ${j.message || j.error || res.status}`);
116
  return j;
117
  }
118
+ // From a kaggle.json file ({ username, key }) or a pasted API token ({ username, token: 'KGAT_…' }).
119
+ async function connectKaggle(input) {
120
  let k;
121
+ if (typeof input === 'string') {
122
+ try { k = JSON.parse(input); } catch { throw new Error('That file is not a kaggle.json.'); }
123
+ if (!k.username || !k.key) throw new Error('kaggle.json must contain "username" and "key".');
124
+ } else {
125
+ k = { username: String(input.username || '').trim(), token: String(input.token || '').trim() };
126
+ if (!/^[A-Za-z0-9_-]{2,40}$/.test(k.username)) throw new Error('Enter your Kaggle username (the name in your profile address, kaggle.com/<username>).');
127
+ if (!/^KGAT_[A-Za-z0-9]{16,}$/.test(k.token)) throw new Error('Paste the API token Kaggle showed you: it starts with KGAT_.');
128
+ }
129
  const c = read();
130
+ c.kaggle = k.token ? { username: k.username, token: seal(k.token) } : { username: String(k.username), key: seal(String(k.key)) };
131
  write(c);
132
  try {
133
  await kaggleCall(`/kernels/list?user=${encodeURIComponent(k.username)}&pageSize=1`);
 
179
  return Buffer.from(await res.arrayBuffer());
180
  }
181
 
182
+ // ---- Cloudflare Workers AI (images only) --------------------------------------------------------------------
183
+ // FLUX.1-schnell over REST: { prompt, steps <= 8, seed } -> { result: { image: base64 JPEG 1024x1024 } }.
184
+ // Free accounts get 10,000 Neurons a day (reset 00:00 UTC); one 1024x1024 image = 4 tiles x 4.8 + steps x 9.6.
185
+ const CF = 'https://api.cloudflare.com/client/v4';
186
+ const CF_MODEL = '@cf/black-forest-labs/flux-1-schnell';
187
+ const cfNeurons = steps => 4 * 4.8 + steps * 9.6;
188
+ async function cfCall(pathname, body) {
189
+ const c = read().cloudflare;
190
+ if (!c) throw new Error('Cloudflare is not connected.');
191
+ const res = await net.fetch(`${CF}/accounts/${encodeURIComponent(c.account)}${pathname}`, {
192
+ method: body ? 'POST' : 'GET', headers: { Authorization: `Bearer ${open(c.token)}`, 'Content-Type': 'application/json' }, body: body ? JSON.stringify(body) : undefined,
193
+ });
194
+ let j; try { j = await res.json(); } catch { j = {}; }
195
+ if (res.status === 401 || res.status === 403) throw new Error('Cloudflare did not accept this token. It needs the "Workers AI" permission (Read is enough) for this account.');
196
+ if (res.status === 429 || /neuron|quota|limit/i.test(JSON.stringify(j.errors || ''))) throw new Error('Cloudflare says today\'s free allowance is used up. It resets at 00:00 UTC.');
197
+ if (!res.ok || j.success === false) throw new Error(`Cloudflare: ${(j.errors && j.errors[0] && j.errors[0].message) || res.status}`);
198
+ return j.result;
199
+ }
200
+ async function connectCloudflare(account, token) {
201
+ account = String(account || '').trim(); token = String(token || '').trim();
202
+ if (!/^[0-9a-f]{32}$/i.test(account)) throw new Error('The Account ID is 32 letters and numbers (Cloudflare dashboard › Workers AI › "Use REST API").');
203
+ if (token.length < 20) throw new Error('Paste the API token you created with the Workers AI permission.');
204
+ const c = read();
205
+ c.cloudflare = { account, token: seal(token) };
206
+ write(c);
207
+ try { await cfCall('/ai/models/search?per_page=1'); return status(); }
208
+ catch (e) { delete c.cloudflare; write(c); throw e; }
209
+ }
210
+ async function runCloudflare(prompt, seed, steps, count, onImage, isCancelled) {
211
+ const out = [];
212
+ for (let i = 0; i < count; i++) {
213
+ if (isCancelled()) break;
214
+ const r = await cfCall(`/ai/run/${CF_MODEL}`, { prompt, steps, seed: (seed + i) % 2147483647 });
215
+ const buf = Buffer.from(r.image, 'base64');
216
+ out.push(buf);
217
+ onImage(i + 1, count);
218
+ }
219
+ return { images: out, neurons: out.length * cfNeurons(steps) };
220
+ }
221
+
222
  function disconnect(which) { const c = read(); delete c[which]; write(c); return status(); }
223
 
224
+ return { status, connectColab, connectKaggle, connectCloudflare, runColab, runKaggle, runCloudflare, cfNeurons, download, disconnect, workerUrl: WORKER_URL };
225
  }
226
 
227
  module.exports = { createRemote };
app/renderer/app.js CHANGED
@@ -39,14 +39,19 @@ let queue = null; // { folder, jobs, index, done: [], cancelled } while sho
39
  let mode = 'video'; // 'video' | 'image'
40
  const imgForm = { model: 'zimage', shape: 'square', size: 'small', count: 1 };
41
  let catalog = []; // the Models screen: entries from main with install state and the requirement check
42
- let online = { kaggle: { connected: false }, colab: { connected: false } };
43
  // "Run on" in the form: auto | gpu | cpu (this computer, kept in settings) or online (Kaggle/Colab, kept here)
44
  const runWhere = () => store('ora.runOnline') && onlineChoice() ? onlineChoice() : 'local';
 
 
 
 
45
  function onlineChoice() {
46
- const pref = store('ora.onlineService');
47
- if (pref && online[pref] && online[pref].connected) return pref;
48
- return online.colab.connected ? 'colab' : online.kaggle.connected ? 'kaggle' : null;
49
  }
 
50
  const T4 = { platform: 'linux', arch: 'x64', ram: 13 * 2 ** 30, freeDisk: null, engine: { id: 'online', gpu: true, args: [] }, gpus: [{ vendor: 'NVIDIA', name: 'T4' }], vram: 16 };
51
  let startImage = null; // { id, file } of an Ora image to animate (image-to-video with the 5B model)
52
  const IMG_SHAPES = [['square', '1:1'], ['landscape', '16:9'], ['portrait', '9:16'], ['insta', '4:5']];
@@ -93,6 +98,9 @@ function sync() {
93
  for (const [id, key] of [['imgShapeSeg', 'shape'], ['imgSizeSeg', 'size'], ['imgCountSeg', 'count']]) {
94
  for (const b of $(id).children) b.setAttribute('aria-checked', String(String(imgForm[key]) === b.dataset.value));
95
  }
 
 
 
96
  if (S) renderImageDownload();
97
  const pv = isPreview(form);
98
  for (const id of ['lengthSeg', 'qualitySeg']) for (const b of $(id).children) b.disabled = pv;
@@ -205,6 +213,14 @@ function onlineEstimate(label, gpuSeconds, n) {
205
 
206
  function estimate() {
207
  if (!S) return;
 
 
 
 
 
 
 
 
208
  if (mode === 'image' && runWhere() !== 'local') {
209
  const w = imageWork();
210
  // a T4 does an 8-step 1024x1024 Z-Image in well under a minute; bigger models scale with their size
@@ -292,7 +308,7 @@ function imageReady() { return S.manifest.image && S.manifest.image.files.every(
292
  function modelReady(key) { return S.manifest.models[key].files.every(k => S.files[k].ready); }
293
 
294
  function showSetup(downloading) {
295
- $('setup').hidden = false; $('studio').hidden = true;
296
  renderSetup(S.files, downloading ? 'Downloading…' : '');
297
  setDownloading(downloading);
298
  }
@@ -334,7 +350,7 @@ function renderImageDownload() {
334
  // --- studio ----------------------------------------------------------------------------------------------------
335
 
336
  function showStudio() {
337
- $('setup').hidden = true; $('studio').hidden = false;
338
  const m = S.manifest.models;
339
  renderModelChoices();
340
  seg($('shapeSeg'), SHAPES.map(([v, l]) => [v, l]), 'shape');
@@ -367,6 +383,13 @@ function renderModelChoices() {
367
  if (m.h3 && catalogOk('h3')) vids.push(['h3', 'Long · MiniMax-H3', `${m.h3.detail} · Beta · shows "MiniMax H3"`]);
368
  seg($('modelSeg'), vids, 'model', renderLengths);
369
  if (!vids.some(v => v[0] === form.model)) form.model = 'fast';
 
 
 
 
 
 
 
370
  const imgs = [['zimage', 'Z-Image-Turbo 6B', 'Default · photo-real, any computer']];
371
  if (catalogOk('flux1s')) imgs.push(['flux1s', 'FLUX.1-schnell 12B', 'Very sharp, 4 steps']);
372
  if (catalogOk('qwenimg')) imgs.push(['qwenimg', 'Qwen-Image 20B', 'Best for text in images']);
@@ -384,10 +407,20 @@ function renderOnline() {
384
  $('kaggleStatus').innerHTML = k.connected ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
385
  if (k.connected) $('kaggleStatus').append(` as ${k.username}`);
386
  $('kaggleRemove').hidden = !k.connected;
387
- $('kaggleConnect').textContent = k.connected ? 'Choose a new kaggle.json…' : 'Choose kaggle.json…';
388
  $('colabStatus').innerHTML = c.connected ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
389
  if (c.connected && c.gpu) $('colabStatus').append(` · ${c.gpu}`);
390
  $('colabRemove').hidden = !c.connected;
 
 
 
 
 
 
 
 
 
 
391
  const u = online.usage || {};
392
  for (const where of ['kaggle', 'colab']) {
393
  const x = u[where] || {};
@@ -396,9 +429,9 @@ function renderOnline() {
396
  if (S && !$('studio').hidden) { renderRunOn(); renderModelChoices(); sync(); }
397
  }
398
  async function openOnline() {
399
- $('colabLine').textContent = await window.ora.workerLine();
400
  await refreshOnline();
401
- $('onlineDlg').showModal();
402
  }
403
 
404
  // --- models screen ---------------------------------------------------------------------------------------------
@@ -464,7 +497,7 @@ function renderCatalog() {
464
  const on = document.createElement('div'); on.className = 'mdl-online';
465
  const where = ['kaggle', 'colab'].filter(w => e.online[w]).map(w => w === 'kaggle' ? 'Kaggle (2 × T4)' : 'Colab (T4)');
466
  on.textContent = `✓ Runs online on ${where.join(' and ')}${e.beta ? ' · Beta' : ''}`;
467
- if (!onlineChoice()) { const b = document.createElement('button'); b.type = 'button'; b.className = 'link'; b.textContent = 'Connect'; b.addEventListener('click', () => { $('modelsDlg').close(); openOnline(); }); on.append(' · ', b); }
468
  d.appendChild(on);
469
  }
470
  box.appendChild(d);
@@ -557,6 +590,10 @@ function setMode(m) {
557
  $('startImage').hidden = mode !== 'video' || !startImage;
558
  $('styleLabel').textContent = mode === 'image' ? 'Style' : 'Style for all shots';
559
  $('stageTitle').textContent = mode === 'image' ? 'Your images appear here.' : 'Your video appears here.';
 
 
 
 
560
  $('projectHint').textContent = mode === 'image' ? '(folder in Pictures/Ora)' : '(folder in Videos/Ora)';
561
  setRunning(!!queue);
562
  if (S) { sync(); }
@@ -608,37 +645,73 @@ function playVideo(meta) {
608
  $('videoInfo').textContent = `${meta.fromImage ? 'From an image · ' : ''}${meta.width}×${meta.height} · ${meta.seconds} s · ${meta.quality === 'preview' ? 'Preview, ' : ''}${MODEL_NAMES[meta.model] || meta.model} · seed ${meta.seed}${mins}`;
609
  }
610
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  function renderGrid() {
 
612
  const g = $('grid');
613
  g.innerHTML = '';
614
- $('gridEmpty').hidden = S.videos.length > 0;
 
615
  $('clearHistoryBtn').hidden = S.videos.length === 0;
616
- for (const meta of S.videos) {
617
- const c = document.createElement('div');
618
- c.className = 'card'; c.tabIndex = 0; c.setAttribute('role', 'button');
619
- c.innerHTML = '<img alt=""><div class="meta"><div class="p"></div><div class="s"></div></div><button class="ghost del" type="button">Delete</button>';
620
- c.querySelector('img').src = `ora://video/${encodeURIComponent(meta.id)}/poster.png`;
621
- c.querySelector('img').style.aspectRatio = `${meta.width} / ${meta.height}`;
622
- c.querySelector('.p').textContent = meta.kind === 'image' ? meta.prompt : meta.project ? `${meta.project.index}. ${meta.project.title}` : meta.prompt;
623
- if (meta.kind === 'image') {
624
- const k = document.createElement('span'); k.className = 'kind'; k.textContent = meta.count > 1 ? `Image ×${meta.count}` : 'Image';
625
- c.prepend(k);
626
- }
627
- if (meta.kind === 'image') c.querySelector('.s').textContent = `${meta.width}×${meta.height} · ${meta.modelLabel || 'Z-Image'} · ${new Date(meta.created).toLocaleString()}`;
628
- else c.querySelector('.s').textContent = `${meta.project && meta.project.total > 1 ? `${meta.project.folder.slice(11)} · ` : ''}${meta.quality === 'preview' ? 'Preview · ' : ''}${meta.seconds} s · ${({ fast: '1.3B', quality: '5B', pro: 'A14B', ltx23: 'LTX-2.3', h3: 'MiniMax H3' })[meta.model] || meta.model} · ${new Date(meta.created).toLocaleString()}`;
629
- const open = () => meta.kind === 'image' ? showImages(meta) : playVideo(meta);
630
- c.addEventListener('click', e => { if (!e.target.closest('.del')) open(); });
631
- c.addEventListener('keydown', e => { if (e.key === 'Enter' && e.target === c) open(); });
632
- c.querySelector('.del').addEventListener('click', async () => {
633
- if (!confirm(meta.kind === 'image' ? 'Delete these images from Ora? The copies in your Pictures folder stay.' : 'Delete this video from Ora? The copy in your Videos folder stays.')) return;
634
- await window.ora.remove(meta.id);
635
- S.videos = S.videos.filter(v => v.id !== meta.id);
636
- if (current && current.id === meta.id) { current = null; showStage('empty'); }
637
- renderGrid();
638
- });
639
- g.appendChild(c);
 
640
  }
641
  }
 
642
 
643
  // Example projects shown while the history is empty; clicking one fills the form.
644
  const IDEAS = [
@@ -708,7 +781,7 @@ async function submitImages() {
708
  const prompt = $('imgPrompt').value.trim();
709
  if (prompt.length < 3) return formError('Describe the image first.');
710
  if (runWhere() === 'local' && !imageReady()) return formError('Download the image model first (button above).');
711
- if (imgForm.model !== 'zimage' && !catalogOk(imgForm.model)) return formError('That image model is not installed. Open Models to download it.');
712
  const seedText = $('seed').value.trim();
713
  if (seedText && !/^\d{1,10}$/.test(seedText)) return formError('The seed must be a whole number.');
714
  const est = runWhere() === 'local' ? imageSeconds() : { sec: null };
@@ -718,7 +791,7 @@ async function submitImages() {
718
  const parts = [prompt.replace(/[.,;]+$/, '')];
719
  for (const [label, text] of STYLES) if (styles.includes(label)) parts.push(text);
720
  const { model: imageModel, ...imgOpts } = imgForm;
721
- const job = { kind: 'image', ...imgOpts, imageModel, prompt: parts.join(', '), seed: seedText ? Math.min(+seedText, 2 ** 31 - 1) : undefined, project: { folder, index: 1, total: 1, title: prompt.slice(0, 300) } };
722
  job.runOn = runWhere();
723
  queue = { folder, jobs: [job], index: 0, done: [], states: ['running'], cancelled: false, kind: 'image', kaggle: job.runOn === 'kaggle' };
724
  setRunning(true);
@@ -1072,7 +1145,7 @@ function engineLabel(e) {
1072
  function renderDevice() {
1073
  const h = S.hardware;
1074
  const w = typeof runWhere === 'function' ? runWhere() : 'local';
1075
- $('deviceChip').textContent = w !== 'local' ? `Online · ${w === 'colab' ? 'Colab' : 'Kaggle'}` : `${engineLabel(h.engine)} · ${Math.round(h.ram / 2 ** 30)} GB RAM`;
1076
  const os = { darwin: 'macOS', win32: 'Windows', linux: 'Linux' }[h.platform] || h.platform;
1077
  const rows = [
1078
  ['System', `${os} (${h.arch})`], ['Processor', `${h.cpu} · ${h.cores} threads`], ['Memory', `${Math.round(h.ram / 2 ** 30)} GB`],
@@ -1207,10 +1280,14 @@ function renderRunOn() {
1207
  const where = runWhere();
1208
  if (where !== 'local') {
1209
  const st = online[where];
1210
- const other = where === 'colab' ? (online.kaggle.connected ? 'kaggle' : null) : (online.colab.connected ? 'colab' : null);
1211
  $('runOnNote').innerHTML = '';
1212
- $('runOnNote').append(`Now: online on your ${where === 'colab' ? 'Colab notebook' : 'Kaggle account'}${st.gpu ? ` (${st.gpu})` : ''}. ${where === 'kaggle' ? 'Each run starts a GPU machine first (2–5 min).' : 'Progress is live.'} `);
1213
- if (other) { const sw = document.createElement('button'); sw.type = 'button'; sw.className = 'link'; sw.textContent = `Use ${other === 'colab' ? 'Colab' : 'Kaggle'} instead`; sw.addEventListener('click', () => { store('ora.onlineService', other); renderRunOn(); sync(); }); $('runOnNote').append(sw); }
 
 
 
 
 
1214
  return;
1215
  }
1216
  $('runOnNote').textContent = e.gpuUnavailable
@@ -1229,11 +1306,20 @@ $('reuseBtn').addEventListener('click', () => {
1229
  store('ora.form', form); saveDraft(); renderShots(); setRunning(false); sync();
1230
  });
1231
  $('openSaveDir').addEventListener('click', () => window.ora.openSaveDir());
1232
- $('modelsBtn').addEventListener('click', async () => { await refreshCatalog(); $('modelsDlg').showModal(); });
1233
- document.addEventListener('click', async e => { if (e.target.closest('[data-open-models]')) { await refreshCatalog(); $('modelsDlg').showModal(); } });
1234
- $('closeModels').addEventListener('click', () => $('modelsDlg').close());
1235
- $('onlineBtn').addEventListener('click', openOnline);
1236
- $('closeOnline').addEventListener('click', () => $('onlineDlg').close());
 
 
 
 
 
 
 
 
 
1237
  $('kaggleOpen').addEventListener('click', () => window.ora.openOnline('kaggle'));
1238
  $('colabOpen').addEventListener('click', () => window.ora.openOnline('colab'));
1239
  $('colabCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('colabLine').textContent); $('colabCopy').textContent = 'Copied'; setTimeout(() => { $('colabCopy').textContent = 'Copy'; }, 1500); } catch { } });
@@ -1250,6 +1336,28 @@ $('colabConnect').addEventListener('click', async () => {
1250
  renderOnline();
1251
  });
1252
  $('kaggleRemove').addEventListener('click', async () => { online = await window.ora.disconnectOnline('kaggle'); renderOnline(); });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1253
  $('kaggleQuotaSave').addEventListener('click', async () => {
1254
  const v = $('kaggleQuota').value.trim();
1255
  online.usage = await window.ora.setQuota('kaggle', v === '' ? null : Number(v));
 
39
  let mode = 'video'; // 'video' | 'image'
40
  const imgForm = { model: 'zimage', shape: 'square', size: 'small', count: 1 };
41
  let catalog = []; // the Models screen: entries from main with install state and the requirement check
42
+ let online = { kaggle: { connected: false }, colab: { connected: false }, cloudflare: { connected: false } };
43
  // "Run on" in the form: auto | gpu | cpu (this computer, kept in settings) or online (Kaggle/Colab, kept here)
44
  const runWhere = () => store('ora.runOnline') && onlineChoice() ? onlineChoice() : 'local';
45
+ // Online services that can make what the form is set to: Cloudflare only makes images.
46
+ function onlineServices() {
47
+ return ['colab', 'kaggle', 'cloudflare'].filter(w => online[w] && online[w].connected && (w !== 'cloudflare' || mode === 'image'));
48
+ }
49
  function onlineChoice() {
50
+ const list = onlineServices(), pref = store('ora.onlineService');
51
+ if (pref && list.includes(pref)) return pref;
52
+ return list[0] || null;
53
  }
54
+ const serviceName = w => w === 'kaggle' ? 'Kaggle' : w === 'cloudflare' ? 'Cloudflare' : (online.colab && online.colab.provider === 'lightning') ? 'Lightning AI' : 'Colab';
55
  const T4 = { platform: 'linux', arch: 'x64', ram: 13 * 2 ** 30, freeDisk: null, engine: { id: 'online', gpu: true, args: [] }, gpus: [{ vendor: 'NVIDIA', name: 'T4' }], vram: 16 };
56
  let startImage = null; // { id, file } of an Ora image to animate (image-to-video with the 5B model)
57
  const IMG_SHAPES = [['square', '1:1'], ['landscape', '16:9'], ['portrait', '9:16'], ['insta', '4:5']];
 
98
  for (const [id, key] of [['imgShapeSeg', 'shape'], ['imgSizeSeg', 'size'], ['imgCountSeg', 'count']]) {
99
  for (const b of $(id).children) b.setAttribute('aria-checked', String(String(imgForm[key]) === b.dataset.value));
100
  }
101
+ const cf = S && runWhere() === 'cloudflare'; // Cloudflare makes 1024x1024 only
102
+ for (const b of $('imgShapeSeg').children) b.disabled = cf && b.dataset.value !== 'square';
103
+ for (const b of $('imgSizeSeg').children) b.disabled = cf;
104
  if (S) renderImageDownload();
105
  const pv = isPreview(form);
106
  for (const id of ['lengthSeg', 'qualitySeg']) for (const b of $(id).children) b.disabled = pv;
 
213
 
214
  function estimate() {
215
  if (!S) return;
216
+ if (mode === 'image' && runWhere() === 'cloudflare') {
217
+ const u = (online.usage || {}).cloudflare || { today: 0, left: 10000, perImage: 57.6 };
218
+ const need = Math.round(u.perImage * imgForm.count);
219
+ $('estTime').textContent = `About ${need} of your free Cloudflare Neurons`;
220
+ $('estimate').textContent = `${imgForm.count} image${imgForm.count > 1 ? 's' : ''} at 1024×1024, a few seconds each. Ora has used ${u.today.toLocaleString()} today; about ${Math.round(u.left).toLocaleString()} of 10,000 left (resets at 00:00 UTC), ${Math.max(0, Math.round(u.left - need)).toLocaleString()} after this.`;
221
+ $('estimateBox').classList.toggle('warn', need > u.left);
222
+ return;
223
+ }
224
  if (mode === 'image' && runWhere() !== 'local') {
225
  const w = imageWork();
226
  // a T4 does an 8-step 1024x1024 Z-Image in well under a minute; bigger models scale with their size
 
308
  function modelReady(key) { return S.manifest.models[key].files.every(k => S.files[k].ready); }
309
 
310
  function showSetup(downloading) {
311
+ $('setup').hidden = view !== 'create'; $('studio').hidden = true;
312
  renderSetup(S.files, downloading ? 'Downloading…' : '');
313
  setDownloading(downloading);
314
  }
 
350
  // --- studio ----------------------------------------------------------------------------------------------------
351
 
352
  function showStudio() {
353
+ $('setup').hidden = true; $('studio').hidden = view !== 'create';
354
  const m = S.manifest.models;
355
  renderModelChoices();
356
  seg($('shapeSeg'), SHAPES.map(([v, l]) => [v, l]), 'shape');
 
383
  if (m.h3 && catalogOk('h3')) vids.push(['h3', 'Long · MiniMax-H3', `${m.h3.detail} · Beta · shows "MiniMax H3"`]);
384
  seg($('modelSeg'), vids, 'model', renderLengths);
385
  if (!vids.some(v => v[0] === form.model)) form.model = 'fast';
386
+ if (runWhere() === 'cloudflare') {
387
+ seg($('imgModelSeg'), [['cf-flux1s', 'FLUX.1-schnell · Cloudflare', 'Instant · 1024×1024 · ~58 free Neurons each']], 'model', null, imgForm);
388
+ imgForm.model = 'cf-flux1s'; imgForm.shape = 'square';
389
+ $('imgModelSeg').hidden = false;
390
+ return;
391
+ }
392
+ if (imgForm.model === 'cf-flux1s') imgForm.model = 'zimage';
393
  const imgs = [['zimage', 'Z-Image-Turbo 6B', 'Default · photo-real, any computer']];
394
  if (catalogOk('flux1s')) imgs.push(['flux1s', 'FLUX.1-schnell 12B', 'Very sharp, 4 steps']);
395
  if (catalogOk('qwenimg')) imgs.push(['qwenimg', 'Qwen-Image 20B', 'Best for text in images']);
 
407
  $('kaggleStatus').innerHTML = k.connected ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
408
  if (k.connected) $('kaggleStatus').append(` as ${k.username}`);
409
  $('kaggleRemove').hidden = !k.connected;
410
+ $('kaggleTokenConnect').textContent = k.connected ? 'Replace' : 'Connect';
411
  $('colabStatus').innerHTML = c.connected ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
412
  if (c.connected && c.gpu) $('colabStatus').append(` · ${c.gpu}`);
413
  $('colabRemove').hidden = !c.connected;
414
+ const prov = c.connected ? (c.provider === 'lightning' ? 'lightning' : 'colab') : null;
415
+ $('colabStatus').innerHTML = prov === 'colab' ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
416
+ if (prov === 'colab' && c.gpu) $('colabStatus').append(` · ${c.gpu}`);
417
+ $('lightningStatus').innerHTML = prov === 'lightning' ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
418
+ if (prov === 'lightning' && c.gpu) $('lightningStatus').append(` · ${c.gpu}`);
419
+ const cf = online.cloudflare || {};
420
+ $('cfStatus').innerHTML = cf.connected ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
421
+ $('cfRemove').hidden = !cf.connected;
422
+ const cu = (online.usage || {}).cloudflare;
423
+ $('cfUsage').textContent = cu ? `Ora has used ${cu.today} Neurons today; about ${Math.round(cu.left).toLocaleString()} of 10,000 left (resets 00:00 UTC). One image ≈ ${Math.round(cu.perImage)}.` : '';
424
  const u = online.usage || {};
425
  for (const where of ['kaggle', 'colab']) {
426
  const x = u[where] || {};
 
429
  if (S && !$('studio').hidden) { renderRunOn(); renderModelChoices(); sync(); }
430
  }
431
  async function openOnline() {
432
+ $('colabLine').textContent = await window.ora.workerLine('colab');
433
  await refreshOnline();
434
+ showView('online');
435
  }
436
 
437
  // --- models screen ---------------------------------------------------------------------------------------------
 
497
  const on = document.createElement('div'); on.className = 'mdl-online';
498
  const where = ['kaggle', 'colab'].filter(w => e.online[w]).map(w => w === 'kaggle' ? 'Kaggle (2 × T4)' : 'Colab (T4)');
499
  on.textContent = `✓ Runs online on ${where.join(' and ')}${e.beta ? ' · Beta' : ''}`;
500
+ if (!onlineChoice()) { const b = document.createElement('button'); b.type = 'button'; b.className = 'link'; b.textContent = 'Connect'; b.addEventListener('click', () => openOnline()); on.append(' · ', b); }
501
  d.appendChild(on);
502
  }
503
  box.appendChild(d);
 
590
  $('startImage').hidden = mode !== 'video' || !startImage;
591
  $('styleLabel').textContent = mode === 'image' ? 'Style' : 'Style for all shots';
592
  $('stageTitle').textContent = mode === 'image' ? 'Your images appear here.' : 'Your video appears here.';
593
+ $('stageHint').textContent = mode === 'image'
594
+ ? (S && !S.hardware.engine.gpu ? 'Tip: on the processor, Small images take about 9 minutes. Cloudflare (Online) makes them in seconds.' : '')
595
+ : (S && !S.hardware.engine.gpu ? 'Tip: on the processor, use Preview to check a prompt first. Full videos take much longer.' : 'Tip: use Preview to check a prompt quickly, then make the full video with Fast or Quality.');
596
+ if (S && !$('studio').hidden) { renderRunOn(); renderModelChoices(); renderDevice(); }
597
  $('projectHint').textContent = mode === 'image' ? '(folder in Pictures/Ora)' : '(folder in Videos/Ora)';
598
  setRunning(!!queue);
599
  if (S) { sync(); }
 
645
  $('videoInfo').textContent = `${meta.fromImage ? 'From an image · ' : ''}${meta.width}×${meta.height} · ${meta.seconds} s · ${meta.quality === 'preview' ? 'Preview, ' : ''}${MODEL_NAMES[meta.model] || meta.model} · seed ${meta.seed}${mins}`;
646
  }
647
 
648
+ // A history card (Library and the Recent strip). Clicking opens it on the Create page.
649
+ function makeCard(meta, withDelete) {
650
+ const c = document.createElement('div');
651
+ c.className = 'card'; c.tabIndex = 0; c.setAttribute('role', 'button');
652
+ c.innerHTML = '<img alt=""><div class="meta"><div class="p"></div><div class="s"></div></div>' + (withDelete ? '<button class="ghost del" type="button">Delete</button>' : '');
653
+ const img = c.querySelector('img');
654
+ img.src = `ora://video/${encodeURIComponent(meta.id)}/poster.png`;
655
+ img.style.aspectRatio = `${meta.width} / ${meta.height}`;
656
+ img.addEventListener('error', () => img.classList.add('noposter'));
657
+ c.querySelector('.p').textContent = meta.kind === 'image' ? meta.prompt : meta.project ? `${meta.project.index}. ${meta.project.title}` : meta.prompt;
658
+ if (meta.kind === 'image') {
659
+ const k = document.createElement('span'); k.className = 'kind'; k.textContent = meta.count > 1 ? `Image ×${meta.count}` : 'Image';
660
+ c.prepend(k);
661
+ } else if (meta.sound) {
662
+ const k = document.createElement('span'); k.className = 'kind'; k.textContent = 'With sound'; c.prepend(k);
663
+ }
664
+ if (meta.kind === 'image') c.querySelector('.s').textContent = `${meta.width}×${meta.height} · ${meta.modelLabel || 'Z-Image'} · ${new Date(meta.created).toLocaleString()}`;
665
+ else c.querySelector('.s').textContent = `${meta.project && meta.project.total > 1 ? `${meta.project.folder.slice(11)} · ` : ''}${meta.quality === 'preview' ? 'Preview · ' : ''}${meta.seconds} s · ${({ fast: '1.3B', quality: '5B', pro: 'A14B', ltx23: 'LTX-2.3', h3: 'MiniMax H3' })[meta.model] || meta.model}${meta.where && meta.where !== 'local' ? ` · ${meta.where === 'kaggle' ? 'Kaggle' : 'Colab'}` : ''} · ${new Date(meta.created).toLocaleString()}`;
666
+ const open = () => { showView('create'); meta.kind === 'image' ? showImages(meta) : playVideo(meta); };
667
+ c.addEventListener('click', e => { if (!e.target.closest('.del')) open(); });
668
+ c.addEventListener('keydown', e => { if (e.key === 'Enter' && e.target === c) open(); });
669
+ if (withDelete) c.querySelector('.del').addEventListener('click', async () => {
670
+ if (!confirm(meta.kind === 'image' ? 'Delete these images from Ora? The copies in your Pictures folder stay.' : 'Delete this video from Ora? The copy in your Videos folder stays.')) return;
671
+ await window.ora.remove(meta.id);
672
+ S.videos = S.videos.filter(v => v.id !== meta.id);
673
+ if (current && current.id === meta.id) { current = null; showStage('empty'); }
674
+ renderGrid();
675
+ });
676
+ return c;
677
+ }
678
+
679
+ let libFilter = 'all';
680
  function renderGrid() {
681
+ const items = S.videos.filter(m => libFilter === 'all' || (m.kind || 'video') === libFilter);
682
  const g = $('grid');
683
  g.innerHTML = '';
684
+ for (const meta of items) g.appendChild(makeCard(meta, true));
685
+ $('gridEmpty').hidden = items.length > 0;
686
  $('clearHistoryBtn').hidden = S.videos.length === 0;
687
+ // Create page: the four newest under the preview
688
+ const rg = $('recentGrid');
689
+ rg.innerHTML = '';
690
+ for (const meta of S.videos.slice(0, 4)) rg.appendChild(makeCard(meta, false));
691
+ $('recentBox').hidden = S.videos.length === 0;
692
+ }
693
+
694
+ // --- top-bar tabs: Create · Library · Models · Online --------------------------------------------------------------
695
+
696
+ let view = 'create';
697
+ function showView(v) {
698
+ view = ['create', 'library', 'models', 'online'].includes(v) ? v : 'create';
699
+ const setup = !$('setup').hidden && view === 'create';
700
+ $('studio').hidden = view !== 'create' || setup || !S || !allReadyOrStarted();
701
+ $('libraryView').hidden = view !== 'library';
702
+ $('modelsView').hidden = view !== 'models';
703
+ $('onlineView').hidden = view !== 'online';
704
+ if (view !== 'create') $('setup').hidden = true; else if (S && !allReadyOrStarted()) $('setup').hidden = false;
705
+ for (const b of $('navTabs').children) b.toggleAttribute('aria-current', b.dataset.view === view), b.dataset.view === view && b.setAttribute('aria-current', 'page');
706
+ document.querySelector('main').scrollTop = 0;
707
+ if (view === 'models') refreshCatalog();
708
+ if (view === 'online') {
709
+ window.ora.workerLine('colab').then(t => { $('colabLine').textContent = t; });
710
+ window.ora.workerLine('lightning').then(t => { $('lightningLine').textContent = t; });
711
+ refreshOnline();
712
  }
713
  }
714
+ function allReadyOrStarted() { return allReady(S.files) || (modelReady('fast') && store('ora.startedFast')); }
715
 
716
  // Example projects shown while the history is empty; clicking one fills the form.
717
  const IDEAS = [
 
781
  const prompt = $('imgPrompt').value.trim();
782
  if (prompt.length < 3) return formError('Describe the image first.');
783
  if (runWhere() === 'local' && !imageReady()) return formError('Download the image model first (button above).');
784
+ if (runWhere() !== 'cloudflare' && imgForm.model !== 'zimage' && !catalogOk(imgForm.model)) return formError('That image model is not installed. Open Models to download it.');
785
  const seedText = $('seed').value.trim();
786
  if (seedText && !/^\d{1,10}$/.test(seedText)) return formError('The seed must be a whole number.');
787
  const est = runWhere() === 'local' ? imageSeconds() : { sec: null };
 
791
  const parts = [prompt.replace(/[.,;]+$/, '')];
792
  for (const [label, text] of STYLES) if (styles.includes(label)) parts.push(text);
793
  const { model: imageModel, ...imgOpts } = imgForm;
794
+ const job = { kind: 'image', ...imgOpts, imageModel: runWhere() === 'cloudflare' ? undefined : imageModel, prompt: parts.join(', '), seed: seedText ? Math.min(+seedText, 2 ** 31 - 1) : undefined, project: { folder, index: 1, total: 1, title: prompt.slice(0, 300) } };
795
  job.runOn = runWhere();
796
  queue = { folder, jobs: [job], index: 0, done: [], states: ['running'], cancelled: false, kind: 'image', kaggle: job.runOn === 'kaggle' };
797
  setRunning(true);
 
1145
  function renderDevice() {
1146
  const h = S.hardware;
1147
  const w = typeof runWhere === 'function' ? runWhere() : 'local';
1148
+ $('deviceChip').textContent = w !== 'local' ? `Online · ${serviceName(w)}` : `${engineLabel(h.engine)} · ${Math.round(h.ram / 2 ** 30)} GB RAM`;
1149
  const os = { darwin: 'macOS', win32: 'Windows', linux: 'Linux' }[h.platform] || h.platform;
1150
  const rows = [
1151
  ['System', `${os} (${h.arch})`], ['Processor', `${h.cpu} · ${h.cores} threads`], ['Memory', `${Math.round(h.ram / 2 ** 30)} GB`],
 
1280
  const where = runWhere();
1281
  if (where !== 'local') {
1282
  const st = online[where];
 
1283
  $('runOnNote').innerHTML = '';
1284
+ const what = { kaggle: 'Each run starts a GPU machine first (2–5 min).', cloudflare: 'FLUX.1-schnell, 1024×1024, a few seconds per image.', colab: 'Progress is live.' }[where];
1285
+ $('runOnNote').append(`Now: online on ${serviceName(where)}${st.gpu ? ` (${st.gpu})` : ''}. ${what} `);
1286
+ for (const other of onlineServices().filter(w => w !== where)) {
1287
+ const sw = document.createElement('button'); sw.type = 'button'; sw.className = 'link'; sw.textContent = `Use ${serviceName(other)}`;
1288
+ sw.addEventListener('click', () => { store('ora.onlineService', other); renderRunOn(); renderModelChoices(); renderDevice(); sync(); });
1289
+ $('runOnNote').append(' ', sw);
1290
+ }
1291
  return;
1292
  }
1293
  $('runOnNote').textContent = e.gpuUnavailable
 
1306
  store('ora.form', form); saveDraft(); renderShots(); setRunning(false); sync();
1307
  });
1308
  $('openSaveDir').addEventListener('click', () => window.ora.openSaveDir());
1309
+ $('navTabs').addEventListener('click', e => { const b = e.target.closest('button[data-view]'); if (b) showView(b.dataset.view); });
1310
+ document.addEventListener('click', e => {
1311
+ if (e.target.closest('[data-open-models]')) showView('models');
1312
+ const l = e.target.closest('[data-view-link]'); if (l) showView(l.dataset.viewLink);
1313
+ });
1314
+ $('closeModels').addEventListener('click', () => showView('create'));
1315
+ $('closeOnline').addEventListener('click', () => showView('create'));
1316
+ $('libFilter').addEventListener('click', e => {
1317
+ const b = e.target.closest('button[data-value]'); if (!b) return;
1318
+ libFilter = b.dataset.value;
1319
+ for (const x of $('libFilter').children) x.setAttribute('aria-checked', String(x === b));
1320
+ renderGrid();
1321
+ });
1322
+ $('openImageDir').addEventListener('click', () => window.ora.openImageDir());
1323
  $('kaggleOpen').addEventListener('click', () => window.ora.openOnline('kaggle'));
1324
  $('colabOpen').addEventListener('click', () => window.ora.openOnline('colab'));
1325
  $('colabCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('colabLine').textContent); $('colabCopy').textContent = 'Copied'; setTimeout(() => { $('colabCopy').textContent = 'Copy'; }, 1500); } catch { } });
 
1336
  renderOnline();
1337
  });
1338
  $('kaggleRemove').addEventListener('click', async () => { online = await window.ora.disconnectOnline('kaggle'); renderOnline(); });
1339
+ $('kaggleTokenConnect').addEventListener('click', async () => {
1340
+ $('kaggleStatus').textContent = 'Checking the token with Kaggle…';
1341
+ try { online = await window.ora.connectKaggleToken($('kaggleUser').value, $('kaggleToken').value); $('kaggleToken').value = ''; store('ora.onlineService', 'kaggle'); }
1342
+ catch (e) { await refreshOnline(); $('kaggleStatus').textContent = cleanErr(e); return; }
1343
+ renderOnline();
1344
+ });
1345
+ $('lightningCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('lightningLine').textContent); $('lightningCopy').textContent = 'Copied'; setTimeout(() => { $('lightningCopy').textContent = 'Copy'; }, 1500); } catch { } });
1346
+ $('lightningOpen').addEventListener('click', () => window.ora.openOnline('lightning'));
1347
+ $('lightningConnect').addEventListener('click', async () => {
1348
+ const code = $('lightningCode').value.trim();
1349
+ if (!code) return;
1350
+ $('lightningStatus').textContent = 'Connecting to your Studio…';
1351
+ try { online = await window.ora.connectColab(code, 'lightning'); $('lightningCode').value = ''; store('ora.onlineService', 'colab'); } catch (e) { await refreshOnline(); $('lightningStatus').textContent = cleanErr(e); return; }
1352
+ renderOnline();
1353
+ });
1354
+ $('cfOpen').addEventListener('click', () => window.ora.openOnline('cloudflare'));
1355
+ $('cfConnect').addEventListener('click', async () => {
1356
+ $('cfStatus').textContent = 'Checking with Cloudflare…';
1357
+ try { online = await window.ora.connectCloudflare($('cfAccount').value, $('cfToken').value); $('cfToken').value = ''; store('ora.onlineService', 'cloudflare'); } catch (e) { await refreshOnline(); $('cfStatus').textContent = cleanErr(e); return; }
1358
+ renderOnline();
1359
+ });
1360
+ $('cfRemove').addEventListener('click', async () => { online = await window.ora.disconnectOnline('cloudflare'); renderOnline(); });
1361
  $('kaggleQuotaSave').addEventListener('click', async () => {
1362
  const v = $('kaggleQuota').value.trim();
1363
  online.usage = await window.ora.setQuota('kaggle', v === '' ? null : Number(v));
app/renderer/index.html CHANGED
@@ -9,11 +9,14 @@
9
  <body>
10
  <header class="top">
11
  <div class="brand"><span class="mark" aria-hidden="true"></span><span>Ora</span><small id="version"></small></div>
12
- <button class="chip" id="deviceChip" type="button" aria-haspopup="dialog"></button>
 
 
 
 
 
13
  <div class="spacer"></div>
14
- <button class="ghost" id="onlineBtn" type="button">Online GPU</button>
15
- <button class="ghost" id="modelsBtn" type="button">Models</button>
16
- <button class="ghost" id="openSaveDir" type="button">Videos folder</button>
17
  </header>
18
 
19
  <main>
@@ -155,6 +158,10 @@
155
  <span class="mark big-mark" aria-hidden="true"></span>
156
  <p id="stageTitle">Your video appears here.</p>
157
  <p class="muted small" id="stageHint"></p>
 
 
 
 
158
  </div>
159
  <div class="stage-run" id="stageRun" hidden>
160
  <div class="run-head">
@@ -201,29 +208,34 @@
201
  </div>
202
  </div>
203
 
204
- <div class="history">
205
- <div class="history-head"><h2>Your work</h2><span class="muted small save-dir" id="saveDirText"></span><span class="spacer"></span><button class="link" id="clearHistoryBtn" type="button" hidden>Clear history</button></div>
206
- <div class="grid" id="grid"></div>
207
- <div class="ideas" id="gridEmpty">
208
- <p class="muted small">Videos and images you make are listed here. Not sure where to start? Pick an idea: it fills in the form.</p>
209
- <div class="idea-grid" id="ideaGrid"></div>
210
- </div>
211
  </div>
212
  </div>
213
  </section>
214
- </main>
215
-
216
- <dialog id="deviceDlg">
217
- <h2>This computer</h2>
218
- <dl id="deviceList"></dl>
219
- <p class="muted small" id="deviceNote"></p>
220
- <div class="dlg-actions"><button class="ghost" id="openModels" type="button">Open models folder</button><button class="primary" id="closeDevice" type="button">Close</button></div>
221
- </dialog>
222
 
223
- <dialog id="modelsDlg" class="models-dlg">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  <div class="mdl-head">
225
- <div><h2>Models</h2><p class="muted small" id="mdlDevice"></p></div>
226
- <button class="ghost" id="closeModels" type="button">Close</button>
227
  </div>
228
  <p class="muted small">Ora picks models to suit this computer. Models it cannot run here stay listed, locked, with the reason. Every model runs on your computer; nothing is uploaded.</p>
229
  <h3 class="mdl-sec">Video</h3>
@@ -231,12 +243,12 @@
231
  <h3 class="mdl-sec">Image</h3>
232
  <div class="mdl-grid" id="mdlImage"></div>
233
  <p class="muted small mdl-foot">Longest open model today: 15 seconds in one clip (MiniMax-H3). For longer videos, make up to 5 shots in a project and join them in your video editor.</p>
234
- </dialog>
235
 
236
- <dialog id="onlineDlg" class="models-dlg">
237
  <div class="mdl-head">
238
- <div><h2>Online GPU</h2><p class="muted small">Use a free graphics card from your own Kaggle or Google account. Ora sends your prompts there and brings the videos and images back to this computer.</p></div>
239
- <button class="ghost" id="closeOnline" type="button">Close</button>
240
  </div>
241
  <div class="mdl-grid online-grid">
242
  <div class="mdl" id="kaggleCard">
@@ -244,11 +256,14 @@
244
  <div class="mdl-made">Free NVIDIA T4 or P100 (16 GB), about 30 hours a week</div>
245
  <ol class="steps-list">
246
  <li>Make a free account at kaggle.com and verify your phone number (Kaggle needs it for GPU and internet).</li>
247
- <li>Kaggle › Settings › API › <b>Create New Token</b>. This downloads <code>kaggle.json</code>.</li>
248
- <li>Choose that file here. Ora starts the GPU for you each time.</li>
249
  </ol>
 
 
250
  <div class="mdl-status" id="kaggleStatus"></div>
251
- <div class="row-btns"><button class="ghost" id="kaggleOpen" type="button">Open Kaggle settings</button><button class="primary" id="kaggleConnect" type="button">Choose kaggle.json…</button><button class="link" id="kaggleRemove" type="button" hidden>Disconnect</button></div>
 
252
  <p class="muted small">Each run starts a fresh machine: allow 2–5 minutes before the first frame. A whole project runs in one go.</p>
253
  <div class="quota-row"><label for="kaggleQuota">GPU hours left on Kaggle now <small class="muted">(Kaggle › Settings › Quota)</small></label><input id="kaggleQuota" inputmode="decimal" placeholder="e.g. 30"><button class="ghost" id="kaggleQuotaSave" type="button">Save</button></div>
254
  <p class="muted small" id="kaggleUsage"></p>
@@ -267,10 +282,48 @@
267
  <div class="row-btns"><button class="ghost" id="colabOpen" type="button">Open Colab</button><button class="link" id="colabRemove" type="button" hidden>Disconnect</button></div>
268
  <p class="muted small" id="colabUsage"></p>
269
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  </div>
271
- <p class="muted small mdl-foot">Your Kaggle token and Colab code are stored encrypted on this computer and sent only to Kaggle or your own notebook. Ora never sees your passwords. Kaggle and Colab are meant for data science and AI work; check their terms of use. Free GPU time is limited by each platform.</p>
 
 
 
 
 
 
 
 
272
  </dialog>
273
 
 
 
274
  <dialog id="clearDlg">
275
  <h2>Clear history</h2>
276
  <p>This removes Ora's list of past videos and the prompts saved with them.</p>
 
9
  <body>
10
  <header class="top">
11
  <div class="brand"><span class="mark" aria-hidden="true"></span><span>Ora</span><small id="version"></small></div>
12
+ <nav class="nav-tabs" id="navTabs" aria-label="Sections">
13
+ <button type="button" data-view="create" aria-current="page">Create</button>
14
+ <button type="button" data-view="library">Library</button>
15
+ <button type="button" data-view="models">Models</button>
16
+ <button type="button" data-view="online">Online</button>
17
+ </nav>
18
  <div class="spacer"></div>
19
+ <button class="chip" id="deviceChip" type="button" aria-haspopup="dialog"></button>
 
 
20
  </header>
21
 
22
  <main>
 
158
  <span class="mark big-mark" aria-hidden="true"></span>
159
  <p id="stageTitle">Your video appears here.</p>
160
  <p class="muted small" id="stageHint"></p>
161
+ <div class="ideas" id="ideasBox">
162
+ <p class="muted small">Not sure where to start? Pick an idea: it fills in the form.</p>
163
+ <div class="idea-grid" id="ideaGrid"></div>
164
+ </div>
165
  </div>
166
  <div class="stage-run" id="stageRun" hidden>
167
  <div class="run-head">
 
208
  </div>
209
  </div>
210
 
211
+ <div class="recent" id="recentBox" hidden>
212
+ <div class="history-head"><h2>Recent</h2><span class="spacer"></span><button class="link" type="button" data-view-link="library">See all in Library</button></div>
213
+ <div class="grid recent-grid" id="recentGrid"></div>
 
 
 
 
214
  </div>
215
  </div>
216
  </section>
 
 
 
 
 
 
 
 
217
 
218
+ <!-- library: everything made, videos and images -->
219
+ <section id="libraryView" class="page" hidden>
220
+ <div class="page-head">
221
+ <div><h1>Library</h1><p class="muted small save-dir" id="saveDirText"></p></div>
222
+ <div class="spacer"></div>
223
+ <div class="seg lib-filter" id="libFilter" role="radiogroup">
224
+ <button type="button" role="radio" data-value="all" aria-checked="true">All</button>
225
+ <button type="button" role="radio" data-value="video" aria-checked="false">Videos</button>
226
+ <button type="button" role="radio" data-value="image" aria-checked="false">Images</button>
227
+ </div>
228
+ <button class="ghost" id="openSaveDir" type="button">Videos folder</button>
229
+ <button class="ghost" id="openImageDir" type="button">Pictures folder</button>
230
+ </div>
231
+ <div class="grid lib-grid" id="grid"></div>
232
+ <p class="muted" id="gridEmpty">Nothing here yet. Videos and images you make appear in this library and are saved to your Videos and Pictures folders.</p>
233
+ <p class="lib-foot"><button class="link" id="clearHistoryBtn" type="button" hidden>Clear history</button></p>
234
+ </section>
235
+ <section id="modelsView" class="page page-models" hidden>
236
  <div class="mdl-head">
237
+ <div><h1>Models</h1><p class="muted small" id="mdlDevice"></p></div>
238
+ <button class="ghost" id="closeModels" type="button">Back to Create</button>
239
  </div>
240
  <p class="muted small">Ora picks models to suit this computer. Models it cannot run here stay listed, locked, with the reason. Every model runs on your computer; nothing is uploaded.</p>
241
  <h3 class="mdl-sec">Video</h3>
 
243
  <h3 class="mdl-sec">Image</h3>
244
  <div class="mdl-grid" id="mdlImage"></div>
245
  <p class="muted small mdl-foot">Longest open model today: 15 seconds in one clip (MiniMax-H3). For longer videos, make up to 5 shots in a project and join them in your video editor.</p>
246
+ </section>
247
 
248
+ <section id="onlineView" class="page page-models" hidden>
249
  <div class="mdl-head">
250
+ <div><h1>Online</h1><p class="muted small">Use free GPU time from your own accounts. Ora sends your prompts there and brings the videos and images back to this computer.</p></div>
251
+ <button class="ghost" id="closeOnline" type="button">Back to Create</button>
252
  </div>
253
  <div class="mdl-grid online-grid">
254
  <div class="mdl" id="kaggleCard">
 
256
  <div class="mdl-made">Free NVIDIA T4 or P100 (16 GB), about 30 hours a week</div>
257
  <ol class="steps-list">
258
  <li>Make a free account at kaggle.com and verify your phone number (Kaggle needs it for GPU and internet).</li>
259
+ <li>Kaggle › Settings › API › <b>Generate New Token</b>. Copy the token it shows (it starts with <code>KGAT_</code>).</li>
260
+ <li>Paste it here with your Kaggle username. Ora starts the GPU for you each time.</li>
261
  </ol>
262
+ <div class="paste-row"><input id="kaggleUser" placeholder="Kaggle username" autocomplete="off" spellcheck="false"></div>
263
+ <div class="paste-row"><input id="kaggleToken" type="password" placeholder="KGAT_…" autocomplete="off" spellcheck="false"><button class="primary" id="kaggleTokenConnect" type="button">Connect</button></div>
264
  <div class="mdl-status" id="kaggleStatus"></div>
265
+ <div class="row-btns"><button class="ghost" id="kaggleOpen" type="button">Open Kaggle settings</button><button class="link" id="kaggleConnect" type="button">Have an older kaggle.json? Choose it…</button><button class="link" id="kaggleRemove" type="button" hidden>Disconnect</button></div>
266
+ <p class="muted small">Never paste the token anywhere but here: it gives access to your Kaggle account. If it leaks, delete it in Kaggle and make a new one.</p>
267
  <p class="muted small">Each run starts a fresh machine: allow 2–5 minutes before the first frame. A whole project runs in one go.</p>
268
  <div class="quota-row"><label for="kaggleQuota">GPU hours left on Kaggle now <small class="muted">(Kaggle › Settings › Quota)</small></label><input id="kaggleQuota" inputmode="decimal" placeholder="e.g. 30"><button class="ghost" id="kaggleQuotaSave" type="button">Save</button></div>
269
  <p class="muted small" id="kaggleUsage"></p>
 
282
  <div class="row-btns"><button class="ghost" id="colabOpen" type="button">Open Colab</button><button class="link" id="colabRemove" type="button" hidden>Disconnect</button></div>
283
  <p class="muted small" id="colabUsage"></p>
284
  </div>
285
+ <div class="mdl" id="lightningCard">
286
+ <div class="mdl-top"><span class="mdl-title">Lightning AI</span><span class="mdl-tag">Live progress</span></div>
287
+ <div class="mdl-made">Free monthly GPU credits on lightning.ai (phone verification), video and images</div>
288
+ <ol class="steps-list">
289
+ <li>Make a free account at lightning.ai, create a Studio and switch it to a <b>GPU</b> (T4 or L4).</li>
290
+ <li>Open the Studio's <b>Terminal</b>, paste this line and press Enter:</li>
291
+ </ol>
292
+ <div class="cmd-line"><code id="lightningLine"></code><button class="ghost" id="lightningCopy" type="button">Copy</button></div>
293
+ <ol class="steps-list" start="3"><li>Paste the connection code it prints (starts with <code>ora1.</code>) here.</li></ol>
294
+ <div class="paste-row"><input id="lightningCode" placeholder="ora1.…" autocomplete="off" spellcheck="false"><button class="primary" id="lightningConnect" type="button">Connect</button></div>
295
+ <div class="mdl-status" id="lightningStatus"></div>
296
+ <div class="row-btns"><button class="ghost" id="lightningOpen" type="button">Open Lightning AI</button></div>
297
+ <p class="muted small">Colab and Lightning share one connection: connecting one replaces the other.</p>
298
+ </div>
299
+ <div class="mdl" id="cloudflareCard">
300
+ <div class="mdl-top"><span class="mdl-title">Cloudflare Workers AI</span><span class="mdl-tag">Images · instant</span></div>
301
+ <div class="mdl-made">10,000 free Neurons a day: about 170 FLUX.1-schnell images (1024×1024). No video.</div>
302
+ <ol class="steps-list">
303
+ <li>Make a free account at cloudflare.com. In the dashboard open <b>AI › Workers AI › Use REST API</b>.</li>
304
+ <li>Copy your <b>Account ID</b>, and create an <b>API token</b> with the "Workers AI" permission.</li>
305
+ <li>Paste both here. Prompts for Cloudflare images are sent to Cloudflare's servers.</li>
306
+ </ol>
307
+ <div class="paste-row"><input id="cfAccount" placeholder="Account ID" autocomplete="off" spellcheck="false"></div>
308
+ <div class="paste-row"><input id="cfToken" type="password" placeholder="API token" autocomplete="off" spellcheck="false"><button class="primary" id="cfConnect" type="button">Connect</button></div>
309
+ <div class="mdl-status" id="cfStatus"></div>
310
+ <div class="row-btns"><button class="ghost" id="cfOpen" type="button">Open Cloudflare</button><button class="link" id="cfRemove" type="button" hidden>Disconnect</button></div>
311
+ <p class="muted small" id="cfUsage"></p>
312
+ </div>
313
  </div>
314
+ <p class="muted small mdl-foot">Tokens and connection codes are stored encrypted on this computer and sent only to that service or your own notebook; Ora never sees your passwords. With Kaggle, Colab and Lightning AI the models run in your own notebook; with Cloudflare, prompts go to Cloudflare's servers. Free allowances are set by each platform; check their terms of use.</p>
315
+ </section>
316
+ </main>
317
+
318
+ <dialog id="deviceDlg">
319
+ <h2>This computer</h2>
320
+ <dl id="deviceList"></dl>
321
+ <p class="muted small" id="deviceNote"></p>
322
+ <div class="dlg-actions"><button class="ghost" id="openModels" type="button">Open models folder</button><button class="primary" id="closeDevice" type="button">Close</button></div>
323
  </dialog>
324
 
325
+
326
+
327
  <dialog id="clearDlg">
328
  <h2>Clear history</h2>
329
  <p>This removes Ora's list of past videos and the prompts saved with them.</p>
app/renderer/styles.css CHANGED
@@ -290,3 +290,29 @@ dd { margin: 0; }
290
  .ring { background: conic-gradient(#1c1530 calc(var(--p) * 1%), var(--panel-2) 0); }
291
  .phase.active .dot { border-color: #1c1530; background: rgba(28, 21, 48, .25); }
292
  body { background-image: none; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  .ring { background: conic-gradient(#1c1530 calc(var(--p) * 1%), var(--panel-2) 0); }
291
  .phase.active .dot { border-color: #1c1530; background: rgba(28, 21, 48, .25); }
292
  body { background-image: none; }
293
+
294
+ /* 0.1.3 layout: tabs in the top bar, full pages for Library / Models / Online */
295
+ .nav-tabs { display: flex; gap: 2px; background: var(--panel-2); border-radius: 11px; padding: 3px; margin-left: 18px; -webkit-app-region: no-drag; }
296
+ .nav-tabs button { border: 0; background: transparent; border-radius: 8px; padding: 6px 14px; font: 600 13.5px -apple-system, sans-serif; color: var(--muted); cursor: pointer; }
297
+ .nav-tabs button[aria-current="page"] { background: #fff; color: var(--text); box-shadow: 0 2px 8px -3px rgba(28, 21, 48, .3); }
298
+ .page { max-width: 1240px; margin: 0 auto; padding: 26px 26px 40px; }
299
+ .page h1 { font-size: 28px; margin: 0 0 4px; }
300
+ .page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
301
+ .page-head > div:first-child { min-width: 0; }
302
+ .lib-filter { width: auto; }
303
+ .lib-filter button { padding: 6px 14px; }
304
+ .lib-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
305
+ .lib-foot { margin-top: 18px; }
306
+ .page-models .mdl-head { margin-bottom: 8px; }
307
+ .stage-empty .ideas { margin-top: 22px; text-align: left; max-width: 760px; margin-left: auto; margin-right: auto; }
308
+ .stage-empty .idea-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
309
+ .stage { min-height: 300px; }
310
+ .recent { display: flex; flex-direction: column; }
311
+ .recent-grid { grid-template-columns: repeat(4, 1fr); }
312
+ @media (max-width: 1250px) { .recent-grid { grid-template-columns: repeat(3, 1fr); } }
313
+
314
+ .card .kind { background: rgba(255, 255, 255, .92); color: #1c1530; }
315
+ .lib-grid, .recent-grid { align-items: start; }
316
+ .card img.noposter { aspect-ratio: 16 / 9 !important; background: #1c1530; }
317
+ .online-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
318
+ @media (max-width: 1050px) { .online-grid { grid-template-columns: 1fr; } }
index.html CHANGED
@@ -37,7 +37,7 @@
37
  <!-- hero -->
38
  <section class="hero">
39
  <div class="hero-copy">
40
- <a class="pill" href="#models"><span class="dot"></span>New: video with sound, up to 15 s · images · free online GPU</a>
41
  <h1>Turn words into <span class="grad">scroll-stopping</span> video.</h1>
42
  <p class="sub">Write up to five shots and Ora turns each one into a video clip, or make product images and bring them to life. All on your own computer: no account, no upload, no monthly fee.</p>
43
  <div class="hero-install" id="heroInstall">
@@ -231,19 +231,29 @@
231
  <!-- online gpu -->
232
  <section class="section" id="online">
233
  <p class="kicker">No graphics card?</p>
234
- <h2>Use a free online GPU from your own account</h2>
235
- <p class="lead">Connect <b>Kaggle</b> or <b>Google Colab</b> in Ora and choose <b>Run on › Online</b>. Your prompts go to your own notebook, the video or image is made on its free NVIDIA GPU, and the files come back to your computer. Online runs also unlock bigger models such as Wan2.2 A14B and Qwen-Image.</p>
236
  <div class="cards">
237
  <div class="card">
238
  <div class="tag">Kaggle · automatic</div>
239
  <h3>About 30 free GPU hours a week</h3>
240
- <p>Make a Kaggle account, verify your phone, create an API token (<code>kaggle.json</code>) and choose it in Ora. Ora starts the GPU for each project by itself; allow 2–5 minutes for it to start.</p>
241
  </div>
242
  <div class="card">
243
  <div class="tag tag-q">Colab · live progress</div>
244
  <h3>A free T4 when available</h3>
245
  <p>Open a Colab notebook with a T4 GPU, paste the one line Ora shows into a cell and run it, then paste the connection code back into Ora. It stays connected until the session ends.</p>
246
  </div>
 
 
 
 
 
 
 
 
 
 
247
  </div>
248
  <div class="quota-demo">
249
  <b>Know what it costs before you start.</b>
 
37
  <!-- hero -->
38
  <section class="hero">
39
  <div class="hero-copy">
40
+ <a class="pill" href="#online"><span class="dot"></span>New: free online GPUs · Kaggle, Colab, Lightning AI, Cloudflare</a>
41
  <h1>Turn words into <span class="grad">scroll-stopping</span> video.</h1>
42
  <p class="sub">Write up to five shots and Ora turns each one into a video clip, or make product images and bring them to life. All on your own computer: no account, no upload, no monthly fee.</p>
43
  <div class="hero-install" id="heroInstall">
 
231
  <!-- online gpu -->
232
  <section class="section" id="online">
233
  <p class="kicker">No graphics card?</p>
234
+ <h2>Use free online GPUs from your own accounts</h2>
235
+ <p class="lead">Connect <b>Kaggle</b>, <b>Google Colab</b>, <b>Lightning AI</b> or <b>Cloudflare</b> in Ora and choose <b>Run on › Online</b>. Your prompts go to your own notebook, the video or image is made on its free NVIDIA GPU, and the files come back to your computer. Online runs also unlock bigger models such as Wan2.2 A14B and Qwen-Image.</p>
236
  <div class="cards">
237
  <div class="card">
238
  <div class="tag">Kaggle · automatic</div>
239
  <h3>About 30 free GPU hours a week</h3>
240
+ <p>Make a Kaggle account, verify your phone, generate an API token (it starts with <code>KGAT_</code>) and paste it into Ora with your username. Ora starts the GPU for each project by itself; allow 2–5 minutes for it to start.</p>
241
  </div>
242
  <div class="card">
243
  <div class="tag tag-q">Colab · live progress</div>
244
  <h3>A free T4 when available</h3>
245
  <p>Open a Colab notebook with a T4 GPU, paste the one line Ora shows into a cell and run it, then paste the connection code back into Ora. It stays connected until the session ends.</p>
246
  </div>
247
+ <div class="card">
248
+ <div class="tag tag-q">Lightning AI · live progress</div>
249
+ <h3>Free monthly GPU credits</h3>
250
+ <p>Create a Lightning AI Studio with a GPU, paste the line Ora shows into its terminal, then paste the connection code back into Ora. Works like Colab, for video and images.</p>
251
+ </div>
252
+ <div class="card">
253
+ <div class="tag">Cloudflare · images in seconds</div>
254
+ <h3>About 170 free images a day</h3>
255
+ <p>Paste your Cloudflare Account ID and a Workers AI token into Ora. FLUX.1-schnell makes 1024×1024 images in seconds from 10,000 free Neurons a day; Ora shows what each image uses and what is left. Images only, and prompts go to Cloudflare.</p>
256
+ </div>
257
  </div>
258
  <div class="quota-demo">
259
  <b>Know what it costs before you start.</b>
worker/ora_worker.py CHANGED
@@ -12,7 +12,7 @@ only requests carrying that code's secret are accepted. Standard library only.
12
  import argparse, base64, hashlib, json, os, re, secrets, shutil, subprocess, sys, tarfile, threading, time, urllib.request
13
  from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
14
 
15
- VERSION = '0.1.2'
16
  SITE = 'https://devseis-ora.static.hf.space'
17
  RELEASES = 'https://huggingface.co/datasets/Devseis/ora-releases/resolve/main'
18
  ENGINE_FILE = 'ora-engine-linux-cuda.tar.gz'
 
12
  import argparse, base64, hashlib, json, os, re, secrets, shutil, subprocess, sys, tarfile, threading, time, urllib.request
13
  from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
14
 
15
+ VERSION = '0.1.3'
16
  SITE = 'https://devseis-ora.static.hf.space'
17
  RELEASES = 'https://huggingface.co/datasets/Devseis/ora-releases/resolve/main'
18
  ENGINE_FILE = 'ora-engine-linux-cuda.tar.gz'