@runeditrun/rer 0.2.94 → 0.2.95
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 +3 -0
- package/cli/README.md +3 -0
- package/cli/agent-journey-fixtures.mjs +1 -1
- package/cli/authoring.mjs +1 -1
- package/cli/business/carry-files.mjs +115 -0
- package/cli/business/carry.mjs +20 -81
- package/cli/business/choices.mjs +12 -7
- package/cli/contract.mjs +1 -1
- package/cli/door-clauses.mjs +28 -2
- package/cli/hosted-output.mjs +4 -2
- package/cli/hosted-queue-producers.mjs +43 -0
- package/cli/jsonc.mjs +1 -115
- package/cli/parse.mjs +1 -1
- package/cli/portability-migrations.mjs +2 -12
- package/edition-authoring/archive-source.mjs +86 -1
- package/edition-authoring/base-copies.mjs +15 -45
- package/edition-authoring/cli.mjs +1 -1
- package/edition-authoring/edition-migrations.mjs +2 -2
- package/edition-authoring/module-closure.mjs +119 -50
- package/edition-authoring/module-packages.mjs +12 -5
- package/edition-authoring/module-syntax.mjs +13 -50
- package/edition-authoring/runtime-dependencies.mjs +4 -4
- package/global/CHANGELOG.md +38 -0
- package/global/README.md +3 -0
- package/modules/agent-door/CLAUSES.md +12 -0
- package/modules/agent-door/conformance/audit.mjs +22 -4
- package/modules/agent-door/conformance/discovery.mjs +32 -1
- package/modules/agent-door/conformance/erasure.mjs +103 -0
- package/modules/agent-door/conformance/journey.mjs +19 -1
- package/modules/agent-door/conformance/policy-phases.mjs +6 -0
- package/modules/agent-door/conformance/protocol.mjs +13 -3
- package/modules/deploy-kit/jsonc.mjs +115 -0
- package/modules/deploy-kit/migration-directory.mjs +16 -0
- package/modules/deploy-kit/prepare.mjs +1 -1
- package/modules/deploy-kit/templates.mjs +9 -4
- package/modules/erasure/cascade.mjs +4 -4
- package/modules/erasure/index.d.mts +1 -1
- package/modules/erasure/index.mjs +1 -1
- package/modules/import-kit/src/d1/README.md +16 -1
- package/modules/import-kit/src/d1/preserved-reverse.ts +5 -2
- package/modules/import-kit/src/d1/read-fence.ts +14 -2
- package/modules/import-kit/src/d1/reverse.ts +4 -1
- package/modules/import-kit/src/d1/sets.ts +8 -0
- package/modules/import-kit/src/d1/snapshot-text.ts +68 -0
- package/modules/import-kit/src/d1/undo-report.ts +4 -1
- package/modules/import-kit/src/door/ADOPTING.md +9 -4
- package/modules/portability/README.md +28 -2
- package/modules/portability/bookkeeping.mjs +8 -4
- package/modules/portability/checkout-history.mjs +12 -6
- package/modules/portability/import.mjs +1 -1
- package/modules/portability/storage.mjs +7 -1
- package/modules/portability/worker-history.d.mts +1 -1
- package/modules/portability/worker-history.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,9 @@ for adoption, refusal behavior, JSON fields and the original Base-checkout form.
|
|
|
23
23
|
contract, preserving its judgments and its own specialist clauses, then runs
|
|
24
24
|
contract document generation and checking. `rer door clauses --check` reports
|
|
25
25
|
missing or stale requirements without writing; use `--cwd DIR` to select a seed.
|
|
26
|
+
Writing requires a `Shared duties (Base)` table and skips duties listed in its
|
|
27
|
+
`Base duty` column. Unlisted duties are synchronized as clauses; a missing table
|
|
28
|
+
refuses the write. The read-only check still inspects clause definitions.
|
|
26
29
|
The CLI can sync a contract before runtime adoption; regenerate the seed's source lock last.
|
|
27
30
|
See [agent door adoption](https://github.com/runeditrun/base/blob/main/modules/agent-door/ADOPTING.md#contract-clauses).
|
|
28
31
|
|
package/cli/README.md
CHANGED
|
@@ -592,6 +592,9 @@ or use its stored device credential.
|
|
|
592
592
|
|
|
593
593
|
`rer door clauses --write` synchronizes Base's thirteen shared agent duties
|
|
594
594
|
into a seed's `CONTRACT.md` and runs its contract-docs generator and check.
|
|
595
|
+
It requires the seed's `Shared duties (Base)` table and skips duties listed
|
|
596
|
+
in its `Base duty` column; only unlisted duties need clause synchronization.
|
|
597
|
+
Without that table it refuses before writing any files.
|
|
595
598
|
`rer door clauses --check` names missing or stale clauses and exits nonzero;
|
|
596
599
|
`--cwd DIR` selects the seed root. Existing statuses, evidence and gaps survive,
|
|
597
600
|
new clauses start missing, and seed-owned AGENT and SURFACE clauses stay intact.
|
|
@@ -12,7 +12,7 @@ export async function journeyFixtures(root, declaration, context) {
|
|
|
12
12
|
const prepare = (await import(pathToFileURL(resolve(root, declaration.module)))).default;
|
|
13
13
|
if (typeof prepare !== 'function') throw new RerError('agent_fixtures_invalid', 'verification.fixtures module must default-export a phase preparation function.', 1);
|
|
14
14
|
return async ({ phase, tool, now }) => {
|
|
15
|
-
try { context.queues?.release(); return await prepare({ ...context, phase, tool, now }); }
|
|
15
|
+
try { context.queues?.release(); await context.queues?.restore(); return await prepare({ ...context, phase, tool, now }); }
|
|
16
16
|
catch (error) {
|
|
17
17
|
if (error instanceof FixtureDatabaseError || error?.code === 'hosted_database_invalid') throw new FixtureDatabaseError();
|
|
18
18
|
throw new Error('Native phase preparation failed; no captured mail, credentials or fixture values are logged.');
|
package/cli/authoring.mjs
CHANGED
|
@@ -10,7 +10,7 @@ export function authoringCommand(options) {
|
|
|
10
10
|
...(options.editionMigration ? options.editionMigration.split(',').flatMap(id => ['--edition-migration', id]) : []),
|
|
11
11
|
options.ref, '--record', options.record ?? 'base-copies.json',
|
|
12
12
|
...(options.base ? ['--base', resolve(options.cwd, options.base)] : []),
|
|
13
|
-
...(options.baseArchive ? ['--base-archive', resolve(options.cwd, options.baseArchive)] : []), ...(options.offline ? ['--offline'] : []),
|
|
13
|
+
...(options.baseArchive ? ['--base-archive', resolve(options.cwd, options.baseArchive)] : []), ...(options.offline ? ['--offline'] : []), ...(options.fromApi ? ['--from-api'] : []),
|
|
14
14
|
], 1));
|
|
15
15
|
} catch (error) { throw refuse(error.message); }
|
|
16
16
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { chmod, lstat, mkdir, readFile, rename, stat, unlink, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { loadState, stateDirectory } from './state.mjs';
|
|
5
|
+
import { serversDirectory } from '../server-registry.mjs';
|
|
6
|
+
import { alive } from '../../modules/job-queue/identity.mjs';
|
|
7
|
+
|
|
8
|
+
const carryPath = checkout => join(checkout, '.rer/local/business.json');
|
|
9
|
+
const registryPath = () => join(stateDirectory(), 'carried.json');
|
|
10
|
+
async function readJson(path) {
|
|
11
|
+
try { return JSON.parse(await readFile(path, 'utf8')); }
|
|
12
|
+
catch (error) { if (error.code === 'ENOENT') return null; throw error; }
|
|
13
|
+
}
|
|
14
|
+
async function recordedCheckouts() {
|
|
15
|
+
const recorded = await readJson(registryPath()) ?? [];
|
|
16
|
+
if (!Array.isArray(recorded)) throw Error('the carry registry is invalid');
|
|
17
|
+
return recorded;
|
|
18
|
+
}
|
|
19
|
+
async function atomicJson(path, value) {
|
|
20
|
+
const directory = dirname(path), temporary = join(directory, `${randomUUID()}.tmp`);
|
|
21
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
22
|
+
await chmod(directory, 0o700);
|
|
23
|
+
try {
|
|
24
|
+
await writeFile(temporary, JSON.stringify(value) + '\n', { flag: 'wx', mode: 0o600 });
|
|
25
|
+
await chmod(temporary, 0o600);
|
|
26
|
+
await rename(temporary, path);
|
|
27
|
+
} finally { await unlink(temporary).catch(error => { if (error.code !== 'ENOENT') throw error; }); }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function regular(path, directory = false, optional = false) {
|
|
31
|
+
let info;
|
|
32
|
+
try { info = await lstat(path); }
|
|
33
|
+
catch (error) { if (optional && error.code === 'ENOENT') return false; throw error; }
|
|
34
|
+
if (info.isSymbolicLink() || !(directory ? info.isDirectory() : info.isFile())) throw Error('the carry path is linked or not a regular file');
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
export async function firstParty(checkout) {
|
|
38
|
+
if (typeof checkout !== 'string' || !isAbsolute(checkout)) return false;
|
|
39
|
+
await regular(checkout, true);
|
|
40
|
+
await regular(join(checkout, 'OPERATIONS.json'));
|
|
41
|
+
return (await readJson(join(checkout, 'OPERATIONS.json')))?.seedContract?.profile === 'first-party';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// This file is generated Business carry, not an app's own settings. Its supported
|
|
45
|
+
// profile values remain carry-owned; unknown documents and foreign carries do not.
|
|
46
|
+
function ownsCarry(prior, carry) {
|
|
47
|
+
return prior && !Array.isArray(prior) && prior.version === carry.version
|
|
48
|
+
&& prior.origin === carry.origin && prior.business_id === carry.business_id && prior.business_url === carry.business_url
|
|
49
|
+
&& typeof prior.name === 'string' && (prior.legal_name === null || typeof prior.legal_name === 'string')
|
|
50
|
+
&& (prior.accent === null || typeof prior.accent === 'string' && /^#[0-9a-f]{6}$/i.test(prior.accent))
|
|
51
|
+
&& (prior.logo_url === null || typeof prior.logo_url === 'string') && typeof prior.refreshed_at === 'string'
|
|
52
|
+
&& Object.keys(prior).length === Object.keys(carry).length + 1 && Object.keys(carry).every(key => Object.hasOwn(prior, key));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function writeCarry(checkout, carry, { existingOnly = false } = {}) {
|
|
56
|
+
if (!await firstParty(checkout)) throw Error('the checkout is not first-party');
|
|
57
|
+
const root = resolve(checkout), path = carryPath(root);
|
|
58
|
+
for (const directory of [join(root, '.rer'), dirname(path)]) await regular(directory, true, !existingOnly);
|
|
59
|
+
const exists = await regular(path, false, !existingOnly);
|
|
60
|
+
const prior = exists ? await readJson(path) : null;
|
|
61
|
+
if (exists && !ownsCarry(prior, carry)) throw Error('the existing file is not a carry for this paired Business');
|
|
62
|
+
const checkouts = await recordedCheckouts();
|
|
63
|
+
// Record custody before the write, so disconnect can clean up even after a crash.
|
|
64
|
+
if (!checkouts.includes(root)) await atomicJson(registryPath(), [...checkouts, root]);
|
|
65
|
+
if (prior && Object.keys(carry).every(key => prior[key] === carry[key])) {
|
|
66
|
+
for (const [file, mode] of [[dirname(path), 0o700], [path, 0o600]]) {
|
|
67
|
+
if (((await stat(file)).mode & 0o777) !== mode) await chmod(file, mode);
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
await atomicJson(path, { ...carry, refreshed_at: new Date().toISOString() });
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// The same read-only liveness check as the installed launcher's liveServers.
|
|
76
|
+
// Keep it portable: vendored Business commands have no global launcher files.
|
|
77
|
+
async function liveCheckouts() {
|
|
78
|
+
const registry = await readJson(join(serversDirectory(), 'state.json'));
|
|
79
|
+
const checkouts = [];
|
|
80
|
+
for (const record of registry?.running ?? []) {
|
|
81
|
+
let live = true;
|
|
82
|
+
try { live = await alive(record.owner); } catch { /* Unverifiable identities stay live, as in the registry. */ }
|
|
83
|
+
if (live) checkouts.push(record.checkout);
|
|
84
|
+
}
|
|
85
|
+
return [...new Set(checkouts)];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function carryCheckouts(refused) {
|
|
89
|
+
const checkouts = new Map();
|
|
90
|
+
try { for (const checkout of await recordedCheckouts()) checkouts.set(checkout, { checkout, live: false }); }
|
|
91
|
+
catch (error) { refused(error); }
|
|
92
|
+
try { for (const checkout of await liveCheckouts()) checkouts.set(checkout, { checkout, live: true }); }
|
|
93
|
+
catch (error) { refused(error); }
|
|
94
|
+
return [...checkouts.values()];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function removeCarries() {
|
|
98
|
+
const state = await loadState();
|
|
99
|
+
if (!state?.origin || !state.businessId) return;
|
|
100
|
+
const carry = { version: 1, origin: state.origin, business_id: state.businessId,
|
|
101
|
+
business_url: `${state.origin}/business/${encodeURIComponent(state.businessId)}`,
|
|
102
|
+
name: null, legal_name: null, accent: null, logo_url: null };
|
|
103
|
+
const recorded = await recordedCheckouts();
|
|
104
|
+
for (const checkout of new Set([...recorded, ...await liveCheckouts()])) {
|
|
105
|
+
try {
|
|
106
|
+
if (!await firstParty(checkout)) continue;
|
|
107
|
+
for (const directory of [join(checkout, '.rer'), dirname(carryPath(checkout))]) await regular(directory, true);
|
|
108
|
+
if (await regular(carryPath(checkout), false, true) && ownsCarry(await readJson(carryPath(checkout)), carry)) await unlink(carryPath(checkout));
|
|
109
|
+
} catch (error) {
|
|
110
|
+
// Disconnect must still clean eligible checkouts when an old one was removed,
|
|
111
|
+
// linked, repurposed or became unreadable. Leave unrelated files untouched.
|
|
112
|
+
if (!['ENOENT', 'ENOTDIR'].includes(error.code) && error.message !== 'the carry path is linked or not a regular file' && !(error instanceof SyntaxError)) throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
package/cli/business/carry.mjs
CHANGED
|
@@ -1,31 +1,12 @@
|
|
|
1
|
-
import { chmod, mkdir, readFile, rename, stat, unlink, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
1
|
import { Api } from './api.mjs';
|
|
5
2
|
import { createCredentialStore } from './keychain.mjs';
|
|
6
|
-
import { credentialHandle, loadState
|
|
3
|
+
import { credentialHandle, loadState } from './state.mjs';
|
|
7
4
|
import { localCause } from './errors.mjs';
|
|
8
|
-
import {
|
|
9
|
-
|
|
5
|
+
import { carryCheckouts, firstParty, writeCarry } from './carry-files.mjs';
|
|
6
|
+
export { removeCarries } from './carry-files.mjs';
|
|
10
7
|
|
|
11
|
-
const carryPath = checkout => join(checkout, '.rer/local/business.json');
|
|
12
8
|
const launched = Symbol.for('rer.business.carry.launched');
|
|
13
9
|
|
|
14
|
-
async function readJson(path) {
|
|
15
|
-
try { return JSON.parse(await readFile(path, 'utf8')); }
|
|
16
|
-
catch (error) { if (error.code === 'ENOENT') return null; throw error; }
|
|
17
|
-
}
|
|
18
|
-
async function atomicJson(path, value) {
|
|
19
|
-
const directory = dirname(path), temporary = join(directory, `${randomUUID()}.tmp`);
|
|
20
|
-
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
21
|
-
await chmod(directory, 0o700);
|
|
22
|
-
try {
|
|
23
|
-
await writeFile(temporary, JSON.stringify(value) + '\n', { flag: 'wx', mode: 0o600 });
|
|
24
|
-
await chmod(temporary, 0o600);
|
|
25
|
-
await rename(temporary, path);
|
|
26
|
-
} finally { await unlink(temporary).catch(error => { if (error.code !== 'ENOENT') throw error; }); }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
10
|
export function buildCarry(state, self) {
|
|
30
11
|
const business = self?.business;
|
|
31
12
|
if (!business) return null; // Older platforms have no local identity to carry.
|
|
@@ -44,65 +25,31 @@ export function buildCarry(state, self) {
|
|
|
44
25
|
logo_url: logo };
|
|
45
26
|
}
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
const root = resolve(checkout), path = carryPath(root), record = join(stateDirectory(), 'carried.json');
|
|
49
|
-
const checkouts = await readJson(record) ?? [];
|
|
50
|
-
// Record custody before the write, so disconnect can clean up even after a crash.
|
|
51
|
-
if (!checkouts.includes(root)) await atomicJson(record, [...checkouts, root]);
|
|
52
|
-
let prior;
|
|
53
|
-
try { prior = await readJson(path); } catch (error) { if (!(error instanceof SyntaxError)) throw error; }
|
|
54
|
-
const values = { ...prior };
|
|
55
|
-
delete values.refreshed_at;
|
|
56
|
-
if (Object.keys(values).length === Object.keys(carry).length && Object.keys(carry).every(key => values[key] === carry[key])) {
|
|
57
|
-
for (const [file, mode] of [[dirname(path), 0o700], [path, 0o600]]) {
|
|
58
|
-
if (((await stat(file)).mode & 0o777) !== mode) await chmod(file, mode);
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
await atomicJson(path, { ...carry, refreshed_at: new Date().toISOString() });
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function firstParty(checkout) {
|
|
67
|
-
return typeof checkout === 'string' && isAbsolute(checkout)
|
|
68
|
-
&& (await readJson(join(checkout, 'OPERATIONS.json')))?.seedContract?.profile === 'first-party';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// The same read-only registry view as the installed launcher's liveServers.
|
|
72
|
-
// Keep this reader in the exported CLI too: vendored Business commands have no global launcher files.
|
|
73
|
-
async function liveCheckouts() {
|
|
74
|
-
const registry = await readJson(join(serversDirectory(), 'state.json'));
|
|
75
|
-
const checkouts = [];
|
|
76
|
-
for (const record of registry?.running ?? []) {
|
|
77
|
-
let live = true;
|
|
78
|
-
try { live = await alive(record.owner); } catch { /* Unverifiable identities stay live, as in the registry. */ }
|
|
79
|
-
if (live) {
|
|
80
|
-
try { if (await firstParty(record.checkout)) checkouts.push(record.checkout); }
|
|
81
|
-
catch { /* A checkout with an unreadable descriptor is not a carry destination. */ }
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return [...new Set(checkouts)];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function warning(origin, error) {
|
|
28
|
+
function warning(origin, error, checkout) {
|
|
88
29
|
// Do not echo server text, response fields or transport messages: they can contain credentials.
|
|
89
30
|
const reason = error.status ? `the server refused the request (HTTP ${error.status})`
|
|
90
31
|
: error.name === 'TimeoutError' || error.name === 'AbortError' ? 'the server did not answer within 5 seconds'
|
|
91
32
|
: error.message?.startsWith('Could not reach the Business server at ') ? 'the server is unreachable'
|
|
92
33
|
: error.message === 'credential unavailable' ? 'the Business credential is unavailable in OS credential storage'
|
|
93
|
-
: localCause(error) ?? (['the response names another Business', 'the Business profile is invalid'].includes(error.message) ? error.message : 'the Business profile could not be refreshed');
|
|
94
|
-
process.stderr.write(`Business carry at ${origin}: ${reason}; keeping the local carry.\n`);
|
|
34
|
+
: localCause(error) ?? (['the response names another Business', 'the Business profile is invalid', 'the checkout is not first-party', 'the carry path is linked or not a regular file', 'the existing file is not a carry for this paired Business', 'the carry registry is invalid'].includes(error.message) ? error.message : 'the Business profile could not be refreshed');
|
|
35
|
+
process.stderr.write(`Business carry at ${origin}${checkout ? ` for ${JSON.stringify(checkout)}` : ''}: ${reason}; keeping the local carry.\n`);
|
|
95
36
|
}
|
|
96
37
|
|
|
97
|
-
export async function
|
|
38
|
+
export async function carryCheckIn(state, self) {
|
|
98
39
|
try {
|
|
40
|
+
if (!state?.origin || !state.businessId || !state.executorId || state.revoked) return;
|
|
99
41
|
const carry = buildCarry(state, self);
|
|
100
42
|
if (!carry) return;
|
|
101
|
-
const checkouts = [];
|
|
102
|
-
|
|
103
|
-
|
|
43
|
+
const checkouts = [], unchanged = [];
|
|
44
|
+
let failed = 0;
|
|
45
|
+
const refused = (error, checkout) => { failed++; warning(state.origin, error, checkout); };
|
|
46
|
+
for (const { checkout, live } of await carryCheckouts(refused)) {
|
|
47
|
+
try {
|
|
48
|
+
const changed = await writeCarry(checkout, carry, { existingOnly: !live });
|
|
49
|
+
(changed ? checkouts : unchanged).push(checkout);
|
|
50
|
+
} catch (error) { refused(error, checkout); }
|
|
104
51
|
}
|
|
105
|
-
return { name: carry.name, checkouts };
|
|
52
|
+
return { name: carry.name, checkouts, unchanged, failed };
|
|
106
53
|
} catch (error) { warning(state.origin, error); }
|
|
107
54
|
}
|
|
108
55
|
|
|
@@ -112,7 +59,7 @@ export async function refreshCarry(api, state, { checkout, signal } = {}) {
|
|
|
112
59
|
if (checkout) {
|
|
113
60
|
const carry = buildCarry(state, self);
|
|
114
61
|
if (carry) await writeCarry(checkout, carry);
|
|
115
|
-
} else await
|
|
62
|
+
} else await carryCheckIn(state, self);
|
|
116
63
|
} catch (error) { if (!signal?.aborted) warning(state.origin, error); }
|
|
117
64
|
}
|
|
118
65
|
|
|
@@ -123,14 +70,14 @@ export async function refreshCheckout(checkout) {
|
|
|
123
70
|
try {
|
|
124
71
|
if (!await firstParty(checkout)) return;
|
|
125
72
|
state = await loadState();
|
|
126
|
-
if (!state?.origin || !state.businessId || !state.executorId) return;
|
|
73
|
+
if (!state?.origin || !state.businessId || !state.executorId || state.revoked) return;
|
|
127
74
|
const credential = await createCredentialStore().get(credentialHandle(state.origin));
|
|
128
75
|
if (!credential) throw Error('credential unavailable');
|
|
129
76
|
await refreshCarry(new Api(state.origin, credential), state, { checkout });
|
|
130
77
|
} catch (error) { warning(state?.origin ?? 'the paired origin', error); }
|
|
131
78
|
}
|
|
132
79
|
|
|
133
|
-
//
|
|
80
|
+
// Reuse the supervisor's existing refresh cycle for live and previously carried apps.
|
|
134
81
|
export async function startCarryRefresh(api, state, signal) {
|
|
135
82
|
const controller = new AbortController(), combined = AbortSignal.any([signal, controller.signal]);
|
|
136
83
|
let pending = Promise.resolve(), busy = false;
|
|
@@ -141,11 +88,3 @@ export async function startCarryRefresh(api, state, signal) {
|
|
|
141
88
|
}, 60_000);
|
|
142
89
|
return async () => { clearInterval(timer); controller.abort(); await pending; };
|
|
143
90
|
}
|
|
144
|
-
|
|
145
|
-
export async function removeCarry(checkout) {
|
|
146
|
-
await unlink(carryPath(checkout)).catch(error => { if (error.code !== 'ENOENT') throw error; });
|
|
147
|
-
}
|
|
148
|
-
export async function removeCarries() {
|
|
149
|
-
const recorded = await readJson(join(stateDirectory(), 'carried.json')) ?? [];
|
|
150
|
-
for (const checkout of new Set([...recorded, ...await liveCheckouts()])) await removeCarry(checkout);
|
|
151
|
-
}
|
package/cli/business/choices.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { join } from 'node:path';
|
|
2
2
|
import { installService, removeService } from './service.mjs';
|
|
3
3
|
import { installPermissions, removePermissions } from './permissions.mjs';
|
|
4
4
|
import { saveState } from './state.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { carryCheckIn } from './carry.mjs';
|
|
6
6
|
import { businessCommand } from './invocation.mjs';
|
|
7
7
|
import { describe } from './errors.mjs';
|
|
8
8
|
|
|
@@ -55,7 +55,7 @@ export async function applyChoices(api, state, { reconnecting = false } = {}) {
|
|
|
55
55
|
// nothing is decided yet. On a new computer this first request activates it.
|
|
56
56
|
try { self = await api.get('/api/business/executors/self'); }
|
|
57
57
|
catch (error) { if (![403, 404].includes(error.status)) throw error; }
|
|
58
|
-
const carried = await
|
|
58
|
+
const carried = await carryCheckIn(state, self);
|
|
59
59
|
const decided = Object.fromEntries(names.map(name => [name, typeof self?.optIns?.[name] === 'boolean' ? self.optIns[name] : null]));
|
|
60
60
|
// The agent this computer reported when it paired, as the owner's browser words its choices:
|
|
61
61
|
// the Claude Code rules apply only to Claude Code. An unknown agent (no route yet) decides nothing.
|
|
@@ -89,9 +89,14 @@ export async function applyChoices(api, state, { reconnecting = false } = {}) {
|
|
|
89
89
|
if (undecided.length) {
|
|
90
90
|
once(`undecided:${undecided.join()}`, `The owner has not chosen yet:\n${undecided.map(name => ` - ${choices[name]}\n`).join('')}They choose on this computer's row in ${state.origin}/business/${encodeURIComponent(state.businessId)}/settings; the run and next commands apply the choices at their next check-in, ${reconnecting ? 'without pairing again' : 'so connect does not need to run again'}.\n`);
|
|
91
91
|
}
|
|
92
|
-
once('choices-next-step', `After choosing this computer's
|
|
93
|
-
if (carried)
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
once('choices-next-step', `After choosing this computer's permissions in Business, run ${businessCommand('next')} to apply them and see the next task.\n`);
|
|
93
|
+
if (carried) {
|
|
94
|
+
const count = carried.checkouts.length;
|
|
95
|
+
process.stdout.write(count
|
|
96
|
+
? `Refreshed ${count} local app carry ${count === 1 ? 'file' : 'files'} for ${JSON.stringify(carried.name)}:\n${carried.checkouts.map(checkout => ` - ${join(checkout, '.rer/local/business.json')}\n`).join('')}Supporting apps apply these values when they read their carry file.\n`
|
|
97
|
+
: `No local app carry files changed for ${JSON.stringify(carried.name)}.\n`);
|
|
98
|
+
for (const checkout of carried.unchanged) process.stdout.write(`Already current: ${join(checkout, '.rer/local/business.json')}\n`);
|
|
99
|
+
if (carried.failed) process.stdout.write(`${carried.failed} local app carry ${carried.failed === 1 ? 'file could' : 'files could'} not be refreshed; see the carry warnings.\n`);
|
|
100
|
+
}
|
|
96
101
|
return { applied: lines.length, serviceInstalled };
|
|
97
102
|
}
|
package/cli/contract.mjs
CHANGED
|
@@ -29,7 +29,7 @@ export const signinVerb = Object.freeze({ bootstrap: 'before', flags: [...common
|
|
|
29
29
|
// Their project-package bootstrap uses the same contract as every checkout verb.
|
|
30
30
|
export const authoringVerbs = Object.freeze({
|
|
31
31
|
'adopt-edition': {bootstrap: 'before', flags: [...commonFlags], effects: 'Add edition.json and sources.lock.json for the existing tracked local source, preserving declared project identity and existing copy/composition records. Create an empty base-copies.json only when none exists. Review and stage the new authoring inputs; no source regeneration, install setup or commit.'},
|
|
32
|
-
'refresh-base': {bootstrap: 'before', flags: [...commonFlags, '--ref', '--base', '--base-archive', '--record', '--offline', '--edition-migration'], effects: 'Consent to each declared edition edit with repeatable --edition-migration ID; refresh leaves the edit owed. Refresh recorded Base copies to --ref FULL_COMMIT, preserving acknowledged adaptations and applied migrations; announce removed singleton retirement. Deliver invoked workflow helpers atomically; adopt tracked known historical Verify templates and preserve divergent workflows with adoption notices. Acquire committed source from the declared Base repository (default https://github.com/runeditrun/base.git), or use --base CHECKOUT or --base-archive DIRECTORY with --ref FULL_COMMIT for an exported source tree. --offline requires --base and never acquires remote source. Refuse incomplete Git checkouts without changing their records. Review the diff and run edition tests before committing.'},
|
|
32
|
+
'refresh-base': {bootstrap: 'before', flags: [...commonFlags, '--ref', '--base', '--base-archive', '--from-api', '--record', '--offline', '--edition-migration'], effects: 'Consent to each declared edition edit with repeatable --edition-migration ID; refresh leaves the edit owed. Refresh recorded Base copies to --ref FULL_COMMIT, preserving acknowledged adaptations and applied migrations; announce removed singleton retirement. Deliver invoked workflow helpers atomically; adopt tracked known historical Verify templates and preserve divergent workflows with adoption notices. Acquire committed source from the declared Base repository (default https://github.com/runeditrun/base.git), or read immutable trees, blobs and ancestry through authenticated gh with --from-api, or use --base CHECKOUT or --base-archive DIRECTORY with --ref FULL_COMMIT for an exported source tree. --offline requires --base or --base-archive and never acquires remote source. Refuse incomplete Git checkouts without changing their records. Review the diff and run edition tests before committing.'},
|
|
33
33
|
});
|
|
34
34
|
export const aliases = Object.fromEntries([...Object.keys(verbs).filter(v => v !== 'install'), 'release', 'deps', 'rer'].map(name => [name, name === 'deps' ? 'install' : name === 'rer' ? null : name]));
|
|
35
35
|
export const releaseFlags = ['--repo', '--project', '--repository', '--output', '--ref', '--public-base', '--dry-run', '--local-verify', '--verify-workflow', '--scan-timeout-seconds', '--tag', '--clean-history', '--onto', '--env-file', '--allow-placeholder-mark', '--no-queue'];
|
package/cli/door-clauses.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { resolve, relative, isAbsolute } from 'node:path';
|
|
5
|
-
import { parseContract } from '../foundation/runtime/seed-contract.mjs';
|
|
5
|
+
import { parseContract, plainText } from '../foundation/runtime/seed-contract.mjs';
|
|
6
6
|
import { RerError } from './errors.mjs';
|
|
7
7
|
|
|
8
8
|
export const clausesHelp = `Usage: rer door clauses (--write | --check) [--cwd DIR]
|
|
@@ -10,6 +10,7 @@ export const clausesHelp = `Usage: rer door clauses (--write | --check) [--cwd D
|
|
|
10
10
|
Synchronize BASE-AGENT-001 through BASE-AGENT-013 in CONTRACT.md.
|
|
11
11
|
--write adds or updates Base's requirements, preserving existing status,
|
|
12
12
|
evidence and gaps, then runs the seed's contract-docs write and check.
|
|
13
|
+
It requires a Shared duties (Base) table and skips duties listed there.
|
|
13
14
|
--check is read-only and names missing or stale clauses (exit 1).
|
|
14
15
|
Seed-owned clauses and the judged revision stay unchanged. Newly added clauses
|
|
15
16
|
start missing. Regenerate the seed's source lock last, before committing.
|
|
@@ -64,6 +65,29 @@ function headings(lines) {
|
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
function sharedDuties(original) {
|
|
69
|
+
const lines = original.split(/\r?\n/), outline = headings(lines);
|
|
70
|
+
const cells = line => line?.trim().replace(/^\|/, '').replace(/(?<!\\)\|$/, '').split(/(?<!\\)\|/).map(cell => cell.trim());
|
|
71
|
+
const section = outline.find(item => item.level === 2 && item.title.trim() === 'Shared duties (Base)');
|
|
72
|
+
const end = section && (outline.find(item => item.index > section.index && item.level <= 2)?.index ?? lines.length);
|
|
73
|
+
let fence;
|
|
74
|
+
for (let i = (section?.index ?? lines.length) + 1; i < end; i++) {
|
|
75
|
+
const mark = /^\s*(`{3,}|~{3,})/.exec(lines[i])?.[1];
|
|
76
|
+
if (mark) { if (!fence) fence = mark[0]; else if (fence === mark[0]) fence = undefined; continue; }
|
|
77
|
+
if (fence) continue;
|
|
78
|
+
if (!lines[i].trimStart().startsWith('|')) continue;
|
|
79
|
+
const header = cells(lines[i]), divider = cells(lines[i + 1]);
|
|
80
|
+
if (plainText(header[0]) !== 'Base duty' || divider?.length !== header.length || !divider.every(cell => /^:?-{3,}:?$/.test(cell))) continue;
|
|
81
|
+
const duties = new Set();
|
|
82
|
+
for (let row = i + 2; row < end && lines[row].trimStart().startsWith('|'); row++) {
|
|
83
|
+
const id = plainText(cells(lines[row])[0]);
|
|
84
|
+
if (/^BASE-AGENT-\d{3}$/.test(id)) duties.add(id);
|
|
85
|
+
}
|
|
86
|
+
return duties;
|
|
87
|
+
}
|
|
88
|
+
fail('CONTRACT.md needs a Shared duties (Base) table with a Base duty column before --write. Add the table, then retry; no files were written.');
|
|
89
|
+
}
|
|
90
|
+
|
|
67
91
|
// contract-docs owns summary generation. Suppress only its three derived rows
|
|
68
92
|
// for structural validation while a contract is awaiting regeneration.
|
|
69
93
|
function withoutSummary(text) {
|
|
@@ -139,7 +163,9 @@ export async function doorClausesCommand(args, env = process.env) {
|
|
|
139
163
|
root = resolve(root);
|
|
140
164
|
const file = resolve(root, 'CONTRACT.md');
|
|
141
165
|
if (!existsSync(file)) fail('No CONTRACT.md found. Run rer door clauses from the seed root or pass --cwd DIR.');
|
|
142
|
-
const original = read(file)
|
|
166
|
+
const original = read(file);
|
|
167
|
+
const inherited = mode === '--write' ? sharedDuties(original) : new Set();
|
|
168
|
+
const { text, changed } = synchronize(original, definitions(canonical(root)).filter(clause => !inherited.has(clause.id)));
|
|
143
169
|
if (changed.length) console.log(`Agent clauses: ${changed.join(', ')}.`);
|
|
144
170
|
if (mode === '--check' && changed.length) return 1;
|
|
145
171
|
const commands = generator(root);
|
package/cli/hosted-output.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import { shared } from './shared.mjs';
|
|
|
15
15
|
import { registerHistoryInstallation, preparationDatabase } from './agent-history-database.mjs';
|
|
16
16
|
import { verificationRpc } from './agent-rpc.mjs';
|
|
17
17
|
import { hostedOrigins } from './hosted-hosts.mjs';
|
|
18
|
+
import { preparationProducers } from './hosted-queue-producers.mjs';
|
|
18
19
|
import { FixtureDatabaseError } from '../modules/agent-door/conformance/fixtures.mjs';
|
|
19
20
|
|
|
20
21
|
// Serve the production build the way rer deploy hosts it (assets behind the
|
|
@@ -126,7 +127,7 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
126
127
|
durableObjects: Object.fromEntries((config.durable_objects?.bindings ?? []).filter(item => !item.script_name).map(item => [item.name, { className: item.class_name, useSQLite: true }])),
|
|
127
128
|
...(config.assets ? { assets: { directory: client, binding: config.assets.binding ?? 'ASSETS', routerConfig: { has_user_worker: true, invoke_user_worker_ahead_of_assets: RUN_WORKER_FIRST } } } : {}),
|
|
128
129
|
}] };
|
|
129
|
-
let preparation, held = false;
|
|
130
|
+
let preparation, producers, held = false;
|
|
130
131
|
const waiting = new Set();
|
|
131
132
|
const release = () => { held = false; for (const resume of waiting) resume(); waiting.clear(); };
|
|
132
133
|
// Install the gate before owner hooks retain any D1 handles; replacing
|
|
@@ -141,6 +142,7 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
141
142
|
if (held) await new Promise(resume => waiting.add(resume));
|
|
142
143
|
return new Response(null, { status: 204 });
|
|
143
144
|
} };
|
|
145
|
+
producers = preparationProducers(options, config);
|
|
144
146
|
}
|
|
145
147
|
const mf = new Miniflare(convertV4MiniflareOptions(options));
|
|
146
148
|
let loopback;
|
|
@@ -179,7 +181,7 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
179
181
|
}
|
|
180
182
|
catch { throw new Error('Native scheduled preparation failed; fixture values are not logged.'); }
|
|
181
183
|
},
|
|
182
|
-
queues: Object.freeze({ hold: () => { held = true; }, release }),
|
|
184
|
+
queues: Object.freeze({ hold: () => { held = true; }, release, ...producers(mf) }),
|
|
183
185
|
});
|
|
184
186
|
})(),
|
|
185
187
|
database: async binding => {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { RerError } from './errors.mjs';
|
|
2
|
+
|
|
3
|
+
// Only disposable conformance hosts install these RPC producers. The native
|
|
4
|
+
// queue lives behind the fault check, so a rejected send cannot enqueue work.
|
|
5
|
+
const producer = `import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
6
|
+
let failed = false;
|
|
7
|
+
// The default control entrypoint is available only to the host. Application
|
|
8
|
+
// bindings use Producer, which exposes only the queue operations below.
|
|
9
|
+
export default { fetch(request) { failed = new URL(request.url).pathname === '/fail'; return new Response(null, { status: 204 }); } };
|
|
10
|
+
export class Producer extends WorkerEntrypoint {
|
|
11
|
+
async send(body, options) { if (failed) throw new Error('Conformance queue producer failure.'); return this.env.QUEUE.send(body, options); }
|
|
12
|
+
async sendBatch(messages, options) { if (failed) throw new Error('Conformance queue producer failure.'); return this.env.QUEUE.sendBatch(messages, options); }
|
|
13
|
+
}`;
|
|
14
|
+
|
|
15
|
+
export function preparationProducers(options, config) {
|
|
16
|
+
const app = options.workers.find(worker => worker.name === 'app');
|
|
17
|
+
const declared = new Map();
|
|
18
|
+
const validate = binding => {
|
|
19
|
+
if (!declared.has(binding)) throw new RerError('hosted_queue_invalid', 'Queue preparation requires a declared producer binding.', 1);
|
|
20
|
+
};
|
|
21
|
+
for (const [index, item] of (config.queues?.producers ?? []).entries()) {
|
|
22
|
+
const name = `rer-conformance-queue-${index}`;
|
|
23
|
+
declared.set(item.binding, name);
|
|
24
|
+
options.workers.push({ name, modules: true, script: producer, compatibilityDate: config.compatibility_date,
|
|
25
|
+
queueProducers: { QUEUE: item.queue },
|
|
26
|
+
});
|
|
27
|
+
app.serviceBindings[item.binding] = { name, entrypoint: 'Producer' };
|
|
28
|
+
}
|
|
29
|
+
app.queueProducers = {};
|
|
30
|
+
return mf => {
|
|
31
|
+
const control = async (binding, action) => {
|
|
32
|
+
const response = await (await mf.getWorker(declared.get(binding))).fetch('https://queue.invalid/' + action, { method: 'POST' });
|
|
33
|
+
if (!response.ok) throw new RerError('hosted_queue_invalid', 'Disposable queue producer control failed.', 1);
|
|
34
|
+
};
|
|
35
|
+
return Object.freeze({
|
|
36
|
+
fail: binding => { validate(binding); return control(binding, 'fail'); },
|
|
37
|
+
restore: binding => {
|
|
38
|
+
if (binding === undefined) return Promise.all([...declared.keys()].map(name => control(name, 'restore')));
|
|
39
|
+
validate(binding); return control(binding, 'restore');
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
package/cli/jsonc.mjs
CHANGED
|
@@ -1,115 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const lines = text.slice(0, position).split('\n');
|
|
3
|
-
return `position ${position} (line ${lines.length} column ${lines.at(-1).length + 1})`;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// Validate JSONC before JSON.parse so diagnostics do not depend on the Node
|
|
7
|
-
// version's error wording. An explicit stack also handles deeply nested input.
|
|
8
|
-
// Only comments and commas accepted by the grammar are masked; offsets stay in
|
|
9
|
-
// the original source and comment removal can never join separate tokens.
|
|
10
|
-
export function parseJsonc(text, onProperty) {
|
|
11
|
-
const result = text.split(''), stack = [{ kind: 'root', state: 'value', path: [] }];
|
|
12
|
-
let index = 0;
|
|
13
|
-
const fail = (message, position = index) => {
|
|
14
|
-
throw new SyntaxError(`${position === text.length ? 'Unexpected end of JSON input' : message} at ${location(text, position)}`);
|
|
15
|
-
};
|
|
16
|
-
const unterminated = (kind, start) => {
|
|
17
|
-
throw new SyntaxError(`Unterminated ${kind} at ${location(text, start)}; close the ${kind}.`);
|
|
18
|
-
};
|
|
19
|
-
const blank = start => {
|
|
20
|
-
for (let i = start; i < index; i++) if (text[i] !== '\n' && text[i] !== '\r') result[i] = ' ';
|
|
21
|
-
};
|
|
22
|
-
const space = () => {
|
|
23
|
-
while (index < text.length) {
|
|
24
|
-
if (' \t\r\n'.includes(text[index])) { index++; continue; }
|
|
25
|
-
const start = index;
|
|
26
|
-
if (text[index] === '/' && text[index + 1] === '/') {
|
|
27
|
-
index += 2;
|
|
28
|
-
while (index < text.length && text[index] !== '\n' && text[index] !== '\r') index++;
|
|
29
|
-
} else if (text[index] === '/' && text[index + 1] === '*') {
|
|
30
|
-
const end = text.indexOf('*/', index + 2);
|
|
31
|
-
if (end === -1) unterminated('block comment', start);
|
|
32
|
-
index = end + 2;
|
|
33
|
-
} else break;
|
|
34
|
-
blank(start);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const string = () => {
|
|
38
|
-
const start = index++;
|
|
39
|
-
let end = index;
|
|
40
|
-
while (end < text.length && text[end] !== '"') end = Math.min(text.length, end + (text[end] === '\\' ? 2 : 1));
|
|
41
|
-
if (end === text.length) unterminated('string', start);
|
|
42
|
-
while (index < end) {
|
|
43
|
-
if (text.charCodeAt(index) < 32) fail('Unescaped control character in string');
|
|
44
|
-
if (text[index++] !== '\\') continue;
|
|
45
|
-
if (text[index] === 'u') {
|
|
46
|
-
index++;
|
|
47
|
-
for (let digit = 0; digit < 4; digit++, index++) {
|
|
48
|
-
if (index >= end || !/[0-9a-fA-F]/.test(text[index])) fail('Invalid Unicode escape');
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
if (!'"\\/bfnrt'.includes(text[index])) fail('Invalid string escape');
|
|
52
|
-
index++;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
index++;
|
|
56
|
-
};
|
|
57
|
-
const digit = () => index < text.length && text[index] >= '0' && text[index] <= '9';
|
|
58
|
-
const digits = () => {
|
|
59
|
-
if (!digit()) fail('Expected a digit');
|
|
60
|
-
do { index++; } while (digit());
|
|
61
|
-
};
|
|
62
|
-
const number = () => {
|
|
63
|
-
if (text[index] === '-') index++;
|
|
64
|
-
if (text[index] === '0') index++;
|
|
65
|
-
else digits();
|
|
66
|
-
if (text[index] === '.') { index++; digits(); }
|
|
67
|
-
if (text[index] === 'e' || text[index] === 'E') {
|
|
68
|
-
index++;
|
|
69
|
-
if (text[index] === '+' || text[index] === '-') index++;
|
|
70
|
-
digits();
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
while (stack.length) {
|
|
74
|
-
space();
|
|
75
|
-
const frame = stack.at(-1), char = text[index], closing = frame.kind === 'object' ? '}' : ']';
|
|
76
|
-
if (frame.state === 'end') {
|
|
77
|
-
if (index < text.length) fail('Unexpected token after JSON value');
|
|
78
|
-
stack.pop();
|
|
79
|
-
} else if ((frame.state === 'keyOrEnd' || frame.state === 'valueOrEnd' || frame.state === 'comma') && char === closing) {
|
|
80
|
-
index++; stack.pop();
|
|
81
|
-
} else if (frame.state === 'keyOrEnd') {
|
|
82
|
-
if (char !== '"') fail('Expected a property name');
|
|
83
|
-
const start = index; string();
|
|
84
|
-
frame.key = onProperty ? JSON.parse(text.slice(start, index)) : undefined;
|
|
85
|
-
onProperty?.([...frame.path, frame.key], start);
|
|
86
|
-
frame.state = 'colon';
|
|
87
|
-
} else if (frame.state === 'colon') {
|
|
88
|
-
if (char !== ':') fail("Expected ':' after property name");
|
|
89
|
-
index++; frame.state = 'value';
|
|
90
|
-
} else if (frame.state === 'comma') {
|
|
91
|
-
if (char !== ',') fail(`Expected ',' or '${closing}'`);
|
|
92
|
-
const comma = index++;
|
|
93
|
-
space();
|
|
94
|
-
if (text[index] === closing) result[comma] = ' ';
|
|
95
|
-
frame.state = frame.kind === 'object' ? 'keyOrEnd' : 'valueOrEnd';
|
|
96
|
-
} else {
|
|
97
|
-
const path = !onProperty ? undefined : frame.kind === 'root' ? [] : [...frame.path, frame.kind === 'array' ? frame.next++ : frame.key];
|
|
98
|
-
frame.state = frame.kind === 'root' ? 'end' : 'comma';
|
|
99
|
-
if (char === '{' || char === '[') {
|
|
100
|
-
index++;
|
|
101
|
-
stack.push({ kind: char === '{' ? 'object' : 'array', state: char === '{' ? 'keyOrEnd' : 'valueOrEnd', path, next: 0 });
|
|
102
|
-
} else if (char === '"') string();
|
|
103
|
-
else if (char === '-' || digit()) number();
|
|
104
|
-
else {
|
|
105
|
-
const literal = { t: 'true', f: 'false', n: 'null' }[char];
|
|
106
|
-
if (!literal) fail('Unexpected token in JSON value');
|
|
107
|
-
for (const expected of literal) {
|
|
108
|
-
if (text[index] !== expected) fail(`Expected '${literal}'`);
|
|
109
|
-
index++;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return JSON.parse(result.join(''));
|
|
115
|
-
}
|
|
1
|
+
export {parseJsonc} from '../modules/deploy-kit/jsonc.mjs';
|
package/cli/parse.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { authoringVerbs, commonFlags, serverDefaults, signinVerb, verbs } from '
|
|
|
3
3
|
import { invalid, refuse } from './errors.mjs';
|
|
4
4
|
import { isLoopbackHost } from '../modules/operator-auth/loopback.mjs';
|
|
5
5
|
import { normalizeEmail } from '../modules/operator-auth/policy.mjs';
|
|
6
|
-
const booleans = new Set(['--help', '--json', '--non-interactive', '--yes', '--dry-run', '--stop', '--detach', '--foreground', '--no-queue', '--login', '--legacy-v1', '--acknowledge-unverified-metadata', '--acknowledge-unverified-schema-objects', '--door', '--direct', '--site', '--remove', '--demo', '--offline']);
|
|
6
|
+
const booleans = new Set(['--help', '--json', '--non-interactive', '--yes', '--dry-run', '--stop', '--detach', '--foreground', '--no-queue', '--login', '--legacy-v1', '--acknowledge-unverified-metadata', '--acknowledge-unverified-schema-objects', '--door', '--direct', '--site', '--remove', '--demo', '--offline', '--from-api']);
|
|
7
7
|
export const mailbox = value => typeof value === 'string' && value.length <= 254 && /^[a-zA-Z0-9.!+_%\-]+@[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)+$/.test(value);
|
|
8
8
|
export const validOwnerName = value => typeof value === 'string' && Boolean(value.trim()) && value.length <= 200 && !/[\p{Cc}\p{Cf}]/u.test(value);
|
|
9
9
|
// A loopback host: the shared predicate (including `*.localhost` door names),
|