@moxuli/moremote 0.0.0-stage → 0.1.0

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 (65) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +31 -0
  3. package/README.md +73 -2
  4. package/bin/moremote-cli.js +34 -0
  5. package/bin/moremote-service.js +7 -0
  6. package/dist/bindings.d.ts +6 -0
  7. package/dist/bindings.js +4 -0
  8. package/dist/cli.d.ts +1 -0
  9. package/dist/cli.js +308 -0
  10. package/dist/cloud-client.d.ts +43 -0
  11. package/dist/cloud-client.js +128 -0
  12. package/dist/config.d.ts +36 -0
  13. package/dist/config.js +68 -0
  14. package/dist/control.d.ts +3 -0
  15. package/dist/control.js +226 -0
  16. package/dist/controls.d.ts +15 -0
  17. package/dist/controls.js +36 -0
  18. package/dist/crypto.d.ts +23 -0
  19. package/dist/crypto.js +68 -0
  20. package/dist/evidence.d.ts +19 -0
  21. package/dist/evidence.js +4 -0
  22. package/dist/journal.d.ts +104 -0
  23. package/dist/journal.js +132 -0
  24. package/dist/limits.d.ts +21 -0
  25. package/dist/limits.js +8 -0
  26. package/dist/official-client.d.ts +120 -0
  27. package/dist/official-client.js +162 -0
  28. package/dist/operations.d.ts +71 -0
  29. package/dist/operations.js +210 -0
  30. package/dist/pairing.d.ts +19 -0
  31. package/dist/pairing.js +68 -0
  32. package/dist/permission.d.ts +9 -0
  33. package/dist/permission.js +66 -0
  34. package/dist/projection.d.ts +24 -0
  35. package/dist/projection.js +35 -0
  36. package/dist/resources.d.ts +76 -0
  37. package/dist/resources.js +299 -0
  38. package/dist/runtime.d.ts +8 -0
  39. package/dist/runtime.js +375 -0
  40. package/dist/service.d.ts +21 -0
  41. package/dist/service.js +310 -0
  42. package/dist/supervisor.d.ts +15 -0
  43. package/dist/supervisor.js +175 -0
  44. package/dist/update-state.d.ts +30 -0
  45. package/dist/update-state.js +158 -0
  46. package/dist/updater.d.ts +9 -0
  47. package/dist/updater.js +152 -0
  48. package/docs/README.md +23 -0
  49. package/docs/STATE.md +132 -0
  50. package/docs/configuration.md +37 -0
  51. package/docs/conventions.md +9 -0
  52. package/docs/decisions/0001-managed-updates.md +19 -0
  53. package/docs/plans/2026-11-10-managed-updates.md +26 -0
  54. package/docs/plans/2026-11-10-notification-delivery.md +118 -0
  55. package/docs/releasing.md +38 -0
  56. package/docs/specs/01-architecture.md +102 -0
  57. package/docs/specs/02-encrypted-delivery.md +194 -0
  58. package/docs/specs/03-api-contract.md +397 -0
  59. package/docs/specs/04-control-and-receipt-lifecycle.md +175 -0
  60. package/docs/specs/05-endpoint-and-lifecycle.md +57 -0
  61. package/docs/specs/06-managed-updates.md +49 -0
  62. package/licenses/Paseo-0.15.3.txt +211 -0
  63. package/package.json +37 -4
  64. package/vectors/bearer-v1.json +6 -0
  65. package/vectors/envelope-v1.json +24 -0
@@ -0,0 +1,158 @@
1
+ import { join } from 'node:path';
2
+ import { openSync, closeSync, fsyncSync, renameSync } from 'node:fs';
3
+ import { randomUUID } from 'node:crypto';
4
+ import { assertStateRoot, inspectResource, readPrivateText, createPrivateFile, removeOwnedResource, hasCode } from './resources.js';
5
+ export const PACKAGE = '@moxuli/moremote';
6
+ export const CHECK_INTERVAL = 6 * 60 * 60 * 1000;
7
+ const OWNER = 'MoRemote CLI updater v1';
8
+ export function exactVersion(value) { if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?$/.test(value))
9
+ throw Error('EXACT_VERSION_REQUIRED'); return value; }
10
+ export function managedRoot(dir) { assertStateRoot(dir); const root = join(dir, 'managed'); inspectResource(root, 'directory'); if (readPrivateText(join(root, '.moremote-cli-managed-owner'), 128).text !== 'MoRemote CLI managed package v1\n')
11
+ throw Error('FOREIGN_MANAGED_DIRECTORY'); return root; }
12
+ export function readUpdateState(dir) {
13
+ let root;
14
+ try {
15
+ root = managedRoot(dir);
16
+ }
17
+ catch (error) {
18
+ if (hasCode(error, 'ENOENT'))
19
+ return;
20
+ throw error;
21
+ }
22
+ const path = join(root, 'update.json');
23
+ if (!inspectResource(path, 'file', true))
24
+ return;
25
+ const s = JSON.parse(readPrivateText(path, 8192).text);
26
+ if (s.owner !== OWNER || typeof s.enabled !== 'boolean' || typeof s.active !== 'string' || typeof s.bootstrap !== 'string')
27
+ throw Error('INVALID_UPDATE_STATE');
28
+ for (const v of [s.active, s.bootstrap, s.previous, s.pending, s.activating, s.failed, s.manualRequired])
29
+ if (v !== undefined)
30
+ exactVersion(v);
31
+ if (s.lastCheck !== undefined && (!Number.isSafeInteger(s.lastCheck) || s.lastCheck < 0) || s.nextCheck !== undefined && (!Number.isSafeInteger(s.nextCheck) || s.nextCheck < 0) || s.error !== undefined && (typeof s.error !== 'string' || !/^[A-Z0-9_]+$/.test(s.error)) || s.pendingManual !== undefined && typeof s.pendingManual !== 'boolean')
32
+ throw Error('INVALID_UPDATE_STATE');
33
+ if (autoUpdateDisabled(dir))
34
+ s.enabled = false;
35
+ return s;
36
+ }
37
+ export function initialUpdateState(version) { return { owner: OWNER, enabled: true, active: exactVersion(version), bootstrap: version }; }
38
+ function syncDirectory(root) { if (process.platform === 'win32')
39
+ return; const fd = openSync(root, 'r'); try {
40
+ fsyncSync(fd);
41
+ }
42
+ finally {
43
+ closeSync(fd);
44
+ } }
45
+ export function writeUpdateState(dir, state) {
46
+ const root = managedRoot(dir), path = join(root, 'update.json');
47
+ readUpdateState(dir);
48
+ const temp = path + '.' + randomUUID() + '.tmp', identity = createPrivateFile(temp, JSON.stringify(state) + '\n');
49
+ try {
50
+ renameSync(temp, path);
51
+ syncDirectory(root);
52
+ }
53
+ finally {
54
+ removeOwnedResource(temp, identity);
55
+ }
56
+ }
57
+ export async function updateLock(dir, work, name = 'writer') {
58
+ const root = managedRoot(dir), path = join(root, name + '.lock');
59
+ const old = inspectResource(path, 'file', true);
60
+ if (old) {
61
+ const value = JSON.parse(readPrivateText(path, 2048).text);
62
+ if (value.owner !== OWNER || !Number.isSafeInteger(value.pid) || value.pid < 1 || typeof value.nonce !== 'string')
63
+ throw Error('FOREIGN_UPDATE_LOCK');
64
+ try {
65
+ process.kill(value.pid, 0);
66
+ throw Error('UPDATE_BUSY');
67
+ }
68
+ catch (error) {
69
+ if (!hasCode(error, 'ESRCH'))
70
+ throw error;
71
+ }
72
+ if (!removeOwnedResource(path, old))
73
+ throw Error('UPDATE_BUSY');
74
+ }
75
+ let identity;
76
+ try {
77
+ identity = createPrivateFile(path, JSON.stringify({ owner: OWNER, pid: process.pid, nonce: randomUUID() }) + '\n');
78
+ }
79
+ catch (error) {
80
+ if (hasCode(error, 'EEXIST'))
81
+ throw Error('UPDATE_BUSY');
82
+ throw error;
83
+ }
84
+ try {
85
+ return await work();
86
+ }
87
+ finally {
88
+ if (!removeOwnedResource(path, identity))
89
+ throw Error('UPDATE_LOCK_CHANGED');
90
+ }
91
+ }
92
+ export function supervisorRunning(dir) {
93
+ const root = managedRoot(dir), path = join(root, 'supervisor.lock'), stat = inspectResource(path, 'file', true);
94
+ if (!stat)
95
+ return false;
96
+ const value = JSON.parse(readPrivateText(path, 2048).text);
97
+ if (value.owner !== OWNER || !Number.isSafeInteger(value.pid) || value.pid < 1 || typeof value.nonce !== 'string')
98
+ throw Error('FOREIGN_UPDATE_LOCK');
99
+ try {
100
+ process.kill(value.pid, 0);
101
+ return true;
102
+ }
103
+ catch (error) {
104
+ if (hasCode(error, 'ESRCH'))
105
+ return false;
106
+ throw error;
107
+ }
108
+ }
109
+ export function supervisorStopRequested(dir, clear = false) {
110
+ const path = join(managedRoot(dir), 'stop-request'), stat = inspectResource(path, 'file', true);
111
+ if (!stat)
112
+ return false;
113
+ if (readPrivateText(path, 128).text !== OWNER + '\n')
114
+ throw Error('FOREIGN_UPDATE_STOP');
115
+ if (clear && !removeOwnedResource(path, stat))
116
+ throw Error('UPDATE_STOP_CHANGED');
117
+ return true;
118
+ }
119
+ export function requestSupervisorStop(dir) {
120
+ if (!readUpdateState(dir))
121
+ return;
122
+ if (supervisorStopRequested(dir))
123
+ return;
124
+ try {
125
+ createPrivateFile(join(managedRoot(dir), 'stop-request'), OWNER + '\n');
126
+ }
127
+ catch (error) {
128
+ if (!hasCode(error, 'EEXIST'))
129
+ throw error;
130
+ supervisorStopRequested(dir);
131
+ }
132
+ }
133
+ export function autoUpdateDisabled(dir, clear = false) {
134
+ const path = join(managedRoot(dir), 'auto-disabled'), stat = inspectResource(path, 'file', true);
135
+ if (!stat)
136
+ return false;
137
+ if (readPrivateText(path, 128).text !== OWNER + '\n')
138
+ throw Error('FOREIGN_UPDATE_POLICY');
139
+ if (clear) {
140
+ if (!removeOwnedResource(path, stat))
141
+ throw Error('UPDATE_POLICY_CHANGED');
142
+ syncDirectory(managedRoot(dir));
143
+ }
144
+ return true;
145
+ }
146
+ export function disableAutoUpdate(dir) {
147
+ if (autoUpdateDisabled(dir))
148
+ return;
149
+ try {
150
+ createPrivateFile(join(managedRoot(dir), 'auto-disabled'), OWNER + '\n');
151
+ syncDirectory(managedRoot(dir));
152
+ }
153
+ catch (error) {
154
+ if (!hasCode(error, 'EEXIST'))
155
+ throw error;
156
+ autoUpdateDisabled(dir);
157
+ }
158
+ }
@@ -0,0 +1,9 @@
1
+ export { readUpdateState } from './update-state.js';
2
+ export declare function packageVersion(): Promise<string>;
3
+ export declare function packageManaged(): Promise<boolean>;
4
+ export declare function compatibleEntry(entry: string): Promise<boolean>;
5
+ export declare function ensureManaged(dir: string): Promise<import("./update-state.js").UpdateState>;
6
+ export declare function queueUpdate(dir: string, version: string): Promise<import("./update-state.js").UpdateState>;
7
+ export declare function setAutoUpdate(dir: string, enabled: boolean): Promise<import("./update-state.js").UpdateState>;
8
+ export declare function checkForUpdate(dir: string, fetcher?: typeof fetch, now?: number): Promise<import("./update-state.js").UpdateState>;
9
+ export declare function serviceEntry(dir: string): Promise<string>;
@@ -0,0 +1,152 @@
1
+ import { basename, dirname, join } from 'node:path';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { privateDirectory, privateManagedDirectory } from './config.js';
5
+ import { managedEntry, stagePackage, command } from './service.js';
6
+ import { PACKAGE, CHECK_INTERVAL, exactVersion, initialUpdateState, readUpdateState, writeUpdateState, updateLock, autoUpdateDisabled, disableAutoUpdate } from './update-state.js';
7
+ import { inspectResource } from './resources.js';
8
+ export { readUpdateState } from './update-state.js';
9
+ export async function packageVersion() { const p = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')); if (p.name !== PACKAGE)
10
+ throw Error('UPDATE_IDENTITY_MISMATCH'); return exactVersion(p.version); }
11
+ export async function packageManaged() {
12
+ const root = dirname(fileURLToPath(new URL('../package.json', import.meta.url)));
13
+ if (basename(root) !== 'moremote' || basename(dirname(root)) !== '@moxuli' || basename(dirname(dirname(root))) !== 'node_modules')
14
+ return false;
15
+ inspectResource(root, 'directory', false, false);
16
+ inspectResource(join(root, 'package.json'), 'file', false, false);
17
+ await packageVersion();
18
+ return true;
19
+ }
20
+ export async function compatibleEntry(entry) {
21
+ const pkg = JSON.parse(await readFile(join(dirname(dirname(entry)), 'package.json'), 'utf8'));
22
+ return pkg.moremote?.updateProtocol === 1 && pkg.moremote?.journalSchema === 1 && pkg.moremote?.wireProtocol === 1;
23
+ }
24
+ async function selectCandidate(dir, version, manual) {
25
+ const state = readUpdateState(dir);
26
+ const entry = await stagePackage(dir, version);
27
+ if (version !== state.active) {
28
+ state.pending = version;
29
+ state.pendingManual = manual;
30
+ delete state.manualRequired;
31
+ if (!await compatibleEntry(entry)) {
32
+ state.manualRequired = version;
33
+ state.error = 'UPDATE_MANUAL_COMPATIBILITY_REQUIRED';
34
+ }
35
+ }
36
+ else {
37
+ delete state.pending;
38
+ delete state.pendingManual;
39
+ delete state.manualRequired;
40
+ }
41
+ if (autoUpdateDisabled(dir))
42
+ state.enabled = false;
43
+ return state;
44
+ }
45
+ export async function ensureManaged(dir) {
46
+ await privateDirectory(dir);
47
+ await privateManagedDirectory(join(dir, 'managed'));
48
+ await privateManagedDirectory(join(dir, 'managed', 'versions'));
49
+ return updateLock(dir, async () => { let state = readUpdateState(dir); if (!state) {
50
+ const version = await packageVersion();
51
+ await stagePackage(dir, version);
52
+ state = initialUpdateState(version);
53
+ writeUpdateState(dir, state);
54
+ } await managedEntry(dir, state.active); return state; });
55
+ }
56
+ export async function queueUpdate(dir, version) {
57
+ exactVersion(version);
58
+ await ensureManaged(dir);
59
+ return updateLock(dir, async () => { const before = readUpdateState(dir); if (before.activating)
60
+ throw Error('UPDATE_ACTIVATING'); const state = await selectCandidate(dir, version, true); if (state.failed === version)
61
+ delete state.failed; writeUpdateState(dir, state); return state; });
62
+ }
63
+ export async function setAutoUpdate(dir, enabled) {
64
+ if (!readUpdateState(dir))
65
+ await ensureManaged(dir);
66
+ if (!enabled)
67
+ disableAutoUpdate(dir);
68
+ try {
69
+ return await updateLock(dir, async () => { if (enabled)
70
+ autoUpdateDisabled(dir, true); const state = readUpdateState(dir); state.enabled = enabled; if (!enabled && !state.pendingManual)
71
+ delete state.pending; writeUpdateState(dir, state); return state; });
72
+ }
73
+ catch (error) {
74
+ if (!enabled && error instanceof Error && error.message === 'UPDATE_BUSY')
75
+ return readUpdateState(dir);
76
+ throw error;
77
+ }
78
+ }
79
+ // Discovery candidates are stable; compare core numerics without coercing an
80
+ // active prerelease patch to NaN. Stable outranks prerelease at the same core.
81
+ function newer(candidate, active) {
82
+ const left = candidate.split('.'), right = active.split('-', 1)[0].split('.');
83
+ for (let i = 0; i < 3; i++) {
84
+ if (left[i].length !== right[i].length)
85
+ return left[i].length > right[i].length;
86
+ if (left[i] !== right[i])
87
+ return left[i] > right[i];
88
+ }
89
+ return active.includes('-');
90
+ }
91
+ export async function checkForUpdate(dir, fetcher = fetch, now = Date.now()) {
92
+ return updateLock(dir, async () => {
93
+ const state = readUpdateState(dir);
94
+ if (!state)
95
+ throw Error('MANAGED_INSTALL_REQUIRED');
96
+ if (!state.enabled || state.activating || state.pending || state.nextCheck !== undefined && now < state.nextCheck || state.lastCheck !== undefined && now - state.lastCheck < CHECK_INTERVAL)
97
+ return state;
98
+ state.lastCheck = now;
99
+ state.nextCheck = now + CHECK_INTERVAL;
100
+ delete state.error;
101
+ writeUpdateState(dir, state);
102
+ try {
103
+ const response = await fetcher('https://registry.npmjs.org/@moxuli%2fmoremote/latest', { signal: AbortSignal.timeout(20000), redirect: 'error' });
104
+ if ([429, 503].includes(response.status)) {
105
+ const raw = response.headers.get('retry-after');
106
+ if (raw) {
107
+ const seconds = /^\d+$/.test(raw) ? Number(raw) : NaN;
108
+ const at = Number.isFinite(seconds) ? now + Math.min(seconds, 86400) * 1000 : Date.parse(raw);
109
+ if (Number.isFinite(at) && at > now)
110
+ state.nextCheck = Math.max(state.nextCheck, Math.min(at, now + 86400000));
111
+ }
112
+ }
113
+ if (!response.ok)
114
+ throw Error('UPDATE_REGISTRY_UNAVAILABLE');
115
+ const reader = response.body?.getReader();
116
+ if (!reader)
117
+ throw Error('UPDATE_REGISTRY_INVALID');
118
+ const chunks = [];
119
+ let size = 0;
120
+ try {
121
+ while (true) {
122
+ const item = await reader.read();
123
+ if (item.done)
124
+ break;
125
+ size += item.value.byteLength;
126
+ if (size > 262144)
127
+ throw Error('UPDATE_REGISTRY_LIMIT');
128
+ chunks.push(item.value);
129
+ }
130
+ }
131
+ finally {
132
+ await reader.cancel();
133
+ }
134
+ const pkg = JSON.parse(Buffer.concat(chunks).toString('utf8'));
135
+ if (pkg.name !== PACKAGE || typeof pkg.version !== 'string' || !/^\d+\.\d+\.\d+$/.test(pkg.version))
136
+ throw Error('UPDATE_IDENTITY_MISMATCH');
137
+ exactVersion(pkg.version);
138
+ if (newer(pkg.version, state.active) && pkg.version !== state.failed) {
139
+ const selected = await selectCandidate(dir, pkg.version, false);
140
+ Object.assign(state, selected);
141
+ }
142
+ }
143
+ catch (error) {
144
+ state.error = error instanceof Error && /^[A-Z0-9_]+$/.test(error.message) ? error.message : 'UPDATE_CHECK_FAILED';
145
+ }
146
+ if (autoUpdateDisabled(dir))
147
+ state.enabled = false;
148
+ writeUpdateState(dir, state);
149
+ return state;
150
+ });
151
+ }
152
+ export async function serviceEntry(dir) { const state = await ensureManaged(dir); const entry = join(dirname(await managedEntry(dir, state.bootstrap)), 'moremote-service.js'); await command(process.execPath, [entry, '--probe'], true, 10000); return entry; }
package/docs/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Documentation index
2
+
3
+ **MoRemote CLI**: independent optional `moremote-cli` repository/command,
4
+ public npm `@moxuli/moremote`, over unmodified Paseo.
5
+ STATE distinguishes historical pre-rename acceptance, renamed-tree checks and
6
+ separately gated cloud/Apple activation.
7
+
8
+ - [Current state and external gates](STATE.md)
9
+ - [Architecture](specs/01-architecture.md)
10
+ - [Encrypted delivery contract v1](specs/02-encrypted-delivery.md)
11
+ - [Relay HTTP contract v1](specs/03-api-contract.md)
12
+ - [Endpoint controls, occurrences and receipt lifecycle](specs/04-control-and-receipt-lifecycle.md)
13
+ - [Endpoint and lifecycle behavior](specs/05-endpoint-and-lifecycle.md)
14
+ - [Managed updates and compatibility](specs/06-managed-updates.md)
15
+ - [Public release and trusted-publisher prerequisites](releasing.md)
16
+ - [Managed-update decision](decisions/0001-managed-updates.md)
17
+ - [Managed-update implementation plan](plans/2026-11-10-managed-updates.md)
18
+ - [Configuration registry](configuration.md)
19
+ - [Conventions](conventions.md)
20
+ - [Implementation plan](plans/2026-11-10-notification-delivery.md)
21
+ - [Changelog](../CHANGELOG.md)
22
+
23
+ 02/03/04 are independently carried relay-v1 contract copies, not sibling runtime dependencies. Public known-answer fixtures are vectors/envelope-v1.json (independent Node hkdfSync/createCipheriv reference) and vectors/bearer-v1.json (canonical bearer text hashing). Endpoint implementation uses standard WebCrypto.
package/docs/STATE.md ADDED
@@ -0,0 +1,132 @@
1
+ # Current state — 2026-11-10
2
+
3
+ ## Scope
4
+
5
+ Owner-approved notification/scoped-delivery first iteration; Apache-2.0. Standalone Node24 companion targeting inspected official SDK/protocol 0.15.3. Existing iOS protocol-vector floor is independent and unchanged. OpenUI, system extensions and broader native surfaces belong to later app iterations.
6
+
7
+ ## Approved identity cutover — locally verified
8
+
9
+ The owner approved the complete rename to **MoRemote CLI** on 2026-11-10:
10
+ repository/command `moremote-cli`, current public npm `@moxuli/moremote`, entry `bin/moremote-cli.js`,
11
+ `MOREMOTE_CLI_HOME`, state `MoRemoteCLI` on macOS/Windows and `moremote-cli`
12
+ on Linux, and services `com.moremote.cli` / `moremote-cli.service` / `MoRemoteCLI`.
13
+ Ownership/runtime/client/managed-package identities move together. There is no
14
+ released package or installed service to migrate: no compatibility aliases or
15
+ automatic adoption of old state. Foreign-resource protections remain strict.
16
+ The `companionHello` role, crypto salt/envelope schema, APNs categories and
17
+ app/Keychain identities are unchanged.
18
+
19
+ The source/documentation cutover and root-directory move are complete. Parent
20
+ verified the renamed source, real compiled command, isolated local state and
21
+ package contents; independent source review accepted the identity contract.
22
+ Historical local acceptance below used the former `moremote-companion` identity;
23
+ its execution transcript remains historically accurate.
24
+
25
+ The owner also approved proceeding toward cloud/Apple activation. Exact
26
+ resource, key, permission and billing-sensitive mutations still require
27
+ point-of-risk interactive confirmation. No production or device acceptance is
28
+ claimed by this approval; publication and everyday-host service installation
29
+ remain separate gates.
30
+
31
+ ## Managed updates and release — local acceptance complete
32
+
33
+ The owner authorized public scoped npm identity `@moxuli/moremote`, retained
34
+ private bootstrap/supervisor, cycle-safe automatic runtime activation and OIDC
35
+ release workflows. Native service/state/executable identities remain unchanged.
36
+ See [decision](decisions/0001-managed-updates.md), [specification](specs/06-managed-updates.md),
37
+ [plan](plans/2026-11-10-managed-updates.md) and [publication prerequisites](releasing.md).
38
+
39
+ The parent exercised the real packaged upgrade9000.0.1→9000.0.2, retained
40
+ bootstrap/previous version, frontend through a parent symlink and clean owned
41
+ shutdown. No everyday service was installed. The first full126-case run had123
42
+ passes and three lifecycle-readiness failures; after correction, all21focused
43
+ control/initialization/frontend cases, types, build and packaged smoke passed.
44
+ Do not describe those separate runs as a newly green full suite.
45
+
46
+ Independent source review's four findings are closed: initialization cleanup,
47
+ termination/parent-death propagation, prerelease precedence and exact scoped
48
+ npm registry pinning. The final control-response/readiness delta also has no
49
+ actionable P1/P2 finding. Cross-provider review timed out without a report; the
50
+ completed independent-context review is not represented as cross-vendor approval.
51
+
52
+ Public GitHub repository `moxuli/moremote-cli` exists. The owner authorized the
53
+ first public0.1.0 release and reuse of an existing locally protected publishing
54
+ token; its npm identity is verified without disclosing the credential. No new
55
+ token or npm login is required. Hosted workflow execution, registry publication
56
+ and trusted-publisher configuration require their actual receiver receipts.
57
+
58
+ ## Locally accepted implementation
59
+
60
+ Real CLI configure/check/pair/run/status/service-install/unpair/cloud-disable/update/stop/uninstall; per-user ownership adapters; one-phone deadline-bounded proof activation; WebCrypto HKDF/AES-GCM; standalone02/03/04 contracts and independent envelope/bearer vectors; actual official SDK narrow observation/send/question/approval adapter; SQLite FULL-sync dispatch/control/occurrence/attention journal; bounded encrypted state. Independent-review corrections include endpoint-authenticated cancel/revoke, immutable acknowledgements, source/generation request bindings, exact question mapping, monotonic receipts, separate24h minimal audit retention and attention invalidation. No builds, tests, formatters, actual user services or real host session mutations have been run by this worker; dependency installation used --ignore-scripts.
61
+
62
+ The retention wording has independent static Stage A approval. Final operation and lifecycle re-reviews report no remaining findings in their scoped corrections. Executed acceptance is recorded below; it does not replace production or cross-platform service gates.
63
+
64
+ The final targeted lifecycle re-review also found no remaining findings among its original six defects and two staged-socket/XML ownership residuals. This covers the inspected source corrections and regression source, not broad security approval or executed platform/service acceptance.
65
+
66
+ ## Verification journal — 2026-11-10
67
+
68
+ Evidence below was reported by the integration owner; implementation workers did not run checks.
69
+
70
+ - Initial combined check attempt timed out after900seconds. Both SDK-wire modes had failed after approximately13seconds each; leaked fixture resources prevented clean process exit and assertion-stack reporting. Build was not reached.
71
+ - Corrected synthetic timeline ranges from start/end to the pinned protocol's startSeq/endSeq, validated complete synthetic responses with official schemas, and supplied the required subscriptionId in release responses. All behavioral assertions remain.
72
+ - Fixture teardown now owns every SDK, socket, server, journal and timer; it closes the wire before SDK disposal, bounds cleanup waits, propagates fixture errors and runs on failure/timeout. It does not wait indefinitely for a release RPC.
73
+ - Focused owner run: `node --import tsx --test tests/official-wire.test.ts` passed2/2 (legacy and owned subscriptions) in26.7seconds, with no hang.
74
+ - Remaining selection: typecheck passed; the runner reported66passing entries and one failure caused only by a strict stderr wording assertion encountering Node's legitimate SQLite experimental warning. The incidental exact-output assertion was removed, preserving exit-failure and no-private-child-output invariants; its focused regression then passed1/1. Warnings were not suppressed. The already-passed two wire consumers were excluded from that remaining selection; one empty wire-file runner entry is not an extra behavior test.
75
+ - Build then passed. Actual compiled bin help and version commands both succeeded; version is0.1.0. No single combined full-suite green run is claimed.
76
+ - Actual three-party journey passed: compiled CLI configured and authenticated read-only to an isolated official0.15.3 daemon; native production Kit/CryptoKit enrolled through actual Pages→Worker→SQLite and verified the exact daemon activation proof.
77
+ - Actual foreground runtime status was cloud-enabled with one active synthetic pair, no runtime error and no installed service. A native immutable command retry to a nonexistent synthetic target received an authenticated rejection, not execution; encrypted revoke obtained the companion's durable authenticated acknowledgement, followed by narrow post-revoke outcome audit.
78
+ - Public-source privacy check found no private owner/account/team/production identifiers. No official agent was created, no model invoked, no real session mutated, and no public release or cloud deployment occurred.
79
+ - Renamed-tree combined `npm run check` passed typecheck,100/100 behavioral tests
80
+ and build. Actual compiled help/version/configure/check/status all exited0 in
81
+ temporary `MOREMOTE_CLI_HOME`, cloud off and no runtime/service/official
82
+ connection. Package dry-run contains54files, the canonical bin and no obsolete
83
+ runtime identity in packaged bin/dist; no package was published.
84
+ - Cost corrections stop active-pair GET/acknowledged state/receipt amplification
85
+ and bound relay-retired recovery. HTTP quota/operator pauses preserve fixed
86
+ deadlines, original immutable bytes and independent origin cadence.
87
+ - Initial Retry-After selection failed11/24 before correction. Its focused29case
88
+ selection passed. A later independent P1 review exposed pause expiry inside a
89
+ slow official snapshot; the real-runtime regression failed with PUT preceding
90
+ the required GET controls. The cycle-fence correction then passed31/31 focused
91
+ cases plus typecheck/build. This delta is not a newly run combined full suite.
92
+ - Independent P1 re-review closed with no new blockers. Multi-origin/multiple-pair
93
+ actual runtime behavior remains unexercised beyond the scoped client/fixture
94
+ checks; source review is not cross-platform or production acceptance.
95
+
96
+
97
+ ## Reproduction commands
98
+
99
+ 1. npm ci --ignore-scripts
100
+ 2. npm run check
101
+ 3. node bin/moremote-cli.js --help
102
+ 4. node bin/moremote-cli.js --version
103
+ 5. With a synthetic temporary MOREMOTE_CLI_HOME, run check, configure, status. Do not install services in ordinary CI.
104
+ 6. Against an explicitly isolated official0.15.3 daemon: configure its exact target/home, check --connect, then run; inspect traffic for only narrow subscriptions/read RPCs and no heartbeat/read acknowledgement/push registration. Use synthetic conversations for explicit send and actual pending question/approval tests. Verify accepted admission separately from agent completion and simulate socket loss after dispatch without replay.
105
+ 7. Run the independent cloud’s local SQLite-backed Worker, configure explicit loopback development at both ends, pair a synthetic endpoint using the public contract, submit an encrypted command and validate its exact encrypted receipt. No repository runtime imports are needed.
106
+
107
+ ### Read-only isolated official smoke
108
+
109
+ Use an already-authorized isolated0.15.3 daemon, empty isolated user home and an unused selected port. Do not point this at everyday Paseo data. The companion commands are:
110
+
111
+ ```sh
112
+ HOME="$SANDBOX/user" PASEO_PASSWORD= node bin/moremote-cli.js configure --data-dir "$SANDBOX/cli" --paseo-home "$SANDBOX/daemon" --target "127.0.0.1:$PASEO_TEST_PORT"
113
+ HOME="$SANDBOX/user" PASEO_PASSWORD= node bin/moremote-cli.js check --connect --data-dir "$SANDBOX/cli"
114
+ ```
115
+
116
+ If no isolated daemon exists, an operator can explicitly authorize and run `paseo onboard --home "$SANDBOX/daemon" --listen "127.0.0.1:$PASEO_TEST_PORT" --no-relay --no-mcp --voice disable --json` with HOME set to "$SANDBOX/user"; afterward `paseo daemon stop --home "$SANDBOX/daemon"`. The owner exercised this isolated read-only setup for local acceptance. It neither created an agent nor called a provider/model. Reuse an already-authorized isolated daemon instead of starting a second one during verification.
117
+
118
+ The actual SDK synthetic-wire cases are `tests/official-wire.test.ts` (waits for the real10s liveness ping; asserts no presence/read/Expo; loses admission ack then reconnects without resend) and `tests/official-permission-wire.test.ts` (real structured question response/resolution, same-ID replacement rejection and lost resolution without resend). These are not mock adapter echoes and do not call a real model.
119
+
120
+ ### Upstream license evidence
121
+
122
+ Official tag v0.15.3 points to commit d91ae138cb931447635e94296023414a58bedcc5. Its root LICENSE expressly grants Apache-2.0 for non-third-party Paseo code and retains third-party terms; matching client/protocol package sources are version0.15.3. Full text and immutable primary URLs are in licenses/Paseo-0.15.3.txt and NOTICE. npm package license fields are absent and were not treated as evidence; no signed npm/source attestation is claimed.
123
+
124
+ ## External gates / substrate gaps
125
+
126
+ - Independent specification and quality/security reviews and frozen local check results belong to the integration owner.
127
+ - Public GitHub repository exists; CI/release workflow source is prepared but no hosted run, tag/release, npm publication, trusted publisher, scheduler or branch/tag protection is claimed. Unpublished npm404 is a real update failure, persisted with bounded discovery rather than a retry storm or fake success.
128
+ - Real per-user launchd/systemd/Windows logon-task installation requires point-of-use operator authorization and testing on each OS; adapters are source, not evidence of another OS’s acceptance.
129
+ - No everyday login service, real work-session action, DNS/cloud deployment, paid model call, Apple key/capability change or public publication has been performed.
130
+ - Production Cloudflare storage/network reachability, Apple provider signing and app topic/environment, actual iOS app enrollment and physical APNs delivery are real external setup/acceptance requirements. Emulation is not proof of delivery.
131
+
132
+ Continue from this file and living specs, not private machine history. Record exercised evidence here before claiming a verified release.
@@ -0,0 +1,37 @@
1
+ # Configuration registry
2
+
3
+ ## Local ownership
4
+
5
+ Config schema1 lives in config.json beneath the companion state directory. It contains a distinct persisted clientId, explicit target (optional), paseoHome, apiOrigin (optional), allowLoopbackHttp, cloudEnabled, pinned daemonServerId, and at most16 independent per-phone pair records. Pair root keys and relay host capabilities are endpoint secrets. API target/official credentials remain private local configuration; diagnostics redact the target and home. config is atomic-replaced and flushed before activation. journal.sqlite uses WAL and synchronous=FULL. runtime.lock/runtime.json/runtime.sock are companion-only control resources; stop authenticates the local IPC request, never kills a PID supplied by a stale file.
6
+ Existing resource ownership is checked before mutation, not inferred from filenames. SQLite application_id remains 0x4d524331 (MRC1, MoRemote CLI v1); the journal schema is unchanged. Read it through an immutable read-only probe before opening a writer; foreign/unmarked databases are rejected, never migrated/adopted. Unreleased development databases without that identity require a fresh temporary CLI state directory, not changes to official data. Runtime locks/records carry versioned CLI ownership and instance/token identity; socket cleanup requires matching provenance/inode. Atomic JSON replacement flushes file data and the POSIX parent directory before dependent tombstone cleanup. CLI root/managed markers, runtime owners and client prefixes change together; preserving the SQLite identity does not authorize old-state adoption.
7
+ Each pairing retains its explicit API origin through retirement. Local revokedAt and original child audit deadlines are never renewed by retries. Retired-key cleanup durably removes credentials before their no-longer-needed tombstones; no old pairing is resurrected. Expired pending offers are pruned24hours after original expiry. Managed selection is separate from pairing/config JSON: `managed/update.json` records only verified exact scoped packages, retained bootstrap/previous, candidate/error/compatibility and persisted discovery deadlines. `managed/auto-disabled` is an independent marked opt-out that wins during staging. Roots and managed directories retain separate ownership markers, foreign entries block purge, and official/companion data paths must not overlap.
8
+
9
+ MOREMOTE_CLI_HOME or --data-dir overrides platform state defaults: ~/Library/Application Support/MoRemoteCLI on macOS, LOCALAPPDATA/MoRemoteCLI on Windows, XDG_STATE_HOME/moremote-cli (fallback ~/.local/state/moremote-cli) on Linux. PASEO_HOME selects the official read-only home, PASEO_PASSWORD matches official CLI password precedence. Only paseo.pid and local-credential are read under the official home, only at an explicit connection. No credential discovery scans or official writes. The unpublished former moremote-companion identity has no command/env aliases or automatic state adoption.
10
+
11
+ ## Central limits (src/limits.ts)
12
+
13
+ Envelope request128KiB; decrypted content64KiB; send text60000 UTF-8 bytes; command/control TTL300s; enrollment/state/attention maximum600s; receipt/controlReceipt maximum8KiB serialized envelope with600s attestation interval; future clock tolerance120s (never expiry grace). User payloads expire at original TTL, minimal encrypted receipts/evidence remain24h after original operation/control expiry. Receipt revision is persisted before I/O; control ack revision1 is immutable. At most1000 operations,1000 controls and1000 attention records per pairing,100 tasks/snapshot,10 pending requests/task,16 providers,8 windows/balances/provider. Raw enhanced request limit8KiB; whole state limit60000bytes. State refresh30s, polling3s backing off to30s, HTTP timeout20s, official connection/read15s, SDK mutation timeout per pinned upstream. Capacity errors never silently evict live authority.
14
+ HTTP response limit is5MiB, separately from the128KiB request limit; the relay count-bounds command/control pages to32. This permits real bounded acquisition pages without silently truncating valid large commands.
15
+ Local pair revocation tombstones are capped at4096, never evicting live protection. Exhaustion is an explicit failure. Running cleanup removes a tombstone only after its pairing credentials have been durably removed and all immutable child audit deadlines have passed. Offline configuration-only reads cannot prune revoked keys without their journal.
16
+
17
+ HTTP429/503 may carry Retry-After as seconds or a canonical HTTP-date. Validate
18
+ it, cap the wait at24hours and retain a fixed deadline per API origin. Paused
19
+ origins make no repeated3second HTTP attempts; unrelated origins keep their own
20
+ cadence. Once observed, a pause fences that origin for the remainder of the
21
+ runtime cycle even if slow SDK work outlasts the deadline. The next cycle first
22
+ reacquires controls before publication, receipt recovery or command acquisition.
23
+ Never reseal/renew an action or automatically repeat an uncertain mutation.
24
+
25
+ A successful upload acknowledges only those exact state/receipt bytes and
26
+ revision. Lost acknowledgements retain immutable retry bytes; acknowledged
27
+ snapshots/receipt revisions are not retransmitted each poll. Relay disappearance
28
+ or retirement fences execution but is not authenticated endpoint revocation.
29
+ Retired recovery ends at original child audit deadlines without extending them.
30
+
31
+ ## Service resources
32
+
33
+ macOS: user Library/LaunchAgents/com.moremote.cli.plist. Linux: XDG_CONFIG_HOME/systemd/user/moremote-cli.service (fallback user .config). Windows: current-user task MoRemoteCLI and UTF-16 XML in CLI state, InteractiveToken/LeastPrivilege; built-in PowerShell checks exact existing task ownership before schtasks mutation. Marker binds the data-directory hash; manager registration/file ownership mismatch fails closed. A private CLI root marker refuses nonempty foreign directories and gates purge. No official Paseo service/resource is altered. Missing managers fail honestly.
34
+
35
+ ## Update source
36
+
37
+ Only exact `@moxuli/moremote` versions from https://registry.npmjs.org are installed with lifecycle scripts disabled. Immutable private prefixes retain the bootstrap and last-known-good packages. Managed installed-package run and explicit per-user service installation use a retained supervisor, six-hour persisted checks, independent opt-out and whole-cycle IPC drain before candidate activation. Source checkout run stays manual; foreign/read-only resources fail honestly. `status` reports actual runtime version plus active/pending/previous/error/deadline facts. `auto-update --disable` prevents all queued activation until re-enabled. Compatible storage/wire protocol is checked before any drain; incompatible candidates remain manual. No official daemon/global package/Node upgrade. See [full lifecycle](specs/06-managed-updates.md) and [release prerequisites](releasing.md).
@@ -0,0 +1,9 @@
1
+ # Engineering conventions
2
+
3
+ Correctness and six-month maintainability first. TypeScript ESM on Node24; strict compiler; pinned direct dependencies and lockfile. Source modules are cohesive and below500 lines. No shell command composition, generic RPC gateway, sibling imports or developer-specific defaults. Native service control uses argument arrays and only owned registrations.
4
+
5
+ crypto owns exact wire validation/standard primitives; pairing owns endpoint proof; official-client owns the pinned official SDK; operations owns action validation and dispatch; journal owns SQLite durability; runtime owns observation/transport; cli owns explicit user intent. Mutation paths cannot bypass operations/journal. SDK reconnection is disabled; read-only reconnection is orchestrated by runtime. The pinned SDK sendAgentMessage/respondToPermissionAndWait methods internally use skipQueue:true; connected-state checks and no reconnect ensure no SDK mutation replay.
6
+
7
+ Tests assert consumer-visible crypto, byte vectors, timing, receipts, restart, revocation, current request/action authority, lifecycle ownership and real CLI behavior. Never assert copied prose or mock echoes as implementation evidence. Do not run live provider calls in tests. Use temp data/home and synthetic target identifiers.
8
+
9
+ Diagnostics contain version/capability/stage/error codes, never raw SDK errors, credentials, pairing offers, prompts or private paths. Display of a QR is explicit secret output, not routine diagnostics. Snapshots are bounded truthful measurements, not inferred progress or full histories. Cross-repo contracts are source-controlled copies and shared public fixtures, never runtime dependencies.
@@ -0,0 +1,19 @@
1
+ # 0001 — Retained private bootstrap, not global self-overwrite
2
+
3
+ Status: owner-authorized design, implementation awaiting integration verification.
4
+
5
+ ## Context
6
+
7
+ A continuously running scoped command consumer cannot safely replace itself or be stopped by an update during an uncertain official write. npm/global, source checkout and separately owned per-user service resources have different ownership boundaries. Manual staging without activation does not satisfy automatic updating.
8
+
9
+ ## Decision
10
+
11
+ Keep exact scoped npm versions immutable in private state. Retain the first bootstrap package and point native login registrations at its supervisor entry. Use bounded persisted discovery, one writer, parent-child IPC drain at a complete journalled-cycle boundary, a declared storage/wire compatibility gate, positive readiness plus startup survival, and retained last-known-good selection. Persist opt-out independently so it can win during staging/drain. Never overwrite global package files, upgrade official Paseo or garbage-collect any referenced prefix.
12
+
13
+ Reject alternatives: global npm self-update (permission/package-manager ownership and vanished entry risk); merely staging a new prefix (never activates running service); force-kill/restart (can interrupt uncertain writes); arbitrary future-schema rollback (old binary may not understand new journal). Compatible automatic releases must remain jointly readable by all retained rollback candidates; incompatible changes remain manual and require their own migration design.
14
+
15
+ ## Consequences
16
+
17
+ More disk is retained; the bootstrap's implementation remains fixed until explicit service maintenance. An update cannot force progress through a hung operation. This is preferable to corrupting authority or reporting false success. Package-manager installation, npm first publication/trusted-publisher setup, OS service acceptance and physical APNs delivery remain distinct gates.
18
+
19
+ Contracts: [managed updates](../specs/06-managed-updates.md), [release prerequisites](../releasing.md), [plan](../plans/2026-11-10-managed-updates.md).
@@ -0,0 +1,26 @@
1
+ # Managed updates and public release
2
+
3
+ Owner-authorized T2 iteration. Public npm identity is `@moxuli/moremote`; repository/executable/service/state identities remain `moremote-cli`.
4
+
5
+ ## Decision and acceptance
6
+
7
+ Use immutable private npm prefixes and a retained bootstrap supervisor, not global npm self-replacement. An explicitly installed service points at the retained bootstrap's service entry forever; a supervisor launches the selected runtime with authenticated-by-parent IPC. Global scoped npm installations enter this managed mode on run; source checkouts remain manual unless explicitly adopted with update/service-install. Default enabled managed checks run at most once per six hours, with one exclusive writer and no immediate retry. Exact stable versions only for automatic discovery, exact semver for explicit updates. Never update official Paseo, Node or global tooling. Read-only/foreign state fails visibly.
8
+
9
+
10
+ Owner refinement: automatic releases must declare unchanged updateProtocol/journalSchema/wireProtocol compatibility; mismatches stay pending/manual without executing. Discovery persists both lastCheck and nextCheck, honors bounded Retry-After, and suppresses a failed candidate across restart. Independent durable opt-out wins even during staging/activation. Installed mode requires actual resolved scoped npm layout, exact manifest and current-user resource ownership. All queued activation waits while disabled, including explicit manual candidates.
11
+ Activation queues a verified candidate. The supervisor requests a drain, never force-kills for an update; runtime finishes its entire current journalled cycle, closes connections/journal/control ownership, then exits. Only after exit does the supervisor launch the candidate. Readiness requires runtime ownership and a durable journal, followed by a ten-second startup window. Failure rolls back to the retained previous version and blocks that candidate from automatic retry. An interrupted activation rolls back at the next supervisor startup. Old prefixes are never garbage-collected automatically. Explicit stop exits the supervisor, not a respawn loop.
12
+
13
+ ## Implementation map
14
+
15
+ - `src/update-state.ts`: marked private JSON state, durable atomic replacement, exclusive process-aware writer/supervisor locks; no package configuration writes.
16
+ - `src/updater.ts`: managed setup, bounded registry discovery, package install and queued activation, opt-out/status.
17
+ - `src/supervisor.ts`, `bin/moremote-service.js`: stable per-user bootstrap and cooperative runtime handoff/rollback.
18
+ - `src/service.ts`: scoped identity verification, immutable installs and bounded npm subprocesses, retain platform ownership adapters.
19
+ - `src/runtime.ts`: parent-only IPC drain at cycle boundary and readiness, preserve mutation/journal semantics.
20
+ - `src/cli.ts`: managed run/service/update/status/opt-out integration and installed-version reporting.
21
+ - `tests/updater.test.ts`: real state/install/handoff processes with synthetic packages, failure/concurrency/opt-out boundaries.
22
+ - `.github/workflows/{ci,release}.yml`, `scripts/release.mjs`: frozen Node24.13.0, exact identity/tag validation, deterministic tarball, separate least-privilege release and OIDC publication.
23
+
24
+ ## Verification entrypoints (integration owner only)
25
+
26
+ `npm run check`; `node --import tsx --test tests/updater.test.ts tests/service-lifecycle.test.ts`; `node scripts/release.mjs validate v0.1.0`; isolated real npm tarball installation/upgrade as documented in release guidance. No service, global npm, registry publish, GitHub write or real host/device mutation in worker verification.