ccdeck 3.48.0 → 3.49.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.
- package/README.md +20 -17
- package/dist/web/assets/{BrowserWatchModal-DuopT2Oa.js → BrowserWatchModal-D-7rOvFP.js} +1 -1
- package/dist/web/assets/{IntegrationModal-CszT-tts.js → IntegrationModal-BbiK7DiR.js} +1 -1
- package/dist/web/assets/{RadioPanel-Cn3WvPUG.js → RadioPanel-BXbw3TO5.js} +1 -1
- package/dist/web/assets/{TrafficRadar-DZA8XSi7.js → TrafficRadar-YQJ7dFlH.js} +2 -2
- package/dist/web/assets/{UsageHistoryModal-MgZJLXbF.js → UsageHistoryModal-XO_w9pBD.js} +1 -1
- package/dist/web/assets/app-DRbxoq7w.css +1 -0
- package/dist/web/assets/app-EEG3dpaG.js +321 -0
- package/dist/web/assets/{index-BK9avF1k.js → index-DfCwddzR.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/release-notes.json +99 -11
- package/src/server/account-notify.mjs +2 -54
- package/src/server/account-watch.mjs +0 -47
- package/src/server/deck-prefs.mjs +28 -23
- package/src/server/integrations/store.mjs +21 -0
- package/src/server/lan-deck.mjs +2 -8
- package/src/server/login-service.mjs +3 -0
- package/src/server/reports.mjs +25 -2
- package/dist/web/assets/app-DjlHxWHg.css +0 -1
- package/dist/web/assets/app-F1xryJpn.js +0 -321
- package/src/server/lan-elsewhere.d.mts +0 -30
- package/src/server/lan-elsewhere.mjs +0 -137
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// The page's view of lan-elsewhere.mjs: the rule the accounts' rows read, the
|
|
2
|
-
// same one the notifier reads on the server.
|
|
3
|
-
|
|
4
|
-
/** The parts of a status row the rule reads — the engine's and the page's
|
|
5
|
-
* status rows are both this and more. */
|
|
6
|
-
export interface ElsewherePeer {
|
|
7
|
-
fp: string;
|
|
8
|
-
peerFp?: string | null;
|
|
9
|
-
name?: string;
|
|
10
|
-
addr?: string;
|
|
11
|
-
paired?: boolean;
|
|
12
|
-
offers?: { at: number; current?: { key?: string } | { hidden: true } | { other: true } | null } | null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ElsewhereStatus<P extends ElsewherePeer = ElsewherePeer> {
|
|
16
|
-
enabled?: boolean;
|
|
17
|
-
peers?: P[];
|
|
18
|
-
addrs?: string[];
|
|
19
|
-
aliases?: Record<string, string>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const ELSEWHERE_FRESH_MS: number;
|
|
23
|
-
export function decksByAccount<P extends ElsewherePeer>(
|
|
24
|
-
status: ElsewhereStatus<P> | null | undefined, now: number, freshMs?: number,
|
|
25
|
-
): Map<string, P[]>;
|
|
26
|
-
export function deckName(p: ElsewherePeer, aliases?: Record<string, string>): string;
|
|
27
|
-
export function namesByAccount(status: ElsewhereStatus | null | undefined, now: number, freshMs?: number): Map<string, string[]>;
|
|
28
|
-
export function deckList(names: readonly string[]): string;
|
|
29
|
-
export function connectLanStatus(status: (() => unknown) | null): void;
|
|
30
|
-
export function elsewhereNow(now?: number): Map<string, string[]>;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
// Which of this deck's accounts another deck is working on right now (#2192).
|
|
2
|
-
//
|
|
3
|
-
// ONE LOGIN, LIVE IN ONE PLACE. A Claude refresh token is good for one renewal:
|
|
4
|
-
// the copy that renews it first gets a new one, and every other copy of that
|
|
5
|
-
// login is refused with invalid_grant from then on. Claude Code answers that by
|
|
6
|
-
// wiping the stored login, and every session on that machine stops with "Login
|
|
7
|
-
// expired · Please run /login". Two machines that hold one copied login hold one
|
|
8
|
-
// expiry too, so both reach for the renewal within minutes of each other and
|
|
9
|
-
// the slower one loses. Measured on one pair of decks: three of seven
|
|
10
|
-
// interruptions in a month landed on the 8-hour renewal with nothing on that
|
|
11
|
-
// machine renewing in between.
|
|
12
|
-
//
|
|
13
|
-
// Local network already says which account each paired deck is on (`current`
|
|
14
|
-
// in its manifest — see currentFor in lan-copies.mjs), so this needs nothing new
|
|
15
|
-
// on the wire: it reads what the status already holds. It is the one rule the
|
|
16
|
-
// row's warning and the notification both ask, so the two cannot disagree
|
|
17
|
-
// about which deck is on what. The page reads it through lan-elsewhere.d.mts;
|
|
18
|
-
// the server through the door at the bottom, which lan-deck.mjs connects to its
|
|
19
|
-
// engine.
|
|
20
|
-
//
|
|
21
|
-
// IT WARNS AND DOES NOTHING ELSE. The login a deck is on already stays on that
|
|
22
|
-
// deck (manifestFor marks it `inUse` and `serve` refuses it), and Auto-switch
|
|
23
|
-
// may still move to a login a paired deck is on (3.43.3). What is left is a
|
|
24
|
-
// copy a paired deck held before this deck went live on it — which only the
|
|
25
|
-
// two decks saying where they are can show, and only a person can settle. A
|
|
26
|
-
// deck that hides which account it is on, or is on one it does not share with
|
|
27
|
-
// this one, says nothing here, and nothing is guessed in its place.
|
|
28
|
-
//
|
|
29
|
-
// Pure apart from that door. No sockets, no timers, no filesystem.
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* How recent a deck's word has to be for "it is on this account right now".
|
|
33
|
-
*
|
|
34
|
-
* A paired deck says which account it is on in every manifest, and a manifest
|
|
35
|
-
* crosses at least once a minute each way — this deck's round asks it, and its
|
|
36
|
-
* round carries one in. Five minutes is five rounds: a dropped round or two does
|
|
37
|
-
* not take the warning down and put it back, which would read as two incidents,
|
|
38
|
-
* and a deck that was switched off stops counting soon after. Past it, what the
|
|
39
|
-
* deck said is its last word rather than its current one.
|
|
40
|
-
*/
|
|
41
|
-
export const ELSEWHERE_FRESH_MS = 5 * 60_000;
|
|
42
|
-
|
|
43
|
-
/** An address that is this machine: loopback, or one of its own. A second deck
|
|
44
|
-
* on this machine shares its Claude login rather than copying it, so it is not
|
|
45
|
-
* another place the login is live. */
|
|
46
|
-
function onThisMachine(addr, mine) {
|
|
47
|
-
if (typeof addr !== "string" || !addr) return false;
|
|
48
|
-
if (addr === "::1" || addr === "localhost" || addr.startsWith("127.")) return true;
|
|
49
|
-
return Array.isArray(mine) && mine.includes(addr);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The paired decks that said, within `freshMs`, that they are working on one of
|
|
54
|
-
* the accounts they share — keyed by account, one row per deck.
|
|
55
|
-
*
|
|
56
|
-
* ONLY WHAT A DECK SAID, AND ONLY RECENTLY. A deck names the account it is on
|
|
57
|
-
* only when it shares that account and its owner left "Show paired decks which
|
|
58
|
-
* of these this deck is using" on; `hidden`, `other`, nothing at all (a deck
|
|
59
|
-
* older than 3.22.15 never says) and a word older than `freshMs` all prove
|
|
60
|
-
* nothing, and none of them is drawn as a deck on an account. A deck that is
|
|
61
|
-
* not paired any more is not counted either: what it said was said to a deck
|
|
62
|
-
* that no longer listens.
|
|
63
|
-
*
|
|
64
|
-
* `status` is the engine's status() — or the page's copy of it, the same shape.
|
|
65
|
-
*/
|
|
66
|
-
export function decksByAccount(status, now, freshMs = ELSEWHERE_FRESH_MS) {
|
|
67
|
-
const out = new Map();
|
|
68
|
-
if (!status?.enabled) return out;
|
|
69
|
-
const seen = new Set();
|
|
70
|
-
for (const p of Array.isArray(status.peers) ? status.peers : []) {
|
|
71
|
-
if (!p || p.paired !== true) continue;
|
|
72
|
-
const said = p.offers;
|
|
73
|
-
const key = said?.current && typeof said.current.key === "string" ? said.current.key : "";
|
|
74
|
-
if (!key || typeof said.at !== "number" || !Number.isFinite(said.at)) continue;
|
|
75
|
-
// Within the window, and not from the future: a clock that ran ahead is not
|
|
76
|
-
// a promise about the next five minutes.
|
|
77
|
-
if (now - said.at > freshMs || said.at - now > freshMs) continue;
|
|
78
|
-
if (onThisMachine(p.addr, status.addrs)) continue;
|
|
79
|
-
// One deck reached two ways is merged into one row by the engine already;
|
|
80
|
-
// the same deck under the same key twice would still be one deck.
|
|
81
|
-
const id = `${key}|${p.peerFp ?? p.fp}`;
|
|
82
|
-
if (seen.has(id)) continue;
|
|
83
|
-
seen.add(id);
|
|
84
|
-
out.set(key, [...(out.get(key) ?? []), p]);
|
|
85
|
-
}
|
|
86
|
-
return out;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** A deck as a sentence names it: the name somebody here gave it, else its own. */
|
|
90
|
-
export function deckName(p, aliases) {
|
|
91
|
-
const id = p?.peerFp ?? p?.fp;
|
|
92
|
-
const given = aliases && typeof aliases === "object" && typeof aliases[id] === "string" ? aliases[id].trim() : "";
|
|
93
|
-
const own = typeof p?.name === "string" ? p.name.trim() : "";
|
|
94
|
-
return given || own || "another deck";
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** The same answer as names: account key to the decks on it, each named once
|
|
98
|
-
* and in order, so one machine reached under two keys is one name. */
|
|
99
|
-
export function namesByAccount(status, now, freshMs = ELSEWHERE_FRESH_MS) {
|
|
100
|
-
const out = new Map();
|
|
101
|
-
for (const [key, rows] of decksByAccount(status, now, freshMs)) {
|
|
102
|
-
const names = [...new Set(rows.map(p => deckName(p, status?.aliases)))].sort((a, b) => a.localeCompare(b));
|
|
103
|
-
out.set(key, names);
|
|
104
|
-
}
|
|
105
|
-
return out;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** "iMac", "iMac and PC", "iMac, Mac and PC". */
|
|
109
|
-
export function deckList(names) {
|
|
110
|
-
if (names.length <= 1) return names[0] ?? "another deck";
|
|
111
|
-
return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// ── the door ────────────────────────────────────────────────────────────────
|
|
115
|
-
//
|
|
116
|
-
// The notifier needs the engine's status, and the engine lives in lan-deck.mjs,
|
|
117
|
-
// which imports far more than the notifier should. So lan-deck.mjs hands its
|
|
118
|
-
// status() in here as it loads, and the notifier asks here. Until it does — a
|
|
119
|
-
// test that runs the notifier on its own — the answer is that no deck is on
|
|
120
|
-
// anything, which is what a deck with Local network off would say too.
|
|
121
|
-
|
|
122
|
-
let _status = null;
|
|
123
|
-
|
|
124
|
-
/** lan-deck.mjs's, once, as it loads. */
|
|
125
|
-
export function connectLanStatus(status) {
|
|
126
|
-
_status = typeof status === "function" ? status : null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** namesByAccount over the engine's status as it is now. Never throws: a
|
|
130
|
-
* status that could not be read is a deck that knows of nobody. */
|
|
131
|
-
export function elsewhereNow(now = Date.now()) {
|
|
132
|
-
try {
|
|
133
|
-
return _status ? namesByAccount(_status(), now) : new Map();
|
|
134
|
-
} catch {
|
|
135
|
-
return new Map();
|
|
136
|
-
}
|
|
137
|
-
}
|