@lensmcp/protocol-types 1.26.2 → 1.26.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.
package/lib/hosts.d.ts ADDED
@@ -0,0 +1,206 @@
1
+ import type { PairingWindowView, PeerPinState, PeerWords } from './peers.js';
2
+ /**
3
+ * SETTINGS › HOSTS — what the dashboard's `GET /api/hosts` answers, and its actions' answers (planning/docker/00-plan.md
4
+ * §§ 7, 9 and 11 «The dashboard», slice D19; issues/open/overseer-74).
5
+ *
6
+ * On the organizer: this Mac's identity, the peer hub (listening where and why, or not and why), the pairing window
7
+ * (never its code), the workers — waiting for the person's approval with their four words, or paired with their link
8
+ * and their version. On a worker (a home that pins an organizer): the organizer it serves, its link, its version and
9
+ * the person's choice to follow the organizer's version.
10
+ *
11
+ * The code of a pairing window is in ONE answer only: the one that opened it ({@link DashHostsPairOpened}). No other
12
+ * answer, listing or log carries it.
13
+ *
14
+ * Every action here is the person's: the dashboard takes it as it takes every other write of the person's — a
15
+ * same-origin JSON POST behind the dashboard's sign-in — and only on a dashboard bound to loopback, as the Changes
16
+ * page's writes. Pure types: the dashboard reads them.
17
+ */
18
+ /** A version state as both dashboards show it: D13's `PeerVersionState` (apps/agent peers/versions.ts) in words. */
19
+ export type HostVersionState = 'in-step' | 'installing' | 'waiting-for-person' | 'out-of-step';
20
+ export interface HostVersionView {
21
+ state: HostVersionState;
22
+ /** What each side runs: its LensMCP version and the peer protocol it speaks. */
23
+ worker: {
24
+ lensmcp: string;
25
+ protocol: string;
26
+ };
27
+ organizer: {
28
+ lensmcp: string;
29
+ protocol: string;
30
+ };
31
+ /** D13's words (`versionStateWords`): a headline, and what it means for the work. */
32
+ headline: string;
33
+ detail: string;
34
+ /** Only a worker in step takes work (§ 9 rule 4). */
35
+ takesWork: boolean;
36
+ /**
37
+ * Where it was read: `hello` — the organizer's view from the worker's hello alone (in step, or out of step and on
38
+ * which side); `worker` — what the worker itself said of its store, its install and its restart.
39
+ */
40
+ from: 'hello' | 'worker';
41
+ /** When it was read, by this Mac's clock. */
42
+ at: number;
43
+ /** The waiting-for-person state's: the organizer's version is in the worker's store already. */
44
+ stored?: boolean;
45
+ }
46
+ /** A link between two Macs, as one side last saw it. */
47
+ export interface HostLinkView {
48
+ /**
49
+ * `connected`: its control stream is up and said hello. `not-connected`: it was, and went (`why`). `lost`: 45 s
50
+ * without a word — its runs read lost. `never`: not since this Mac began keeping the link's account.
51
+ */
52
+ state: 'connected' | 'not-connected' | 'lost' | 'never';
53
+ /** Connected since. */
54
+ since?: number;
55
+ /** The address it came from (the organizer's view), or the one it dials (the worker's). */
56
+ remote?: string;
57
+ /** The last word from the other side, by this Mac's clock — none: not known. */
58
+ lastHeardAt?: number;
59
+ /** When it went: disconnected, or found lost. */
60
+ wentAt?: number;
61
+ why?: string;
62
+ }
63
+ /** A worker as the organizer's Settings › Hosts shows it — its pin, and what the peer hub knows of its link. */
64
+ export interface HostsWorker {
65
+ name: string;
66
+ model: string;
67
+ fingerprint: string;
68
+ /** Its certificate's fingerprint as a person reads it: the first sixteen characters, in fours. */
69
+ short: string;
70
+ /** The four words the person compares with the worker's terminal before approving. */
71
+ words: PeerWords;
72
+ state: PeerPinState;
73
+ answeredAt: number;
74
+ /** A pending worker is dropped at this time unless the person approved it. */
75
+ approveBy?: number;
76
+ approvedAt?: number;
77
+ /** The address it paired from: evidence only — a worker is its certificate. */
78
+ from?: string;
79
+ link: HostLinkView;
80
+ /** Its versions, as last read — none: not heard since it was paired. */
81
+ version?: HostVersionView;
82
+ /** Whether it follows the organizer's version by itself, as it last said — none: it has not said. Its person sets it, on the worker. */
83
+ follow?: boolean;
84
+ }
85
+ /** The organizer's peer hub: listening where and why, or not and why. */
86
+ export interface HostsHub {
87
+ /** As `hub.json` says it — `never`: no hub has run in this home. A `listening` whose process is gone reads `stopped`. */
88
+ state: 'listening' | 'idle' | 'stopped' | 'never';
89
+ why: string;
90
+ address?: string;
91
+ port?: number;
92
+ pid?: number;
93
+ /** When the hub last wrote its status. */
94
+ at?: number;
95
+ /** What the files say it should do now (pairing.ts `hubWanted`) — the page says when the two disagree. */
96
+ wanted: {
97
+ wanted: boolean;
98
+ why: string;
99
+ address?: string;
100
+ port?: number;
101
+ };
102
+ }
103
+ /** This Mac, as the other side sees it. */
104
+ export interface HostsSelf {
105
+ /** The name it goes by as a peer (`LENSMCP_PEER_NAME`, else its Computer Name). */
106
+ name: string;
107
+ /** Its model identifier («Mac14,13»). */
108
+ model: string;
109
+ /** Its certificate's fingerprint — none: no identity was made yet (the first pairing makes it). */
110
+ fingerprint?: string;
111
+ short?: string;
112
+ }
113
+ /** Where a new pairing window would listen, and what else this Mac could listen on (DW-Q6: ONE address the person picks). */
114
+ export interface HostsListen {
115
+ address?: string;
116
+ port: number;
117
+ /** `env`: LENSMCP_PEER_ADDRESS; `kept`: the address the paired workers dial; `primary`: the primary interface's. */
118
+ from?: 'env' | 'kept' | 'primary';
119
+ /** This Mac's own addresses a window may listen on — never every interface, multicast or broadcast. */
120
+ choices: string[];
121
+ /** Why there is no address to listen on. */
122
+ none?: string;
123
+ }
124
+ export interface HostsOrganizerSide {
125
+ hub: HostsHub;
126
+ /** The pairing window, never with its code — none: none is open or used now. */
127
+ window?: PairingWindowView;
128
+ listen: HostsListen;
129
+ /** The pending ones first, then the paired, by name. */
130
+ workers: HostsWorker[];
131
+ }
132
+ /** This Mac as a worker: the organizer it serves. */
133
+ export interface HostsWorkerSide {
134
+ organizer: {
135
+ name: string;
136
+ model: string;
137
+ fingerprint: string;
138
+ short: string;
139
+ words: PeerWords;
140
+ /** `pending`: it gave the right code and waits for the organizer's person. */
141
+ state: PeerPinState;
142
+ /** Where it dials. */
143
+ address: string;
144
+ port: number;
145
+ answeredAt: number;
146
+ approvedAt?: number;
147
+ };
148
+ /** The link the worker daemon keeps — `never` when no daemon has run here since the pairing. */
149
+ link: HostLinkView & {
150
+ /** The daemon that keeps it, while it runs. */
151
+ daemon?: {
152
+ pid: number;
153
+ };
154
+ /** The organizer's own LensMCP version, as its welcome said. */
155
+ organizerVersion?: string;
156
+ };
157
+ /** Its versions, as its daemon last said them — none: no daemon has said. */
158
+ version?: HostVersionView;
159
+ /** The person's choice on this Mac (D13 `versions.json`, per pairing): follow the organizer's version by itself (yes by default), and the version they approved. */
160
+ follow: {
161
+ follow: boolean;
162
+ approved?: string;
163
+ };
164
+ }
165
+ /** `GET /api/hosts`: Settings › Hosts. */
166
+ export interface DashHostsView {
167
+ at: number;
168
+ self: HostsSelf;
169
+ organizer: HostsOrganizerSide;
170
+ /** Present on a Mac that pins an organizer. */
171
+ worker?: HostsWorkerSide;
172
+ /**
173
+ * Whether this dashboard takes the person's actions on this page: a dashboard bound to loopback only — refused (and
174
+ * said why) on one bound wider, as the Changes page's writes are.
175
+ */
176
+ writes: {
177
+ ok: true;
178
+ } | {
179
+ ok: false;
180
+ why: string;
181
+ };
182
+ }
183
+ /**
184
+ * `POST /api/hosts/pair`'s answer — the ONE answer that carries a window's code. The page keeps it in memory only, for
185
+ * the person to copy: reloaded, the page no longer has it (open another window).
186
+ */
187
+ export interface DashHostsPairOpened {
188
+ window: PairingWindowView;
189
+ /** The code as it is shown: two groups of five, `7K3MQ-XW2PD`. */
190
+ code: string;
191
+ /** What the person types on the other Mac. */
192
+ line: string;
193
+ /** The hub listens for this window now. */
194
+ listening: boolean;
195
+ /** Why it does not listen yet, and what changes for workers already paired. */
196
+ notes: string[];
197
+ hosts: DashHostsView;
198
+ }
199
+ /** Every other action's answer: what was done, in a sentence, and the page as it is after it. */
200
+ export interface DashHostsDone {
201
+ said: string;
202
+ hosts: DashHostsView;
203
+ }
204
+ /** The actions of Settings › Hosts, each `POST /api/hosts/<action>` — the person's, every one. */
205
+ export declare const HOSTS_ACTIONS: readonly ["pair", "close", "approve", "decline", "revoke", "forget", "follow", "approve-version"];
206
+ export type HostsAction = (typeof HOSTS_ACTIONS)[number];
package/lib/hosts.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";export const HOSTS_ACTIONS=["pair","close","approve","decline","revoke","forget","follow","approve-version"];
@@ -0,0 +1,117 @@
1
+ import type { MainFollowState, MainSendVerdict, MainUpdateReport } from './peers.js';
2
+ /**
3
+ * Main on a worker Mac, as both dashboards' Changes page shows it (planning/docker/00-plan.md § 14, slice D34) —
4
+ * `GET /api/changes/peers`. On the ORGANIZER: one row per worker — its commits to bring into main and where they
5
+ * stand, what is uncommitted on its main and the snapshot's age, what it has not sent, what it lacks of main. On a
6
+ * WORKER: its own main against the organizer's. Read only; the writes are `POST /api/changes/bring-in` (the organizer),
7
+ * `/api/changes/update-main`, `/api/changes/commit-send` and `/api/changes/send-main` (a worker).
8
+ */
9
+ /** Which side of a pairing this dashboard's checkout is: the organizer's main, a worker's main, or neither. */
10
+ export type DashMainRole = 'organizer' | 'worker' | 'none';
11
+ /** Where a worker's sent commits stand against main NOW (not only at the last attempt). */
12
+ export type DashMainBringIn =
13
+ /** Nothing sent, or every commit sent is on main. */
14
+ 'in-main'
15
+ /** A fast-forward on a clean main: «Bring in» moves main. */
16
+ | 'ready'
17
+ /** A fast-forward, and main has uncommitted changes, or is not on its branch: they wait. */
18
+ | 'waiting'
19
+ /** Main moved past what they were made on: the worker updates from main and sends again. */
20
+ | 'not-ff';
21
+ /** What is uncommitted on a worker's main, and the newest snapshot of it. */
22
+ export interface DashMainUncommitted {
23
+ files: number;
24
+ /** When the newest snapshot of it was made (ms) — what «snapshot 3 min ago» counts from. */
25
+ snapshotAt?: number;
26
+ snapshot?: string;
27
+ /** The snapshot reached the organizer (`refs/lensmcp/peers/<worker>/wip/<branch>`). */
28
+ sent?: boolean;
29
+ /** Its files the snapshot holds. */
30
+ snapshotFiles?: number;
31
+ }
32
+ /** A worker's main, as the organizer's Changes page shows it. */
33
+ export interface DashMainWorker {
34
+ /** Its certificate's fingerprint: what its namespace is named by (`refs/lensmcp/peers/<peer>/…`). */
35
+ peer: string;
36
+ name: string;
37
+ paired: boolean;
38
+ connected: boolean;
39
+ /** Its sent commits not on main. */
40
+ toBringIn: number;
41
+ bringIn: DashMainBringIn;
42
+ /** One sentence: where they stand, and what moves them. */
43
+ why: string;
44
+ /** Its sent tip, and when it came. */
45
+ sent?: string;
46
+ sentAt?: number;
47
+ /** The last attempt to bring them in. */
48
+ last?: MainSendVerdict;
49
+ /** What is uncommitted there, as it last said and as its snapshot holds. */
50
+ uncommitted?: DashMainUncommitted;
51
+ /** Its commits it has not sent (as it said). */
52
+ notSent?: number;
53
+ /** Main's commits its main lacks (counted here, from the head it said). */
54
+ toPull?: number;
55
+ follow?: MainFollowState;
56
+ /** Its last «Update from main» — a conflict, and who it asked. */
57
+ update?: MainUpdateReport;
58
+ /** When it last said how its main stands. */
59
+ reportedAt?: number;
60
+ /** «Bring in» does something now. */
61
+ canBringIn: boolean;
62
+ }
63
+ /** A send waiting for the link to the organizer. */
64
+ export interface DashMainPending {
65
+ /** `heads/<branch>` or `wip/<branch>`. */
66
+ ref: string;
67
+ sha: string;
68
+ at: number;
69
+ /** Commits it carries (a send of main), files (a snapshot). */
70
+ count?: number;
71
+ files?: number;
72
+ }
73
+ /** This Mac's main, as a worker's Changes page shows it. */
74
+ export interface DashMainSelf {
75
+ /** The organizer, by its name. */
76
+ organizer: string;
77
+ root: string;
78
+ branch: string;
79
+ head?: string;
80
+ organizerHead?: string;
81
+ follow: MainFollowState;
82
+ /** One sentence: how it stands, and what happens next. */
83
+ why: string;
84
+ /** Its commits the organizer does not hold. */
85
+ notSent: number;
86
+ /** Main's commits it lacks. */
87
+ toPull: number;
88
+ /** Tracked files with changes (what holds a move of main). */
89
+ dirty: number;
90
+ uncommitted: DashMainUncommitted;
91
+ /** Sends waiting for the link. */
92
+ pending: DashMainPending[];
93
+ /** The last send the organizer answered. */
94
+ lastSend?: {
95
+ sha: string;
96
+ at: number;
97
+ verdict?: MainSendVerdict;
98
+ };
99
+ update?: MainUpdateReport;
100
+ /** «Update from main» does something now. */
101
+ canUpdate: boolean;
102
+ /** «Send» does something now: commits not sent, none waiting. */
103
+ canSend: boolean;
104
+ }
105
+ export interface DashMainMirror {
106
+ at: number;
107
+ role: DashMainRole;
108
+ /** The branch main is. */
109
+ branch: string;
110
+ /** The organizer: its main's head; a worker: its own main's. */
111
+ mainHead?: string;
112
+ /** The organizer: tracked files changed on main now — what makes a worker's commits wait. */
113
+ mainDirty?: number;
114
+ workers?: DashMainWorker[];
115
+ self?: DashMainSelf;
116
+ notes: string[];
117
+ }
@@ -0,0 +1 @@
1
+ "use strict";export{};