@north-light/cli 0.3.731 → 0.3.732

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 (51) hide show
  1. package/dist/api/client.d.ts +3 -2
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/builtin-memory/northlight-apps/get-started.md +4 -4
  6. package/dist/clients/attach/overlays/graph.d.ts +2 -0
  7. package/dist/clients/attach/overlays/graph.js +1 -1
  8. package/dist/clients/attach/viewer.js +478 -478
  9. package/dist/commands/sys/daemon.js +1 -1
  10. package/dist/commands/sys/import/move.d.ts +2 -0
  11. package/dist/commands/sys/import/move.js +9 -7
  12. package/dist/commands/sys/join.js +1 -1
  13. package/dist/commands/sys/signin.js +2 -2
  14. package/dist/core/canvas/canvas.d.ts +1 -1
  15. package/dist/core/canvas/canvas.js +16 -16
  16. package/dist/core/canvas/tree.d.ts +4 -0
  17. package/dist/core/canvas/tree.js +6 -6
  18. package/dist/core/directory/join.d.ts +6 -26
  19. package/dist/core/directory/join.js +1 -1
  20. package/dist/core/grants/sync.js +1 -1
  21. package/dist/core/providers/call.js +1 -1
  22. package/dist/core/storage/client.js +2 -2
  23. package/dist/daemon/api/handlers/canvas.js +5 -5
  24. package/dist/daemon/api/handlers/shares.js +1 -1
  25. package/dist/daemon/crtrd.js +8 -8
  26. package/dist/daemon/manage.d.ts +2 -7
  27. package/dist/daemon/manage.js +3 -3
  28. package/docs/apps/get-started.md +4 -4
  29. package/docs/cli/join-northlight.md +16 -22
  30. package/package.json +3 -3
  31. package/packages/crouter-api/dist/api/client.js +4 -3
  32. package/packages/crouter-api/dist/api/contract.js +1 -1
  33. package/packages/crouter-api/dist/clients/attach/overlays/graph.js +18 -1
  34. package/packages/crouter-api/dist/commands/sys/daemon.js +1 -3
  35. package/packages/crouter-api/dist/commands/sys/import/move.js +12 -0
  36. package/packages/crouter-api/dist/commands/sys/join.js +5 -37
  37. package/packages/crouter-api/dist/commands/sys/signin.js +6 -4
  38. package/packages/crouter-api/dist/core/canvas/canvas.js +7 -3
  39. package/packages/crouter-api/dist/core/canvas/tree.js +20 -0
  40. package/packages/crouter-api/dist/core/directory/join.js +35 -86
  41. package/packages/crouter-api/dist/core/grants/sync.js +1 -1
  42. package/packages/crouter-api/dist/core/providers/call.js +1 -1
  43. package/packages/crouter-api/dist/core/storage/client.js +1 -1
  44. package/packages/crouter-api/dist/daemon/manage.js +2 -16
  45. package/packages/crouter-api/package.json +1 -1
  46. package/packages/crouter-identity/package.json +1 -1
  47. package/packages/crouter-plugin/package.json +3 -3
  48. package/runtime.lock.json +14 -14
  49. package/dist/core/directory/join-lock.d.ts +0 -13
  50. package/dist/core/directory/join-lock.js +0 -1
  51. package/packages/crouter-api/dist/core/directory/join-lock.js +0 -61
@@ -1,61 +0,0 @@
1
- // The "join in progress" lock. `crtr sys join` stops the daemon, rewrites local
2
- // identity, and starts the daemon again. Stopping the daemon kills every broker,
3
- // so every open viewer sees a cold socket and its client would autostart a new
4
- // daemon within seconds, which makes the join refuse (`daemon_running`). While
5
- // this lock is held by a live process, `ensureDaemon` and `spawnDaemon` (so also
6
- // `sys daemon start` and a handover successor) decline to start a daemon.
7
- //
8
- // It is the shared token-checked directory lock (`core/exclusive-lock.ts`): the
9
- // holder's pid is in its marker's name, a dead holder is reclaimed by exactly the
10
- // marker it observed (so a lagging reclaimer can never strip a live successor),
11
- // and only the holder's own marker releases it. PURITY: Node built-ins, path
12
- // builders and the pid probe only, so `daemon/manage.ts` can import it.
13
- import { mkdirSync } from 'node:fs';
14
- import { join } from 'node:path';
15
- import { crtrHome } from '../canvas/paths.js';
16
- import { isPidAlive } from '../canvas/pid.js';
17
- import { exclusiveLockOwnerPid, withExclusiveDirectoryLockAsync } from '../exclusive-lock.js';
18
- import { InputError } from '../io.js';
19
- /** How long a second joiner waits for the first before it refuses. Long enough to reclaim a dead holder's lock. */
20
- const ACQUIRE_WAIT_MS = 1_000;
21
- export function joinLockPath() {
22
- return join(crtrHome(), 'join.lock');
23
- }
24
- /** The live process holding the lock, or null when no join is running (no lock, or a holder that died). */
25
- export function joinLockHolder() {
26
- const pid = exclusiveLockOwnerPid(joinLockPath());
27
- return pid !== null && isPidAlive(pid) ? pid : null;
28
- }
29
- /** Whether a join is in progress. The joiner starts its own daemon through `spawnDaemon`, never through the implicit paths that ask this. */
30
- export function joinInProgress() {
31
- return joinLockHolder() !== null;
32
- }
33
- export function joinInProgressError(pid) {
34
- return new InputError({
35
- error: 'join_in_progress',
36
- message: pid === null
37
- ? '`crtr sys join` is running and holds the daemon down until it finishes'
38
- : `\`crtr sys join\` (pid ${pid}) is running and holds the daemon down until it finishes`,
39
- next: 'Wait for the join to finish; it starts the daemon again itself. If it is stuck, `crtr sys daemon start --force`.',
40
- });
41
- }
42
- /** Resolve once no other live process holds the join lock, or after `timeoutMs`. For a start that must happen
43
- * but must read the settings a join is about to commit (a daemon handover's successor): it waits the join out
44
- * instead of bypassing the lock, so nothing but the join starts a daemon while the lock is held. */
45
- export async function awaitJoinLockRelease(timeoutMs, pollMs = 100) {
46
- const deadline = Date.now() + timeoutMs;
47
- for (;;) {
48
- const holder = joinLockHolder();
49
- if (holder === null || holder === process.pid || Date.now() >= deadline)
50
- return;
51
- await new Promise((resolve) => setTimeout(resolve, pollMs));
52
- }
53
- }
54
- /** Run `operation` holding the join lock. Throws `join_in_progress` when a live process holds it. */
55
- export async function withJoinLock(operation) {
56
- mkdirSync(crtrHome(), { recursive: true });
57
- return withExclusiveDirectoryLockAsync(joinLockPath(), operation, {
58
- timeoutMs: ACQUIRE_WAIT_MS,
59
- timeoutError: () => joinInProgressError(joinLockHolder()),
60
- });
61
- }