@crievo/omni 0.1.7 → 0.1.9

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 (76) hide show
  1. package/omnivideo.config.example.json +2 -0
  2. package/package.json +1 -1
  3. package/reference/cloud.md +15 -1
  4. package/reference/learnings.md +7 -0
  5. package/reference/scenes-contract.md +3 -2
  6. package/reference/studio.md +3 -2
  7. package/studio/api/app.ts +4 -0
  8. package/studio/api/routes/cost.ts +13 -0
  9. package/studio/api/routes/me.ts +8 -0
  10. package/studio/api/services/agent-persona.ts +1 -0
  11. package/studio/api/services/agent-tools.ts +2 -2
  12. package/studio/api/services/cost.ts +22 -0
  13. package/studio/api/services/me.ts +67 -0
  14. package/studio/api/services/sessions.ts +8 -2
  15. package/studio/api/services/sound.ts +17 -6
  16. package/studio/runner/runner.ts +57 -10
  17. package/studio/shared/omni-screens.ts +1 -1
  18. package/studio/shared/schemas/cost.ts +10 -0
  19. package/studio/shared/types/api.ts +77 -1
  20. package/studio/studio.ts +27 -2
  21. package/studio/web/components/AppShell.tsx +11 -3
  22. package/studio/web/components/FirstConnection.tsx +222 -0
  23. package/studio/web/components/OfflineNotice.tsx +59 -0
  24. package/studio/web/components/SetupSteps.tsx +63 -0
  25. package/studio/web/components/Sidebar.tsx +10 -25
  26. package/studio/web/components/StudioOffline.tsx +48 -50
  27. package/studio/web/components/UserCard.tsx +79 -0
  28. package/studio/web/components/icons.tsx +2 -0
  29. package/studio/web/hooks/useComputers.ts +55 -0
  30. package/studio/web/hooks/useCost.ts +11 -0
  31. package/studio/web/hooks/useMe.ts +32 -0
  32. package/studio/web/hooks/useSetupProgress.ts +54 -0
  33. package/studio/web/lib/me.ts +17 -0
  34. package/studio/web/lib/query-client.ts +6 -0
  35. package/studio/web/lib/settings-categories.ts +2 -2
  36. package/studio/web/lib/setup-retry.ts +29 -0
  37. package/studio/web/lib/sound-timeline.ts +33 -0
  38. package/studio/web/lib/studio-offline.ts +105 -59
  39. package/studio/web/pages/ConnectPreviewPage/index.tsx +215 -0
  40. package/studio/web/pages/SettingsPage/components/AgentCategory.tsx +18 -9
  41. package/studio/web/pages/SettingsPage/components/AgentCostPanel.tsx +253 -0
  42. package/studio/web/pages/SettingsPage/components/ComputersPanel.tsx +145 -0
  43. package/studio/web/pages/SettingsPage/components/PublishingCategory/OmnichatSettingsPanel.tsx +2 -2
  44. package/studio/web/pages/SettingsPage/components/PublishingCategory/SchedulePanel.tsx +3 -3
  45. package/studio/web/pages/SettingsPage/components/UsageCategory.tsx +7 -2
  46. package/studio/web/pages/SettingsPage/index.tsx +15 -1
  47. package/studio/web/pages/VideoPage/components/PublishForm.tsx +5 -2
  48. package/studio/web/pages/VideoPage/components/SoundTimeline/EffectChoice.tsx +10 -8
  49. package/studio/web/pages/VideoPage/components/SoundTimeline/SoundLibrary.tsx +31 -18
  50. package/studio/web/router.tsx +8 -0
  51. package/studio/web/styles/components/setup-steps.css +163 -0
  52. package/studio/web/styles/components/user-card.css +121 -0
  53. package/studio/web/styles/index.css +2 -0
  54. package/studio/web/styles/pages/settings/shell.css +79 -0
  55. package/studio/web/styles/pages/settings/usage.css +47 -0
  56. package/studio/web/styles/pages/studio-offline.css +224 -38
  57. package/tools/cost.mjs +114 -0
  58. package/tools/lib/agents.mjs +3 -2
  59. package/tools/lib/channel.mjs +1 -1
  60. package/tools/lib/cloud-user.mjs +58 -0
  61. package/tools/lib/cost.mjs +357 -0
  62. package/tools/lib/deps.mjs +27 -12
  63. package/tools/lib/oauth-client.mjs +28 -14
  64. package/tools/lib/pages-style.mjs +67 -0
  65. package/tools/lib/pairing.mjs +1 -1
  66. package/tools/lib/schedule/schedule.mjs +1 -1
  67. package/tools/lib/self-update.mjs +122 -0
  68. package/tools/lib/setup-progress.mjs +315 -0
  69. package/tools/lib/up.mjs +176 -61
  70. package/tools/metrics.mjs +6 -1
  71. package/tools/omni.mjs +41 -16
  72. package/tools/omnichat.mjs +45 -9
  73. package/tools/platforms.mjs +75 -14
  74. package/tools/runner.mjs +6 -6
  75. package/tools/setup.mjs +18 -5
  76. package/tools/sound.mjs +198 -94
@@ -0,0 +1,357 @@
1
+ /* What the agents spent: the cost of every Claude turn, split by video, stage, fork and model.
2
+
3
+ The source is what the studio already writes: .sessions/<id>/turn-<n>.jsonl, claude's
4
+ stream-json. Each turn ends with a `result` that carries `total_cost_usd` and, per model, the
5
+ `costUSD` of everything the session ran so far, forks included. That total is the truth, and
6
+ it is CUMULATIVE: a resumed session keeps adding to it, so a turn costs the difference to the
7
+ previous result. The per-message `usage` lines are only used to SPLIT that cost (which fork
8
+ spent what): they come with the output tokens undercounted, so the split is scaled per model
9
+ to what the result says (the price table only gives the weights between token kinds, never the
10
+ final value). A turn without `result` (running, interrupted) is the uncalibrated estimate,
11
+ marked `partial`.
12
+
13
+ A fork is a message whose `parent_tool_use_id` points at a Skill or Agent tool_use. A stage
14
+ skill (`context: fork`) shows up as a Skill, a fan-out scene as an Agent ("compose c01").
15
+ Codex reports tokens, never dollars: its turns count as turns, with no cost.
16
+
17
+ Everything here is read-only. The only thing written is a cache per finished turn file
18
+ (.cost/turns/), which never goes stale: a turn with `result` does not change. */
19
+
20
+ import {
21
+ createReadStream,
22
+ existsSync,
23
+ mkdirSync,
24
+ readFileSync,
25
+ readdirSync,
26
+ renameSync,
27
+ statSync,
28
+ writeFileSync,
29
+ } from "node:fs";
30
+ import { createInterface } from "node:readline";
31
+ import { dirname, join } from "node:path";
32
+ import { fileURLToPath } from "node:url";
33
+
34
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
35
+ export const SESSIONS_DIR = join(ROOT, ".sessions");
36
+ export const CACHE_DIR = join(ROOT, ".cost", "turns");
37
+ const CACHE_VERSION = 1;
38
+
39
+ /* USD per million tokens: input, output, cache read, cache write. Only the proportion between
40
+ the four matters (calibration fixes the scale); a model missing here is priced as Opus. */
41
+ const PRICES = {
42
+ opus: [4, 20, 0.2, 5],
43
+ sonnet: [2, 10, 0.2, 2.5],
44
+ haiku: [1, 5, 0.1, 1.25],
45
+ };
46
+ const priceOf = model => PRICES[Object.keys(PRICES).find(k => String(model).includes(k)) ?? "opus"];
47
+
48
+ export const shortModel = m =>
49
+ String(m ?? "?")
50
+ .replace(/^claude-/, "")
51
+ .replace(/-\d{8}$/, "");
52
+
53
+ /* the skills before the English migration, under the name they have today */
54
+ const LEGACY_SKILLS = {
55
+ "av-roteiro": "av-script",
56
+ "av-narracao": "av-narration",
57
+ "av-voz": "av-voice",
58
+ "av-legenda": "av-captions",
59
+ "av-montar": "av-assemble",
60
+ "av-previa": "av-preview",
61
+ };
62
+
63
+ /* fork description → stage. The Skill forks carry their own name (av-motion…). */
64
+ const AGENT_STAGES = {
65
+ wireframe: "wireframe",
66
+ compose: "compose",
67
+ compor: "compose",
68
+ narration: "av-narration",
69
+ narrar: "av-narration",
70
+ };
71
+ export function stageOf(name, input = {}) {
72
+ if (name === "Skill") {
73
+ const skill = String(input.skill ?? "skill").replace(/^.*:/, "");
74
+ return LEGACY_SKILLS[skill] ?? skill;
75
+ }
76
+ const word = String(input.description ?? "")
77
+ .split(/\s+/)[0]
78
+ .toLowerCase();
79
+ return AGENT_STAGES[word] ?? `agent:${input.subagent_type ?? "general-purpose"}`;
80
+ }
81
+
82
+ const costOf = (u, model) => {
83
+ const [pi, po, pr, pw] = priceOf(model);
84
+ return (
85
+ ((u.input_tokens ?? 0) * pi +
86
+ (u.output_tokens ?? 0) * po +
87
+ (u.cache_read_input_tokens ?? 0) * pr +
88
+ (u.cache_creation_input_tokens ?? 0) * pw) /
89
+ 1e6
90
+ );
91
+ };
92
+
93
+ const round = (n, d = 4) => +n.toFixed(d);
94
+
95
+ /* One turn file → what it says, still uncalibrated. Streams the file and only parses the lines
96
+ that matter: an image Read puts megabytes of base64 on one `user` line.
97
+ `cum` is the `result` (the session's running total up to the end of this turn), `groups` the
98
+ split of this turn's own messages in raw dollars. `settle` turns the two into the turn's cost. */
99
+ export async function readTurnCost(file) {
100
+ const messages = new Map(); // message.id → { model, parent, usage }: the last usage wins, it only grows
101
+ const forks = new Map(); // tool_use id → { stage, label }
102
+ let result = null;
103
+ const rl = createInterface({ input: createReadStream(file, { encoding: "utf8" }), crlfDelay: Infinity });
104
+ for await (const line of rl) {
105
+ /* `result` does not open with "type" (it starts at duration_api_ms), so it is found by its field */
106
+ const assistant = line.startsWith('{"type":"assistant"');
107
+ if (!assistant && !line.includes('"total_cost_usd"')) continue;
108
+ let o;
109
+ try {
110
+ o = JSON.parse(line);
111
+ } catch {
112
+ continue;
113
+ }
114
+ if (!assistant) {
115
+ if (o.type === "result" && o.total_cost_usd != null) result = o;
116
+ continue;
117
+ }
118
+ const m = o.message;
119
+ if (!m?.id || m.model === "<synthetic>") continue;
120
+ for (const b of m.content ?? []) {
121
+ if (b.type === "tool_use" && (b.name === "Skill" || b.name === "Agent")) {
122
+ forks.set(b.id, { stage: stageOf(b.name, b.input), label: b.input?.description || b.input?.skill || b.name });
123
+ }
124
+ }
125
+ const prev = messages.get(m.id);
126
+ const u = m.usage ?? {};
127
+ const keep = prev ? { ...prev.usage } : {};
128
+ for (const k of ["input_tokens", "output_tokens", "cache_read_input_tokens", "cache_creation_input_tokens"]) {
129
+ keep[k] = Math.max(keep[k] ?? 0, u[k] ?? 0);
130
+ }
131
+ messages.set(m.id, {
132
+ model: shortModel(m.model ?? prev?.model),
133
+ parent: o.parent_tool_use_id ?? null,
134
+ usage: keep,
135
+ });
136
+ }
137
+
138
+ const raw = {};
139
+ const groups = new Map();
140
+ const group = key => {
141
+ if (!groups.has(key)) {
142
+ const f =
143
+ key === "root"
144
+ ? { stage: "orchestrator", label: "orquestrador" }
145
+ : (forks.get(key) ?? { stage: "other", label: "?" });
146
+ groups.set(key, {
147
+ ...f,
148
+ fork: key !== "root",
149
+ cost: 0,
150
+ messages: 0,
151
+ models: {},
152
+ tokens: { in: 0, out: 0, cacheRead: 0, cacheWrite: 0 },
153
+ });
154
+ }
155
+ return groups.get(key);
156
+ };
157
+ for (const { model, parent, usage } of messages.values()) {
158
+ const cost = costOf(usage, model);
159
+ raw[model] = (raw[model] ?? 0) + cost;
160
+ const g = group(parent ?? "root");
161
+ g.cost += cost;
162
+ g.messages += 1;
163
+ g.models[model] = (g.models[model] ?? 0) + cost;
164
+ g.tokens.in += usage.input_tokens ?? 0;
165
+ g.tokens.out += usage.output_tokens ?? 0;
166
+ g.tokens.cacheRead += usage.cache_read_input_tokens ?? 0;
167
+ g.tokens.cacheWrite += usage.cache_creation_input_tokens ?? 0;
168
+ }
169
+ return {
170
+ v: CACHE_VERSION,
171
+ session_id: result?.session_id ?? null,
172
+ cum: result
173
+ ? {
174
+ total: result.total_cost_usd,
175
+ models: Object.fromEntries(
176
+ Object.entries(result.modelUsage ?? {}).map(([m, u]) => [shortModel(m), u.costUSD ?? 0]),
177
+ ),
178
+ }
179
+ : null,
180
+ raw_models: raw,
181
+ groups: [...groups.values()].sort((a, b) => b.cost - a.cost),
182
+ };
183
+ }
184
+
185
+ /* the cached reading of a turn; a finished turn never changes, an open one is read again */
186
+ export async function turnCost(file) {
187
+ const st = statSync(file);
188
+ const cache = join(CACHE_DIR, `${file.split("/").slice(-2).join("-")}.json`);
189
+ try {
190
+ const c = JSON.parse(readFileSync(cache, "utf8"));
191
+ if (c.v === CACHE_VERSION && c.cum && c.size === st.size) return c;
192
+ } catch {}
193
+ const c = { ...(await readTurnCost(file)), size: st.size };
194
+ try {
195
+ mkdirSync(CACHE_DIR, { recursive: true });
196
+ const tmp = `${cache}.${process.pid}.tmp`;
197
+ writeFileSync(tmp, JSON.stringify(c));
198
+ renameSync(tmp, cache);
199
+ } catch {}
200
+ return c;
201
+ }
202
+
203
+ const sum = o => Object.values(o).reduce((a, b) => a + b, 0);
204
+
205
+ /* The `result` of a resumed session is CUMULATIVE (cost and models grow turn after turn, same
206
+ session_id), so a turn's own cost is the difference to the previous result of its session.
207
+ A turn without `result` (running or interrupted) is the uncalibrated estimate of its
208
+ messages, marked `partial`; the next result also holds what that turn spent, so the estimate
209
+ is taken out of it and the session still adds up to its last total.
210
+ `chain` is the running state of one session: { key, total, models, pending: { total, models } }. */
211
+ export function settle(reading, chain) {
212
+ if (!reading.cum) {
213
+ const total = sum(reading.raw_models);
214
+ chain.pending.total += total;
215
+ for (const [m, c] of Object.entries(reading.raw_models))
216
+ chain.pending.models[m] = (chain.pending.models[m] ?? 0) + c;
217
+ return {
218
+ partial: true,
219
+ total: round(total),
220
+ models: roundAll(reading.raw_models),
221
+ groups: reading.groups.map(g => roundGroup(g, () => 1)),
222
+ };
223
+ }
224
+ if (reading.session_id !== chain.key) Object.assign(chain, { key: reading.session_id, total: 0, models: {} }); // another conversation: starts from zero
225
+ const delta = (cum, before, pending) => Math.max(0, cum - before - pending);
226
+ const total = delta(reading.cum.total, chain.total, chain.pending.total);
227
+ const models = {};
228
+ for (const [m, cum] of Object.entries(reading.cum.models)) {
229
+ const d = delta(cum, chain.models[m] ?? 0, chain.pending.models[m] ?? 0);
230
+ if (d > 0) models[m] = d;
231
+ }
232
+ /* each model's messages are scaled to what the result says that model spent in this turn */
233
+ const factor = m => (reading.raw_models[m] > 0 && models[m] != null ? models[m] / reading.raw_models[m] : 1);
234
+ const groups = reading.groups.map(g => roundGroup(g, factor));
235
+ Object.assign(chain, {
236
+ total: reading.cum.total,
237
+ models: { ...reading.cum.models },
238
+ pending: { total: 0, models: {} },
239
+ });
240
+ return { partial: false, total: round(total), models: roundAll(models), groups };
241
+ }
242
+
243
+ const roundAll = o => Object.fromEntries(Object.entries(o).map(([k, v]) => [k, round(v)]));
244
+ const roundGroup = (g, factor) => {
245
+ const models = Object.fromEntries(Object.entries(g.models).map(([m, c]) => [m, c * factor(m)]));
246
+ return { ...g, cost: round(sum(models)), models: roundAll(models) };
247
+ };
248
+
249
+ /** every turn of every session, one row each: who it belongs to, when, what it cost
250
+ @param {{ sessionsDir?: string, since?: number | null }} [opts] `since`: epoch ms, earlier turns are not listed */
251
+ export async function readTurns({ sessionsDir = SESSIONS_DIR, since = null } = {}) {
252
+ if (!existsSync(sessionsDir)) return [];
253
+ const rows = [];
254
+ for (const id of readdirSync(sessionsDir)) {
255
+ let rec;
256
+ try {
257
+ rec = JSON.parse(readFileSync(join(sessionsDir, id, "session.json"), "utf8"));
258
+ } catch {
259
+ continue;
260
+ }
261
+ const chain = { key: null, total: 0, models: {}, pending: { total: 0, models: {} } };
262
+ for (const t of rec.turns ?? []) {
263
+ const base = {
264
+ session: rec.id,
265
+ type: rec.type,
266
+ target: rec.target,
267
+ n: t.n,
268
+ at: t.started_at,
269
+ provider: t.provider ?? "claude",
270
+ account: t.account ?? null,
271
+ origin: t.origin,
272
+ };
273
+ const file = join(sessionsDir, id, t.file);
274
+ if (base.provider !== "claude" || !existsSync(file)) {
275
+ rows.push({ ...base, total: null, partial: false, models: {}, subagents: 0, groups: [] });
276
+ continue;
277
+ }
278
+ /* a turn out of the window is still settled (the chain needs it), only not listed */
279
+ const s = settle(await turnCost(file), chain);
280
+ if (since && Date.parse(t.started_at) < since) continue;
281
+ rows.push({ ...base, ...s, subagents: s.groups.filter(g => g.fork).length });
282
+ }
283
+ }
284
+ return rows.sort((a, b) => a.at.localeCompare(b.at));
285
+ }
286
+
287
+ const add = (o, k, v) => {
288
+ o[k] = round((o[k] ?? 0) + v);
289
+ };
290
+
291
+ /* turns → the numbers the CLI and the studio show */
292
+ export function summarize(rows) {
293
+ const out = {
294
+ total: 0,
295
+ turns: rows.length,
296
+ sessions: new Set(rows.map(r => r.session)).size,
297
+ partial: 0,
298
+ unmeasured: 0,
299
+ by_kind: {},
300
+ by_stage: {},
301
+ by_model: {},
302
+ by_day: {},
303
+ by_video: {},
304
+ top_forks: [],
305
+ };
306
+ const forks = [];
307
+ for (const r of rows) {
308
+ if (r.total == null) {
309
+ out.unmeasured += 1;
310
+ continue;
311
+ }
312
+ if (r.partial) out.partial += 1;
313
+ out.total += r.total;
314
+ add(out.by_kind, r.type, r.total);
315
+ add(out.by_day, r.at.slice(0, 10), r.total);
316
+ for (const [m, c] of Object.entries(r.models)) add(out.by_model, m, c);
317
+ const v = out.by_video[r.target] ?? {
318
+ video: r.target,
319
+ type: r.type,
320
+ total: 0,
321
+ turns: 0,
322
+ first: r.at,
323
+ last: r.at,
324
+ stages: {},
325
+ models: {},
326
+ };
327
+ out.by_video[r.target] = v;
328
+ v.total += r.total;
329
+ v.turns += 1;
330
+ v.last = r.at;
331
+ for (const [m, c] of Object.entries(r.models)) add(v.models, m, c);
332
+ /* the groups are the turn's estimate calibrated per model, so they add up to its total */
333
+ for (const g of r.groups) {
334
+ add(out.by_stage, g.stage, g.cost);
335
+ add(v.stages, g.stage, g.cost);
336
+ if (g.fork)
337
+ forks.push({
338
+ video: r.target,
339
+ session: r.session,
340
+ turn: r.n,
341
+ stage: g.stage,
342
+ label: g.label,
343
+ cost: g.cost,
344
+ messages: g.messages,
345
+ });
346
+ }
347
+ }
348
+ out.total = round(out.total);
349
+ out.by_video = Object.values(out.by_video)
350
+ .map(v => ({ ...v, total: round(v.total) }))
351
+ .sort((a, b) => b.total - a.total);
352
+ out.top_forks = forks.sort((a, b) => b.cost - a.cost).slice(0, 15);
353
+ out.by_day = Object.entries(out.by_day)
354
+ .sort(([a], [b]) => a.localeCompare(b))
355
+ .map(([day, cost]) => ({ day, cost }));
356
+ return out;
357
+ }
@@ -241,26 +241,41 @@ export function checkDeps(codeRoot) {
241
241
  };
242
242
  }
243
243
 
244
+ /** the setup steps that are one of these programs (tools/lib/setup-progress.mjs names them for the user) */
245
+ export const DEP_STEPS = /** @type {const} */ (["video", "render", "voice", "style"]);
246
+
247
+ /** Fetches one program, by the id of the setup step it belongs to; throws when it can't (a retry from the page).
248
+ * @param {string} id @param {string} codeRoot */
249
+ export async function ensureDep(id, codeRoot) {
250
+ if (id === "video") return ensureFfmpeg();
251
+ if (id === "render") return ensureChrome();
252
+ if (id === "voice") return ensurePython(codeRoot);
253
+ if (id === "style") return ensureYtdlp();
254
+ throw new Error(`etapa desconhecida: ${id}`);
255
+ }
256
+
244
257
  /**
245
- * Fetches whatever doesn't answer, one piece at a time, and says how it went.
246
- * @param {string} codeRoot @param {{ log?: (line: string) => void }} [o]
258
+ * Fetches whatever doesn't answer, one piece at a time, and says how it went. `onStep` hears each piece by the
259
+ * id of the setup step it belongs to (tools/lib/setup-progress.mjs): running, then done or error.
260
+ * @param {string} codeRoot
261
+ * @param {{ log?: (line: string) => void, onStep?: (id: string, state: "running" | "done" | "error", error?: string) => void }} [o]
247
262
  * @returns {Promise<{ ok: boolean, missing: string[], errors: string[] }>}
248
263
  */
249
- export async function ensureDeps(codeRoot, { log = () => {} } = {}) {
264
+ export async function ensureDeps(codeRoot, { log = () => {}, onStep = () => {} } = {}) {
250
265
  /** @type {string[]} */
251
266
  const errors = [];
252
- const steps = /** @type {const} */ ([
253
- ["ffmpeg", () => ensureFfmpeg()],
254
- ["Chrome sem janela", () => ensureChrome()],
255
- ["Python", () => ensurePython(codeRoot)],
256
- ["yt-dlp", () => ensureYtdlp()],
257
- ]);
258
- for (const [name, run] of steps) {
267
+ const names = { video: "ffmpeg", render: "Chrome sem janela", voice: "Python", style: "yt-dlp" };
268
+ for (const id of DEP_STEPS) {
269
+ const name = names[id];
259
270
  try {
260
271
  log(`preparando ${name}…`);
261
- await run();
272
+ onStep(id, "running");
273
+ await ensureDep(id, codeRoot);
274
+ onStep(id, "done");
262
275
  } catch (e) {
263
- errors.push(`${name}: ${/** @type {Error} */ (e).message}`);
276
+ const message = /** @type {Error} */ (e).message;
277
+ errors.push(`${name}: ${message}`);
278
+ onStep(id, "error", message);
264
279
  }
265
280
  }
266
281
  const c = checkDeps(codeRoot);
@@ -20,6 +20,7 @@ import { mkdirSync, rmSync, statSync } from "node:fs";
20
20
  import { createServer } from "node:http";
21
21
  import { homedir } from "node:os";
22
22
  import { join } from "node:path";
23
+ import { confirmation, document_ } from "./pages-style.mjs";
23
24
  import { openUrl } from "./platform.mjs";
24
25
  import { defaultVault } from "./vault.mjs";
25
26
 
@@ -155,25 +156,38 @@ export async function login(studioUrl, o) {
155
156
  res.writeHead(404).end();
156
157
  return;
157
158
  }
158
- const page = (/** @type {string} */ msg) =>
159
- `<!doctype html><meta charset="utf-8"><title>OmniVideo</title><body style="font:16px system-ui;padding:48px;max-width:32em">${msg}</body>`;
159
+ const html = (/** @type {Parameters<typeof confirmation>[0]} */ c) => document_(c.title, confirmation(c));
160
160
  if (u.searchParams.get("state") !== state) {
161
- res
162
- .writeHead(400, { "content-type": "text/html; charset=utf-8" })
163
- .end(page("Esse retorno não é deste login. Rode o comando de novo."));
161
+ res.writeHead(400, { "content-type": "text/html; charset=utf-8" }).end(
162
+ html({
163
+ kind: "error",
164
+ title: "Esse retorno não é deste login",
165
+ text: "Esta página veio de outra tentativa de login. Nada foi conectado.",
166
+ hint: "Abra uma nova sessão do Claude Code para tentar de novo.",
167
+ }),
168
+ );
164
169
  return;
165
170
  }
166
171
  const code = u.searchParams.get("code");
167
172
  const error = u.searchParams.get("error");
168
- res
169
- .writeHead(code ? 200 : 400, { "content-type": "text/html; charset=utf-8" })
170
- .end(
171
- page(
172
- code
173
- ? "Pronto: este computador entrou no OmniVideo. Pode fechar esta aba."
174
- : "O login foi recusado. Pode fechar esta aba.",
175
- ),
176
- );
173
+ res.writeHead(code ? 200 : 400, { "content-type": "text/html; charset=utf-8" }).end(
174
+ html(
175
+ code
176
+ ? {
177
+ kind: "ok",
178
+ title: "Computador conectado",
179
+ text: "Pode fechar esta aba. Estamos preparando este computador em segundo plano: acompanhe cada etapa no Omni.",
180
+ action: { href: studioUrl, label: "Abrir o Omni" },
181
+ hint: "Este login vale só para este computador. Você pode desconectá-lo em Configurações → Agente de IA.",
182
+ }
183
+ : {
184
+ kind: "error",
185
+ title: "Login recusado",
186
+ text: "Este computador não foi conectado ao Omni.",
187
+ hint: "Para tentar de novo, abra uma nova sessão do Claude Code.",
188
+ },
189
+ ),
190
+ );
177
191
  settle(code ? { code } : { error: error ?? "recusado" });
178
192
  });
179
193
  await new Promise((resolve, reject) => {
@@ -0,0 +1,67 @@
1
+ /* The look of the few pages that are not the studio's web app: the hosted sign-in and the computer's approval
2
+ (cloud/studio/src/pages.mjs, account-pages.mjs) and the page the CLI's loopback shows when the login is done
3
+ (tools/lib/oauth-client.mjs). They come before any session or any app, so they can't reuse the bundle; this
4
+ file carries the same tokens (studio/web/styles/tokens.css: the ElevenLabs layer, Schibsted Grotesk, 12 px
5
+ controls, 7.5 % borders, light and dark) so they read as the same product. Pure strings: no Worker or Node API,
6
+ so both sides import it. Text in Portuguese: it reaches the user as it is. */
7
+
8
+ export const esc = (/** @type {unknown} */ s) => String(s ?? "").replace(/[&<>"']/g, c => `&#${c.charCodeAt(0)};`);
9
+
10
+ /* the brand ring, black on transparent (studio/web/assets/logos/omni-black.png); the dark theme inverts it */
11
+ const RING =
12
+ "iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAARGVYSWZNTQAqAAAACAABh2kABAAAAAEAAAAaAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAADAoAMABAAAAAEAAADAAAAAAE07OcoAAAHLaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIj4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT4xPC9leGlmOkNvbG9yU3BhY2U+CiAgICAgICAgIDxleGlmOlBpeGVsWERp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ubt+K6el6HPO4BWvRIlCzS2wJbUPBScBq4DrpPN2+El39VHo712xD4bbAMS9cQCzCAWgrSt4hHgUUAfldJvkV2SMzYiGUiVeZZwvzzh8jMb2tHk3MCJvuvz2RHSfnyzTI+OxU7rkWqNVFF7dgH7Aa2maCnxTiTaN2+4zCn7EpXryXnO0slElhMEkiO4pCmY3tbK6U8fQR+1SnvxMUJfqdiJfdWzqV7aa6S98fcZYTeOO4KtQdnHpEiOIu2718P4JeCH4FygEV5fcLsKJBqIBRY9AMq6YXMSNQ/X8qqOCoatgIJFb6JXA/1STlMYvY3V84W+r6nPEsrpLwc/BxrtlZ4oWSBZIFkgWSBZIFkgWSBZIFlgSBb4f5ZqkORg1V9cAAAAAElFTkSuQmCC";
13
+
14
+ export const brandMark = (/** @type {number} */ size = 28) =>
15
+ `<img class="ring" src="data:image/png;base64,${RING}" width="${size}" height="${size}" alt="">`;
16
+
17
+ export const brand = () => `<span class="brand">${brandMark(28)}<span>Omni</span></span>`;
18
+
19
+ /** Google's mark, in its own colors (the outlined "Entrar com Google" button) */
20
+ export const GOOGLE_LOGO =
21
+ '<svg class="g" viewBox="0 0 48 48" width="18" height="18" aria-hidden="true"><path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/><path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/><path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/><path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/></svg>';
22
+
23
+ /** the round badge on the confirmation pages: a check in emerald, a cross in the error color, or a mark in amber
24
+ * @param {"ok" | "error" | "warning"} kind */
25
+ export const badge = kind =>
26
+ kind === "warning"
27
+ ? '<span class="badge warning" aria-hidden="true"><svg viewBox="0 0 24 24" width="30" height="30" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M12 7v6M12 17h.01"/></svg></span>'
28
+ : kind === "ok"
29
+ ? '<span class="badge ok" aria-hidden="true"><svg viewBox="0 0 24 24" width="30" height="30" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span>'
30
+ : '<span class="badge error" aria-hidden="true"><svg viewBox="0 0 24 24" width="30" height="30" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M6.5 6.5l11 11M17.5 6.5l-11 11"/></svg></span>';
31
+
32
+ export const STYLE = `:root{color-scheme:light dark;--bg:#fff;--surface-2:#f4f4f4;--text:#0f0f10;--text-2:#00000087;--text-3:#00000070;--border:#00000013;--border-strong:#0000001a;--muted:#0000000b;--action:#0f0f10;--action-text:#fff;--action-hover:#2e2e2e;--emerald:#059669;--ok-bg:rgb(0 204 68/.1);--error:#ef4444;--error-bg:rgb(239 68 68/.1);--warning:#c2610c;--warning-bg:rgb(245 158 11/.12)}
33
+ @media (prefers-color-scheme:dark){:root{--bg:#0f0f10;--surface-2:#18181b;--text:#fff;--text-2:#ffffffa4;--text-3:#ffffff87;--border:#ffffff13;--border-strong:#ffffff1a;--muted:#ffffff0b;--action:#fff;--action-text:#0f0f10;--action-hover:#e5e5e5;--emerald:#34d399;--ok-bg:rgb(0 204 68/.16);--error:#ff6b6b;--error-bg:rgb(255 107 107/.14);--warning:#fda05e;--warning-bg:rgb(252 122 55/.15)}.ring{filter:invert(1)}}
34
+ *{box-sizing:border-box}html,body{height:100%}body{margin:0;background:var(--bg);color:var(--text);font:400 14px/20px "Schibsted Grotesk","Helvetica Neue",Arial,sans-serif;-webkit-font-smoothing:antialiased}
35
+ a{color:inherit}code{font:400 13px/20px "Geist Mono",ui-monospace,Menlo,monospace;padding:1px 6px;border:1px solid var(--border-strong);border-radius:6px;overflow-wrap:anywhere}
36
+ .brand{display:inline-flex;align-items:center;gap:8px;font-weight:700;font-size:18px;letter-spacing:-.2px}.ring{display:block}
37
+ h1{margin:0;font:400 28px/36px "Schibsted Grotesk","Helvetica Neue",Arial,sans-serif;letter-spacing:-.21px}p{margin:0;color:var(--text-2)}
38
+ .button{display:inline-flex;align-items:center;justify-content:center;gap:10px;width:100%;height:40px;padding:0 16px;border-radius:12px;border:1px solid transparent;background:var(--action);color:var(--action-text);font-family:inherit;font-weight:500;font-size:14px;line-height:20px;cursor:pointer;text-decoration:none}
39
+ .button:hover{background:var(--action-hover)}.button.outline{background:transparent;color:var(--text);border-color:var(--border-strong)}.button.outline:hover{background:var(--muted)}
40
+ .button:focus-visible{outline:2px solid var(--text);outline-offset:2px}.button .g{flex:none}.row{display:grid;gap:8px}
41
+ .notice{padding:10px 12px;border-radius:12px;font-size:13px;line-height:18px}.notice.error{background:var(--error-bg);color:var(--error)}.notice.warning{background:var(--warning-bg);color:var(--warning)}
42
+ .badge{display:grid;place-items:center;width:72px;height:72px;border-radius:50%}.badge.ok{background:var(--ok-bg);color:var(--emerald)}.badge.error{background:var(--error-bg);color:var(--error)}.badge.warning{background:var(--warning-bg);color:var(--warning)}
43
+ /* the confirmation card: one centered column */
44
+ .center{min-height:100%;display:grid;place-items:center;padding:24px 16px}.card{width:100%;max-width:420px;display:grid;justify-items:center;gap:12px;text-align:center}
45
+ .card .brand{margin-bottom:12px}.card .two{grid-template-columns:1fr 1fr}.code-big{font:600 24px/32px "Geist Mono",ui-monospace,Menlo,monospace;letter-spacing:2px;padding:10px 18px;border:1px solid var(--border-strong);border-radius:12px;background:var(--surface-2)}.card p{max-width:46ch}.card .row{width:100%;margin-top:12px}.card .hint{font-size:13px;color:var(--text-3)}
46
+ /* the sign-in: two columns, the form on the right */
47
+ .split{min-height:100%;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
48
+ .split .intro{display:flex;flex-direction:column;justify-content:space-between;gap:32px;padding:40px 48px;background:var(--surface-2);border-right:1px solid var(--border)}
49
+ .split .intro h2{margin:0 0 12px;font:400 28px/36px "Schibsted Grotesk","Helvetica Neue",Arial,sans-serif;letter-spacing:-.21px;max-width:18ch}.split .intro ul{list-style:none;margin:0;padding:0;display:grid;gap:14px;max-width:44ch}
50
+ .split .intro li{display:grid;grid-template-columns:20px 1fr;gap:10px;color:var(--text-2)}.split .intro li svg{margin-top:2px;color:var(--emerald)}.split .intro li b{display:block;color:var(--text);font-weight:500}
51
+ .split .intro small{color:var(--text-3);font-size:12px}
52
+ .split .side{display:grid;place-items:center;padding:40px 24px}.split form,.split .box{width:100%;max-width:360px;display:grid;gap:16px}.split .box .head{display:grid;gap:6px}
53
+ .split .box .brand-top{display:none}
54
+ @media (max-width:860px){.split{grid-template-columns:1fr}.split .intro{display:none}.split .box .brand-top{display:inline-flex;margin-bottom:8px}}
55
+ @media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}`;
56
+
57
+ /** The whole document.
58
+ * @param {string} title @param {string} body @param {{ head?: string }} [o] */
59
+ export function document_(title, body, { head = "" } = {}) {
60
+ return `<!doctype html><html lang="pt-BR"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(title)} · Omni</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Schibsted+Grotesk:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap">${head}<style>${STYLE}</style></head><body>${body}</body></html>`;
61
+ }
62
+
63
+ /** a centered confirmation: the badge, a title and a disclaimer, with an optional button
64
+ * @param {{ kind: "ok" | "error" | "warning", title: string, text: string, hint?: string, action?: { href: string, label: string }, extra?: string }} o
65
+ * `text`, `hint` and `extra` are HTML: whoever calls escapes what came from outside */
66
+ export const confirmation = ({ kind, title, text, hint, action, extra = "" }) =>
67
+ `<main class="center"><div class="card">${brand()}${badge(kind)}<h1>${esc(title)}</h1><p>${text}</p>${extra}${action ? `<div class="row"><a class="button" href="${esc(action.href)}">${esc(action.label)}</a></div>` : ""}${hint ? `<p class="hint">${hint}</p>` : ""}</div></main>`;
@@ -77,7 +77,7 @@ export async function finishPairing(url, code, name, d = {}) {
77
77
  if (!session) throw new Error("o código do pareamento expirou");
78
78
  const reg = await call(url, "/runner/register", { body: { name }, token: session }, f);
79
79
  if (!reg.ok || !reg.body?.key)
80
- throw new Error(`o studio não entregou a chave do Mac (${reg.status}: ${reg.body?.error ?? "?"})`);
80
+ throw new Error(`o studio não entregou a chave da máquina (${reg.status}: ${reg.body?.error ?? "?"})`);
81
81
  return { key: reg.body.key, name: reg.body.name };
82
82
  }
83
83
 
@@ -121,7 +121,7 @@ export function dueAction(sch, { now, alive, settings }) {
121
121
  if (!sch.attempts && delay > settings.max_delay_h)
122
122
  return {
123
123
  action: "missed",
124
- message: `o Mac estava dormindo ou desligado na hora: ${delay.toFixed(1)} h de atraso passa do limite de ${settings.max_delay_h} h (publish.schedule.max_delay_h)`,
124
+ message: `a máquina estava dormindo ou desligada na hora: ${delay.toFixed(1)} h de atraso passa do limite de ${settings.max_delay_h} h (publish.schedule.max_delay_h)`,
125
125
  };
126
126
  return { action: "run" };
127
127
  }