@cline/core 0.0.77 → 0.0.78

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.
@@ -1,3 +1,4 @@
1
+ import { type HubServerProbeRecord } from "../discovery";
1
2
  import { type HubEndpointOverrides } from "../discovery/defaults";
2
3
  export declare const __test__: {
3
4
  /** Retire attempts are module state keyed by URL; clear between cases. */
@@ -17,7 +18,27 @@ export declare function readSupersededHubDiscovery(discoveryPath: string): {
17
18
  authToken?: string;
18
19
  pid?: number;
19
20
  } | undefined;
21
+ /**
22
+ * Gracefully retire a discovered hub. Shared by every replacement path
23
+ * (detached ensure, in-process ensure) so retirement always means the same
24
+ * thing: drain first, then an authenticated shutdown, SIGTERM only as a
25
+ * last resort, and discovery cleared only once the hub is actually gone.
26
+ */
27
+ export declare function retireDiscoveredHub(record: {
28
+ url: string;
29
+ authToken?: string;
30
+ pid?: number;
31
+ }, discoveryPath: string): Promise<boolean>;
20
32
  export type HubRetirementOutcome = "reusable" | "retired" | "deferred_busy" | "failed";
33
+ /**
34
+ * Whether the Hub is currently serving sessions, and so must not be shut down
35
+ * under them.
36
+ *
37
+ * Failing open (treating an unanswerable Hub as idle) preserves the existing
38
+ * replacement path for a Hub that is wedged or too old to answer the query;
39
+ * only a Hub that positively reports live sessions is spared.
40
+ */
41
+ export declare function hubHasLiveSessions(record: Pick<HubServerProbeRecord, "url" | "authToken">): Promise<boolean>;
21
42
  export declare function spawnDetachedHubServer(workspaceRoot: string, endpoint?: HubEndpointOverrides): void;
22
43
  export declare function spawnDetachedHubServerWithRetry(workspaceRoot: string, endpoint?: HubEndpointOverrides): Promise<void>;
23
44
  export declare function prewarmDetachedHubServer(workspaceRoot: string, endpoint?: HubEndpointOverrides & {
@@ -0,0 +1,51 @@
1
+ /**
2
+ * OS-backed exclusive Hub instance lock.
3
+ *
4
+ * Authority over a Hub owner context (the discovery path) is an
5
+ * operating-system exclusive lock, not a PID file, not a heartbeat, and not
6
+ * build arbitration: the lock is a SQLite database held inside a
7
+ * never-committed `BEGIN EXCLUSIVE` transaction, which SQLite maps onto OS
8
+ * file locks. The kernel releases the lock the instant the holding process
9
+ * dies — crashed holders cannot leak ownership, and a live holder cannot be
10
+ * displaced by deleting a file.
11
+ *
12
+ * A process that fails to acquire the lock must connect to the running Hub
13
+ * or diagnose — never kill it and never bind another endpoint on its own.
14
+ * This makes the historical mutual-retire loop (two installs SIGTERMing each
15
+ * other's daemon, #13145/#13230) structurally impossible: at most one live
16
+ * Hub can exist per owner context, enforced by the OS before either process
17
+ * gets a chance to disagree.
18
+ *
19
+ * The startup-lock directory (`<discoveryPath>.lock`, see `withHubLock`)
20
+ * remains a short-lived mutex around discovery reads/writes; this lock is a
21
+ * different thing — it is held for the entire lifetime of the serving Hub.
22
+ */
23
+ /** Exit code for a daemon that lost the singleton race: diagnose, never replace. */
24
+ export declare const HUB_LOCK_HELD_EXIT_CODE = 3;
25
+ /** The lock is held by another live Hub process (or connection). */
26
+ export declare class HubLockHeldError extends Error {
27
+ readonly lockFile: string;
28
+ constructor(lockFile: string);
29
+ }
30
+ export declare function isHubLockHeldError(error: unknown): error is HubLockHeldError;
31
+ /** The lock file that guards one owner context (derived from its discovery path). */
32
+ export declare function resolveHubInstanceLockPath(discoveryPath: string): string;
33
+ export declare class HubInstanceLock {
34
+ private db;
35
+ readonly lockFile: string;
36
+ private constructor();
37
+ get held(): boolean;
38
+ /** Release the lock (process exit releases it too, via the OS). */
39
+ release(): void;
40
+ /**
41
+ * Attempt to take exclusive ownership of a Hub owner context. Throws
42
+ * `HubLockHeldError` when another live process holds it.
43
+ *
44
+ * Only a positively held lock (SQLITE_BUSY/LOCKED) refuses startup. Any
45
+ * other failure — SQLite unavailable in this runtime, an unwritable lock
46
+ * directory — degrades to an unheld lock (`held === false`) and the Hub
47
+ * starts without singleton enforcement, matching how the event log and
48
+ * run queue already degrade rather than making SQLite a hard requirement.
49
+ */
50
+ static acquire(lockFile: string): HubInstanceLock;
51
+ }
@@ -28,8 +28,11 @@ export * from "./daemon/runtime-handlers";
28
28
  export * from "./daemon/start-shared-server";
29
29
  export * from "./discovery";
30
30
  export * from "./discovery/defaults";
31
+ export * from "./discovery/instance-lock";
31
32
  export * from "./discovery/workspace";
32
33
  export * from "./server";
33
34
  export * from "./server/browser-websocket";
34
35
  export * from "./server/command-transport";
36
+ export * from "./server/hub-event-log";
37
+ export * from "./server/hub-run-queue";
35
38
  export * from "./server/native-transport";