@runeditrun/rer 0.2.100 → 0.2.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +30 -102
  2. package/cli/README.md +16 -89
  3. package/cli/app-address.mjs +2 -0
  4. package/cli/business/api.mjs +2 -1
  5. package/cli/business/choices.mjs +1 -1
  6. package/cli/business/command.mjs +36 -30
  7. package/cli/business/connect.mjs +1 -1
  8. package/cli/business/lease.mjs +0 -9
  9. package/cli/business/local-commands.mjs +1 -27
  10. package/cli/business/outbound.mjs +2 -14
  11. package/cli/business/questions.mjs +85 -48
  12. package/cli/business/service.mjs +1 -24
  13. package/cli/business/setup-command.mjs +33 -26
  14. package/cli/business/state.mjs +1 -1
  15. package/cli/business/supervisor.mjs +26 -91
  16. package/cli/companion/command.mjs +2 -0
  17. package/cli/demo-native.mjs +1 -1
  18. package/cli/parse.mjs +2 -1
  19. package/global/CHANGELOG.md +24 -0
  20. package/global/README.md +30 -102
  21. package/global/main.mjs +2 -0
  22. package/modules/container/adapters/d1-limits.mjs +2 -10
  23. package/modules/d1-transport/limits.d.mts +10 -0
  24. package/modules/d1-transport/limits.mjs +10 -0
  25. package/modules/demo-host/native/prepare.mjs +2 -1
  26. package/modules/import-kit/schema/importers.schema.json +104 -2
  27. package/modules/import-kit/src/d1/README.md +13 -0
  28. package/modules/import-kit/src/d1/apply-reads.ts +48 -0
  29. package/modules/import-kit/src/d1/apply.ts +21 -8
  30. package/modules/import-kit/src/d1/history.ts +2 -2
  31. package/modules/import-kit/src/d1/types.ts +11 -0
  32. package/modules/import-kit/src/door/ADOPTING.md +0 -37
  33. package/modules/import-kit/src/door/README.md +0 -66
  34. package/modules/import-kit/src/door/admission.ts +3 -13
  35. package/modules/import-kit/src/door/authority.ts +0 -1
  36. package/modules/import-kit/src/door/failures.ts +1 -1
  37. package/modules/import-kit/src/door/grants.ts +5 -19
  38. package/modules/import-kit/src/door/handler.ts +1 -12
  39. package/modules/import-kit/src/door/index.ts +0 -6
  40. package/modules/import-kit/src/door/planning.ts +19 -44
  41. package/modules/import-kit/src/door/protocol.ts +2 -4
  42. package/modules/import-kit/src/door/schema.ts +0 -2
  43. package/modules/import-kit/src/door/store.ts +2 -2
  44. package/modules/import-kit/src/door/types.ts +1 -24
  45. package/modules/import-kit/src/provenance/credentials.ts +14 -5
  46. package/modules/import-kit/src/status/evidence.ts +3 -1
  47. package/modules/import-kit/src/status/index.ts +17 -2
  48. package/modules/import-kit/src/status/schema.ts +8 -0
  49. package/modules/import-kit/src/status/types.ts +25 -4
  50. package/package.json +1 -1
  51. package/cli/business/archive-task.mjs +0 -32
  52. package/cli/business/bounded-waves.d.mts +0 -23
  53. package/cli/business/bounded-waves.mjs +0 -57
  54. package/cli/business/catchup-task.mjs +0 -49
  55. package/cli/business/export-inputs.mjs +0 -79
  56. package/cli/business/export-task.mjs +0 -24
  57. package/cli/business/legacy-package.mjs +0 -117
  58. package/cli/business/package-transfer.mjs +0 -127
  59. package/cli/business/setup-demo.mjs +0 -95
  60. package/cli/business/vendor-door.mjs +0 -303
  61. package/cli/business/vendors/README.md +0 -215
  62. package/cli/business/vendors/calendly.mjs +0 -80
  63. package/cli/business/vendors/common.mjs +0 -280
  64. package/cli/business/vendors/credential-names.mjs +0 -124
  65. package/cli/business/vendors/index.mjs +0 -96
  66. package/cli/business/vendors/pagerduty.mjs +0 -61
  67. package/cli/business/vendors/sentry.mjs +0 -85
  68. package/cli/business/vendors/sorry.mjs +0 -106
  69. package/cli/business/vendors/uptimerobot.mjs +0 -21
  70. package/cli/business/vendors/zendesk-attachments.mjs +0 -57
  71. package/cli/business/vendors/zendesk-encode.mjs +0 -133
  72. package/cli/business/vendors/zendesk-guide.mjs +0 -34
  73. package/cli/business/vendors/zendesk-package.mjs +0 -28
  74. package/cli/business/vendors/zendesk-pages.mjs +0 -61
  75. package/cli/business/vendors/zendesk-people.mjs +0 -7
  76. package/cli/business/vendors/zendesk-store.mjs +0 -154
  77. package/cli/business/vendors/zendesk-tickets.mjs +0 -21
  78. package/cli/business/vendors/zendesk-token.mjs +0 -31
  79. package/cli/business/vendors/zendesk-transport.mjs +0 -48
  80. package/cli/business/vendors/zendesk.mjs +0 -61
  81. package/modules/import-kit/src/door/package.ts +0 -121
  82. package/modules/import-kit/src/door/waves/README.md +0 -158
  83. package/modules/import-kit/src/door/waves/digests.ts +0 -38
  84. package/modules/import-kit/src/door/waves/inventory.ts +0 -84
  85. package/modules/import-kit/src/door/waves/journal.ts +0 -19
  86. package/modules/import-kit/src/door/waves/lifecycle.ts +0 -242
  87. package/modules/import-kit/src/door/waves/preparation.ts +0 -190
  88. package/modules/import-kit/src/door/waves/schema.ts +0 -73
  89. package/modules/import-kit/src/door/waves/store.ts +0 -112
  90. package/modules/import-kit/src/door/waves/types.ts +0 -76
@@ -4,7 +4,6 @@ import { sensitive } from './detector.mjs';
4
4
  import { paired, revokedByServer, revokedText } from './local-commands.mjs';
5
5
  import { applyChoices } from './choices.mjs';
6
6
  import { businessCommand } from './invocation.mjs';
7
- import { titledVendor, keyStep, keyed, vendorNames, vendorHandle } from './vendor-door.mjs';
8
7
 
9
8
  const protocolVersion = '2025-11-25';
10
9
  const headers = { Accept: 'application/json, text/event-stream', 'MCP-Protocol-Version': protocolVersion };
@@ -36,7 +35,7 @@ export async function nextQuestions(api, signal) {
36
35
  if (!Array.isArray(result.tasks)) throw Error('Business server returned invalid task summaries.');
37
36
  return result.tasks;
38
37
  }
39
- const ownerKinds = new Set(['signup.checkout','connect.cloudflare','connect.github','consent.grant','confirm.inventory','plan.review','wave.approve','switchoff.cancel','cutover.billing','rollback.billing']);
38
+ const ownerKinds = new Set(['signup.checkout','connect.cloudflare','connect.github','consent.grant','confirm.inventory','plan.review']);
40
39
  export const ownerLink = state => `${state.origin}/business/${encodeURIComponent(identifier(state.businessId))}`;
41
40
 
42
41
  // What this computer is waiting for, in the owner's terms. Until its own
@@ -53,45 +52,72 @@ export function waitingFor(state) {
53
52
  return `Waiting for the next task. Nothing needs this computer until the owner moves the plan forward: ${ownerLink(state)}`;
54
53
  }
55
54
  const runWork = { 'discover.local': "this computer's names-only scan of the folders the owner allowed" };
56
- // The vendor tasks run performs into an app's import door, and what each one is, in the owner's terms.
57
- const vendorSteps = {
58
- 'export.vendor': name => `export the owner's ${name} history into its app's import door. It lands as a preview: nothing changes in the app until the owner approves it in the browser.`,
59
- 'catchup.vendor': name => `bring the owner's recent ${name} changes into its app's import door as a catch-up. Within the owner's standing catch-up approval Business applies it; anything larger waits for the owner's approval in the browser.`,
60
- 'switchoff.archive': name => `archive the owner's final ${name} export in its app's import door. The app keeps the exact file in its own storage and test-restores it with no writes; cancelling ${name} stays the owner's step.`,
61
- };
62
- const vendorStep = task => Object.hasOwn(vendorSteps, task.kind) && task.runner === 'executor' && ['ready', 'leased'].includes(task.state);
55
+ // A Move in step: the seed's own Move in page does the import; this computer's agent only brings the old tool's export to it.
56
+ const moveInStep = task => task.kind === 'move.in' && task.runner === 'executor' && ['ready', 'leased'].includes(task.state);
63
57
  const agentQuestion = task => task.kind === 'classify.row' && task.runner === 'executor' && ['ready', 'leased'].includes(task.state);
58
+ const known = new Set(['discover.local', 'classify.row', 'move.in', ...ownerKinds]);
59
+ // A step this rer does not handle is reported by its kind, never failed.
60
+ const unhandledStep = task => task.runner === 'executor' && ['ready', 'leased'].includes(task.state) && !known.has(task.kind);
64
61
 
65
- // A move's owner steps: freezing the old tool, a rollback (its card when Business
66
- // cannot undo the switch itself) and cancelling at the vendor. Each happens in the
67
- // browser and is never this computer's agent work.
68
- const moveSteps = {
69
- 'freeze.vendor': name => `freeze ${name} (pause changes in it as the move page lists), then confirm the freeze there`,
70
- rollback: () => 'follow the rollback card for this switch on the move page (Business undoes what it can itself and checks the rest)',
71
- 'switchoff.cancel': name => `cancel ${name} at the vendor once the move is ready to cancel, then confirm it there (RER never contacts the vendor)`,
72
- };
73
- const moveStep = kind => typeof kind !== 'string' ? null : kind.startsWith('rollback.') ? moveSteps.rollback : ['freeze.vendor', 'switchoff.cancel'].includes(kind) ? moveSteps[kind] : null;
74
- /** The move's page when the task names its tool, else the switch-over board (the Business home, which links each move). */
75
- function moveLink(state, task) {
76
- const tool = typeof task.tool_id === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,399}$/.test(task.tool_id) && !sensitive(task.tool_id) ? task.tool_id : null;
77
- return tool ? `${ownerLink(state)}/moves/${encodeURIComponent(tool)}` : ownerLink(state);
62
+ const text = (value, limit) => typeof value === 'string' && value.length > 0 && value.length <= limit && !sensitive(value) ? value.replace(/\s+/g, ' ').trim() : null;
63
+ /** An address on the seed or in the seed's repository, or null. Only https (or http on this machine) and no credentials. */
64
+ function address(value) {
65
+ if (typeof value !== 'string' || value.length > 2000) return null;
66
+ try {
67
+ const url = new URL(value);
68
+ if (url.username || url.password || sensitive(value)) return null;
69
+ if (url.protocol === 'https:' || url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)) return url.href;
70
+ } catch { /* Not an address. */ }
71
+ return null;
78
72
  }
79
- /** A move's owner step in plain words with its link, or null. The vendor is named from a closed local table. */
80
- export function ownerStep(task, state) {
81
- const step = moveStep(task.kind);
82
- if (!step) return null;
83
- const vendor = titledVendor(task.kind, task.title);
84
- return { words: step(vendor ? vendorNames[vendor] : 'the old tool'), link: moveLink(state, task) };
73
+ const accepted = { file: 'a file export from the old tool', key: "a read-only key for the old tool, entered in the seed's Move in page", address: "the old tool's public address, entered in the seed's Move in page" };
74
+
75
+ /** The seed's import-format document: a GitHub link pinned to its release commit (each path part is checked on its own,
76
+ * and the 40-hex commit id is not a credential), or another plain address. */
77
+ function formatLink(value) {
78
+ if (typeof value !== 'string' || value.length > 2000) return null;
79
+ try {
80
+ const url = new URL(value), pinned = url.pathname.match(/^\/[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}\/blob\/([0-9a-f]{40})\/[A-Za-z0-9_.~%/-]{1,500}$/);
81
+ if (url.protocol === 'https:' && url.hostname === 'github.com' && pinned && !url.username && !url.password && !url.search && !url.hash
82
+ && !url.pathname.split('/').some(part => part !== pinned[1] && sensitive(decodeURIComponent(part)))) return url.href;
83
+ } catch { /* Not an address. */ }
84
+ return address(value);
85
85
  }
86
- /** The owner steps of moves that Business lists, as what this computer waits for. */
87
- export function ownerWaiting(tasks, state) {
88
- return [...new Set(tasks.map(task => ownerStep(task, state)).filter(Boolean).map(step => `Waiting for the owner to ${step.words}: ${step.link}`))];
86
+ /** A Move in path on the seed (`/app/move-in`), or null. */
87
+ const movePath = value => typeof value === 'string' && /^\/[A-Za-z0-9._~!$&'()*+,;=:@%/-]{0,199}$/.test(value) && !value.startsWith('//') && !sensitive(value) ? value : null;
88
+
89
+ /** What the seed's Move in step asks of this computer's agent, in words. The step carries Business's view of the seed's own
90
+ * declaration (its pinned `importers.json` row): `{tool, app, app_name, app_address, move_in: {state, address, path, accepts,
91
+ * export, format}}`, with `state` one of `declared`, `format` or `not_declared`. Only closed shapes and short text are printed. */
92
+ export function moveInLines(task) {
93
+ const view = task.move_in && typeof task.move_in === 'object' ? task.move_in : {};
94
+ const move = view.move_in && typeof view.move_in === 'object' ? view.move_in : {};
95
+ const tool = text(view.tool, 80), app = text(view.app_name, 80) ?? text(view.app, 80), home = address(view.app_address);
96
+ const lines = [`Step: Move ${tool ?? 'the old tool'} into ${app ?? 'its seed'} with the seed's own Move in page. The seed shows the dry run's counts, imports and undoes; Business imports nothing itself.`];
97
+ const format = formatLink(move.format);
98
+ const page = move.state === 'declared' ? address(move.address) : null, path = move.state === 'declared' ? movePath(move.path) : null;
99
+ if (page) lines.push(`Move in page (sign in as the owner): ${page}`);
100
+ else if (path) lines.push(`Move in page (sign in as the owner): ${path} on the seed${home ? ` at ${home}` : ', once it has an address'}`);
101
+ else {
102
+ lines.push(`This seed declares no Move in page for the tool.${home ? ` Its address: ${home}` : ''}`);
103
+ if (move.state === 'format' && format) lines.push(`Export what the old tool offers, convert it to the seed's own import format and upload it in the seed. The format: ${format}`);
104
+ return lines;
105
+ }
106
+ const takes = Array.isArray(move.accepts) ? move.accepts.filter(item => Object.hasOwn(accepted, item)) : [];
107
+ if (takes.length) lines.push(`The seed takes: ${takes.map(item => accepted[item]).join('; or ')}.`);
108
+ const how = text(move.export, 1000);
109
+ if (how) lines.push(`How to export from the old tool: ${how}`);
110
+ if (format) lines.push(`The seed's own import format (for a tool it has no importer for): ${format}`);
111
+ return lines;
89
112
  }
90
113
 
91
114
  /** Agent steps that wait on this computer but not on run itself, in plain words. */
92
115
  export function agentWaiting(tasks) {
93
- return tasks.some(agentQuestion) ? [`A question waits for this computer's agent. Answer it with: ${businessCommand('next')}`] : [];
116
+ return [...(tasks.some(agentQuestion) ? [`A question waits for this computer's agent. Answer it with: ${businessCommand('next')}`] : []),
117
+ ...(tasks.some(moveInStep) ? [`A Move in step waits for this computer's agent. See it with: ${businessCommand('next')}`] : []),
118
+ ...(tasks.some(unhandledStep) ? [`Business has a step this version of rer does not handle (${[...new Set(tasks.filter(unhandledStep).map(task => kindName(task.kind)))].join(', ')}). Update rer, or do it in the browser.`] : [])];
94
119
  }
120
+ const kindName = kind => typeof kind === 'string' && /^[a-z][a-z0-9._-]{0,63}$/.test(kind) ? kind : 'unknown';
95
121
 
96
122
  function classification(task) {
97
123
  const toolId = identifier(task.question?.tool_id), vendorId = task.question?.vendor_id;
@@ -118,31 +144,21 @@ export async function next() {
118
144
  throw Error(`Business pairing expired or was revoked. This computer was ${revokedText(await revokedByServer(state))}`);
119
145
  }
120
146
  // This computer's agent hears its own steps first, then the owner's.
121
- const item = tasks.find(task => task.kind === 'classify.row' || vendorStep(task)) ?? tasks.find(task => task.runner === 'owner' || ownerKinds.has(task.kind) || moveStep(task.kind));
147
+ const item = tasks.find(task => task.kind === 'classify.row' || moveInStep(task)) ?? tasks.find(task => task.runner === 'owner' || ownerKinds.has(task.kind));
122
148
  if (!item) {
123
149
  // Nothing to answer here; say whether run has work, or what it waits for.
124
150
  const work = tasks.find(task => Object.hasOwn(runWork, task.kind) && task.state === 'ready');
125
151
  if (work) { process.stdout.write(`Ready for run: ${runWork[work.kind]}. Start it with: ${businessCommand('run --once')}\n`); return; }
126
- process.stdout.write(`${waitingFor(state)}\nNothing yet.\n`); return;
152
+ const unhandled = agentWaiting(tasks.filter(unhandledStep));
153
+ process.stdout.write(`${unhandled.length ? unhandled.join('\n') + '\n' : ''}${waitingFor(state)}\nNothing yet.\n`); return;
127
154
  }
128
155
  const id = identifier(item.task_id);
129
156
  if (sensitive(id)) throw Error('Business task identifier was refused by the outbound detector.');
130
- const step = ownerStep(item, state);
131
- if (step) {
132
- process.stdout.write(`Owner: ${id}\nOwner step, not this computer's agent work: ${step.words}.\nIn the browser: ${step.link}\n`); return;
133
- }
134
157
  if (item.runner === 'owner' || ownerKinds.has(item.kind)) {
135
158
  process.stdout.write(`Owner: ${id}\nAnswer in your browser: ${ownerLink(state)}\n`); return;
136
159
  }
137
- if (Object.hasOwn(vendorSteps, item.kind)) {
138
- // The vendor is named from a closed local table, never from server text.
139
- const vendor = titledVendor(item.kind, item.title), name = vendor ? vendorNames[vendor] : 'vendor';
140
- const stored = vendor && (state.vendorHandles ?? []).includes(vendorHandle(vendor));
141
- process.stdout.write(`Agent: ${id}\nStep: ${vendorSteps[item.kind](name)}\n`
142
- + (vendor && !keyed(vendor) ? `Vendor key: none; ${name} is read from its public page, with no key.\n`
143
- : stored ? `Vendor key: the owner's read-only ${name} key is stored in this computer's OS credential storage. To replace it, ${keyStep(vendor)}\n`
144
- : `Vendor key: ${keyStep(vendor)}${vendor ? '' : `\n where <vendor> is the tool this step reads: ${Object.keys(vendorNames).filter(keyed).join(' | ')}`}\n`)
145
- + `Then run: ${businessCommand('run --once')}\n`);
160
+ if (moveInStep(item)) {
161
+ process.stdout.write(`Agent: ${id}\n${moveInLines(item).join('\n')}\nWhen the owner has the data in the seed, finish this step: ${businessCommand(`done ${id} --note "what moved, from the dry run's counts"`)}\n`);
146
162
  return;
147
163
  }
148
164
  const { toolId, vendorId, vendors } = classification(item);
@@ -158,7 +174,7 @@ export async function answer(id, vendorId, choice, rawConfidence = '1') {
158
174
  const confidence = Number(rawConfidence);
159
175
  const { state, credential } = await paired(), api = new Api(state.origin, credential), signal = AbortSignal.timeout(55_000);
160
176
  const summary = await (await mcpClient(api, { signal }))('explain_task', { task_id: id });
161
- if (summary.runner === 'owner' || ownerKinds.has(summary.kind) || moveStep(summary.kind)) throw Error(`This item requires the owner in the browser: ${ownerStep(summary, state)?.link ?? ownerLink(state)}`);
177
+ if (summary.runner === 'owner' || ownerKinds.has(summary.kind)) throw Error(`This item requires the owner in the browser: ${ownerLink(state)}`);
162
178
  if (summary.kind !== 'classify.row' || summary.runner !== 'executor') throw Error('This item does not accept a CLI classification answer.');
163
179
  const { vendors } = classification(summary);
164
180
  if (!vendors.includes(vendorId)) throw Error('Choose a catalog vendor id from this question, or none.');
@@ -175,6 +191,27 @@ export async function answer(id, vendorId, choice, rawConfidence = '1') {
175
191
  process.stdout.write('Business answer submitted for server validation.\n');
176
192
  }
177
193
 
194
+ /** Finish a Move in step with a short note, through the same claim-then-complete answer door as a classification. */
195
+ export async function done(id, flag, note) {
196
+ identifier(id);
197
+ if (flag !== '--note' || typeof note !== 'string' || !note.trim() || note.length > 500) throw Error('Finish a Move in step with: done ID --note "what moved" (up to 500 characters).');
198
+ if (sensitive(note)) throw Error('The note looks like it holds a secret, so it was not sent. Say what moved, without keys or tokens.');
199
+ const { state, credential } = await paired(), api = new Api(state.origin, credential), signal = AbortSignal.timeout(55_000);
200
+ const summary = await (await mcpClient(api, { signal }))('explain_task', { task_id: id });
201
+ if (summary.kind !== 'move.in' || summary.runner !== 'executor') throw Error('This item is not a Move in step for this computer.');
202
+ const tool = await mcpClient(api, { taskId: id, signal });
203
+ let lease = summary;
204
+ if (summary.state === 'ready') lease = await tool('answer', { task_id: id, action: 'claim', client_event_id: randomUUID(), fence: summary.fence });
205
+ if (typeof lease.grant_id !== 'string') throw Error('Business did not return a grant for this step.');
206
+ try {
207
+ await tool('answer', { task_id: id, action: 'complete', client_event_id: randomUUID(), fence: lease.fence, grant_id: lease.grant_id, outputs: { note: note.trim() } });
208
+ } catch (error) {
209
+ try { await tool('answer', { task_id: id, action: 'release', client_event_id: randomUUID(), fence: lease.fence, grant_id: lease.grant_id, reason: 'failed' }); } catch { /* Expiry/revocation still fences the lease. */ }
210
+ throw error;
211
+ }
212
+ process.stdout.write('Business Move in step finished.\n');
213
+ }
214
+
178
215
  export async function token() {
179
216
  const { state, credential } = await paired();
180
217
  const result = await new Api(state.origin, credential).mintToken('mcp');
@@ -1,4 +1,4 @@
1
- import { execFile, spawn } from 'node:child_process';
1
+ import { execFile } from 'node:child_process';
2
2
  import { mkdir, readFile, writeFile, rename, unlink, realpath, stat, lstat, rmdir } from 'node:fs/promises';
3
3
  import { homedir } from 'node:os';
4
4
  import { dirname, join, isAbsolute } from 'node:path';
@@ -130,26 +130,3 @@ export async function serviceStatus(input = {}) {
130
130
  : await o.run('systemctl', ['--user', 'is-active', '--quiet', unit]);
131
131
  return { installed: true, running: result.code === 0 && (o.platform !== 'darwin' || /(?:^|\n)\s*state = running\s*(?:\n|$)/.test(result.stdout ?? '')) };
132
132
  }
133
-
134
- /** The caller holds an export lease only within this callback. -w also makes
135
- * caffeinate stop if the executor is killed before its finally block runs.
136
- */
137
- export async function withExportAwake(work, { consent = false, platform = process.platform, signal } = {}) {
138
- if (platform !== 'darwin') return work();
139
- if (consent !== true) throw new Error('Keeping this Mac awake for an export requires explicit consent.');
140
- signal?.throwIfAborted();
141
- const child = spawn('/usr/bin/caffeinate', ['-i', '-w', String(process.pid)], { stdio: 'ignore' });
142
- const closed = new Promise(resolve => child.once('close', resolve));
143
- const stop = () => { if (child.exitCode === null && !child.killed) child.kill('SIGTERM'); };
144
- const onExit = () => stop();
145
- try {
146
- await new Promise((resolve, reject) => { child.once('spawn', resolve); child.once('error', () => reject(new Error('Could not keep this Mac awake for the export.'))); });
147
- signal?.addEventListener('abort', stop, { once: true }); process.once('exit', onExit);
148
- signal?.throwIfAborted();
149
- return await work();
150
- } finally {
151
- signal?.removeEventListener('abort', stop); process.off('exit', onExit);
152
- stop();
153
- if (child.pid) await closed;
154
- }
155
- }
@@ -1,45 +1,31 @@
1
1
  import { constants } from 'node:fs';
2
- import { open } from 'node:fs/promises';
3
- import { setupDemo } from './setup-demo.mjs';
2
+ import { open, readFile } from 'node:fs/promises';
4
3
 
5
- // The platform command prints its receipt as JSON in both human and --json mode.
4
+ const company = JSON.parse(await readFile(new URL('./setup-company.json', import.meta.url), 'utf8'));
5
+
6
+ // The receipt is JSON in both human and --json mode.
6
7
  export async function setupCommand(args) {
7
- try { return await setup(args) ?? 0; }
8
+ try { return await setup(args); }
8
9
  catch (error) {
9
10
  // Paths, cookies and peer bodies must never appear in diagnostics.
10
- const code=typeof error?.message==='string'&&/^[a-z0-9_]{1,100}$/.test(error.message)?error.message:'demo_setup_failed';
11
+ const code=typeof error?.message==='string'&&/^[a-z0-9_]{1,100}$/.test(error.message)?error.message:'business_setup_failed';
11
12
  process.stderr.write(JSON.stringify({code})+'\n');return 1;
12
13
  }
13
14
  }
14
15
 
15
16
  async function setup(args){
16
- const usage=`Usage: rer business setup --origin URL --session-file FILE --confirm-demo [--hosting managed|assisted|self_host] [--wait-seconds 0..240] [--json]
17
- Provision the synthetic Run your business demo through the platform's owner routes.
18
- Run again to resume; completed seeds are read without provisioning again.
19
-
20
- --origin URL Platform address to set up the demo on.
21
- --session-file FILE The signed-in session file Business setup reads: an owned,
22
- regular 0600 file containing rer_session=VALUE or
23
- __Host-rer_session=VALUE. Symlinks are refused.
24
- The session is sent only as the platform Cookie header.
25
- --confirm-demo Required confirmation to provision the synthetic demo.
26
- --hosting MODE managed (default), assisted or self_host.
27
- --wait-seconds N Provisioning wait, 0..240 seconds (default: 240).
28
- --json Print the platform JSON receipt (also the default).
29
- --help, -h Show this help without reading the session file.`;
30
- if(args.some(arg => ['--help', '-h'].includes(arg))){process.stdout.write(usage+'\n');return;}
31
17
  const options={};
32
18
  for(let i=0;i<args.length;i++){
33
19
  if(args[i]==='--json'&&!options.json){options.json=true;continue;}
34
20
  if(args[i]==='--confirm-demo'){options.confirm=true;continue;}
35
- if(!['--origin','--session-file','--hosting','--wait-seconds'].includes(args[i])||!args[i+1]||Object.hasOwn(options,args[i]))throw Error('demo_arguments_invalid');
21
+ if(!['--origin','--session-file','--hosting'].includes(args[i])||!args[i+1]||Object.hasOwn(options,args[i]))throw Error('demo_arguments_invalid');
36
22
  options[args[i]]=args[++i];
37
23
  }
38
24
  if(!options.confirm||!options['--origin']||!options['--session-file'])throw Error('demo_confirmation_and_session_file_required');
39
25
  const url=new URL(options['--origin']);
40
26
  if(url.username||url.password||url.search||url.hash||url.pathname!=='/'||url.protocol!=='https:'&&!(url.protocol==='http:'&&['localhost','127.0.0.1','[::1]'].includes(url.hostname)))throw Error('demo_origin_invalid');
41
- const hosting=options['--hosting']??'managed',waitSeconds=Number(options['--wait-seconds']??240);
42
- if(!['managed','assisted','self_host'].includes(hosting)||!Number.isInteger(waitSeconds)||waitSeconds<0||waitSeconds>240)throw Error('demo_arguments_invalid');
27
+ const hosting=options['--hosting']??'managed';
28
+ if(!['managed','assisted','self_host'].includes(hosting))throw Error('demo_arguments_invalid');
43
29
  const handle=await open(options['--session-file'],constants.O_RDONLY|constants.O_NOFOLLOW);
44
30
  let cookie;
45
31
  try{
@@ -49,14 +35,35 @@ Run again to resume; completed seeds are read without provisioning again.
49
35
  if(!/^(?:__Host-)?rer_session=[^\s;]+$/.test(cookie))throw Error('demo_session_file_invalid');
50
36
  const session=cookie.slice(cookie.indexOf('=')+1);
51
37
  try {
52
- const receipt=await setupDemo({origin:url.origin,cookie,hosting,waitSeconds});
53
- const output=JSON.stringify(receipt,null,2)+'\n';
38
+ const output=JSON.stringify(await createBusiness({origin:url.origin,cookie,hosting}),null,2)+'\n';
54
39
  if(output.includes(session))throw Error('demo_session_in_response');
55
40
  process.stdout.write(output);
56
- if(receipt.complete !== true)return 1;
57
41
  return 0;
58
42
  } catch(error) {
59
43
  if(String(error?.message).includes(session))throw Error('demo_session_in_response');
60
44
  throw error;
61
45
  }
62
46
  }
47
+
48
+ /** Create, or reuse, the Business named in setup-company.json and give it that profile, through the owner's Business routes.
49
+ * A repeat whose Business and profile already match reads only. Cookies and peer bodies never enter the receipt. */
50
+ async function createBusiness({origin,cookie,hosting}){
51
+ const api=async(path,method='GET',body)=>{
52
+ let response;
53
+ try{response=await fetch(new URL(path,origin),{method,redirect:'manual',signal:AbortSignal.timeout(60000),headers:{Origin:origin,Cookie:cookie,'Content-Type':'application/json'},...(body===undefined?{}:{body:JSON.stringify(body)})});}
54
+ catch{throw Error('platform_transport_unavailable');}
55
+ let answer;try{answer=await response.json();}catch{throw Error(`platform_http_${response.status}`);}
56
+ if(!response.ok){const code=answer?.code;throw Error(typeof code==='string'&&/^[a-z0-9_]{1,100}$/.test(code)?code:`platform_http_${response.status}`);}
57
+ return answer;
58
+ };
59
+ let business=(await api('/api/business')).businesses?.find(row=>row.name===company.name);
60
+ const created=!business;
61
+ if(created)business=(await api('/api/business','POST',{name:company.name,default_hosting:hosting,executor_preference:hosting==='self_host'?'local':'managed'})).business;
62
+ if(typeof business?.id!=='string')throw Error('platform_business_invalid');
63
+ if(business.default_hosting!==hosting)throw Error('existing_demo_hosting_differs');
64
+ const root='/api/business/'+encodeURIComponent(business.id);
65
+ const current=created?{}:(await api(root+'/profile')).profile??{};
66
+ const changed=Object.entries(company.profile).some(([field,value])=>current[field]!==value);
67
+ if(changed)await api(root+'/profile','PUT',company.profile);
68
+ return {business_id:business.id,name:company.name,default_hosting:hosting,created,profile:changed?'saved':'unchanged'};
69
+ }
@@ -86,7 +86,7 @@ export async function checkStateWritable({ codeExists = true } = {}) {
86
86
 
87
87
  // Files this CLI writes in its state folder. A folder named by RER_BUSINESS_STATE_DIR
88
88
  // may hold other things, so only these are removed from it.
89
- const owned = /^(?:(?:state|pairing|progress|permissions|service|carried|legacy-package)\.json|(?:run|pairing)\.lock|disconnect|service(?:-error)?\.log|discovery-[A-Za-z0-9_.:-]+\.(?:json|tmp)|export-[0-9a-f]{32}\.bundle|package-[0-9a-f]{32}|.*[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.tmp(?:\.check)?)$/;
89
+ const owned = /^(?:(?:state|pairing|progress|permissions|service|carried)\.json|(?:run|pairing)\.lock|disconnect|service(?:-error)?\.log|discovery-[A-Za-z0-9_.:-]+\.(?:json|tmp)|export-[0-9a-f]{32}\.bundle|.*[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.tmp(?:\.check)?)$/;
90
90
  /** After a revocation whose local cleanup was refused, keep only what a later
91
91
  * disconnect needs to finish: the state and the receipts of what remains. */
92
92
  export async function removeWorkFiles(keep = ['state.json', 'permissions.json', 'service.json']) {
@@ -2,55 +2,27 @@ import { startCarryRefresh } from './carry.mjs';
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import { access, unlink } from 'node:fs/promises';
4
4
  import { join } from 'node:path';
5
- import { Api, taskPath, pause } from './api.mjs';
5
+ import { Api, pause } from './api.mjs';
6
6
  import { paired, revokedByServer, revokedText } from './local-commands.mjs';
7
- import { nextQuestions, ownerLink, waitingFor, agentWaiting, ownerWaiting } from './questions.mjs';
7
+ import { nextQuestions, ownerLink, waitingFor, agentWaiting } from './questions.mjs';
8
8
  import { lockSupervisor, stateDirectory, saveState, loadState } from './state.mjs';
9
9
  import { loadProgress, saveProgress } from './progress.mjs';
10
10
  import { Lease } from './lease.mjs';
11
11
  import { runDiscovery } from './discovery-task.mjs';
12
12
  import { applyChoices } from './choices.mjs';
13
13
  import { businessCommand } from './invocation.mjs';
14
- import { ExportWaiting, vendorHandle, titledVendor } from './vendor-door.mjs';
15
- import { runExport } from './export-task.mjs';
16
- import { runCatchup } from './catchup-task.mjs';
17
- import { runArchive } from './archive-task.mjs';
18
14
 
19
- // The vendor tasks this computer performs into an app's import door.
20
- const vendorWork = { 'export.vendor': runExport, 'catchup.vendor': runCatchup, 'switchoff.archive': runArchive };
21
- const kinds = new Set(['discover.local', ...Object.keys(vendorWork)]);
15
+ // The one task this computer performs itself: the names-only folder scan. Move in and every other step is reported by `next`.
16
+ const kinds = new Set(['discover.local']);
22
17
  export function supportsTaskKind(kind) { return kinds.has(kind); }
23
18
  const checkIn = 25_000;
24
19
 
25
- // Only these platform refusals hand work to the owner. Catch-up completion
26
- // has already surrendered its lease; an export-input wait never claims one.
27
- function ownerWait(error, state, task) {
28
- if (error.status !== 409) return null;
29
- const catchup = error.code === 'business_catchup_approval_required';
30
- if (!catchup && !(error.code === 'business_export_inputs_required' && error.state === 'waiting_for_owner')) return null;
31
- let link = ownerLink(state);
32
- if (catchup && typeof error.link === 'string') {
33
- try {
34
- const url = new URL(error.link, state.origin);
35
- if (url.origin === state.origin && !url.username && !url.password && !url.search && !url.hash
36
- && url.pathname.startsWith(new URL(link).pathname + '/moves/')) link = url.href;
37
- } catch { /* The Business page is where the owner can find this step. */ }
38
- }
39
- const vendor = task && titledVendor(task.kind, task.title);
40
- const step = catchup ? 'approve this catch-up' : vendor === 'sorry' ? 'confirm the address'
41
- : ['sentry', 'pagerduty'].includes(vendor) ? 'confirm the export details' : null;
42
- if (!step) return `${error.reason ?? "Waiting for the owner's export inputs."}\nIn Business: ${link}`;
43
- return `${error.reason ? error.reason + '\n' : ''}Waiting for the owner to ${step} in Business: ${link}`;
44
- }
45
-
46
20
  /** Work this computer's tasks. It says what it is doing and what it waits
47
21
  * for, applies the owner's choices at every check-in, and removes run.lock on
48
22
  * every exit, including Ctrl-C, SIGTERM and a closed terminal (SIGHUP). */
49
23
  export async function run({ once = false } = {}) {
50
24
  const { state, credential } = await paired(), api = new Api(state.origin, credential), directory = stateDirectory();
51
- // Tasks this run handed back as paused, with what each waits for. An export
52
- // waiting only for the owner's vendor key is picked up again once it is stored.
53
- const parked = new Map(), ownerWaits = new Map(), unlock = await lockSupervisor(), stop = new AbortController();
25
+ const unlock = await lockSupervisor(), stop = new AbortController();
54
26
  // A terminal's Ctrl-C reaches npx and this process together, and npx then
55
27
  // forwards another SIGINT, which can arrive at any moment until this process
56
28
  // has exited. So the handlers stay for the rest of the process: a repeated
@@ -63,9 +35,8 @@ export async function run({ once = false } = {}) {
63
35
  let progress, stopCarry, said = '', held = null, summaries = [];
64
36
  const say = text => { if (text !== said) { said = text; process.stdout.write(text + '\n'); } };
65
37
  // An agent step that waits is said in its own words, never as "Nothing yet".
66
- const waits = () => [...new Set([...ownerWaits.values()].concat(summaries.filter(task => parked.has(task.task_id)).map(task => parked.get(task.task_id).message), agentWaiting(summaries)))];
67
- // With no agent step waiting, a move's owner step (freeze, rollback, cancellation) is named with its link.
68
- const idle = () => { const owner = ownerWaiting(summaries, state); return owner.length ? owner.join('\n') : waitingFor(state); };
38
+ const waits = () => agentWaiting(summaries);
39
+ const idle = () => waitingFor(state);
69
40
  try {
70
41
  stopCarry = await startCarryRefresh(api, state, stop.signal);
71
42
  progress = await loadProgress();
@@ -81,12 +52,7 @@ export async function run({ once = false } = {}) {
81
52
  }
82
53
  if (!progress.pendingClaim) {
83
54
  summaries = await nextQuestions(api, stop.signal);
84
- // A wait belongs only to a task Business still lists as needing input.
85
- // Cancellation, completion or another computer taking it clears the line.
86
- for (const id of ownerWaits.keys()) if (!summaries.some(task => task.task_id === id && ['needs_input', 'waiting_for_owner'].includes(task.state))) ownerWaits.delete(id);
87
- const handles = (await loadState())?.vendorHandles ?? [];
88
- for (const [id, wait] of parked) if (wait.keyMissing && handles.includes(vendorHandle(wait.keyMissing))) parked.delete(id);
89
- const selected = summaries.find(task => kinds.has(task.kind) && ['ready','leased'].includes(task.state) && !parked.has(task.task_id));
55
+ const selected = summaries.find(task => kinds.has(task.kind) && ['ready','leased'].includes(task.state));
90
56
  if (!selected) {
91
57
  const waiting = waits();
92
58
  say(waiting.length ? waiting.join('\n') : idle());
@@ -100,18 +66,10 @@ export async function run({ once = false } = {}) {
100
66
  let claimed;
101
67
  try { claimed = await api.post('/api/business/executors/claim', { ...progress.pendingClaim, wait_seconds: 25 }, { signal: stop.signal }); }
102
68
  catch (error) {
103
- const waiting = ownerWait(error, state, summaries.find(task => task.task_id === progress.pendingClaim.task_id));
104
- if (!waiting) {
105
- if (error.status !== 409) throw error;
106
- progress = {}; await saveProgress(progress);
107
- held = null;
108
- if (once) throw error;
109
- await pause(checkIn, stop.signal); continue;
110
- }
111
- ownerWaits.set(progress.pendingClaim.task_id, waiting); say(waiting);
69
+ if (error.status !== 409) throw error;
112
70
  progress = {}; await saveProgress(progress);
113
71
  held = null;
114
- if (once) return;
72
+ if (once) throw error;
115
73
  await pause(checkIn, stop.signal); continue;
116
74
  }
117
75
  if (!claimed.task || claimed.task.state !== 'leased' || claimed.task.fence !== claimed.fence || Date.parse(claimed.lease_expires_at) <= Date.now()) {
@@ -135,51 +93,28 @@ export async function run({ once = false } = {}) {
135
93
  try {
136
94
  progress.current = { kind: claimed.task.kind, checkpoint: claimed.task.checkpoint, uploadedBytes: claimed.task.checkpoint?.bytes_done ?? 0 };
137
95
  await saveProgress(progress);
138
- if (Object.hasOwn(vendorWork, claimed.task.kind)) {
139
- try {
140
- const done = await vendorWork[claimed.task.kind]({ lease, task: claimed.task, grant: claimed.grant, directory, say, ownerPage: ownerLink(state) });
141
- finished = true;
142
- say(done);
143
- } catch (error) {
144
- if (!(error instanceof ExportWaiting) || lease.signal.aborted) throw error;
145
- // Business shows the owner what this vendor task waits for; the lease goes back as paused.
146
- parked.set(claimed.task.id, { message: error.message, keyMissing: error.keyMissing });
147
- await lease.send(taskPath(claimed.task.id, 'events'), { event: { kind: 'question', payload: { question: error.question } } });
148
- throw error;
149
- }
150
- } else {
151
- const page = claimed.task.checkpoint?.page;
152
- say(page ? `Resuming the names-only scan of this computer's allowed folders from page ${page + 1}.` : 'Scanning this computer\'s allowed folders for tool names (names only; no file contents leave this computer).');
153
- const result = await runDiscovery({ task: claimed.task, grant: claimed.grant, checkpoint: claimed.task.checkpoint, signal: lease.signal,
154
- send: (destination, body) => lease.send(destination, body), stateDir: directory,
155
- saveCheckpoint: async checkpoint => {
156
- await lease.checkpointSaved(checkpoint);
157
- if (checkpoint.page) process.stdout.write(`Sent page ${checkpoint.page} of ${checkpoint.total}; the server has ${checkpoint.records_done} names and saved this checkpoint.\n`);
158
- } });
159
- await lease.complete(); finished = true;
160
- await result.cleanup();
161
- if (!state.discovered) { state.discovered = true; await saveState(state); }
162
- say('Business discover.local completed and checked by the server.');
163
- }
96
+ const page = claimed.task.checkpoint?.page;
97
+ say(page ? `Resuming the names-only scan of this computer's allowed folders from page ${page + 1}.` : 'Scanning this computer\'s allowed folders for tool names (names only; no file contents leave this computer).');
98
+ const result = await runDiscovery({ task: claimed.task, grant: claimed.grant, checkpoint: claimed.task.checkpoint, signal: lease.signal,
99
+ send: (destination, body) => lease.send(destination, body), stateDir: directory,
100
+ saveCheckpoint: async checkpoint => {
101
+ await lease.checkpointSaved(checkpoint);
102
+ if (checkpoint.page) process.stdout.write(`Sent page ${checkpoint.page} of ${checkpoint.total}; the server has ${checkpoint.records_done} names and saved this checkpoint.\n`);
103
+ } });
104
+ await lease.complete(); finished = true;
105
+ await result.cleanup();
106
+ if (!state.discovered) { state.discovered = true; await saveState(state); }
107
+ say('Business discover.local completed and checked by the server.');
164
108
  } catch (error) { failure = lease.signal.aborted ? lease.signal.reason : error; }
165
109
  finally {
166
- if (!finished && failure?.status !== 401 && !ownerWait(failure ?? {}, state)) {
167
- try { await lease.release(stop.signal.aborted ? 'handover' : parked.has(claimed.task.id) ? 'paused' : 'failed'); released = true; }
110
+ if (!finished && failure?.status !== 401) {
111
+ try { await lease.release(stop.signal.aborted ? 'handover' : 'failed'); released = true; }
168
112
  catch (error) { if (error.status === 401) failure = error; }
169
113
  }
170
114
  await lease.close();
171
- if (finished || released || ownerWait(failure ?? {}, state)) { progress = {}; await saveProgress(progress); }
172
- }
173
- if (failure) {
174
- const waiting = ownerWait(failure, state);
175
- if (waiting && !stop.signal.aborted) {
176
- ownerWaits.set(claimed.task.id, waiting); say(waiting); held = null;
177
- if (once) return;
178
- await pause(checkIn, stop.signal); continue;
179
- }
180
- if (failure.status === 401 || once || !parked.has(claimed.task.id)) throw failure;
181
- process.stderr.write(failure.message + '\n');
115
+ if (finished || released) { progress = {}; await saveProgress(progress); }
182
116
  }
117
+ if (failure) throw failure;
183
118
  if (once) return;
184
119
  } while (!stop.signal.aborted);
185
120
  } catch (error) {
@@ -5,6 +5,7 @@ import { loadState, saveState } from './state.mjs';
5
5
  import { map, commands, pair, pairUsage } from './setup.mjs';
6
6
  import { codexAuth, claudeAuth } from './auth.mjs';
7
7
  import { assertSandboxPlatform } from './providers/sandbox.mjs';
8
+ import { appSignInHelp } from '../app-address.mjs';
8
9
 
9
10
  export const usage = `Usage: rer companion VERB
10
11
  Pairs this computer with a Run Edit Run app, then runs the app's change
@@ -35,6 +36,7 @@ State: ~/.rer-local (RER_LOCAL_HOME picks another private folder). The device ke
35
36
  is kept there (0600); the app keeps only its hash.
36
37
  Revoke: in the app, Settings > Devices > Revoke. A running companion stops at its
37
38
  next request. Then delete the state folder on this computer.
39
+ ${appSignInHelp}
38
40
  `;
39
41
 
40
42
  async function locked(root,work) {
@@ -22,7 +22,7 @@ export async function nativeDemoCommand(project, options, store, signal, out, op
22
22
  await demoBundle(project, operation, app, join(folder, 'bundle'), store, label, signal);
23
23
  for (const file of DEMO_FILES) await cp(new URL(`../modules/demo-host/${file}`, import.meta.url), join(folder, 'modules/demo-host', file));
24
24
  for (const file of RUNTIME_FILES) await cp(new URL(`../modules/demo-host/native/${file}.mjs`, import.meta.url), join(folder, `modules/demo-host/native/${file}.mjs`));
25
- for (const directory of ['deploy-kit']) await cp(new URL(`../modules/${directory}/`, import.meta.url), join(folder, 'modules', directory), { recursive: true });
25
+ for (const directory of ['deploy-kit', 'd1-transport']) await cp(new URL(`../modules/${directory}/`, import.meta.url), join(folder, 'modules', directory), { recursive: true });
26
26
  await mkdir(join(folder, 'modules/container/adapters'), { recursive: true });
27
27
  await cp(new URL('../modules/container/adapters/d1-limits.mjs', import.meta.url), join(folder, 'modules/container/adapters/d1-limits.mjs'));
28
28
  for (const file of ['migrations.mjs', 'demo-egress.mjs']) await cp(new URL(`../modules/container/${file}`, import.meta.url), join(folder, 'modules/container', file));
package/cli/parse.mjs CHANGED
@@ -3,6 +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
+ import { appSignInHelp } from './app-address.mjs';
6
7
  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
8
  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
9
  export const validOwnerName = value => typeof value === 'string' && Boolean(value.trim()) && value.length <= 200 && !/[\p{Cc}\p{Cf}]/u.test(value);
@@ -108,7 +109,7 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
108
109
  }
109
110
 
110
111
  export function help(verb) {
111
- if (!verb) return `Usage: rer VERB [FLAGS]\nCommands: ${Object.keys({...verbs, ...authoringVerbs}).join(', ')}, signin, release, listing\nRun rer VERB --help for flags.\n`;
112
+ if (!verb) return `Usage: rer VERB [FLAGS]\nCommands: ${Object.keys({...verbs, ...authoringVerbs}).join(', ')}, signin, release, listing\nRun rer VERB --help for flags.\n${appSignInHelp}\n`;
112
113
  const known = verbs[verb] ?? authoringVerbs[verb] ?? (verb === 'signin' ? signinVerb : undefined);
113
114
  const door = ['export', 'import'].includes(verb) ? 'To move records, start the app and open its signed-in owner import door:\n\n rer dev\n\nOpen /app/import, then export or upload and review supported records there.\n\nTo back up or restore this installation:\n' : '';
114
115
  return `${door}Usage: rer ${verb}${verb === 'refresh-base' ? ' --ref FULL_COMMIT' : ''} [FLAGS]\nFlags: ${(known?.flags ?? commonFlags).join(', ')}\n${known?.effects ?? 'Execute the declared OPERATIONS v2 argv with explicit arguments after --.'}\n`;
@@ -2,6 +2,30 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.101
6
+
7
+ ### Person erasure keeps other people's agent-door records
8
+
9
+ - Data-safety fix: erasing a person could also remove agent-door records that belong to other people. The agent-door erasure matcher in the default seed and the Penny artifact map matched a person's identifiers and personal text literals as bare substrings (Penny's map for every subject, the default seed for text literals), so a short identifier, or one that occurs inside a longer identifier, a path segment or another person's text, selected unrelated calls, approvals, reviews, audit rows and events. The matcher now searches only decoded string values (never JSON keys or numbers) and requires a token boundary on both sides of every hit, including a later hit after an embedded one. Short identifiers keep version and URI tokens such as `1.0` whole; identifiers of eight or more characters, and email addresses, can also be separated at path segments. The selected decision set is resolved once per audit row. A seed or edition receives the fix only by taking this source: do not use People erase on live data with an earlier release.
10
+
11
+ ### Import apply reads in sets
12
+
13
+ - `D1TargetAdapter` gains optional `readMany(database, destination, keys)` and, for private-transport adapters, `stagingReadMany`. Each returns what the same number of single reads would, in key order, including duplicate keys and missing rows; reads only the selected keys; and keeps the adapter's native decoding and exact before-read guards. An adapter without them keeps individual reads, any bulk-read error discards the snapshot and uses that path, and an inherited bulk method must preserve an overridden single read or throw. The default seed's people target implements `readMany`.
14
+ - Each apply transaction reads its entries' source ownership, native rows and predecessor provenance as three set reads, chunked to the D1 variable limit, instead of reading per entry. On the 14,770-entry replay, apply round trips fall from 61,695 to 19,764 and entry reads from 44,310 to 2,379. One documented difference at the budget boundary: saved read budget can advance a budget-limited call's checkpoint, or surface a later entry's refusal one call earlier, with the same error code and text; such a refusal publishes none of the gathered entries and leaves the job at its last consistent durable checkpoint (`modules/import-kit/src/d1/README.md`). The D1 query limits now live in `modules/d1-transport/limits.mjs`, and the native demo bundle carries that module.
15
+ - The import credential check no longer stops a whole import on free text that merely starts like a URL (for example `http:// see below`). A string that does not parse yields no user name and still goes through the raw query-key scans; strings that parse are checked exactly as before.
16
+
17
+ ### Business is light
18
+
19
+ - Business is light: `rer business` keeps pairing, token, scan, setup, run, next, answer, status and disconnect, and no longer exports from old tools. `vendor-key` and `legacy-package` are gone with the Sentry, PagerDuty, Sorry, UptimeRobot, Calendly and Zendesk exporters and the export, catch-up and archive tasks: each seed imports in its own Move in page. `rer business next` names a seed's Move in page, what it takes and how to export, `rer business done ID --note TEXT` finishes the step, and `run` reports a step kind it does not know instead of failing. A read-only key stored by an earlier rer is still removed by `disconnect`.
20
+ - This removes what 0.2.100 added to the import door and Business: the logical package transport (`rer-door-package/1`, the `package` source option and segment assembly), the opt-in bounded-wave protocol with its grant actions and schema, the local legacy package registration and transfer, and the Zendesk exporter. This release carries no migration for the bounded-wave schema an adopter may have taken from 0.2.100.
21
+ - `importers.json` has a version 2: each row declares the seed's Move in path (`moveIn`), what it takes (`accepts`: file, key, address) and how to export (`export`), with `status` and `evidence` optional, and the file may name the seed's own import format. Version 1 files stay valid. `rer business next` prints that format link, including a GitHub link pinned to a commit.
22
+ - `rer business setup --confirm-demo` now only creates (or reuses) the synthetic demo company's Business and saves its profile; it provisions no seeds and calls no demo routes, and `--wait-seconds` is gone. Its receipt is `{business_id, name, default_hosting, created, profile}`.
23
+ - The computer-awake choice is still recorded, and the CLI now says plainly that nothing keeps the computer awake because rer runs no exports.
24
+
25
+ ### Sign-in address in help
26
+
27
+ - Top-level, companion pairing and Business setup, next and done help now name the app sign-in address for invited people, https://app.runeditrun.com, which is also the default Business origin.
28
+
5
29
  ## 0.2.100
6
30
 
7
31
  ### Deploy with outbound email explicitly off