@runeditrun/rer 0.2.61 → 0.2.63
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.
- package/README.md +48 -27
- package/cli/business/api.mjs +40 -6
- package/cli/business/command.mjs +8 -6
- package/cli/business/connect.mjs +80 -44
- package/cli/business/device.mjs +20 -0
- package/cli/business/errors.mjs +26 -0
- package/cli/business/keychain.mjs +48 -17
- package/cli/business/local-commands.mjs +5 -7
- package/cli/business/opt-ins.mjs +13 -4
- package/cli/business/permissions.mjs +3 -1
- package/cli/business/policy.mjs +1 -1
- package/cli/business/scan-command.mjs +6 -3
- package/cli/business/service.mjs +6 -3
- package/cli/business/state.mjs +67 -10
- package/global/CHANGELOG.md +10 -0
- package/global/README.md +48 -27
- package/modules/demo-host/README.md +7 -2
- package/modules/demo-host/native/prepare.mjs +1 -1
- package/modules/demo-host/page-style.mjs +2 -2
- package/modules/demo-host/pages.mjs +5 -5
- package/modules/demo-host/start-script.mjs +1 -1
- package/modules/demo-host/theme-css.mjs +49 -0
- package/modules/demo-host/theme-script.mjs +24 -7
- package/modules/demo-host/theme.mjs +8 -8
- package/onboarding/schema/SETUP.schema.json +8 -0
- package/onboarding/schema/setup-validation.mjs +15 -1
- package/onboarding/setup-manifest.mjs +4 -3
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { mkdir, readFile, writeFile, unlink, rename, lstat, open, rmdir } from '
|
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join, dirname, isAbsolute } from 'node:path';
|
|
4
4
|
import { createHash, randomUUID } from 'node:crypto';
|
|
5
|
+
import { stateDirectory } from './state.mjs';
|
|
5
6
|
|
|
6
7
|
export const BUSINESS_DENY_RULES = Object.freeze([
|
|
7
8
|
'Read(**/secrets/**)', 'Read(**/.ssh/**)', 'Read(**/.aws/**)', 'Read(**/.gnupg/**)',
|
|
@@ -16,7 +17,8 @@ export const BUSINESS_DENY_RULES = Object.freeze([
|
|
|
16
17
|
|
|
17
18
|
const hash = text => text === null ? null : createHash('sha256').update(text).digest('hex');
|
|
18
19
|
const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
19
|
-
function paths(
|
|
20
|
+
function paths(input = {}) {
|
|
21
|
+
const home = input.home ?? homedir(), stateDir = input.stateDir ?? (input.home === undefined ? stateDirectory() : join(home, '.rer', 'business'));
|
|
20
22
|
if (!isAbsolute(home) || !isAbsolute(stateDir)) throw new Error('Business permission paths must be absolute.');
|
|
21
23
|
return { settings: join(home, '.claude', 'settings.json'), receipt: join(stateDir, 'permissions.json'), stateDir };
|
|
22
24
|
}
|
package/cli/business/policy.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename } from 'node:path';
|
|
2
2
|
|
|
3
|
-
const outputs = new Set(['node_modules', 'vendor', '.git', 'dist', 'build', 'target', 'coverage', '.next', '.nuxt', '.output', '.cache', '.venv', 'venv', '__pycache__', '.terraform', '.pulumi', '.wrangler', '.rer', '.seed', 'playwright-report', 'test-results']);
|
|
3
|
+
const outputs = new Set(['node_modules', 'vendor', '.git', 'dist', 'build', 'target', 'coverage', '.next', '.nuxt', '.output', '.cache', '.venv', 'venv', '__pycache__', '.terraform', '.pulumi', '.wrangler', '.rer', '.rer-business', '.seed', 'playwright-report', 'test-results']);
|
|
4
4
|
const tools = new Set(['.claude', '.codex', '.cursor', '.worktrees', '.idea', '.vscode', '.vscode-insiders', '.windsurf', '.continue', '.zed', '.aider', '.gemini', '.opencode']);
|
|
5
5
|
|
|
6
6
|
export const toolDirectory = path => path.split('/').some(part => tools.has(part.toLowerCase()));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { scan } from './scan.mjs';
|
|
2
|
+
import { localCause } from './errors.mjs';
|
|
2
3
|
|
|
3
4
|
const usage = 'Usage: rer business scan [DIR...] [--json]\nNames-only local discovery; returns rer-business-signals/1 JSON. No network calls.\n';
|
|
4
5
|
|
|
@@ -19,9 +20,11 @@ export async function scanCommand(argv) {
|
|
|
19
20
|
const result = await scan(directories.length ? directories : [process.cwd()]);
|
|
20
21
|
process.stdout.write(JSON.stringify(result) + '\n');
|
|
21
22
|
return 0;
|
|
22
|
-
} catch {
|
|
23
|
-
// Node/format errors can contain input paths, keys or source excerpts
|
|
24
|
-
|
|
23
|
+
} catch (error) {
|
|
24
|
+
// Node/format errors can contain input paths, keys or source excerpts, so
|
|
25
|
+
// only the system cause is named.
|
|
26
|
+
const cause = localCause(error);
|
|
27
|
+
process.stderr.write(`Business scan could not read a local input${cause ? ` (${cause})` : ', or one was not in a format it reads'}. No scan document was emitted.\n`);
|
|
25
28
|
return 1;
|
|
26
29
|
}
|
|
27
30
|
}
|
package/cli/business/service.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { dirname, join, isAbsolute } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { createHash, randomUUID } from 'node:crypto';
|
|
7
|
+
import { stateDirectory } from './state.mjs';
|
|
7
8
|
|
|
8
9
|
const label = 'com.runeditrun.business', unit = 'rer-business.service';
|
|
9
10
|
const digest = text => createHash('sha256').update(text).digest('hex');
|
|
@@ -16,7 +17,7 @@ function execute(binary, args) {
|
|
|
16
17
|
function options(input = {}) {
|
|
17
18
|
const home = input.home ?? homedir(), platform = input.platform ?? process.platform;
|
|
18
19
|
if (!isAbsolute(home) || !['darwin', 'linux'].includes(platform)) throw new Error('Business background services require macOS or Linux and an absolute home directory.');
|
|
19
|
-
const stateDir = input.stateDir ?? join(home, '.rer', 'business');
|
|
20
|
+
const stateDir = input.stateDir ?? (input.home === undefined ? stateDirectory() : join(home, '.rer', 'business'));
|
|
20
21
|
if (!isAbsolute(stateDir)) throw new Error('Business service state directory must be absolute.');
|
|
21
22
|
return { ...input, home, platform, stateDir, run: input.run ?? execute };
|
|
22
23
|
}
|
|
@@ -64,9 +65,11 @@ export async function installService(input = {}) {
|
|
|
64
65
|
if (!isAbsolute(node) || !isAbsolute(entrypoint) || !(await stat(node)).isFile() || !(await stat(entrypoint)).isFile()) throw new Error('Business requires an absolute Node executable and rer entrypoint.');
|
|
65
66
|
const log = join(o.stateDir, 'service.log'), errorLog = join(o.stateDir, 'service-error.log');
|
|
66
67
|
const environmentPath = `${dirname(node)}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`;
|
|
68
|
+
// A state folder chosen with RER_BUSINESS_STATE_DIR goes with the service.
|
|
69
|
+
const environment = [['HOME', o.home], ['PATH', environmentPath], ...(o.stateDir !== join(o.home, '.rer', 'business') ? [['RER_BUSINESS_STATE_DIR', o.stateDir]] : [])];
|
|
67
70
|
const text = o.platform === 'darwin'
|
|
68
|
-
? `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0"><dict>\n<key>Label</key><string>${label}</string>\n<key>ProgramArguments</key><array>${[node, entrypoint, 'business', 'run'].map(arg => `<string>${xml(arg)}</string>`).join('')}</array>\n<key>EnvironmentVariables</key><dict
|
|
69
|
-
: `[Unit]\nDescription=Run Edit Run Business executor\nAfter=network-online.target\n\n[Service]\nType=simple\nExecStart=${[node, entrypoint, 'business', 'run'].map(value => unitValue(value).replaceAll('$', () => '$$')).join(' ')}\nWorkingDirectory=${unitValue(o.home)}\nEnvironment=${
|
|
71
|
+
? `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0"><dict>\n<key>Label</key><string>${label}</string>\n<key>ProgramArguments</key><array>${[node, entrypoint, 'business', 'run'].map(arg => `<string>${xml(arg)}</string>`).join('')}</array>\n<key>EnvironmentVariables</key><dict>${environment.map(([key, value]) => `<key>${key}</key><string>${xml(value)}</string>`).join('')}</dict>\n<key>WorkingDirectory</key><string>${xml(o.home)}</string>\n<key>RunAtLoad</key><true/><key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>\n<key>ThrottleInterval</key><integer>30</integer><key>Umask</key><integer>63</integer>\n<key>StandardOutPath</key><string>${xml(log)}</string><key>StandardErrorPath</key><string>${xml(errorLog)}</string>\n</dict></plist>\n`
|
|
72
|
+
: `[Unit]\nDescription=Run Edit Run Business executor\nAfter=network-online.target\n\n[Service]\nType=simple\nExecStart=${[node, entrypoint, 'business', 'run'].map(value => unitValue(value).replaceAll('$', () => '$$')).join(' ')}\nWorkingDirectory=${unitValue(o.home)}\nEnvironment=${environment.map(([key, value]) => unitValue(`${key}=${value}`)).join(' ')}\nRestart=on-failure\nRestartSec=30\nUMask=0077\n\n[Install]\nWantedBy=default.target\n`;
|
|
70
73
|
const existing = await readOptional(path), oldReceipt = await readOptional(receiptPath);
|
|
71
74
|
if (existing !== null && (!oldReceipt || JSON.parse(oldReceipt).hash !== digest(existing))) throw new Error('A background service already exists at the Business service path; it was not overwritten.');
|
|
72
75
|
if (oldReceipt && existing !== null && existing !== text) throw new Error('Remove the existing Business service before changing its installation paths.');
|
package/cli/business/state.mjs
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import { mkdir, readFile, writeFile, rename, chmod, open, unlink } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
1
|
+
import { mkdir, readFile, readdir, writeFile, rename, chmod, open, unlink, rm, rmdir, lstat } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { createHash, randomUUID } from 'node:crypto';
|
|
5
|
+
import { localCause } from './errors.mjs';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
// RER_BUSINESS_STATE_DIR names the folder itself, for agent sandboxes that may write only
|
|
8
|
+
// inside their working folder. Without it the state lives in ~/.rer/business.
|
|
9
|
+
// RER_STATE_DIR belongs to rer demo and is never read here.
|
|
10
|
+
export const chosenStateDirectory = () => Boolean(process.env.RER_BUSINESS_STATE_DIR);
|
|
11
|
+
export function stateDirectory() {
|
|
12
|
+
const chosen = process.env.RER_BUSINESS_STATE_DIR;
|
|
13
|
+
if (!chosen) return join(homedir(), '.rer', 'business');
|
|
14
|
+
if (chosen.includes('\0')) throw Error('RER_BUSINESS_STATE_DIR must name a folder.');
|
|
15
|
+
return resolve(chosen);
|
|
16
|
+
}
|
|
7
17
|
export const credentialHandle = origin => `device:${createHash('sha256').update(origin).digest('hex')}`;
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
async function loadJson(name) {
|
|
20
|
+
const path = join(stateDirectory(), name);
|
|
21
|
+
let text;
|
|
22
|
+
try { text = await readFile(path, 'utf8'); }
|
|
23
|
+
// Under a path that is not a folder (ENOTDIR) nothing can have been saved yet.
|
|
24
|
+
catch (error) { if (['ENOENT', 'ENOTDIR'].includes(error.code)) return null; throw error; }
|
|
25
|
+
try { return JSON.parse(text); }
|
|
26
|
+
catch { throw Error(`Business could not read ${path}: it is not valid JSON. Remove it, or run rer business disconnect, then connect again.`); }
|
|
12
27
|
}
|
|
13
28
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
catch (error) { if (error.code === 'ENOENT') return null; throw error; }
|
|
17
|
-
}
|
|
29
|
+
export const loadState = () => loadJson('state.json');
|
|
30
|
+
export const loadPending = () => loadJson('pairing.json');
|
|
18
31
|
export const savePending = pending => saveJson('pairing.json', pending);
|
|
19
32
|
export async function clearPending() {
|
|
20
33
|
await unlink(join(stateDirectory(), 'pairing.json')).catch(error => { if (error.code !== 'ENOENT') throw error; });
|
|
@@ -39,6 +52,50 @@ async function saveJson(name, value) {
|
|
|
39
52
|
} finally { await unlink(temporary).catch(error => { if (error.code !== 'ENOENT') throw error; }); }
|
|
40
53
|
}
|
|
41
54
|
|
|
55
|
+
/** Before a one-use code is spent or an approval collected, prove the state
|
|
56
|
+
* folder takes the same private create, write and replace the pairing needs.
|
|
57
|
+
* Folders made only for the check are removed again, so a refused connect
|
|
58
|
+
* leaves nothing behind.
|
|
59
|
+
*/
|
|
60
|
+
export async function checkStateWritable() {
|
|
61
|
+
const directory = stateDirectory(), probe = join(directory, `${randomUUID()}.tmp`), created = [];
|
|
62
|
+
for (let path = directory; path !== dirname(path); path = dirname(path)) {
|
|
63
|
+
try { await lstat(path); break; } catch (error) { if (error.code !== 'ENOENT') break; created.push(path); }
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
67
|
+
await chmod(directory, 0o700);
|
|
68
|
+
await writeFile(probe, '{}\n', { mode: 0o600, flag: 'wx' });
|
|
69
|
+
await rename(probe, probe + '.check');
|
|
70
|
+
await unlink(probe + '.check');
|
|
71
|
+
} catch (error) {
|
|
72
|
+
await unlink(probe).catch(() => {});
|
|
73
|
+
const fix = chosenStateDirectory()
|
|
74
|
+
? 'Allow writes to that folder in this session, or set RER_BUSINESS_STATE_DIR to a folder this session can write'
|
|
75
|
+
: 'Allow writes to that folder, or set RER_BUSINESS_STATE_DIR to a folder this session can write (in Codex, one inside the working folder, such as RER_BUSINESS_STATE_DIR="$PWD/.rer-business")';
|
|
76
|
+
throw Error(`Business cannot save its state in ${directory}: ${localCause(error) ?? error.message}. Nothing was sent, so the pairing code still works. ${fix}, then run connect again.`);
|
|
77
|
+
} finally {
|
|
78
|
+
for (const path of created) await rmdir(path).catch(() => {});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Files this CLI writes in its state folder. A folder named by RER_BUSINESS_STATE_DIR
|
|
83
|
+
// may hold other things, so only these are removed from it.
|
|
84
|
+
const owned = /^(?:(?:state|pairing|progress|permissions|service)\.json|run\.lock|disconnect|service(?:-error)?\.log|discovery-[A-Za-z0-9_.:-]+\.(?:json|tmp)|.*[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.tmp(?:\.check)?)$/;
|
|
85
|
+
export async function removeStateDirectory() {
|
|
86
|
+
const directory = stateDirectory();
|
|
87
|
+
if (!chosenStateDirectory()) {
|
|
88
|
+
await rm(directory, { recursive: true, force: true });
|
|
89
|
+
// Remove only an empty parent; other rer commands may own it.
|
|
90
|
+
await rmdir(dirname(directory)).catch(error => { if (!['ENOENT', 'ENOTEMPTY', 'EEXIST'].includes(error.code)) throw error; });
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let entries;
|
|
94
|
+
try { entries = await readdir(directory); } catch (error) { if (error.code === 'ENOENT') return; throw error; }
|
|
95
|
+
for (const name of entries) if (owned.test(name)) await rm(join(directory, name), { force: true });
|
|
96
|
+
await rmdir(directory).catch(error => { if (!['ENOENT', 'ENOTEMPTY', 'EEXIST'].includes(error.code)) throw error; });
|
|
97
|
+
}
|
|
98
|
+
|
|
42
99
|
export async function lockSupervisor() {
|
|
43
100
|
const directory = stateDirectory();
|
|
44
101
|
await mkdir(directory, { recursive: true, mode: 0o700 });
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.63
|
|
4
|
+
|
|
5
|
+
- **Business connect waits for approval and keeps durable state (#277).** Pairing resumes after interruption, sends a readable device name and working folder, and accepts an explicit `RER_BUSINESS_STATE_DIR` when the usual state folder is unwritable. A refused macOS Keychain write stops before redeeming the code and explains how to approve the command outside the sandbox. Browser choices remain authoritative.
|
|
6
|
+
- **Setup fields and groups can declare their audience (#297).** Public fields accept `audience: "owner" | "developer"`, inherit group audience, and default to owner. Invalid audiences and an owner field inside a developer group are refused. Local installer and terminal setup keep their existing active-field visibility; managed consumers can use the metadata.
|
|
7
|
+
|
|
8
|
+
## 0.2.62
|
|
9
|
+
|
|
10
|
+
- **Themed demo gates keep waiting visibly disabled (#292).** Waiting, working and other non-actionable buttons use muted outlines from the seed’s theme tokens. Turnstile explicitly follows the card’s painted light/dark scheme, including declared dark media tokens.
|
|
11
|
+
- **First paint returns to the 0.2.59 baseline.** Critical theme/import/font CSS is inline under the existing CSP, font faces use swap or optional, and prefetch lists are unchanged. The reviewed browser-cold local-host Plinth medians for 0.2.59 / 0.2.60 / this fix were 20 / 28 / 20 ms; Default was 20 / 24 / 20 ms. Seeds pick up the fix with rer 0.2.62 and a normal demo refresh.
|
|
12
|
+
|
|
3
13
|
## 0.2.61
|
|
4
14
|
|
|
5
15
|
- **One import path for every seed (#272).** The signed-in move-in screen, rer and Business can share upload → plan → reviewed fingerprint → apply → reconcile → undo, retaining native edit protection, history and erasure across catch-up chains. This integration supersedes #246, #262, #252, #250, #259 and #267.
|
package/global/README.md
CHANGED
|
@@ -371,36 +371,57 @@ formats and syntax may yield no signals.
|
|
|
371
371
|
## Business device commands
|
|
372
372
|
|
|
373
373
|
`rer business connect --code ABCD-1234 [--origin https://app.runeditrun.com]`
|
|
374
|
-
redeems a browser-created code
|
|
375
|
-
approval in the browser that created it
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
374
|
+
redeems a browser-created code, prints a six-digit confirmation number for
|
|
375
|
+
approval in the browser that created it, and waits in the foreground until the
|
|
376
|
+
owner approves or refuses there or the code expires (ten minutes). It exits 0
|
|
377
|
+
only once the computer is active: the credential is stored and the server has
|
|
378
|
+
seen the computer. A refusal or expiry exits 1 with the server's reason.
|
|
379
|
+
Interrupting it (Ctrl-C, or an agent's tool timeout) keeps the redeemed pairing:
|
|
380
|
+
run `rer business connect` again to resume the same pairing and number; a new
|
|
381
|
+
server pairing is never started until the old one is refused, expired or
|
|
382
|
+
disconnected. The waiting line names the command that works from the agent's
|
|
383
|
+
own shell: `rer` when it is on PATH, the launcher install.sh wrote, or
|
|
384
|
+
`npx -y @runeditrun/rer` after an npx run. Pending tokens are kept until the
|
|
385
|
+
code's expiry plus the ten minutes the server allows after an approval, so an
|
|
386
|
+
approval near the code's end can still be collected.
|
|
387
|
+
|
|
388
|
+
State lives in `$RER_BUSINESS_STATE_DIR` when it is set, and in `~/.rer/business`
|
|
389
|
+
otherwise. `RER_STATE_DIR` is `rer demo`'s variable and Business never reads it.
|
|
390
|
+
Connect also sends the computer's plain name (its host name's first word group,
|
|
391
|
+
without the login name, at most 64 characters) and the folder it runs in, so the
|
|
392
|
+
browser can show which computer this is and prefill the scan folder.
|
|
393
|
+
Before redeeming the code (or collecting an approval), connect proves
|
|
394
|
+
it can write that folder and that OS credential storage accepts a write; if
|
|
395
|
+
either fails it stops, names the folder or the cause, and the code still works.
|
|
396
|
+
Device credentials stay in macOS Keychain or Linux Secret Service; there is no
|
|
397
|
+
plaintext credential store. Linux needs `secret-tool` and an unlocked desktop
|
|
398
|
+
Secret Service session. Every failure names its cause: the server's reason, the
|
|
399
|
+
local system cause, or what to change.
|
|
400
|
+
|
|
401
|
+
The owner chooses three things on the computer's row in the browser: "Add rules
|
|
402
|
+
so Claude Code never reads your secret files" (Claude Code user Read deny
|
|
403
|
+
rules), "Keep this computer awake while it works" (export-scoped macOS wake
|
|
404
|
+
prevention) and "Install the background service" (a launchd or systemd user
|
|
405
|
+
service). Connect reads them as `optIns` from device-authenticated
|
|
406
|
+
`GET /api/business/executors/self`, with keys `installPermissions`,
|
|
407
|
+
`awakeConsent` and `installService`; the CLI prints only the sentences. Only
|
|
408
|
+
`true` enables an option. Undecided (`null`) options are listed with a browser
|
|
409
|
+
link; an older server without this route (it answers 403 or 404) leaves all
|
|
410
|
+
options undecided. Run connect again after the owner decides. The first
|
|
411
|
+
device-authenticated request happens after both the credential and local
|
|
412
|
+
pairing state are stored, so a storage failure cannot activate the computer.
|
|
413
|
+
A service installed with `RER_BUSINESS_STATE_DIR` set keeps that folder. Background
|
|
414
|
+
services use absolute Node and CLI paths. No model process is started.
|
|
398
415
|
|
|
399
416
|
An agent can run `npx -y @runeditrun/rer business connect --code ABCD-1234 --origin URL`
|
|
400
417
|
directly, without a global installation. In Codex's workspace-write sandbox,
|
|
401
|
-
allow network access
|
|
402
|
-
|
|
403
|
-
|
|
418
|
+
allow network access, set `RER_BUSINESS_STATE_DIR="$PWD/.rer-business"` so state stays
|
|
419
|
+
inside the working folder, and put npm's cache there too with
|
|
420
|
+
`npm_config_cache="$PWD/.rer/npm"`. macOS refuses Keychain writes from inside
|
|
421
|
+
that sandbox, so connect stops before redeeming and asks for this one command to
|
|
422
|
+
run outside the sandbox (in Codex, approve running that command outside the
|
|
423
|
+
sandbox when it asks); later commands
|
|
424
|
+
only read the credential and run inside the sandbox. Do not install a
|
|
404
425
|
background service or change user settings unless the owner enables those
|
|
405
426
|
options and the sandbox permits their locations.
|
|
406
427
|
|
|
@@ -13,8 +13,13 @@ host. See [adoption and deployment](../../export/DEMO.md#hosting-the-demo).
|
|
|
13
13
|
- `worker.mjs`, `pages.mjs`, `start-script.mjs`: Turnstile start, progress,
|
|
14
14
|
cancellation and visitor routing. Static assets are served at the edge.
|
|
15
15
|
- `theme.mjs`, `page-style.mjs`, `theme-script.mjs`: the start and ended pages
|
|
16
|
-
|
|
17
|
-
colours, type and mark follow its `--rer-*` tokens,
|
|
16
|
+
inline the seed's built `rer-theme.css`, fonts CSS and imports in the same
|
|
17
|
+
cascade as the Lobby. Their colours, type and mark follow its `--rer-*` tokens,
|
|
18
|
+
including media rules. Font faces use swap or optional display, so neither
|
|
19
|
+
CSS fetches nor fonts hold first paint. Disabled buttons use the surface,
|
|
20
|
+
border and muted-text tokens; only actionable buttons use the accent fill.
|
|
21
|
+
`theme-script.mjs` sets the page and Turnstile scheme from the painted card's
|
|
22
|
+
background and text before the widget renders, and updates on preference changes.
|
|
18
23
|
The maintained default seed's theme assets supply missing tokens or an
|
|
19
24
|
absent theme, under `/__demo/theme/`. Styles, fonts and marks stay same-origin;
|
|
20
25
|
a missing mark leaves the product name visible.
|
|
@@ -40,7 +40,7 @@ export async function prepareNative(folder) {
|
|
|
40
40
|
const bundle = { iconHead, compatibilityDate: config.compatibility_date, compatibilityFlags: [...new Set([...(config.compatibility_flags ?? []), 'nodejs_compat'])], modules,
|
|
41
41
|
bindings, migrations: manifest.migrations, vars: config.vars ?? {}, crons: config.triggers?.crons ?? [],
|
|
42
42
|
assetPaths: [...assets.filter(file => !file.path.split('/').some(part => part.startsWith('.'))).map(file => '/' + file.path), ...theme.paths],
|
|
43
|
-
theme: theme.
|
|
43
|
+
theme: theme.css,
|
|
44
44
|
immutable: [...builtChunks(assets, manifest.assetsDir)].sort(),
|
|
45
45
|
warm: (await warmList(assets, root, manifest.operatorPath, manifest.assetsDir)).paths };
|
|
46
46
|
bundle.digest = createHash('sha256').update(JSON.stringify(bundle)).digest('hex');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Gate layout; presentation comes from the same --rer-* tokens as the Lobby.
|
|
2
|
-
export const STYLE =
|
|
2
|
+
export const STYLE = `:root{color-scheme:light}:root[data-demo-scheme=dark]{color-scheme:dark}*{box-sizing:border-box}body{margin:0;background:var(--rer-page);color:var(--rer-text);font-family:var(--rer-font-body);-webkit-font-smoothing:antialiased}
|
|
3
3
|
main{width:666px;margin:clamp(32px,18vh,184px) auto 48px}.card{padding:40px 42px 44px;background:var(--rer-surface);border:1px solid var(--rer-border);border-radius:var(--rer-radius);box-shadow:0 12px 45px color-mix(in srgb,var(--rer-text) 5%,transparent)}
|
|
4
4
|
.brand{display:flex;align-items:center;gap:12px;font-family:var(--rer-font-heading,var(--rer-font-body));font-size:18px;line-height:22px;font-weight:var(--rer-wordmark-weight,600);letter-spacing:var(--rer-wordmark-tracking,normal);color:var(--rer-text);margin:0 0 20px}.brand img{display:block;width:40px;height:40px;object-fit:contain}.brand img[hidden]{display:none}
|
|
5
5
|
h1{font-family:var(--rer-font-heading,var(--rer-font-body));font-size:42px;line-height:50px;letter-spacing:-1.3px;margin:0 0 14px;font-weight:700}.intro{font-size:20px;line-height:28px;color:var(--rer-muted);margin:0}
|
|
6
6
|
ul{padding:0;margin:23px 0 35px;list-style:none;color:var(--rer-muted);font-size:18px;line-height:33px}li{position:relative;padding-left:33px}li:before{content:'';position:absolute;left:7px;top:14px;width:7px;height:7px;background:var(--rer-accent);border-radius:50%}
|
|
7
7
|
.notice{margin:0 0 16px;padding:12px 16px;border-radius:8px;background:var(--rer-page);color:var(--rer-text);border:1px solid var(--rer-border);font-size:16px;line-height:22px}
|
|
8
8
|
.cf-turnstile{min-height:65px}.button{display:flex;align-items:center;justify-content:center;gap:12px;width:100%;margin-top:28px;min-height:58px;border:1px solid var(--rer-accent);border-radius:var(--rer-button-radius,var(--rer-radius));background:var(--rer-accent);color:var(--rer-accent-text);font:inherit;font-size:20px;font-weight:700;line-height:26px;padding:15px;text-align:center;text-decoration:none;cursor:pointer}
|
|
9
|
-
.button:disabled{
|
|
9
|
+
.button:disabled{background:var(--rer-surface);border-color:var(--rer-border);color:var(--rer-muted);font-weight:600;cursor:default}
|
|
10
10
|
.spinner{display:none;flex:none;width:20px;height:20px;border:3px solid color-mix(in srgb,currentColor 35%,transparent);border-top-color:currentColor;border-radius:50%;animation:spin .8s linear infinite}[data-state=working] .spinner,[data-state=signing] .spinner{display:block}@keyframes spin{to{transform:rotate(360deg)}}
|
|
11
11
|
ol.steps{display:none;list-style:none;margin:22px auto 0;padding:0;width:max-content;max-width:100%;font-size:16px;line-height:22px;color:var(--rer-muted)}[data-state=working] .steps,[data-state=signing] .steps,[data-state=slow] .steps{display:grid;gap:10px}[data-state=failed] .note{display:none}
|
|
12
12
|
.steps li{padding-left:30px;margin:0}.steps li:before{left:0;top:2px;width:18px;height:18px;box-sizing:border-box;background:none;border:2px solid var(--rer-muted)}.steps [data-at=done]{color:var(--rer-muted)}.steps [data-at=done]:before{content:'✓';border:0;background:var(--rer-accent);color:var(--rer-accent-text);font-size:12px;line-height:18px;font-weight:700;text-align:center}.steps [data-at=now]{color:var(--rer-text);font-weight:600}.steps [data-at=now]:before{border-color:var(--rer-border);border-top-color:var(--rer-accent);animation:spin .8s linear infinite}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Both are one card in the family's quiet sign-in style.
|
|
4
4
|
import { START_SCRIPT } from './start-script.mjs';
|
|
5
5
|
import { STYLE } from './page-style.mjs';
|
|
6
|
-
import {
|
|
6
|
+
import { THEME_SCRIPT } from './theme-script.mjs';
|
|
7
7
|
|
|
8
8
|
const escape = value => String(value).replace(/[&<>"']/g, character => `&#${character.charCodeAt(0)};`);
|
|
9
9
|
|
|
@@ -15,8 +15,8 @@ const warm = env => (env.DEMO_WARM ?? []).map(path => `<link rel="prefetch" href
|
|
|
15
15
|
function html(env, { page, title, body, status = 200, headers = {}, turnstile = false, refresh = false }) {
|
|
16
16
|
const nonce = crypto.randomUUID().replaceAll('-', ''), site = new URL(env.DEMO_SITE);
|
|
17
17
|
const policy = `default-src 'none'; style-src 'self' 'nonce-${nonce}'; font-src 'self'; img-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'; script-src 'nonce-${nonce}'${turnstile ? ` https://challenges.cloudflare.com; frame-src https://challenges.cloudflare.com; connect-src 'self' https://challenges.cloudflare.com` : ''}`;
|
|
18
|
-
return new Response(`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>${escape(title)}</title>${env.DEMO_ICON_HEAD ?? ''}${refresh ? '<noscript><meta http-equiv="refresh" content="2;url=/__demo/status"></noscript>' : ''}${(env.DEMO_THEME ??
|
|
19
|
-
<body class="${page}"><main><section class="card" aria-labelledby="title"><p class="brand"><img class="mark" alt="${escape(env.DEMO_NAME)}" width="40" height="40" hidden><span>${escape(env.DEMO_NAME)}</span></p>${body}</section><nav class="back" aria-label="Return"><a href="${escape(site.origin)}/">Back to ${escape(site.host)}</a></nav></main><script nonce="${nonce}">${
|
|
18
|
+
return new Response(`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>${escape(title)}</title>${env.DEMO_ICON_HEAD ?? ''}${refresh ? '<noscript><meta http-equiv="refresh" content="2;url=/__demo/status"></noscript>' : ''}<style nonce="${nonce}">${(env.DEMO_THEME ?? '').replace(/<(?=\/style)/gi, '\\3c ')}\n${STYLE}</style>${turnstile ? `<noscript><style nonce="${nonce}">#note{display:none}</style></noscript><script nonce="${nonce}">${START_SCRIPT}</script>${warm(env)}` : ''}</head>
|
|
19
|
+
<body class="${page}"><main><section class="card" aria-labelledby="title"><p class="brand"><img class="mark" alt="${escape(env.DEMO_NAME)}" width="40" height="40" hidden><span>${escape(env.DEMO_NAME)}</span></p>${body}</section><nav class="back" aria-label="Return"><a href="${escape(site.origin)}/">Back to ${escape(site.host)}</a></nav></main><script nonce="${nonce}">${THEME_SCRIPT}</script>${turnstile ? `<script nonce="${nonce}" src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=rerDemoRender&render=explicit" async defer></script>` : ''}</body></html>`,
|
|
20
20
|
{ status, headers: { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store', 'content-security-policy': policy, 'referrer-policy': 'strict-origin', 'x-content-type-options': 'nosniff', ...headers } });
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -26,8 +26,8 @@ export function startPage(env, { status = 200, notice, pending = false, headers
|
|
|
26
26
|
return html(env, { page: 'start', title: `Try ${env.DEMO_NAME}`, status, headers, turnstile: true, refresh: pending, body: `<h1 id="title">Try ${name}</h1>
|
|
27
27
|
<p class="intro">Your own copy of ${name}, signed in as its owner, with sample data.</p>
|
|
28
28
|
<ul><li>Public checks run live. Messages and account changes are simulated.</li><li>It ends after an hour, or 15 idle minutes.</li><li>Then it is deleted. Nobody else can see it.</li></ul>
|
|
29
|
-
<p class="notice" id="notice" role="alert"${notice ? '' : ' hidden'}>${notice ? escape(notice) : ''}</p><form id="start" method="post" action="/__demo/start" data-auto="${notice || pending ? '0' : '1'}"${pending ? ' data-resume="1" data-state="working"' : ''}><div class="cf-turnstile" data-sitekey="${escape(env.TURNSTILE_SITE_KEY)}" data-size="flexible" data-callback="rerDemoVerified" data-before-interactive-callback="rerDemoInteractive" data-after-interactive-callback="rerDemoChecking" data-expired-callback="rerDemoExpired" data-error-callback="rerDemoCheckFailed"></div>
|
|
30
|
-
<button class="button" type="submit"
|
|
29
|
+
<p class="notice" id="notice" role="alert"${notice ? '' : ' hidden'}>${notice ? escape(notice) : ''}</p><form id="start" method="post" action="/__demo/start" data-auto="${notice || pending ? '0' : '1'}"${pending ? ' data-resume="1" data-state="working"' : ' data-state="waiting"'}><div class="cf-turnstile" data-theme="light" data-sitekey="${escape(env.TURNSTILE_SITE_KEY)}" data-size="flexible" data-callback="rerDemoVerified" data-before-interactive-callback="rerDemoInteractive" data-after-interactive-callback="rerDemoChecking" data-expired-callback="rerDemoExpired" data-error-callback="rerDemoCheckFailed"></div>
|
|
30
|
+
<button class="button" type="submit" disabled><span class="spinner" aria-hidden="true"></span><span class="label">${pending ? 'Starting your demo…' : 'Waiting for the human check…'}</span></button>
|
|
31
31
|
<ol class="steps" aria-hidden="true"><li data-at="done">Checking you're human</li><li data-at="now">Starting a private copy</li><li data-at="next">Signing you in</li></ol>
|
|
32
32
|
<p class="note" id="note">${pending ? 'Your demo will open automatically when ready.' : 'Complete the human check to start your demo.'}</p><noscript><p class="note">The human check needs JavaScript. Turn it on to start the demo.</p></noscript><p class="visually-hidden" id="status" role="status"></p></form>` });
|
|
33
33
|
}
|
|
@@ -77,7 +77,7 @@ window.rerDemoExpired=()=>checking()&&waiting();
|
|
|
77
77
|
window.rerDemoCheckFailed=()=>checking()&&show('failed',{label:'Try again',note:'',live:'',notice:'The human check did not load. Try again.'});
|
|
78
78
|
addEventListener('DOMContentLoaded',()=>{
|
|
79
79
|
if(el().form.dataset.resume==='1')go(true);
|
|
80
|
-
else if(
|
|
80
|
+
else if(el().form.dataset.state==='waiting')waiting();
|
|
81
81
|
el().form.addEventListener('submit',event=>{
|
|
82
82
|
event.preventDefault();
|
|
83
83
|
const state=el().form.dataset.state;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Resolve the built seed's CSS before serving the gate: no stylesheet round
|
|
2
|
+
// trips, and relative imports/font/mark URLs still refer to their source file.
|
|
3
|
+
const origin = 'https://theme.invalid';
|
|
4
|
+
const imports = /@import\s+(?:url\(\s*(['"]?)([^'"\s)]+)\1\s*\)|(['"])([^'"]+)\3)\s*([^;]*);/gi;
|
|
5
|
+
|
|
6
|
+
function localURL(value, path) {
|
|
7
|
+
const url = new URL(value, origin + path);
|
|
8
|
+
if (url.origin !== origin) throw Error(`Demo theme must use same-origin assets: ${value}`);
|
|
9
|
+
return url.pathname + url.search + url.hash;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function conditioned(css, conditions) {
|
|
13
|
+
// @import allows layer, supports, then media; keep their cascade semantics.
|
|
14
|
+
const wrappers = [];
|
|
15
|
+
let rest = conditions.trim();
|
|
16
|
+
for (const kind of ['layer', 'supports']) {
|
|
17
|
+
if (!rest.startsWith(kind)) continue;
|
|
18
|
+
rest = rest.slice(kind.length).trimStart();
|
|
19
|
+
let value = '';
|
|
20
|
+
if (rest.startsWith('(')) {
|
|
21
|
+
let depth = 0, end = 0;
|
|
22
|
+
do { if (rest[end] === '(') depth++; if (rest[end] === ')') depth--; end++; } while (depth && end < rest.length);
|
|
23
|
+
if (depth) throw Error(`Invalid demo theme import: ${conditions}`);
|
|
24
|
+
value = rest.slice(1, end - 1); rest = rest.slice(end).trimStart();
|
|
25
|
+
} else if (kind === 'supports') throw Error(`Invalid demo theme import: ${conditions}`);
|
|
26
|
+
wrappers.push(kind === 'supports' ? `@supports (${value})` : `@layer ${value}`);
|
|
27
|
+
}
|
|
28
|
+
if (rest) wrappers.push(`@media ${rest}`);
|
|
29
|
+
return wrappers.reduceRight((body, wrapper) => `${wrapper}{${body}}`, css);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function inlineTheme(files, paths) {
|
|
33
|
+
function expand(path, parents = []) {
|
|
34
|
+
const key = new URL(path, origin).pathname;
|
|
35
|
+
if (parents.includes(key)) throw Error(`Cyclic demo theme import: ${[...parents, key].join(' -> ')}`);
|
|
36
|
+
const bytes = files.get(key);
|
|
37
|
+
if (!bytes) throw Error(`Demo theme asset missing: ${key}`);
|
|
38
|
+
const css = bytes.toString().replace(/\/\*[\s\S]*?\*\//g, '').replace(/@charset\s+['"][^'"]+['"]\s*;/gi, '');
|
|
39
|
+
// Rebase before expansion so an imported file keeps its own URL base.
|
|
40
|
+
const rebased = css.replace(/url\(\s*(['"]?)([^'"\s)]+)\1\s*\)/gi, (_, _quote, value) => `url("${localURL(value, key)}")`);
|
|
41
|
+
return rebased.replace(imports, (_, _q1, url, _q2, string, conditions) => conditioned(expand(localURL(url ?? string, key), [...parents, key]), conditions));
|
|
42
|
+
}
|
|
43
|
+
return paths.map(path => expand(path)).join('\n').replace(/@font-face\s*\{([^{}]*)\}/gi, (_, body) => {
|
|
44
|
+
// A seed's block/auto/default display must not hold the gate's first paint.
|
|
45
|
+
const declarations = body.replace(/font-display\s*:[^;}]*(;|$)/gi, '');
|
|
46
|
+
const display = /font-display\s*:\s*optional\s*(?:;|$)/i.test(body) ? 'optional' : 'swap';
|
|
47
|
+
return `@font-face{${declarations.trim().replace(/;?$/, ';')}font-display:${display};}`;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
export const
|
|
5
|
-
const
|
|
1
|
+
// Resolve the seed's actual painted palette, including CSS aliases and dark
|
|
2
|
+
// media rules, before Turnstile renders. A light-only seed stays light even
|
|
3
|
+
// when the visitor prefers dark. Marks follow the same media changes.
|
|
4
|
+
export const THEME_SCRIPT = `(()=>{
|
|
5
|
+
const root=document.documentElement,card=document.querySelector('.card');
|
|
6
|
+
const widget=document.querySelector('.cf-turnstile'),mark=document.querySelector('.brand img'),name=document.querySelector('.brand span');
|
|
7
|
+
let widgetId,pixel;
|
|
8
|
+
const luminance=colour=>{
|
|
9
|
+
if(!pixel){const canvas=document.createElement('canvas');canvas.width=canvas.height=1;pixel=canvas.getContext('2d',{willReadFrequently:true})}
|
|
10
|
+
pixel.fillStyle=colour;pixel.fillRect(0,0,1,1);
|
|
11
|
+
const [r,g,b]=[...pixel.getImageData(0,0,1,1).data].slice(0,3).map(value=>{const c=value/255;return c<=.04045?c/12.92:((c+.055)/1.055)**2.4});
|
|
12
|
+
return .2126*r+.7152*g+.0722*b;
|
|
13
|
+
};
|
|
14
|
+
window.rerDemoRender=()=>{update();if(widget)widgetId=turnstile.render(widget,{theme:widget.dataset.theme})};
|
|
6
15
|
const update=()=>{
|
|
7
|
-
const
|
|
16
|
+
const style=getComputedStyle(card),scheme=luminance(style.backgroundColor)<luminance(style.color)?'dark':'light';
|
|
17
|
+
root.dataset.demoScheme=scheme;
|
|
18
|
+
if(widget&&widget.dataset.theme!==scheme){
|
|
19
|
+
widget.dataset.theme=scheme;
|
|
20
|
+
if(widgetId!==undefined){window.rerDemoExpired();turnstile.remove(widgetId);window.rerDemoRender()}
|
|
21
|
+
}
|
|
22
|
+
const token=getComputedStyle(root).getPropertyValue('--rer-logo');
|
|
8
23
|
const match=/url\\(\\s*(['"]?)([^'"\\)]+)\\1\\s*\\)/.exec(token);
|
|
9
24
|
mark.hidden=true;name.removeAttribute('aria-hidden');
|
|
10
25
|
if(!match)return;
|
|
@@ -14,5 +29,7 @@ export const LOGO_SCRIPT = `(()=>{
|
|
|
14
29
|
mark.onerror=()=>{mark.hidden=true;name.removeAttribute('aria-hidden')};
|
|
15
30
|
mark.src=url.href;
|
|
16
31
|
};
|
|
17
|
-
|
|
32
|
+
// The inline CSS paints the card immediately; mark/scheme work follows that
|
|
33
|
+
// first frame. If Turnstile arrives sooner, its callback updates before render.
|
|
34
|
+
requestAnimationFrame(()=>setTimeout(update,0));matchMedia('(prefers-color-scheme: dark)').addEventListener('change',update);
|
|
18
35
|
})()`;
|
|
@@ -2,26 +2,26 @@ import { mkdir, writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { shared } from '../../cli/shared.mjs';
|
|
5
|
+
import { inlineTheme } from './theme-css.mjs';
|
|
5
6
|
|
|
6
7
|
const prefix = '/__demo/theme';
|
|
7
8
|
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// a seed's own files. The seed stylesheet follows it, just as in the Lobby;
|
|
11
|
-
// the browser resolves imports, token aliases and light/dark media rules.
|
|
9
|
+
// Keep the Lobby's cascade (maintained defaults, seed fonts, seed theme), but
|
|
10
|
+
// resolve it at build time so the gate can paint without blocking CSS fetches.
|
|
12
11
|
export async function prepareTheme(folder, assets) {
|
|
13
12
|
const { loadSeedTheme } = await shared('theme-files.mjs');
|
|
14
13
|
const defaults = await loadSeedTheme(fileURLToPath(new URL('../../default-seed/', import.meta.url)), 'public/rer-theme.css');
|
|
15
|
-
const paths = [];
|
|
14
|
+
const paths = [], files = new Map(assets.map(file => ['/' + file.path, Buffer.from(file.base64, 'base64')]));
|
|
16
15
|
for (const [path, file] of defaults.files) {
|
|
17
16
|
const target = join(folder, 'assets', prefix, path);
|
|
18
17
|
await mkdir(dirname(target), { recursive: true });
|
|
19
18
|
const bytes = file.type === 'text/css'
|
|
20
|
-
? file.bytes.toString().replace(/url\((['"]?)(\/[^)'"\s]+)\1\)/g, (_, quote, url) => `url(${quote}${prefix}${url}${quote})`)
|
|
19
|
+
? Buffer.from(file.bytes.toString().replace(/url\((['"]?)(\/[^)'"\s]+)\1\)/g, (_, quote, url) => `url(${quote}${prefix}${url}${quote})`))
|
|
21
20
|
: file.bytes;
|
|
22
21
|
await writeFile(target, bytes);
|
|
22
|
+
files.set(prefix + path, bytes);
|
|
23
23
|
paths.push(prefix + path);
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
return { paths,
|
|
25
|
+
const stylesheets = [prefix + '/rer-theme.css', ...['/fonts/fonts.css', '/rer-theme.css'].filter(path => files.has(path))];
|
|
26
|
+
return { paths, css: inlineTheme(files, stylesheets) };
|
|
27
27
|
}
|
|
@@ -104,6 +104,10 @@
|
|
|
104
104
|
"help": {
|
|
105
105
|
"type": "string"
|
|
106
106
|
},
|
|
107
|
+
"audience": {
|
|
108
|
+
"enum": ["owner", "developer"],
|
|
109
|
+
"description": "Audience inherited by this group's public fields: owner when absent, or developer. An explicit owner field inside a developer group is invalid. This metadata does not change local installer or rer setup visibility."
|
|
110
|
+
},
|
|
107
111
|
"presentations": {
|
|
108
112
|
"type": "array",
|
|
109
113
|
"items": {
|
|
@@ -141,6 +145,10 @@
|
|
|
141
145
|
"secret"
|
|
142
146
|
]
|
|
143
147
|
},
|
|
148
|
+
"audience": {
|
|
149
|
+
"enum": ["owner", "developer"],
|
|
150
|
+
"description": "Public fields only: owner or developer. When absent, inherit the group's audience, or owner without a group audience. An explicit owner value inside a developer group is invalid. This metadata does not change local installer or rer setup visibility; secret visibility uses ownerVisible and input."
|
|
151
|
+
},
|
|
144
152
|
"required": {
|
|
145
153
|
"type": "boolean"
|
|
146
154
|
},
|
|
@@ -6,6 +6,11 @@ export const SETUP_SCHEMA_ID = 'urn:rer:setup:1';
|
|
|
6
6
|
|
|
7
7
|
const PUBLIC_KINDS = new Set(['text', 'email', 'url', 'select', 'colour', 'timezone']);
|
|
8
8
|
|
|
9
|
+
/** Effective audience of a validated public field, including its group default. */
|
|
10
|
+
export function setupFieldAudience(field, groups) {
|
|
11
|
+
return field.audience ?? groups.find(group => group.id === field.group)?.audience ?? 'owner';
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
/** Match a validated condition against raw public input; whitespace is a value. */
|
|
10
15
|
export function setupConditionMatches(condition, values) {
|
|
11
16
|
const value = values[condition.field];
|
|
@@ -131,6 +136,7 @@ export function setupManifestSemanticErrors(data) {
|
|
|
131
136
|
if (field.group !== undefined && !groups.has(field.group)) fail(`${path}.group`, 'group must reference a declared group');
|
|
132
137
|
|
|
133
138
|
if (isSecret) {
|
|
139
|
+
if (Object.hasOwn(field, 'audience')) fail(`${path}.audience`, `${field.name}: secret fields cannot declare audience`);
|
|
134
140
|
for (const name of ['default', 'prefill', 'options', 'runtimeEditable']) {
|
|
135
141
|
if (Object.hasOwn(field, name)) fail(`${path}.${name}`, 'secret fields cannot declare public input metadata');
|
|
136
142
|
}
|
|
@@ -144,6 +150,9 @@ export function setupManifestSemanticErrors(data) {
|
|
|
144
150
|
fail(`${path}.ownerVisible`, 'only generated or explicitly entered secret values may be shown to the owner');
|
|
145
151
|
}
|
|
146
152
|
} else {
|
|
153
|
+
if (field.audience === 'owner' && groups.get(field.group)?.audience === 'developer') {
|
|
154
|
+
fail(`${path}.audience`, `${field.name} cannot declare owner audience inside developer group ${field.group}`);
|
|
155
|
+
}
|
|
147
156
|
for (const name of ['generate', 'ownerVisible', 'input']) {
|
|
148
157
|
if (Object.hasOwn(field, name)) fail(`${path}.${name}`, 'public fields cannot declare secret metadata');
|
|
149
158
|
}
|
|
@@ -320,6 +329,11 @@ export function validateSetupManifest(schema, data) {
|
|
|
320
329
|
if (schema?.$id !== SETUP_SCHEMA_ID) throw new Error('Expected setup schema version 1');
|
|
321
330
|
checkSchema(schema);
|
|
322
331
|
const errors = validate(schema, data);
|
|
323
|
-
if (errors.length) return errors
|
|
332
|
+
if (errors.length) return errors.map(error => {
|
|
333
|
+
const match = error.match(/^(\$\.(fields|groups)\[(\d+)\]\.audience):/);
|
|
334
|
+
if (!match) return error;
|
|
335
|
+
const item = data[match[2]][Number(match[3])];
|
|
336
|
+
return `${match[1]}: ${item.name ?? item.id} audience must be "owner" or "developer"`;
|
|
337
|
+
});
|
|
324
338
|
return setupManifestSemanticErrors(data);
|
|
325
339
|
}
|