@runeditrun/rer 0.2.120 → 0.2.122
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/cli/README.md +173 -5
- package/cli/archive.mjs +1 -1
- package/cli/authoring.mjs +1 -1
- package/cli/browser-runtime.mjs +33 -18
- package/cli/business/agent-help.mjs +11 -11
- package/cli/business/agent-verbs.mjs +9 -8
- package/cli/business/api.mjs +11 -7
- package/cli/business/carry.mjs +4 -3
- package/cli/business/choices.mjs +1 -1
- package/cli/business/command.mjs +33 -11
- package/cli/business/connect.mjs +4 -4
- package/cli/business/credential-file.mjs +102 -0
- package/cli/business/errors.mjs +5 -2
- package/cli/business/invocation.mjs +7 -4
- package/cli/business/keychain.mjs +6 -2
- package/cli/business/local-commands.mjs +9 -3
- package/cli/business/mcp-bridge.mjs +2 -1
- package/cli/business/questions.mjs +1 -1
- package/cli/business/run-child.mjs +5 -5
- package/cli/business/run-grant.mjs +27 -8
- package/cli/business/run-mask.mjs +8 -1
- package/cli/business/scan-command.mjs +1 -1
- package/cli/business/service.mjs +4 -2
- package/cli/business/state.mjs +2 -2
- package/cli/checkout-folders.mjs +1 -1
- package/cli/checkout-preparation.mjs +4 -4
- package/cli/command-guidance.mjs +9 -0
- package/cli/companion/command.mjs +4 -3
- package/cli/companion/providers/sandbox.mjs +1 -1
- package/cli/companion/setup.mjs +4 -4
- package/cli/contract.mjs +8 -8
- package/cli/demo.mjs +1 -1
- package/cli/deploy-command.mjs +10 -5
- package/cli/deploy-hook.mjs +3 -2
- package/cli/deploy-inputs.mjs +20 -3
- package/cli/deploy-owner-input.mjs +2 -2
- package/cli/deploy-settings.mjs +14 -0
- package/cli/deploy-source.mjs +1 -1
- package/cli/deploy-variables.mjs +7 -1
- package/cli/deploy.mjs +6 -4
- package/cli/deployment-record.mjs +1 -1
- package/cli/dev-identity.mjs +4 -4
- package/cli/door-clauses.mjs +2 -2
- package/cli/door-mode.mjs +7 -7
- package/cli/door.mjs +7 -7
- package/cli/errors.mjs +15 -1
- package/cli/export-summary.mjs +1 -1
- package/cli/export.mjs +1 -1
- package/cli/hosted-export.mjs +1 -1
- package/cli/hosted-output.mjs +2 -2
- package/cli/human-error.mjs +8 -2
- package/cli/hydration/browser.mjs +1 -1
- package/cli/hydration/check.mjs +1 -1
- package/cli/import-summary.mjs +2 -2
- package/cli/inspect.mjs +9 -4
- package/cli/lifecycle.mjs +10 -10
- package/cli/listen.mjs +1 -1
- package/cli/listing.mjs +1 -1
- package/cli/local-env.mjs +1 -1
- package/cli/local.mjs +4 -4
- package/cli/managed-server.mjs +36 -13
- package/cli/output.mjs +2 -1
- package/cli/owner-entry-ready.mjs +92 -0
- package/cli/parse.mjs +19 -9
- package/cli/port.mjs +3 -3
- package/cli/portability-runtime.mjs +16 -0
- package/cli/portability.mjs +4 -4
- package/cli/production-auth.mjs +4 -2
- package/cli/production-mail.mjs +1 -1
- package/cli/project.mjs +2 -0
- package/cli/rehearse/options.mjs +3 -3
- package/cli/release-candidate.mjs +2 -2
- package/cli/release.mjs +5 -5
- package/cli/server-registry.mjs +3 -3
- package/cli/server-resources.mjs +1 -1
- package/cli/setup-input.mjs +6 -6
- package/cli/signin.mjs +11 -10
- package/cli/site-render.mjs +1 -1
- package/cli/size/schema.mjs +1 -1
- package/cli/size/verify-step.mjs +1 -1
- package/cli/transfers.mjs +4 -4
- package/edition-authoring/api-source.mjs +121 -0
- package/edition-authoring/archive-source.mjs +1 -86
- package/edition-authoring/base-copies.mjs +5 -3
- package/global/CHANGELOG.md +47 -0
- package/global/browser-runtime.mjs +9 -5
- package/global/cli/command.mjs +6 -5
- package/global/cli/install.mjs +6 -3
- package/global/cli/path-link.mjs +11 -22
- package/global/cli/repo-command.mjs +4 -3
- package/global/cli/repository-contract.mjs +3 -3
- package/global/door/command.mjs +39 -38
- package/global/door/control.mjs +3 -3
- package/global/door/pages.mjs +6 -5
- package/global/door/server.mjs +8 -5
- package/global/door/sites.mjs +14 -13
- package/global/launch/capacity.mjs +2 -2
- package/global/launch/dev.mjs +6 -6
- package/global/launch/door.mjs +1 -1
- package/global/launch/facts.mjs +2 -2
- package/global/launch/failure.mjs +1 -1
- package/global/launch/prepare.mjs +3 -3
- package/global/launch/render.mjs +3 -2
- package/global/launch/worker.mjs +1 -1
- package/global/list.mjs +4 -4
- package/global/main.mjs +32 -31
- package/global/registry.mjs +1 -1
- package/global/run.mjs +5 -5
- package/global/update/command.mjs +5 -5
- package/global/update/notice.mjs +1 -1
- package/global/version.mjs +1 -1
- package/install.sh +17 -4
- package/modules/deploy-kit/README.md +11 -3
- package/modules/deploy-kit/asset-health.mjs +6 -4
- package/modules/deploy-kit/cancellation.mjs +26 -0
- package/modules/deploy-kit/d1-import-diagnostics.mjs +3 -2
- package/modules/deploy-kit/deploy.mjs +8 -3
- package/modules/deploy-kit/diagnostics.mjs +11 -4
- package/modules/deploy-kit/health-request.mjs +16 -9
- package/modules/deploy-kit/health.mjs +14 -11
- package/modules/deploy-kit/owner-cli.mjs +55 -25
- package/modules/deploy-kit/owner-remove.mjs +7 -6
- package/modules/deploy-kit/owner-secret-copy.mjs +2 -1
- package/modules/deploy-kit/owner-secret.mjs +8 -5
- package/modules/deploy-kit/owner.mjs +49 -30
- package/modules/deploy-kit/provider-transport.mjs +2 -0
- package/modules/deploy-kit/provider.mjs +10 -9
- package/modules/deploy-kit/readiness-window.mjs +5 -3
- package/modules/deploy-kit/site.mjs +1 -1
- package/modules/deploy-kit/teardown.mjs +5 -4
- package/modules/deploy-kit/validation.mjs +1 -0
- package/modules/deploy-kit/worker.mjs +1 -0
- package/modules/operator-auth/dev/index.mjs +4 -3
- package/modules/operator-auth/dev/sign-in-as.mjs +2 -1
- package/modules/operator-auth/dev-gate.mjs +3 -2
- package/modules/operator-auth/routes.mjs +2 -1
- package/modules/operator-auth/terminal-guidance.mjs +3 -0
- package/onboarding/adapter-settings.mjs +1 -0
- package/onboarding/adapter.mjs +3 -3
- package/onboarding/agent-handoff.mjs +1 -1
- package/onboarding/busy.mjs +1 -1
- package/onboarding/launcher.mjs +1 -1
- package/onboarding/local/environment.mjs +1 -1
- package/onboarding/local/operation.mjs +12 -4
- package/onboarding/local/owner.mjs +2 -2
- package/onboarding/operator-installer.mjs +4 -3
- package/onboarding/operator-migrations.mjs +1 -1
- package/onboarding/operator-prerequisites.mjs +26 -14
- package/onboarding/operator-settings.mjs +28 -0
- package/onboarding/process-diagnostics.mjs +2 -2
- package/onboarding/project-vite.mjs +1 -1
- package/package.json +1 -1
package/cli/door.mjs
CHANGED
|
@@ -201,8 +201,8 @@ export async function claimSiteName(env, checkout, { preferred, mode, origin, ex
|
|
|
201
201
|
const claimed = await changeDoorState(env, state => {
|
|
202
202
|
const { entry, holder } = claimEntry(state, checkout, preferred, held);
|
|
203
203
|
if (exact && entry.name !== preferred) throw refuse(holder
|
|
204
|
-
? `This checkout's saved origin names ${preferred}.localhost, which the front door has registered for another checkout (${holder.checkout}). Nothing was started and no sign-in link was printed. Give this checkout its own name: rer dev --direct, then rer dev --door.`
|
|
205
|
-
: `This checkout's saved origin names ${preferred}.localhost, but the front door has it registered as ${entry.name}. Nothing was started and no sign-in link was printed. Move it again: rer dev --direct, then rer dev --door.`);
|
|
204
|
+
? `This checkout's saved origin names ${preferred}.localhost, which the front door has registered for another checkout (${holder.checkout}). Nothing was started and no sign-in link was printed. Give this checkout its own name: ~/.local/bin/rer dev --direct, then ~/.local/bin/rer dev --door.`
|
|
205
|
+
: `This checkout's saved origin names ${preferred}.localhost, but the front door has it registered as ${entry.name}. Nothing was started and no sign-in link was printed. Move it again: ~/.local/bin/rer dev --direct, then ~/.local/bin/rer dev --door.`);
|
|
206
206
|
describe(entry);
|
|
207
207
|
return { name: entry.name, id: entry.id };
|
|
208
208
|
});
|
|
@@ -246,19 +246,19 @@ async function verifyOnce(env, port) {
|
|
|
246
246
|
const holders = (await listeners(undefined,context,port)).filter(row => row.names.some(name => portOf(name) === port));
|
|
247
247
|
const foreign = holders.find(row => row.pid !== record?.pid);
|
|
248
248
|
const withheld = 'No sign-in link was printed.';
|
|
249
|
-
if (foreign) throw refuse(`Port ${port} is held by PID ${foreign.pid} (${await processName(foreign.pid,context)}), which is not this account's front door${record ? ` (PID ${record.pid})` : ''}. ${withheld} Stop PID ${foreign.pid}, then run rer door restart.`);
|
|
250
|
-
if (!record || record.port !== port) throw refuse(`The front door is not running on port ${port}. ${withheld} Start it with rer door start, then run this again.`);
|
|
249
|
+
if (foreign) throw refuse(`Port ${port} is held by PID ${foreign.pid} (${await processName(foreign.pid,context)}), which is not this account's front door${record ? ` (PID ${record.pid})` : ''}. ${withheld} Stop PID ${foreign.pid}, then run ~/.local/bin/rer door restart.`);
|
|
250
|
+
if (!record || record.port !== port) throw refuse(`The front door is not running on port ${port}. ${withheld} Start it with ~/.local/bin/rer door start, then run this again.`);
|
|
251
251
|
const token = (await readPrivate(join(directory, 'token')))?.trim();
|
|
252
|
-
if (!token) throw refuse(`The front door's token is missing from ${directory}. ${withheld} Run rer door restart.`);
|
|
252
|
+
if (!token) throw refuse(`The front door's token is missing from ${directory}. ${withheld} Run ~/.local/bin/rer door restart.`);
|
|
253
253
|
for (const host of ['127.0.0.1', '::1']) {
|
|
254
254
|
let answer;
|
|
255
255
|
try { answer = await challenge(host, port, token); }
|
|
256
256
|
catch (error) {
|
|
257
257
|
// No IPv6 loopback, or nothing on [::1]:P while the door serves only 127.0.0.1.
|
|
258
258
|
if (host === '::1' && ['ECONNREFUSED', 'EADDRNOTAVAIL', 'EAFNOSUPPORT', 'ENETUNREACH'].includes(error.code) && !record.addresses?.includes('::1')) continue;
|
|
259
|
-
throw refuse(`The front door (PID ${record.pid}) did not answer on ${host === '::1' ? '[::1]' : host}:${port}: ${error.code ?? error.message}. ${withheld} Run rer door restart.`);
|
|
259
|
+
throw refuse(`The front door (PID ${record.pid}) did not answer on ${host === '::1' ? '[::1]' : host}:${port}: ${error.code ?? error.message}. ${withheld} Run ~/.local/bin/rer door restart.`);
|
|
260
260
|
}
|
|
261
|
-
if (!answer || answer.pid !== record.pid) throw refuse(`Something other than this account's front door (PID ${record.pid}) answers on ${host === '::1' ? '[::1]' : host}:${port}. ${withheld} Find and stop it, then run rer door restart.`);
|
|
261
|
+
if (!answer || answer.pid !== record.pid) throw refuse(`Something other than this account's front door (PID ${record.pid}) answers on ${host === '::1' ? '[::1]' : host}:${port}. ${withheld} Find and stop it, then run ~/.local/bin/rer door restart.`);
|
|
262
262
|
}
|
|
263
263
|
return record;
|
|
264
264
|
}
|
package/cli/errors.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { transferDiagnostic } from '../modules/portability/http-client.mjs';
|
|
2
|
+
import { nativeFailure } from './portability-progress.mjs';
|
|
3
|
+
import { relative } from 'node:path';
|
|
2
4
|
|
|
3
5
|
export class RerError extends Error {
|
|
4
6
|
constructor(code, message, exitCode, details = {}) { super(message); Object.assign(this, { code, exitCode, ...details }); }
|
|
@@ -14,5 +16,17 @@ export async function lifecycleError(error, store) {
|
|
|
14
16
|
const {shared}=await import('./shared.mjs');
|
|
15
17
|
const {approvedFailure}=await shared('failures.mjs');
|
|
16
18
|
const approved=approvedFailure(error);
|
|
17
|
-
|
|
19
|
+
const native=nativeFailure(error);
|
|
20
|
+
return new RerError(['owner_conflict','machine_busy'].includes(approved?.code)?'safety_refusal':'command_failed', approved?.message ?? `${store?.state?.step ?? 'Local lifecycle'} failed (${native.class}${native.code ? `, code ${native.code}` : ''}).`, approved?.exitCode ?? 1, {childExitCode:approved?.childExitCode,signal:approved?.signal,...(approved?.d1Import ? {d1Import:approved.d1Import} : {})});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Only classified diagnostics reach this boundary: unexpected native messages
|
|
24
|
+
// can contain SQL or row values. Name a log only after its failure entry writes.
|
|
25
|
+
export function retainTransferFailure(error,store,root) {
|
|
26
|
+
if(!store?.logPath){error.message+=' No capture log was created.';return error;}
|
|
27
|
+
try {
|
|
28
|
+
store.report(`${error.code}: ${error.message}`,{logOnly:true});
|
|
29
|
+
error.message+=`\nFull output: ${store.redact(relative(root,store.logPath))}`;
|
|
30
|
+
} catch { error.message+=' The private capture log could not be written.'; }
|
|
31
|
+
return error;
|
|
18
32
|
}
|
package/cli/export-summary.mjs
CHANGED
|
@@ -11,7 +11,7 @@ export function exportSummary({ target = 'local', origin, output, bytes, tables,
|
|
|
11
11
|
return [
|
|
12
12
|
`Exported ${copy} to ${output} (${size(bytes)}): ${counted(tables.length, 'table')}, ${counted(rows, 'row')}`,
|
|
13
13
|
captureLog && `Full output: ${captureLog}`,
|
|
14
|
-
`To restore into an empty installation: rer import --input ${file} --yes`,
|
|
14
|
+
`To restore into an empty installation: ~/.local/bin/rer import --input ${file} --yes`,
|
|
15
15
|
].filter(Boolean).join('\n');
|
|
16
16
|
}
|
|
17
17
|
|
package/cli/export.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { execFileSync } from 'node:child_process';
|
|
|
9
9
|
// load sibling modules and data dynamically; they belong in the inventory too.
|
|
10
10
|
export const sourceRoots = ['default-seed/public/rer-theme.css', 'default-seed/public/brand/mark.svg', 'default-seed/public/fonts/outfit', 'bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/delivery-producer/mail.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/site', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/import-kit/src/receipt', 'modules/import-kit/src/status', 'modules/import-kit/schema', 'modules/import-kit/src/d1', 'modules/import-kit/src/door', 'modules/import-kit/src/readers', 'modules/import-kit/src/provenance/numeric-credentials.ts', 'modules/import-kit/src/types.ts', 'modules/import-kit/src/plan', 'modules/import-kit/src/provenance/canonical-hash.ts', 'modules/import-kit/src/provenance/canonical-stream.ts', 'modules/import-kit/src/provenance/credential-names.ts', 'modules/import-kit/src/provenance/credentials.ts', 'modules/import-kit/src/provenance/identity.ts', 'modules/import-kit/src/provenance/json-snapshot.ts', 'modules/import-kit/src/provenance/resumable-sha256.ts', 'modules/import-kit/src/provenance/validate-json.ts', 'modules/import-kit/src/journal/authority.ts', 'modules/import-kit/src/storage/originals.ts', 'modules/import-kit/src/storage/provenance.ts', 'modules/import-kit/src/storage/schema.ts', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/adopt.mjs', 'edition-authoring/base-acknowledgements.mjs', 'edition-authoring/base-copies.mjs', 'edition-authoring/module-closure.mjs', 'edition-authoring/edition-migrations.mjs', 'edition-authoring/cli.mjs', 'edition-authoring/copy-checkout.mjs', 'edition-authoring/files.mjs', 'edition-authoring/lock.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/offline-git.mjs', 'edition-authoring/parent-comparison.mjs', 'edition-authoring/projection-lock.mjs', 'edition-authoring/release.mjs', 'edition-authoring/runtime-dependencies.mjs', 'edition-authoring/module-resolution.mjs', 'edition-authoring/package-target.mjs', 'edition-authoring/module-syntax.mjs', 'edition-authoring/module-edges.mjs', 'edition-authoring/vendor/babel-parser', 'edition-authoring/workflow-copies.mjs', 'edition-authoring/workflow-scripts.mjs', 'edition-authoring/vendor/yaml', 'edition-authoring/sources.mjs', 'edition-authoring/updates.mjs', 'foundation/runtime/seed-contract.mjs', 'foundation/runtime/run-data.mjs', 'foundation/runtime/run-data.d.mts', 'foundation/runtime/contract-docs.mjs'];
|
|
11
11
|
sourceRoots.push('modules/agent-door/capabilities.mjs', 'modules/agent-door/capabilities.d.mts', 'modules/agent-door/conformance', 'modules/agent-door/CLAUSES.md');
|
|
12
|
-
sourceRoots.push('edition-authoring/archive-source.mjs');
|
|
12
|
+
sourceRoots.push('edition-authoring/archive-source.mjs', 'edition-authoring/api-source.mjs');
|
|
13
13
|
sourceRoots.push('edition-authoring/copy-namespaces.mjs');
|
|
14
14
|
sourceRoots.push('edition-authoring/module-packages.mjs');
|
|
15
15
|
sourceRoots.push('foundation/runtime/contract-prose.mjs', 'foundation/runtime/contract-prose-patterns.mjs', 'foundation/runtime/contract-anchor.mjs');
|
package/cli/hosted-export.mjs
CHANGED
|
@@ -24,6 +24,6 @@ export async function refuseHostedExport(project, options) {
|
|
|
24
24
|
...exports,
|
|
25
25
|
...(databases.length ? [] : [' (npx wrangler d1 list names the hosted databases.)']),
|
|
26
26
|
...(buckets.length ? [`Files the hosted install keeps in R2 (${buckets.join(', ')}) are not in that export.`] : []),
|
|
27
|
-
'To export the local copy, run: rer export --output exports/local.rer',
|
|
27
|
+
'To export the local copy, run: ~/.local/bin/rer export --output exports/local.rer',
|
|
28
28
|
].join('\n'));
|
|
29
29
|
}
|
package/cli/hosted-output.mjs
CHANGED
|
@@ -90,7 +90,7 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
90
90
|
const build = dirname(join(root, wrangler));
|
|
91
91
|
let config;
|
|
92
92
|
try { config = await read(join(root, wrangler)); }
|
|
93
|
-
catch { throw new RerError('hosted_output_missing', `No production build at ${wrangler}. Run rer build, then rer verify.`, 1); }
|
|
93
|
+
catch { throw new RerError('hosted_output_missing', `No production build at ${wrangler}. Run ~/.local/bin/rer build, then ~/.local/bin/rer verify.`, 1); }
|
|
94
94
|
// The build's own wrangler file says where its assets are: ../client from dist/server.
|
|
95
95
|
const client = resolve(build, config.assets?.directory ?? '../client');
|
|
96
96
|
let declaration;
|
|
@@ -262,7 +262,7 @@ export async function checkHostedOutput(root, options) {
|
|
|
262
262
|
const deployment = body?.deployment ?? {};
|
|
263
263
|
const wrong = health.status !== 200 ? [`HTTP ${health.status}`] : [...(body?.ok === true ? [] : ['ok']), ...['sourceSha', 'fingerprint', 'versionId'].filter(key => deployment[key] !== identity[key]).map(key => `deployment.${key}`)];
|
|
264
264
|
if (wrong.length) failures.push(`/health lacks the deploy identity (${wrong.join(', ')}); it must answer {ok:true, deployment:{sourceSha, fingerprint, versionId}} from RER_DEPLOY_SOURCE, RER_DEPLOY_FINGERPRINT and RER_VERSION.id`);
|
|
265
|
-
if (failures.length) throw new RerError('hosted_output_failed', `The production build would break when hosted: rer deploy runs the Worker before static assets (run_worker_first), and served this way:\n ${failures.join('\n ')}\nServe built files with staticAssetResponse and answer /health with deploymentHealth (SEED-COMMAND-CONTRACT.md, Hosted assets and deploy identity).`, 1, { failures });
|
|
265
|
+
if (failures.length) throw new RerError('hosted_output_failed', `The production build would break when hosted: ~/.local/bin/rer deploy runs the Worker before static assets (run_worker_first), and served this way:\n ${failures.join('\n ')}\nServe built files with staticAssetResponse and answer /health with deploymentHealth (SEED-COMMAND-CONTRACT.md, Hosted assets and deploy identity).`, 1, { failures });
|
|
266
266
|
return { assets: paths.length, health: 'identity' };
|
|
267
267
|
} finally { await hosted.close(); }
|
|
268
268
|
}
|
package/cli/human-error.mjs
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
// Presentation only: the structured error and its captured step stay intact.
|
|
2
|
-
|
|
2
|
+
import { withCommandHelp } from './command-guidance.mjs';
|
|
3
|
+
|
|
4
|
+
export function humanError(error, options = {}) {
|
|
5
|
+
return withCommandHelp(renderError(error, options));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function renderError(error, { retry } = {}) {
|
|
3
9
|
if (error.humanMessage) return error.humanMessage;
|
|
4
10
|
const text = String(error?.message ?? error);
|
|
5
11
|
const download = /https?:\/\/[^\s"'<>]+/.exec(text)?.[0];
|
|
6
12
|
if (download && /ECONNREFUSED/.test(text)) {
|
|
7
13
|
let url; try { url = new URL(download); } catch {}
|
|
8
14
|
const archive = url && /\/([^/]+)-(\d[^/]*)\.tgz/.exec(url.pathname);
|
|
9
|
-
if (url && archive) return `Could not download a dependency (${archive[1]} ${archive[2]}) because the package registry at ${url.host} refused the connection. Check your network or registry setting, then run: ${retry ?? 'rer install'}.`;
|
|
15
|
+
if (url && archive) return `Could not download a dependency (${archive[1]} ${archive[2]}) because the package registry at ${url.host} refused the connection. Check your network or registry setting, then run: ${retry ?? '~/.local/bin/rer install'}.`;
|
|
10
16
|
}
|
|
11
17
|
const technical = /(?:^|\n)\s*(?:at |[A-Za-z]*Error:)/.test(text);
|
|
12
18
|
if (technical || ['command_failed', 'launch_failed'].includes(error.code ?? error.event?.code)) {
|
|
@@ -12,7 +12,7 @@ export async function launchChromium(root) {
|
|
|
12
12
|
// Pages fulfilled by the check would otherwise count as public, and Chromium would
|
|
13
13
|
// refuse a dev server's loopback HMR socket from them.
|
|
14
14
|
try { return await playwright.chromium.launch({ args: ['--disable-features=LocalNetworkAccessChecks'] }); }
|
|
15
|
-
catch (error) { throw new RerError('hydration_browser_missing', `The hydration check could not start Chromium from the seed's ${name}: ${String(error.message).split('\n').find(line => line.trim()) ?? error}. Run rer verify, which downloads the browser it pins first.`, 1); }
|
|
15
|
+
catch (error) { throw new RerError('hydration_browser_missing', `The hydration check could not start Chromium from the seed's ${name}: ${String(error.message).split('\n').find(line => line.trim()) ?? error}. Run ~/.local/bin/rer verify, which downloads the browser it pins first.`, 1); }
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const strip = new Set(['content-encoding', 'content-length', 'transfer-encoding', 'connection']);
|
package/cli/hydration/check.mjs
CHANGED
|
@@ -50,7 +50,7 @@ export async function checkHydration(root, { origin, pages: declared, declaratio
|
|
|
50
50
|
work.forEach(({ page, item }, index) => { (page.loads ??= []).push({ item, load: loads[index] }); });
|
|
51
51
|
for (const page of pages.filter(page => page.hydrated)) failures.push(...judgePage({ ...page, loads: page.loads ?? [] }));
|
|
52
52
|
const result = {
|
|
53
|
-
served: server.mode === 'hosted' ? 'production build as rer deploy hosts it' : server.origin,
|
|
53
|
+
served: server.mode === 'hosted' ? 'production build as ~/.local/bin/rer deploy hosts it' : server.origin,
|
|
54
54
|
pages: pages.map(page => page.skipped ? { path: page.path, skipped: 'plain HTML: React does not hydrate this page and it loads no application script' } : {
|
|
55
55
|
path: page.path,
|
|
56
56
|
sections: page.survey.sections.map(section => `${section.label} (${section.key})`),
|
package/cli/import-summary.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Only declared safe replacement values and aggregate counts reach the terminal.
|
|
2
2
|
export function importSummary(details = {}) {
|
|
3
|
-
const { input, tables, target = 'local', objects, captureLog, nextCommand = 'rer setup' } = details;
|
|
3
|
+
const { input, tables, target = 'local', objects, captureLog, nextCommand = '~/.local/bin/rer setup' } = details;
|
|
4
4
|
if (typeof input !== 'string' || !Array.isArray(tables)) return undefined;
|
|
5
5
|
const rows = tables.reduce((sum, table) => sum + (Number.isSafeInteger(table?.count) ? table.count : 0), 0);
|
|
6
6
|
return [
|
|
7
7
|
`Restored ${target === 'local' ? 'the local copy' : 'the hosted install'} from ${input}: ${count(tables.length, 'table')}, ${count(rows, 'row')}${Number.isSafeInteger(objects) ? `, ${count(objects, 'file')}` : ''}.`,
|
|
8
8
|
importSafetySummary(details),
|
|
9
9
|
captureLog && `Full output: ${captureLog}`,
|
|
10
|
-
`Next: ${nextCommand}${target === 'local' ? ', then rer dev to open the restored app' : ''}.`,
|
|
10
|
+
`Next: ${nextCommand}${target === 'local' ? ', then ~/.local/bin/rer dev to open the restored app' : ''}.`,
|
|
11
11
|
].filter(Boolean).join('\n');
|
|
12
12
|
}
|
|
13
13
|
const count = (value, noun) => `${value.toLocaleString('en-US')} ${noun}${value === 1 ? '' : 's'}`;
|
package/cli/inspect.mjs
CHANGED
|
@@ -59,6 +59,7 @@ export async function describe(project) {
|
|
|
59
59
|
local: { state: project.adapter?.state, settings: project.adapter?.settings ?? [], installerState: '.seed/installer', ...await localState(project), origin: await savedOrigin(project), ...(project.adapter?.devIdentity ? { devIdentity: true, devKey: '.rer/local/dev-key.env' } : {}) },
|
|
60
60
|
// This pin serves a checkout through the machine's front door (rer door).
|
|
61
61
|
door: { protocol: doorProtocol },
|
|
62
|
+
browser: await browserDoctor(project.root, project.adapter?.browser),
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -168,7 +169,7 @@ async function packageClauses(root, pkg) {
|
|
|
168
169
|
}
|
|
169
170
|
// Delivery operations, the scripts they run and CI workflows call the package too.
|
|
170
171
|
const calls = await vendoredCalls(root);
|
|
171
|
-
clauses.push(['SC-13.package.calls', !calls.length, `Run pnpm exec rer VERB instead of the removed vendored copy (pnpm install --frozen-lockfile first where nothing has installed yet) in ${calls.length} place${calls.length === 1 ? '' : 's'}:\n${calls.slice(0, 20).join('\n')}${calls.length > 20 ? `\n...and ${calls.length - 20} more` : ''}`]);
|
|
172
|
+
clauses.push(['SC-13.package.calls', !calls.length, `Run pnpm exec ~/.local/bin/rer VERB instead of the removed vendored copy (pnpm install --frozen-lockfile first where nothing has installed yet) in ${calls.length} place${calls.length === 1 ? '' : 's'}:\n${calls.slice(0, 20).join('\n')}${calls.length > 20 ? `\n...and ${calls.length - 20} more` : ''}`]);
|
|
172
173
|
return clauses;
|
|
173
174
|
}
|
|
174
175
|
|
|
@@ -241,7 +242,7 @@ export async function doctor(project, store, signal) {
|
|
|
241
242
|
if (directory) { usePnpm(directory); try { pnpm = await probePnpm(project.root, store, signal); pnpmIssues.length = 0; } catch (error) { if (signal?.aborted) throw error; pnpmIssues.push(store.redact(error.message)); } }
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
|
-
const browser = project.profile === 'first-party' ? await browserDoctor(project.root) : undefined;
|
|
245
|
+
const browser = project.profile === 'first-party' ? await browserDoctor(project.root, project.adapter?.browser) : undefined;
|
|
245
246
|
const aiIssues = await localAiDiagnostics(project,process.env);
|
|
246
247
|
const dependencies=project.profile==='first-party'?await dependencyDoctor(project.root):[];
|
|
247
248
|
const expectedNode = await projectNodePin(project.root);
|
|
@@ -264,6 +265,10 @@ export async function doctor(project, store, signal) {
|
|
|
264
265
|
}
|
|
265
266
|
const setupNeeded = firstParty ? !(await localState(project)).prepared : false;
|
|
266
267
|
const warnings = project.profile === 'first-party' ? await cacheWarnings(project.root) : [];
|
|
268
|
+
if (firstParty) {
|
|
269
|
+
const variables = await deployVariableClause(project.root, project.adapter);
|
|
270
|
+
if (!variables.ok) warnings.push(`Deployment declaration: ${variables.message}`);
|
|
271
|
+
}
|
|
267
272
|
return { dependencies, warnings, browser, operations: diagnostic, ok: browser?.ok !== false && !aiIssues.length && dependencies.every(d=>d.ok) && diagnostic.ok && stateValid && !inputs.length && (project.profile !== 'first-party' || (Boolean(expectedPnpm) && process.versions.node === expectedNode && pnpm === expectedPnpm)),
|
|
268
273
|
node: { actual: process.versions.node, expected: expectedNode },
|
|
269
274
|
pnpm: project.profile === 'first-party' ? { actual: pnpm, expected: expectedPnpm ?? null, ...(pnpmIssues.length ? { issue: [...new Set(pnpmIssues)].join('\n') } : {}) } : undefined,
|
|
@@ -282,7 +287,7 @@ export function doctorSummary(result) {
|
|
|
282
287
|
if (result.missingInputs.length) {
|
|
283
288
|
lines.push('Missing local inputs:');
|
|
284
289
|
for (const name of result.missingInputs) lines.push(` ${name}${result.sources[name] ? `: ${result.sources[name]}` : ''}`);
|
|
285
|
-
if (result.setupNeeded) lines.push('Run rer setup to configure this checkout.');
|
|
290
|
+
if (result.setupNeeded) lines.push('Run ~/.local/bin/rer setup to configure this checkout.');
|
|
286
291
|
}
|
|
287
292
|
const unavailable = result.operations.commands.filter(command => !command.available);
|
|
288
293
|
if (unavailable.length) lines.push('Unavailable command inputs:', ...unavailable.map(command => ` ${command.name}: restore its declared input files.`));
|
|
@@ -311,6 +316,6 @@ async function devIdentityClauses(root, adapter) {
|
|
|
311
316
|
const configs = (await Promise.all(['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs', 'wrangler.local.jsonc', 'wrangler.local.json', 'wrangler.local.toml'].map(text))).filter(Boolean);
|
|
312
317
|
return [
|
|
313
318
|
['SC-05.dev-identity.entry', entry && await text(entry) !== null && entry !== main && configs.some(config => config.includes(entry)), 'Declare devIdentity.entry as an existing local-only Worker entry that the local Vite or wrangler configuration loads and that is not the deployed main.'],
|
|
314
|
-
['SC-05.dev-identity.exclusion', production !== null && !/operator-auth\/dev\//.test(production) && !production.includes(entry.replace(/\.[a-z]+$/, '')) && Array.isArray(declaration.output) && declaration.output.length > 0, 'Keep the deployed main free of the dev layer and its local entry, and declare devIdentity.output so rer build refuses output containing the dev layer.'],
|
|
319
|
+
['SC-05.dev-identity.exclusion', production !== null && !/operator-auth\/dev\//.test(production) && !production.includes(entry.replace(/\.[a-z]+$/, '')) && Array.isArray(declaration.output) && declaration.output.length > 0, 'Keep the deployed main free of the dev layer and its local entry, and declare devIdentity.output so ~/.local/bin/rer build refuses output containing the dev layer.'],
|
|
315
320
|
];
|
|
316
321
|
}
|
package/cli/lifecycle.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { join } from 'node:path';
|
|
|
9
9
|
import { shared } from './shared.mjs';
|
|
10
10
|
import { tools, doctor } from './inspect.mjs';
|
|
11
11
|
import { availablePort, selectedOrigin, setupInput, stateSafety, refuseLegacyProcess } from './local.mjs';
|
|
12
|
-
import { missing, refuse, RerError, lifecycleError } from './errors.mjs';
|
|
12
|
+
import { missing, refuse, RerError, lifecycleError, retainTransferFailure } from './errors.mjs';
|
|
13
13
|
import { executeDeclared } from './independent.mjs';
|
|
14
14
|
import { transfer } from './transfers.mjs';
|
|
15
15
|
import { runtimeFrontDoor } from './runtime-front-door.mjs';
|
|
@@ -37,7 +37,7 @@ export async function runCommand(project, options, out) {
|
|
|
37
37
|
|
|
38
38
|
async function runLifecycle(project, options, out, deployRedaction) {
|
|
39
39
|
if (project.profile === 'first-party' && ['build','deploy'].includes(options.verb) && !options.demo && !options.site && process.env.RER_DEMO) throw refuse('Production build and deploy refuse the local-only RER_DEMO environment binding. Unset it before retrying.');
|
|
40
|
-
if(project.profile==='first-party'&&options.verb==='outbox')throw refuse('Captured mail has been retired. Run rer dev and open its RER_OPEN link.');
|
|
40
|
+
if(project.profile==='first-party'&&options.verb==='outbox')throw refuse('Captured mail has been retired. Run ~/.local/bin/rer dev and open its RER_OPEN link.');
|
|
41
41
|
if(project.profile==='first-party'&&['dev','preview'].includes(options.verb))return (await import('./managed-server.mjs')).managedServer(project,options,out);
|
|
42
42
|
const cancellation = new AbortController(), signal = cancellation.signal;
|
|
43
43
|
let termination, operation, store, temporary, proxy, failed = false, installingFrozen = false;
|
|
@@ -55,7 +55,7 @@ async function runLifecycle(project, options, out, deployRedaction) {
|
|
|
55
55
|
}
|
|
56
56
|
if (project.profile === 'first-party' && options.verb !== 'doctor') {
|
|
57
57
|
if (!project.adapter?.run) throw refuse('The first-party command adapter is unavailable. Restore the shared lifecycle adapter.');
|
|
58
|
-
if (options.forwarded.length) throw refuse('First-party commands do not accept arbitrary forwarded arguments. Run rer VERB --help.');
|
|
58
|
+
if (options.forwarded.length) throw refuse('First-party commands do not accept arbitrary forwarded arguments. Run ~/.local/bin/rer VERB --help.');
|
|
59
59
|
await stateSafety(project);
|
|
60
60
|
const { localOperation } = await shared('local/operation.mjs');
|
|
61
61
|
// The run site reads no local state: it builds beside a running rer dev.
|
|
@@ -106,16 +106,16 @@ async function runLifecycle(project, options, out, deployRedaction) {
|
|
|
106
106
|
installingFrozen = false;
|
|
107
107
|
// The test browser downloads on first need (verify), not here. Package
|
|
108
108
|
// scripts run with the pinned pnpm through rer run, which keeps pnpm off PATH.
|
|
109
|
-
if (!options.json) store.report('Run this project\'s package scripts with rer run SCRIPT (it uses the pnpm this project pins).');
|
|
109
|
+
if (!options.json) store.report('Run this project\'s package scripts with ~/.local/bin/rer run SCRIPT (it uses the pnpm this project pins).');
|
|
110
110
|
return {};
|
|
111
111
|
} catch (error) { if (signal.aborted) throw error; throw await installStepError(error, store, project.root); } finally { installingFrozen = false; }
|
|
112
112
|
}
|
|
113
113
|
if (options.verb === 'verify') {
|
|
114
114
|
const target = adapter.verify;
|
|
115
115
|
if (!Array.isArray(target)) throw refuse('A complete internal verification target is missing.');
|
|
116
|
-
await ensureChromium(project.root, store, signal);
|
|
116
|
+
await ensureChromium(project.root, store, signal, project.adapter?.browser);
|
|
117
117
|
await store.run('Verifying application', target[0], target[1], { cwd: project.root, signal, env: { ...process.env, RER_LOCAL_OPERATION: operation.token } });
|
|
118
|
-
await store.step('Serving the production build as rer deploy hosts it');
|
|
118
|
+
await store.step('Serving the production build as ~/.local/bin/rer deploy hosts it');
|
|
119
119
|
const declaration = adapter.deployDeclaration ?? adapter.deploy?.declaration;
|
|
120
120
|
const hosted = await (await import('./hosted-output.mjs')).checkHostedOutput(project.root, { declaration });
|
|
121
121
|
await store.step('Checking that page sections hydrate as separate units');
|
|
@@ -165,15 +165,15 @@ async function runLifecycle(project, options, out, deployRedaction) {
|
|
|
165
165
|
else {
|
|
166
166
|
const { checkoutPath } = await shared('step-failure.mjs');
|
|
167
167
|
out.human(`Setup complete: ${state.migrationsApplied ? `${state.migrationsApplied} migration${state.migrationsApplied === 1 ? '' : 's'} applied` : 'database already up to date'}, owner set up. Full output: ${store.redact(checkoutPath(project.root, store.logPath))}`);
|
|
168
|
-
out.human(`RER_SETUP_READY ${url}`); out.human(`Next: rer dev opens ${url} signed in as the owner; first-run setup finishes at ${url}/setup. rer preview prints a one-time native owner link on loopback; rer demo also prints a separate native owner entry.`);
|
|
169
|
-
if (deployNeeds.length) out.human(['To host it on your own Cloudflare account later, rer deploy needs:', ...deployNeeds.map(item => ` - ${item}`), 'Set them in your environment or a private (mode 0600) file passed with --env-file, then check with rer deploy --dry-run.'].join('\n'));
|
|
168
|
+
out.human(`RER_SETUP_READY ${url}`); out.human(`Next: ~/.local/bin/rer dev opens ${url} signed in as the owner; first-run setup finishes at ${url}/setup. ~/.local/bin/rer preview prints a one-time native owner link on loopback; ~/.local/bin/rer demo also prints a separate native owner entry.`);
|
|
169
|
+
if (deployNeeds.length) out.human(['To host it on your own Cloudflare account later, ~/.local/bin/rer deploy needs:', ...deployNeeds.map(item => ` - ${item}`), 'Set them in your environment or a private (mode 0600) file passed with --env-file, then check with ~/.local/bin/rer deploy --dry-run.'].join('\n'));
|
|
170
170
|
}
|
|
171
171
|
} else if (options.verb !== 'build') throw refuse('The requested first-party capability is unavailable.');
|
|
172
172
|
return {};
|
|
173
173
|
} catch (error) {
|
|
174
174
|
failed = true;
|
|
175
|
-
|
|
176
|
-
throw
|
|
175
|
+
const failure=await lifecycleError(error,store);
|
|
176
|
+
throw ['export','import'].includes(options.verb) ? retainTransferFailure(failure,store,project.root) : failure;
|
|
177
177
|
} finally {
|
|
178
178
|
// Every closer runs: one that fails must not leave the job-queue policy socket
|
|
179
179
|
// listening (the process would never exit) or the local operation held, and
|
package/cli/listen.mjs
CHANGED
|
@@ -17,7 +17,7 @@ export async function listen(server, host, port) {
|
|
|
17
17
|
});
|
|
18
18
|
return;
|
|
19
19
|
} catch (error) {
|
|
20
|
-
if (error.code !== 'EADDRINUSE') throw refuse(`Could not listen on ${host} port ${port}: ${error.code === 'EACCES' ? 'permission denied' : error.code ?? 'socket error'}. Check the address and permissions, then run rer dev again or use rer setup --port PORT with a free port.`);
|
|
20
|
+
if (error.code !== 'EADDRINUSE') throw refuse(`Could not listen on ${host} port ${port}: ${error.code === 'EACCES' ? 'permission denied' : error.code ?? 'socket error'}. Check the address and permissions, then run ~/.local/bin/rer dev again or use ~/.local/bin/rer setup --port PORT with a free port.`);
|
|
21
21
|
const unavailable = async listener => refuse(await busyPortMessage({ port, host, root: process.cwd(), context, listener: listener ?? null }));
|
|
22
22
|
if (context && performance.now() >= context.deadline) throw await unavailable();
|
|
23
23
|
const { inspectionContext } = await shared('process-diagnostics.mjs');
|
package/cli/listing.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { previousListing } from '../modules/release/previous-listing.mjs';
|
|
|
3
3
|
|
|
4
4
|
export async function dispatchListing(args) {
|
|
5
5
|
if (args.length === 1 && args[0] === '--help') {
|
|
6
|
-
console.log('Usage: rer listing --repo DIR --ref COMMIT --output NEW_DIR\n\nRead committed listing facts and assets without gates, signing or tags.\nWrites listing.json and its relative asset paths. --ref defaults to HEAD.');
|
|
6
|
+
console.log('Usage: ~/.local/bin/rer listing --repo DIR --ref COMMIT --output NEW_DIR\n\nRead committed listing facts and assets without gates, signing or tags.\nWrites listing.json and its relative asset paths. --ref defaults to HEAD.');
|
|
7
7
|
return 0;
|
|
8
8
|
}
|
|
9
9
|
try {
|
package/cli/local-env.mjs
CHANGED
|
@@ -27,7 +27,7 @@ export async function refuseLocalEnvOutput(root, outputs, { uploaded = false } =
|
|
|
27
27
|
try { await refuseLocalEnvFiles(root, outputs ?? ['dist']); }
|
|
28
28
|
catch (error) {
|
|
29
29
|
if (!error.resource) throw error;
|
|
30
|
-
if (uploaded) throw refuse(`The deploy hook's build output holds the local settings file ${error.resource}, and the hook has already uploaded its build, so it may be on the live Worker. Remove what copies it into the build output, rotate every credential in that file, then run rer deploy again.`);
|
|
30
|
+
if (uploaded) throw refuse(`The deploy hook's build output holds the local settings file ${error.resource}, and the hook has already uploaded its build, so it may be on the live Worker. Remove what copies it into the build output, rotate every credential in that file, then run ~/.local/bin/rer deploy again.`);
|
|
31
31
|
throw refuse(`The build output holds the local settings file ${error.resource}; a deployment never carries one. Remove what puts it there (a file in public/, or a build step that copies it), then run the command again. Nothing was uploaded.`);
|
|
32
32
|
}
|
|
33
33
|
}
|
package/cli/local.mjs
CHANGED
|
@@ -36,7 +36,7 @@ export async function selectedOrigin(project, options, { setup = false } = {}) {
|
|
|
36
36
|
// Setup on a saved checkout moves it to another port; the host stays.
|
|
37
37
|
let moved;
|
|
38
38
|
if (setup && previous && previous.origin !== url) {
|
|
39
|
-
if (previous.hostname.replace(/^\[|\]$/g, '') !== host) throw refuse('Setup origin conflicts with the saved installation. Reuse its origin or back up data and run rer reset --yes.');
|
|
39
|
+
if (previous.hostname.replace(/^\[|\]$/g, '') !== host) throw refuse('Setup origin conflicts with the saved installation. Reuse its origin or back up data and run ~/.local/bin/rer reset --yes.');
|
|
40
40
|
moved = { from: savedPort, to: port };
|
|
41
41
|
}
|
|
42
42
|
return { url, host, port, vars, savedOrigin: previous?.origin, moved, explicitPort: options.port !== undefined, ...(taken ? { skipped: defaultPort } : {}) };
|
|
@@ -48,7 +48,7 @@ export async function availablePort(host, port, { root, saved = false, verb = 'd
|
|
|
48
48
|
const context = inspectionContext({port,verb});
|
|
49
49
|
const result = await probePort(host, port, { context });
|
|
50
50
|
if (result.available) return;
|
|
51
|
-
if (result.code && result.code !== 'EADDRINUSE') throw refuse(`Port ${port} cannot be used on ${host}: ${result.code}. Check the address or use rer setup --port PORT with a free port, then run rer dev again.`);
|
|
51
|
+
if (result.code && result.code !== 'EADDRINUSE') throw refuse(`Port ${port} cannot be used on ${host}: ${result.code}. Check the address or use ~/.local/bin/rer setup --port PORT with a free port, then run ~/.local/bin/rer dev again.`);
|
|
52
52
|
throw refuse(await busyPortMessage({ port, host, root, saved, context, listener: result.listener ?? null }));
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -80,7 +80,7 @@ export async function reset(project, options, out) {
|
|
|
80
80
|
async function resetHeld(project,options,out,operation) {
|
|
81
81
|
await refuseLegacyProcess(project,{reset:true,verb:'reset',operation});
|
|
82
82
|
const { strandedOriginals } = await shared('local/recovery.mjs');
|
|
83
|
-
if ((await strandedOriginals(project.root)).length) throw refuse('An interrupted build holds private settings. Run rer build to recover them before reviewing reset.');
|
|
83
|
+
if ((await strandedOriginals(project.root)).length) throw refuse('An interrupted build holds private settings. Run ~/.local/bin/rer build to recover them before reviewing reset.');
|
|
84
84
|
// The seed's own safety check (legacy data it still has to recover, for
|
|
85
85
|
// example) runs before the inventory and confirmation; --yes cannot skip it.
|
|
86
86
|
const preflight = project.adapter.resetPreflight;
|
|
@@ -124,7 +124,7 @@ export async function refuseLegacyProcess(project,{reset=false,verb='dev',operat
|
|
|
124
124
|
if(!isolated){
|
|
125
125
|
const {sqliteCustody}=await shared('local/sqlite-custody.mjs');
|
|
126
126
|
const database=await sqliteCustody(project.root);
|
|
127
|
-
if(database)throw refuse(`Another process holds an active SQLite lock on ${database}. Process inspection did not identify its PID. Stop unmanaged local servers (including Wrangler), then retry. Use rer dev --stop or rer preview --stop for a registered server.`);
|
|
127
|
+
if(database)throw refuse(`Another process holds an active SQLite lock on ${database}. Process inspection did not identify its PID. Stop unmanaged local servers (including Wrangler), then retry. Use ~/.local/bin/rer dev --stop or ~/.local/bin/rer preview --stop for a registered server.`);
|
|
128
128
|
}
|
|
129
129
|
return {lockProof:true};
|
|
130
130
|
}
|
package/cli/managed-server.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { launchSummary } from './run-transfers.mjs';
|
|
2
2
|
import { readySummary } from './ready-summary.mjs';
|
|
3
|
+
import { ownerEntryReady } from './owner-entry-ready.mjs';
|
|
3
4
|
import { nativeOwnerEntry } from './native-owner-entry.mjs';
|
|
4
5
|
import { prepareLiveModels } from './ai-local.mjs';
|
|
5
6
|
import {fileURLToPath} from 'node:url';
|
|
@@ -32,19 +33,19 @@ export async function ready(out,url,dev,json=false,siteUrl,demo,root,ownerOpenUr
|
|
|
32
33
|
out.human(`RER_READY ${url}`);
|
|
33
34
|
if(dev){
|
|
34
35
|
if(dev.signedInAs)out.human(`RER_SIGNED_IN ${dev.signedInAs}`);
|
|
35
|
-
else if(dev.ownerLeft)out.human('No active owner remains in this app. Use rer dev --as PERSONA with an active operator, or rer reset --yes and rer setup for a new owner.');
|
|
36
|
+
else if(dev.ownerLeft)out.human('No active owner remains in this app. Use ~/.local/bin/rer dev --as PERSONA with an active operator, or ~/.local/bin/rer reset --yes and ~/.local/bin/rer setup for a new owner.');
|
|
36
37
|
out.human(`RER_OPEN ${dev.openUrl}`);
|
|
37
38
|
if (!root && !dev.native) out.human("Open that link on this computer. Its fragment holds this checkout's dev key, which the page keeps only as a cookie; never share the link.");
|
|
38
39
|
}
|
|
39
40
|
if(ownerOpenUrl){out.human(`RER_OWNER_OPEN ${ownerOpenUrl}`);out.human('Native owner entry: open on this computer once within 15 minutes. The link is not saved.');}
|
|
40
41
|
if(siteUrl){if(!root)out.human(`Site: ${siteUrl}`);out.human(`RER_SITE ${siteUrl}`);}
|
|
41
|
-
if(demo){out.human(`RER_DEMO_ENDS_ON_STOP ${demo.state}`);out.human(`This demo runs on its own data in that folder, which is deleted when it stops: rer demo --stop, Ctrl-C, or at its end (${demo.ends.slice(11,16)}). Public reads and checks run for real. This checkout's own data is untouched.`);}
|
|
42
|
+
if(demo){out.human(`RER_DEMO_ENDS_ON_STOP ${demo.state}`);out.human(`This demo runs on its own data in that folder, which is deleted when it stops: ~/.local/bin/rer demo --stop, Ctrl-C, or at its end (${demo.ends.slice(11,16)}). Public reads and checks run for real. This checkout's own data is untouched.`);}
|
|
42
43
|
}
|
|
43
44
|
export async function managedServer(project,options,out,{clock={}}={}){
|
|
44
45
|
const registry=await serverRegistry(project.root),controller=new AbortController();
|
|
45
46
|
// A demo registers as its own mode: `rer dev --stop` never stops it by accident.
|
|
46
47
|
const mode=options.demo?'demo':options.verb;
|
|
47
|
-
let store,operation,proxy,activity,app,termination,reason,cleanupPromise,finished,selected,cleaned,site,demo,demoEnd,ownerEntry;
|
|
48
|
+
let store,operation,proxy,activity,app,termination,reason,cleanupPromise,finished,selected,cleaned,site,demo,demoEnd,ownerEntry,forwarding=false;
|
|
48
49
|
const scheduling=new AbortController();
|
|
49
50
|
let activityWrites=Promise.resolve(),pendingActivity,activityWriting=false,infrastructureFailure;
|
|
50
51
|
function recordActivity(fields){
|
|
@@ -85,11 +86,12 @@ export async function managedServer(project,options,out,{clock={}}={}){
|
|
|
85
86
|
if(devIdentity)devKey=await requireDevKey(project.root);
|
|
86
87
|
// A key is sent (or printed) for a door origin only once the door proves it is ours.
|
|
87
88
|
if(devIdentity)await verifyDoorFor(running.url);
|
|
88
|
-
const
|
|
89
|
-
await
|
|
89
|
+
const ownerOpenUrl=await checkedNativeEntry(project.root,()=>registry.ownerEntry(running).then(value=>value.ownerOpenUrl),controller.signal);
|
|
90
|
+
const dev=devIdentity&&options.verb==='dev'&&await devReady(project.root,running.url,devKey,options,controller.signal);
|
|
91
|
+
await emitReady(out,options,project.root,running.url,dev,running.siteUrl,running.demo,ownerOpenUrl);return {reused:true};
|
|
90
92
|
}
|
|
91
93
|
await registry.serve(async action=>{
|
|
92
|
-
if(action==='status')return {...activity?.snapshot(),url:selected?.url,probe:proxy?.probe,siteUrl:site?.url,demo};
|
|
94
|
+
if(action==='status')return {...activity?.snapshot(),forwarding,url:selected?.url,probe:proxy?.probe,siteUrl:site?.url,demo};
|
|
93
95
|
if(action==='owner-entry')return ownerEntry?{ownerOpenUrl:ownerEntry.issue()}:{};
|
|
94
96
|
if(action==='stop')return stop('explicit stop');
|
|
95
97
|
throw Error('Unknown management operation');
|
|
@@ -105,12 +107,17 @@ export async function managedServer(project,options,out,{clock={}}={}){
|
|
|
105
107
|
const keys=localSettingKeys(project);
|
|
106
108
|
selected=await selectedOrigin(project,options);
|
|
107
109
|
if(!selected.door)await availablePort(selected.host,selected.port,{root:project.root,saved:!selected.explicitPort&&selected.savedOrigin!==undefined,verb:options.verb});
|
|
108
|
-
if(!selected.vars[keys.email])throw missing(
|
|
110
|
+
if(!selected.vars[keys.email])throw missing(`Local prerequisite ${keys.email}: found unset; expected set; run ~/.local/bin/rer setup.`);
|
|
109
111
|
if(devIdentity&&!devKey)devKey=await requireDevKey(project.root);
|
|
110
112
|
if(devIdentity&&['dev','preview'].includes(options.verb))refuseManagedInstallation(selected.vars,process.env);
|
|
111
113
|
if(options.demo)demo=await demoPreflight(project,selected.vars,options.idleTimeout);
|
|
112
114
|
const prerequisites=async()=>{
|
|
113
|
-
if(
|
|
115
|
+
if(demo||!project.adapter.localPrerequisites)return;
|
|
116
|
+
const result=await project.adapter.localPrerequisites({root:project.root,vars:selected.vars,email:selected.vars[keys.email],demo:false});
|
|
117
|
+
if(result===true)return;
|
|
118
|
+
// Older adapters can still return false; named failures carry only safe values.
|
|
119
|
+
const {field,found,expected}=result||{field:'localPrerequisites',found:'false',expected:'true'};
|
|
120
|
+
throw missing(`Local prerequisite ${field}: found ${found}; expected ${expected}; run ~/.local/bin/rer setup.`);
|
|
114
121
|
};
|
|
115
122
|
if(options.verb!=='dev')await prerequisites();
|
|
116
123
|
await registry.update({url:selected.url,host:selected.host,port:selected.port,models:options.models??'fake'});
|
|
@@ -140,10 +147,16 @@ export async function managedServer(project,options,out,{clock={}}={}){
|
|
|
140
147
|
if(!identity)throw Error('Runtime exited before custody registration.');
|
|
141
148
|
await registry.update({runtimeProcess:{pid:identity.pid,start:identity.start}});
|
|
142
149
|
},controller.signal,{...adapterOptions,verb:options.verb,dev:project.adapter.dev,preview:project.adapter.preview});
|
|
150
|
+
// The runtime can receive public requests now. Keep announcement/registry
|
|
151
|
+
// readiness false until the browser has verified that same public door.
|
|
152
|
+
forwarding=true;
|
|
143
153
|
// A key is sent (or printed) for a door origin only once the door proves it is ours.
|
|
144
154
|
if(devKey)await verifyDoorFor(selected.url);
|
|
145
155
|
if(demo)await demoGuarded(selected.url,demo.state,controller.signal);
|
|
146
|
-
|
|
156
|
+
// Demo's dev-key exchange is authorized only after a native entry exists.
|
|
157
|
+
// Verify that entry first, then leave a fresh single-use link for the owner.
|
|
158
|
+
const ownerOpenUrl=await checkedNativeEntry(project.root,()=>ownerEntry?.issue(),controller.signal,store);
|
|
159
|
+
const dev=devIdentity&&options.verb==='dev'&&await devReady(project.root,selected.url,devKey,options,controller.signal,store);
|
|
147
160
|
if(options.verb==='dev'&&project.adapter.site){
|
|
148
161
|
const {devSite}=await import('./site.mjs');
|
|
149
162
|
try {
|
|
@@ -151,11 +164,11 @@ export async function managedServer(project,options,out,{clock={}}={}){
|
|
|
151
164
|
await registry.update({siteUrl:site.url});
|
|
152
165
|
} catch(error) {
|
|
153
166
|
if(error.code!=='site_private_data')throw error;
|
|
154
|
-
const message=`Run site preview refused: ${error.message} The app is running; fix the site and run rer build --site before publishing it.`;
|
|
167
|
+
const message=`Run site preview refused: ${error.message} The app is running; fix the site and run ~/.local/bin/rer build --site before publishing it.`;
|
|
155
168
|
if(options.json)out.event('warning',{code:error.code,message});else out.progress(`Warning: ${message}\n`);
|
|
156
169
|
}
|
|
157
170
|
}
|
|
158
|
-
activity.ready();await emitReady(out,options,project.root,selected.url,dev,site?.url,demo,
|
|
171
|
+
activity.ready();await emitReady(out,options,project.root,selected.url,dev,site?.url,demo,ownerOpenUrl);
|
|
159
172
|
if(crons.length){
|
|
160
173
|
out.progress(`Running ${crons.length===1?'the scheduled trigger':'the scheduled triggers'} locally: ${crons.join(' | ')}\n`);
|
|
161
174
|
void runScheduled({crons,url:`http://127.0.0.1:${proxy.runtimePort}`,path:options.verb==='preview'?'/cdn-cgi/local/scheduled':undefined,signal:scheduling.signal,report:run=>reportScheduled(out,options,run)});
|
|
@@ -182,9 +195,19 @@ async function emitReady(out,options,root,url,dev,siteUrl,demo,ownerOpenUrl){
|
|
|
182
195
|
}
|
|
183
196
|
await ready(out,url,dev||(ownerOpenUrl?{openUrl:ownerOpenUrl,native:true}:undefined),options.json,siteUrl,demo,options.verb === 'dev' && !options.demo ? root : undefined,ownerOpenUrl);
|
|
184
197
|
}
|
|
185
|
-
async function devReady(url,key,options,signal){
|
|
198
|
+
async function devReady(root,url,key,options,signal,store){
|
|
186
199
|
const as=options.as??'owner',persona=await resolvePersona(url,key,as,signal);
|
|
187
200
|
// The owner persona names the owner the session will actually have (the
|
|
188
201
|
// remaining owner once the setup owner has left), or none when none is left.
|
|
189
|
-
|
|
202
|
+
const link=openUrl(url,key,{path:'/__dev/key',as:persona.as});
|
|
203
|
+
await ownerEntryReady(root,link,signal,store);
|
|
204
|
+
return {identity:true,signedInAs:persona.email??null,ownerLeft:as==='owner'&&!persona.email,openUrl:link};
|
|
205
|
+
}
|
|
206
|
+
async function checkedNativeEntry(root,issue,signal,store){
|
|
207
|
+
const link=await issue();
|
|
208
|
+
if(!link)return;
|
|
209
|
+
await ownerEntryReady(root,link,signal,store);
|
|
210
|
+
// The probe redeemed its single-use grant. Announce a fresh grant through
|
|
211
|
+
// that same checked public entry, leaving its redemption to the owner.
|
|
212
|
+
return issue();
|
|
190
213
|
}
|
package/cli/output.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withCommandHelp } from './command-guidance.mjs';
|
|
1
2
|
import { humanError } from './human-error.mjs';
|
|
2
3
|
import { handleBrokenPipes } from './stdio.mjs';
|
|
3
4
|
import { exportSummary } from './export-summary.mjs';
|
|
@@ -14,7 +15,7 @@ export function output(options) {
|
|
|
14
15
|
const write = (fd, text) => { const stream = fd === 1 ? process.stdout : process.stderr; if (!stream.destroyed) stream.write(text); };
|
|
15
16
|
return {
|
|
16
17
|
event(event, details = {}) { write(1, JSON.stringify({ version: 1, verb: options.verb ?? 'unknown', event, ...details }) + '\n'); },
|
|
17
|
-
human(text) { write(1, text + '\n'); },
|
|
18
|
+
human(text) { write(1, (options.json || structuredResult || options.verb === 'describe' ? text : withCommandHelp(text)) + '\n'); },
|
|
18
19
|
progress(text) { write(2, text); },
|
|
19
20
|
result(ok, exitCode, details = {}) {
|
|
20
21
|
if (finished) throw Error('Duplicate CLI result'); finished = true;
|