@cline/core 0.0.73 → 0.0.74-nightly.1786676845

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 (38) hide show
  1. package/dist/ClineCore.d.ts +13 -3
  2. package/dist/cline-core/types.d.ts +2 -2
  3. package/dist/extensions/tools/runtime.d.ts +1 -0
  4. package/dist/hub/client/index.d.ts +15 -0
  5. package/dist/hub/client/managed-hub-build-watcher.d.ts +54 -0
  6. package/dist/hub/client/session-client.d.ts +2 -2
  7. package/dist/hub/daemon/entry.js +191 -187
  8. package/dist/hub/daemon/index.d.ts +19 -0
  9. package/dist/hub/daemon/shutdown-coordinator.d.ts +31 -0
  10. package/dist/hub/discovery/index.d.ts +57 -0
  11. package/dist/hub/discovery/workspace.d.ts +9 -0
  12. package/dist/hub/index.d.ts +1 -0
  13. package/dist/hub/index.js +178 -174
  14. package/dist/hub/runtime-host/hub-runtime-host.d.ts +1 -1
  15. package/dist/hub/server/hub-server-options.d.ts +14 -4
  16. package/dist/hub/server/hub-websocket-server.d.ts +1 -1
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.js +172 -168
  19. package/dist/runtime/host/local-runtime-host.d.ts +2 -2
  20. package/dist/runtime/host/runtime-host-support.d.ts +1 -1
  21. package/dist/runtime/host/runtime-host.d.ts +4 -4
  22. package/dist/runtime/orchestration/runtime-event-adapter.d.ts +1 -1
  23. package/dist/runtime/orchestration/session-runtime.d.ts +2 -1
  24. package/dist/services/agent-events.d.ts +25 -0
  25. package/dist/services/global-settings.d.ts +13 -1
  26. package/dist/services/telemetry/core-events.d.ts +3 -0
  27. package/dist/services/telemetry/index.js +1 -1
  28. package/dist/session/checkpoint-restore.d.ts +4 -4
  29. package/dist/session/display-messages.d.ts +28 -0
  30. package/dist/session/persisted-tool-result-content.d.ts +8 -0
  31. package/dist/session/services/persistence-service.d.ts +2 -2
  32. package/dist/session/session-snapshot.d.ts +2 -2
  33. package/dist/session/session-versioning-service.d.ts +4 -4
  34. package/dist/session/stores/session-manifest-store.d.ts +1 -1
  35. package/dist/session/team/team-child-session-manager.d.ts +2 -2
  36. package/dist/types.d.ts +2 -3
  37. package/package.json +4 -4
  38. package/dist/hub/daemon/shutdown-watchdog.d.ts +0 -13
@@ -1,4 +1,23 @@
1
1
  import { type HubEndpointOverrides } from "../discovery/defaults";
2
+ export declare const __test__: {
3
+ /** Retire attempts are module state keyed by URL; clear between cases. */
4
+ resetRetireAttempts(): void;
5
+ };
6
+ /**
7
+ * Reads the discovery record the npm postinstall set aside (see
8
+ * apps/cli/script/postinstall.mjs). Deliberately bypasses readHubDiscovery —
9
+ * the file is best-effort recovery metadata, not a live record — and stays
10
+ * synchronous so it adds no async boundary to the ensure flow.
11
+ *
12
+ * Exported for `cline doctor`, which must not mistake a shielded live hub for
13
+ * a stale daemon just because its record is set aside.
14
+ */
15
+ export declare function readSupersededHubDiscovery(discoveryPath: string): {
16
+ url?: string;
17
+ authToken?: string;
18
+ pid?: number;
19
+ } | undefined;
20
+ export type HubRetirementOutcome = "reusable" | "retired" | "deferred_busy" | "failed";
2
21
  export declare function spawnDetachedHubServer(workspaceRoot: string, endpoint?: HubEndpointOverrides): void;
3
22
  export declare function spawnDetachedHubServerWithRetry(workspaceRoot: string, endpoint?: HubEndpointOverrides): Promise<void>;
4
23
  export declare function prewarmDetachedHubServer(workspaceRoot: string, endpoint?: HubEndpointOverrides & {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Kept below the caller-side retirement wait so a current daemon exits through
3
+ * its own cleanup deadline before an older caller considers force retirement.
4
+ */
5
+ export declare const HUB_DAEMON_SHUTDOWN_DEADLINE_MS = 2000;
6
+ export interface HubDaemonShutdownRequest {
7
+ reason: string;
8
+ exitCode: number;
9
+ }
10
+ export type HubDaemonShutdownState = "idle" | "shutting_down" | "forced" | "finished";
11
+ export interface HubDaemonShutdownCoordinatorOptions {
12
+ deadlineMs: number;
13
+ cleanup(): Promise<void>;
14
+ exit(code: number): void;
15
+ onCleanupError?(error: unknown): void;
16
+ onForcedExit?(request: HubDaemonShutdownRequest): void;
17
+ }
18
+ export interface HubDaemonShutdownCoordinator {
19
+ request(request: HubDaemonShutdownRequest): Promise<void>;
20
+ force(request: HubDaemonShutdownRequest): void;
21
+ getState(): HubDaemonShutdownState;
22
+ }
23
+ /**
24
+ * Owns the daemon's monotonic shutdown lifecycle.
25
+ *
26
+ * Every graceful trigger shares one cleanup promise. A later fatal trigger can
27
+ * raise the eventual exit code, but it cannot run cleanup twice. The deadline
28
+ * and an explicit second-signal path both use `force`, whose exit is also
29
+ * guarded so an injected test exit that returns cannot be called repeatedly.
30
+ */
31
+ export declare function createHubDaemonShutdownCoordinator(options: HubDaemonShutdownCoordinatorOptions): HubDaemonShutdownCoordinator;
@@ -8,6 +8,7 @@ export interface HubServerDiscoveryRecord {
8
8
  capabilities?: readonly string[];
9
9
  coreVersion?: string;
10
10
  buildId?: string;
11
+ buildEpochMs?: number;
11
12
  authToken: string;
12
13
  host: string;
13
14
  port: number;
@@ -23,6 +24,7 @@ export type HubServerProbeRecord = {
23
24
  capabilities?: readonly string[];
24
25
  coreVersion?: string;
25
26
  buildId?: string;
27
+ buildEpochMs?: number;
26
28
  host: string;
27
29
  port: number;
28
30
  url: string;
@@ -38,6 +40,13 @@ export interface HubOwnerContext {
38
40
  }
39
41
  export declare function createHubAuthToken(): string;
40
42
  export declare function resolveHubBuildId(): string;
43
+ /**
44
+ * When this SDK build was produced, embedded at bundle time. Orders builds so
45
+ * managed-Hub handling can distinguish a newer daemon (attach and prompt the
46
+ * user to update) from a stale one (retire and replace). Undefined when
47
+ * running from unbundled sources, where no meaningful ordering exists.
48
+ */
49
+ export declare function resolveHubBuildEpochMs(): number | undefined;
41
50
  export type ManagedHubCompatibilityResult = {
42
51
  compatible: true;
43
52
  } | {
@@ -56,11 +65,59 @@ export type ManagedHubCompatibilityResult = {
56
65
  export declare function getManagedHubCompatibility(record: HubProtocolMetadata & {
57
66
  buildId?: string;
58
67
  }, expectedBuildId?: string): ManagedHubCompatibilityResult;
68
+ export interface HubBuildIdentity {
69
+ buildId?: string;
70
+ buildEpochMs?: number;
71
+ coreVersion?: string;
72
+ }
73
+ /**
74
+ * Total order over Hub builds: negative when `a` is older than `b`, positive
75
+ * when newer, zero when the two are indistinguishable.
76
+ *
77
+ * The ordering is what keeps concurrent installations from replacing each
78
+ * other's daemons. A one-sided "may I reuse this?" predicate lets both sides
79
+ * answer no, and two clients then retire each other's Hub forever; a total
80
+ * order is antisymmetric by construction, so at most one side can ever decide
81
+ * to retire. Every tier below preserves that: a field decides only when both
82
+ * records carry it, and the final fallback is "equal", which means reuse.
83
+ *
84
+ * Tiers, in order: identical build, embedded build epoch, core release
85
+ * version, then build id as a deterministic tiebreak.
86
+ */
87
+ export declare function compareHubBuilds(a: HubBuildIdentity, b: HubBuildIdentity): number;
88
+ /**
89
+ * This build's own identity, in the same shape a daemon publishes into its
90
+ * discovery record.
91
+ *
92
+ * Self and peer identities must be built from the same fields. Enriching only
93
+ * the local side - filling in a `coreVersion` the wire record can omit, say -
94
+ * makes a build's identity depend on which role it is playing, and two
95
+ * installations then decide the comparison on different tiers and each
96
+ * conclude that it is the newer one. Callers that need a synthetic identity
97
+ * pass it verbatim rather than layering overrides onto this.
98
+ */
99
+ export declare function resolveHubBuildIdentity(): HubBuildIdentity;
100
+ /**
101
+ * Whether a client may keep using a managed local Hub instead of retiring it.
102
+ *
103
+ * A Hub is retired only when this client's build is *strictly newer* by
104
+ * {@link compareHubBuilds}. Same build, newer Hub, and indistinguishable
105
+ * builds all attach over the compatible wire protocol and let the
106
+ * build-mismatch watcher prompt the user to update. Because the decision is
107
+ * derived from a total order, two installations can never retire each other.
108
+ *
109
+ * Genuine protocol incompatibility is unaffected: those Hubs cannot be spoken
110
+ * to at all and are still replaced.
111
+ */
112
+ export declare function isManagedHubReusable(record: HubProtocolMetadata & HubBuildIdentity, options?: {
113
+ self?: HubBuildIdentity;
114
+ }): boolean;
59
115
  export declare function resolveHubOwnerContext(ownerBasis?: string): HubOwnerContext;
60
116
  export declare function createInMemoryHubOwnerContext(label?: string): HubOwnerContext;
61
117
  export declare function readHubDiscovery(discoveryPath: string): Promise<HubServerDiscoveryRecord | undefined>;
62
118
  export declare function writeHubDiscovery(discoveryPath: string, record: HubServerDiscoveryRecord): Promise<void>;
63
119
  export declare function clearHubDiscovery(discoveryPath: string): Promise<void>;
120
+ export declare function clearHubDiscoveryIfOwned(discoveryPath: string, hubId: string): Promise<boolean>;
64
121
  export declare function withHubStartupLock<T>(discoveryPath: string, callback: () => Promise<T>): Promise<T>;
65
122
  export declare function probeHubServer(url: string, options?: {
66
123
  authToken?: string;
@@ -1,4 +1,13 @@
1
1
  import { type HubOwnerContext } from ".";
2
2
  export declare function resolveWorkspaceHubOwnerContext(workspaceRoot: string): HubOwnerContext;
3
+ /**
4
+ * Development builds change on every compile, so a single shared owner record
5
+ * puts every checkout and every rebuild in contention for one daemon - and the
6
+ * loser of that contention gets shut down mid-session. Scoping the owner by
7
+ * build id lets differing dev builds run their own Hub side by side instead of
8
+ * arbitrating over one. Production keeps a single owner (see
9
+ * {@link resolveProductionHubOwnerContext}), where the singleton matters and
10
+ * builds are ordered.
11
+ */
3
12
  export declare function resolveSharedHubOwnerContext(label?: string): HubOwnerContext;
4
13
  export declare function resolveProductionHubOwnerContext(): HubOwnerContext;
@@ -18,6 +18,7 @@ export { HubScheduleService } from "../cron/service/schedule-service";
18
18
  export { type ConfiguredTelemetryHandle, type CreateOpenTelemetryTelemetryServiceOptions, createConfiguredTelemetryHandle, createConfiguredTelemetryService, } from "../services/telemetry/OpenTelemetryProvider";
19
19
  export * from "./client";
20
20
  export * from "./client/connect";
21
+ export * from "./client/managed-hub-build-watcher";
21
22
  export * from "./client/session-client";
22
23
  export * from "./client/ui-client";
23
24
  export * from "./daemon";