@moxuli/moremote 0.1.2 → 0.1.4

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.
@@ -8,6 +8,66 @@ Each pairing retains its explicit API origin through retirement. Local revokedAt
8
8
 
9
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
10
 
11
+ Unreleased single-pairing onboarding uses explicit `setup --yes`: stop only the
12
+ owned CLI runtime/service, reload its latest configuration, authenticate the
13
+ existing official daemon and preserve its exact identity, then enable cloud and
14
+ local enrollment before installing/starting the existing owned service.
15
+ Configured custom HTTPS origin/target, existing active/revoked phones and update
16
+ policy are preserved. An absent origin selects
17
+ `https://moremote-cloud-ingress.pages.dev`. Source checkout without managed state
18
+ binds its own current frontend and stays manual-update. Installed packages and
19
+ retained managed state use capability-aware setup: if selected code predates
20
+ enrollment, explicit setup installs/verifies the exact current version before
21
+ enabling the feature, then moves active/bootstrap while retaining previous
22
+ packages, pairs/custom origin and the independent auto-update opt-out.
23
+ `SETUP_CURRENT_PACKAGE_UNAVAILABLE`/`SETUP_CAPABILITY_REQUIRED` are failures,
24
+ never enabled success or an older-package fallback. Nothing patches/upgrades
25
+ official Paseo or global tools. This capability requires CLI0.1.4 or later.
26
+
27
+ Optional schema-1 fields are `localEnrollment:{home:<absolute user home>}` and
28
+ at most16 `enrollmentRequests`. Only explicit setup supplies that home; ordinary
29
+ `run`/tests with legacy configuration never create discovery in the real HOME.
30
+ Each durable record stores the exact request bytes, SHA256 fingerprint, parsed
31
+ request, original pair/offer, exact cloud-create JSON bytes and confirmed-create
32
+ flag. Per-pair `automaticClientId` and `automaticRequestId` retain app/request
33
+ identity without replacing an old pair. Runtime-cycle ownership serializes all enrollment/config changes;
34
+ there is no second config writer or background watcher.
35
+
36
+ Config reads, owned-resource validation and atomic writes share a524288-byte
37
+ bound, including the serialized trailing newline. This accommodates16 maximum
38
+ 4096-byte requests even when literal tab/newline bytes expand during JSON
39
+ serialization. Oversize writes fail before replacing any config. Fresh `run`
40
+ initializes config only after acquiring runtime ownership; duplicate `run`
41
+ refuses without rewriting a live enrollment snapshot.
42
+
43
+ The private tree is `<home>/.moremote-cli-connect/<sha256(UTF8 daemonServerId)>/`;
44
+ its parent/host/request/response directories have owned markers and POSIX0700.
45
+ Descriptor and secret responses are0600; official-created requests may be0644
46
+ inside the private request directory. Reject links, foreign markers/owners,
47
+ collisions and competing runtime locks before cloud creation. Windows relies on
48
+ the user-profile ACL. Only this owned local tree is written, not official files.
49
+ The app gets the real home via official directory suggestions, never a guessed
50
+ path. Descriptor includes the configured/default validated HTTPS `apiOrigin`,
51
+ which pins the original canonical offer's origin.
52
+
53
+ Unchanged request bytes resume the same endpoint and idempotent create bytes
54
+ through lost acknowledgements/restarts; changed bytes/client/daemon/expiry fail
55
+ closed. No more than16 request files are consumed per cycle and no more than16
56
+ pairs exist. At most one optional cloud-create attempt runs per cycle with its
57
+ own3s abort deadline; existing phones retain ordinary controls/command handling.
58
+ Descriptor lifetime90s/renewal30s; request/offer lifetime at most600s.
59
+ Activation/expiry removes private responses, expiry removes durable request
60
+ records. An old exact request remains disabled after revocation; only the app's
61
+ explicit fresh Enable request may create a new endpoint after prior retirement.
62
+ Full schemas and ownership behavior:
63
+ [single-pairing contract](specs/05-endpoint-and-lifecycle.md#single-pairing-local-enrollment-v1-unreleased).
64
+
65
+ Loading config, `check` and `status` do not create discovery, enable cloud,
66
+ select an origin, enroll or install a service; `check --connect` is read-only.
67
+ Manual `pair` remains expert-only and installs no service. Published0.1.2 lacks
68
+ `setup` and still requires explicit origin/cloud configuration before manual
69
+ pairing; this source delta is not published.
70
+
11
71
  ## Central limits (src/limits.ts)
12
72
 
13
73
  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.
@@ -69,6 +69,18 @@ read-only but cannot approve a replacement. Before dispatch, refresh the actual
69
69
  pending request, match its binding/source and validate the selected actual action.
70
70
  Do not depend on requestId never being reused.
71
71
 
72
+ Request notifications use the exact current occurrence's first-observed clock,
73
+ independent of a task's older completion or global attention timestamp. Keep that
74
+ clock stable across repeated observations. A request/resolution event or a newer
75
+ accepted observation fences older in-flight reads of that agent before journal
76
+ synchronization or notification; delayed responses cannot recreate a retired
77
+ occurrence, replace newer authority or supply a fresh notification clock.
78
+ The official adapter owns synchronization into its exact journal; binding callers
79
+ do not observe the returned request array again. They match its generation/source
80
+ fingerprint and recheck currentness after binding. Queued internal request events
81
+ capture their occurrence when observed, so delayed draining cannot attach an old
82
+ event's clock to a replacement occurrence or consume its notification identity.
83
+
72
84
  Reject response fields outside the real upstream response shape. Any remembered
73
85
  permissions must be an actual offered suggestion explicitly selected by the user;
74
86
  never accept an arbitrary new grant or silently set remember. Edited input is
@@ -1,11 +1,135 @@
1
1
  # 05 — Endpoint and lifecycle behavior
2
2
 
3
- ## Enrollment QR v1
3
+ ## Single-pairing local enrollment v1 — unreleased
4
+
5
+ Normal users pair only official Paseo. Explicit `setup --yes` authenticates the
6
+ existing official daemon, enables automatic enrollment/cloud and installs/starts
7
+ only the existing owned CLI per-user service. Stop/reload only owned CLI state;
8
+ preserve custom origin/target, active/revoked pairs and update preference. An
9
+ absent API origin selects the built-in production HTTPS endpoint. Source checkout
10
+ without managed state binds its current frontend and manual-update policy;
11
+ installed packages/retained managed state use capability-aware exact-current
12
+ setup migration before enabling enrollment, retaining prior packages and update
13
+ opt-out while selecting an enrollment-capable active/bootstrap. Unavailable or
14
+ incapable current packages fail explicitly without cloud opt-in. Manifest
15
+ `localEnrollment:1` and `configBytes:524288` declare that capability.
16
+ `check`, `status` and config reads remain passive. Manual `pair` is expert-only.
17
+ No official modifications, new listener, hidden terminal/workspace, model prompt,
18
+ new relay, global upgrade or package publication is part of this protocol.
19
+
20
+ Discovery tree:
21
+
22
+ ```text
23
+ <home>/.moremote-cli-connect/<sha256(UTF8 daemonServerId)>/
24
+ descriptor.json
25
+ requests/<request UUID>.json
26
+ responses/<request UUID>.json
27
+ ```
28
+
29
+ Parent, daemon and request/response directories carry owned markers and are
30
+ ordinary owned POSIX0700 directories. Descriptor/responses are0600. Requests
31
+ created by the official file API may be0644 inside their private parent.
32
+ Windows relies on the user profile ACL. Reject symlinks, hardlinks, foreign
33
+ markers/users/types, response collisions and competing runtime ownership.
34
+ One marked daemon directory binds to the exact CLI state directory. Its own
35
+ exclusive PID/instance lock can be reclaimed only after the recorded process
36
+ is dead; this lock never authorizes signalling another process. No new socket
37
+ is created. Existing runtime ownership serializes config/cycle work.
38
+
39
+ The app obtains the actual home through official `directory_suggestions_request`
40
+ with query `~/././.`, preserving Windows path joining. A <=4096-byte descriptor is
41
+ exactly:
42
+
43
+ ```text
44
+ {version:1,daemonServerId,instanceId,apiOrigin,enabled,measuredAt,expiresAt}
45
+ ```
46
+
47
+ `instanceId` is a lowercase UUID. Times are safe integer Unix milliseconds.
48
+ `apiOrigin` is the configured/default validated canonical HTTPS origin, pinned
49
+ over the already authenticated official file channel. Descriptor lifetime is90s,
50
+ renewed no faster than30s; disablement can remove resources or publish disabled
51
+ without granting a new enabled lease. This is not a cloud heartbeat.
52
+
53
+ After validating the original authenticated host/session/generation and fresh
54
+ descriptor, the app durably retains one exact immutable UTF-8 request before
55
+ official create/read-revision/write. Empty files are unfinished creates, not
56
+ admissions. Unknown outcomes read the same exact path and never mint another
57
+ request identity. Request <=4096bytes:
58
+
59
+ ```text
60
+ {version:1,id,clientId,daemonServerId,issuedAt,expiresAt}
61
+ ```
62
+
63
+ IDs/client IDs are lowercase UUIDs; lifetime is at most600000ms, with no future
64
+ issuance or expiry grace. At most16 files are consumed per cycle with a rotating
65
+ cursor, and the existing16-pair ceiling remains. A durable record saves exact
66
+ bytes/fingerprint, original pair/canonical offer and exact cloud-create JSON
67
+ before I/O. Lost creation acknowledgements retry those identical bytes through
68
+ the unchanged relay's exact-offer-digest idempotency. A confirmed creation is
69
+ saved before any secret response. Changed bytes/client/daemon/expiry cannot
70
+ replace authority. A client with a current live endpoint cannot manufacture
71
+ another by changing its request ID. Old exact revoked/retired requests remain
72
+ disabled; an explicit fresh app Enable request can create a new independent
73
+ endpoint after retirement. Existing pairs are never reused or revived.
74
+
75
+ At most one cloud-create attempt runs per serialized cycle, independently aborted
76
+ after3s; no optional admission may accumulate sixteen20s cloud waits ahead of an
77
+ existing phone's commands. Requests retain original authority across that abort.
78
+
79
+ Response <=8192bytes:
80
+
81
+ ```text
82
+ {version:1,id,clientId,daemonServerId,expiresAt,status,offer?,code?}
83
+ ```
84
+
85
+ Status vocabulary is `pending|offer|active|disabled|error`. Only `offer` carries
86
+ the original canonical version1 offer defined below. Its origin must exactly
87
+ match the authenticated descriptor pin. Response expiry never exceeds either
88
+ original request or offer expiry. Pending/unknown cloud creation has no secret
89
+ response. Invalid/conflicting/foreign files fail closed without overwriting
90
+ them; the normal runtime reports only a redacted cycle failure. Disabled/retired
91
+ admitted requests can receive a nonsecret disabled response. The app stages and
92
+ claims automatically, without an offer-review screen, using the unchanged
93
+ phoneHello/companionHello proof and independently verified daemon identity.
94
+
95
+ Activation removes the owned request/private response. Expiry removes them and
96
+ their durable enrollment record; existing pair/audit retirement is unchanged.
97
+ Stop removes only owned responses/descriptor/lock, retaining exact request/pair
98
+ authority for restart until original expiry. Explicit cloud-off removes secret
99
+ responses and never creates another pair. Automatic observation is bounded by
100
+ the app to10 response reads over at most30s; a later foreground refresh retains
101
+ the same exact request. No forever polling, recursive requests or cloud pairing
102
+ on each launch.
103
+
104
+ Implementation APIs are `LocalEnrollment.cleanup/cycle/close`,
105
+ `EnrollmentFiles`/`discoveryDirectory`, `setupEnrollment`, and the explicit
106
+ `EnrollmentRequest`, `EnrollmentOffer`, `EnrollmentRecord`,
107
+ `EnrollmentDescriptor`, `EnrollmentResponse` types. All test homes/storage and
108
+ service lifecycle I/O are injectable; tests never create discovery in real HOME
109
+ or implicitly register a real service. Focused isolated consumers live in
110
+ `tests/local-enrollment.test.ts` and `tests/setup-command.test.ts`; they are
111
+ verification instructions, not a claim of execution.
112
+
113
+ Config/resource readers and atomic writers use the same524288-byte serialized
114
+ bound, preserving full original request bytes. Oversize writes reject before
115
+ replacement. Only acquired runtime ownership initializes fresh config; duplicate
116
+ `run` never writes an old loaded config over live enrollment.
117
+
118
+ ## Expert-only manual enrollment offer v1
4
119
 
5
120
  Canonical offer is compact UTF-8 JSON with exactly {version:1,apiOrigin,pairId,enrollmentToken,rootKey,expiresAt}. pairId is a lowercase UUID; token/rootKey are independently random canonical unpadded-base64url32-byte values. The ten-minute original expiry bounds claim, both proofs and activation; a claim just before the deadline does not extend it. Default QR/link is moremote://enhance# plus unpadded-base64url of those exact JSON bytes. --json emits raw JSON. The fragment never reaches an HTTP origin. Consumers reject extras, unsupported versions, expired/noncanonical offers and origin changes; HTTPS except explicit loopback development. The secret QR is explicit output, never diagnostics.
6
121
 
7
122
  The companion persists its root/host/enrollment capabilities before POST pairs, sending only identity, expiry and SHA256 hashes of the canonical bearer UTF-8 text (not decoded bytes). It verifies the pending phoneHello claim/token hash exactly, saves the accepted phone and immutable companionHello proof before activation, and enables actions only after confirmation within the original deadline. The phone independently verifies proof and exact saved daemon identity. Every phone is a separate pairing/key. Cloud credentials cannot satisfy this endpoint proof.
8
123
 
124
+ Unreleased source onboarding: invoking `pair` is explicit cloud consent. If
125
+ `apiOrigin` is absent, select the built-in
126
+ `https://moremote-cloud-ingress.pages.dev`; otherwise preserve and validate the
127
+ configured origin. Existing target, local official discovery and daemon pin
128
+ remain authoritative. Persist cloud-enabled configuration and the new offer
129
+ only after the official connection succeeds, before relay creation. Retained
130
+ pair keys, origins and revocation are never changed by a new enrollment.
131
+ Passive config loads/check/status do not opt in, and pairing installs no service.
132
+
9
133
  ## Official compatibility and observation
10
134
 
11
135
  Pin client/protocol0.15.3. createHostClient from client/node and exported internal/daemon-client types are the inspected API. Use clientType cli and a distinct companion clientId. Missing explicitEventSubscriptions fails closed. Subscribe only agent_attention_required, agent_permission_request, agent_permission_resolved, status.server_info with official remote notifications disabled. Never call client_heartbeat, clear_agent_attention, workspace read acknowledgement or register_push_token. Inspected SDK automatic liveness uses bare protocol ping (10s), not visible-user presence. Actual synthetic WebSocket consumers exercise the real adapter/SDK, await that liveness interval, verify wire traffic, then lose send/permission acknowledgements and reconnect without a second mutation.
@@ -16,7 +140,7 @@ Only selected paseo.pid and local-credential files are read, with bounded I/O an
16
140
 
17
141
  ## Bounded encrypted state and attention
18
142
 
19
- State plaintext is exactly {version:1,daemonServerId,hostName,measuredAt,tasks:[{agentId,title,status,updatedAt,requiresAttention,attentionReason,pendingRequests:[{requestId,requestBinding,request:<complete original official request JSON>}]}],usage,tasksTruncated}. At most100 recent noninternal/nonarchived tasks,10 requests/task,16 provider summaries and8 windows/balances/provider. A raw request over8KiB is omitted from enhanced actions, not silently truncated into another authority. Whole trailing tasks are omitted to keep serialized state under60000bytes; tasksTruncated is explicit. Unavailable usage is null/unavailable, never zero. No full conversation or files are projected. Measurement time survives immutable state retries.
143
+ State plaintext is exactly {version:1,daemonServerId,hostName,measuredAt,tasks:[{agentId,provider,title,status,createdAt,updatedAt,lastUserMessageAt,activeTurnStartedAt,cwd,requiresAttention,attentionReason,pendingRequests:[{requestId,requestBinding,request:<complete original official request JSON>}]}],usage,tasksTruncated}. Provider and creation time are additive unreleased source fields; older snapshots may omit them. Preserve genuine official provider and ISO-8601 createdAt/lastUserMessageAt facts; a missing last-user time stays null, never replaced by assistant-driven updatedAt. Consumers order recents by lastUserMessageAt, then creation time only when absent, then stable identity for ties. At most100 recent noninternal/nonarchived tasks,10 requests/task,16 provider summaries and8 windows/balances/provider. A raw request over8KiB is omitted from enhanced actions, not silently truncated into another authority. Whole trailing tasks are omitted to keep serialized state under60000bytes; tasksTruncated is explicit. Unavailable usage is null/unavailable, never zero. No full conversation or files are projected. Measurement time survives immutable state retries.
20
144
 
21
145
  Attention plaintext is exactly {agentId,requestId?,requestBinding?,kind,timestamp}. No form or prompt is in the push route. For question/approval actions the app must find the exact matching authenticated raw request and binding in state or open the original form; it cannot paste the same reply into unsupported/multiple questions. Own notification policy uses genuine short viewing leases, never official shouldNotify. Stable semantic attention identity is independent of reconnect-generated authority tokens: reconnect may retire an old action binding without replaying historical attention as a new push. Source change/resolution/current no-longer-requires-attention facts persist exact event invalidation and POST its resolve endpoint, stopping future relay retries without changing official read state. An already in-flight/displayed push cannot be retracted.
22
146
 
@@ -32,6 +32,31 @@ Automatic discovery requests bounded latest metadata once per six hours, persist
32
32
 
33
33
  `auto-update --disable` writes a separate durable marked private opt-out even while another writer is staging/draining. Readers immediately report disabled. No queued candidate activates while disabled, including an explicit manual candidate; `auto-update --enable` resumes eligible queued work. An automatic pending candidate is cancelled when the writer is available; a concurrent installation may finish staging but cannot activate. Enabling never resets discovery deadlines or failed-version suppression. `status` distinguishes package bootstrap required, source-checkout manual mode, and the managed active/pending/previous/error/check facts.
34
34
 
35
+ ## Explicit setup capability migration — CLI0.1.4 and later
36
+
37
+ `setup --yes` authorizes a specific owned CLI migration, not a global package,
38
+ Node or official daemon upgrade and not a change to automatic-update policy.
39
+ The current frontend recognizes its `localEnrollment:1` capability and routes
40
+ setup to selected code only when that selected package supports the same
41
+ enrollment/config-bound capability. A retained public0.1.2 handler cannot swallow
42
+ the command as unknown before the new handler runs.
43
+
44
+ After stopping only the owned runtime/service and authenticating official
45
+ identity, setup stages/verifies its exact current version when necessary.
46
+ Unavailable current packages or missing capability fail before feature/cloud
47
+ enablement; no old npm fallback is accepted. Then active/bootstrap move to the
48
+ capable package, previous/immutable packages and pair/custom-origin state remain,
49
+ and the independent update opt-out still wins for future automatic updates.
50
+ Source checkout without managed state instead binds its current own frontend.
51
+ Actual publication and installation receipts are recorded in docs/STATE.md.
52
+
53
+ All current config readers/resource validators/writers share524288bytes and
54
+ reject an oversized serialized replacement before publication. Original request
55
+ bytes are retained even when JSON control-character escaping expands them.
56
+ This explicit capability migration does not assert that a directly invoked old
57
+ 128KiB config reader can consume larger state. Retained public frontends route
58
+ subsequent commands to selected capable code rather than invoking old handlers.
59
+
35
60
  ## Compatibility and activation
36
61
 
37
62
  Every publish declares `moremote: {updateProtocol:1,journalSchema:1,wireProtocol:1}`. Both staging selection and the retained supervisor independently check this exact compatibility tuple. Missing/different compatibility remains pending with manualRequired and `UPDATE_MANUAL_COMPATIBILITY_REQUIRED`; it never drains or executes. Automatic-release validation also rejects another tuple. A compatible release MUST preserve all older retained versions' ability to read/write the same config/journal, mutation tombstones and wire lifecycle. A mere startup survival window cannot prove this property. Breaking storage/wire changes require a separately designed, owner-approved migration/release process; do not relabel an incompatible schema as1 or promise arbitrary downgrade safety. The existing FULL-sync journal, occurrence, revoke and no-replay contracts are unchanged.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxuli/moremote",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Optional encrypted notification and scoped-action companion for Paseo",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://github.com/moxuli/moremote-cli#readme",
9
9
  "bugs": {"url": "https://github.com/moxuli/moremote-cli/issues"},
10
10
  "publishConfig": {"access": "public", "registry": "https://registry.npmjs.org"},
11
- "moremote": {"updateProtocol": 1, "journalSchema": 1, "wireProtocol": 1},
11
+ "moremote": {"updateProtocol": 1, "journalSchema": 1, "wireProtocol": 1, "localEnrollment": 1, "configBytes": 524288},
12
12
  "files": ["bin", "dist", "docs", "vectors", "licenses", "LICENSE", "NOTICE", "README.md"],
13
13
  "engines": {
14
14
  "node": ">=24.13.0 <25"