@cline/core 0.0.81-nightly.1788229734 → 0.0.82

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,8 +1,21 @@
1
1
  import type { BasicLogger } from "@cline/shared";
2
2
  import type { ResolveCronSpecsDirOptions } from "@cline/shared/storage";
3
3
  import type { HubScheduleRuntimeHandlers } from "../service/schedule-service";
4
- import type { CronRunRecord, SqliteCronStore } from "../store/sqlite-cron-store";
4
+ import type { CronRunRecord, CronSpecRecord, SqliteCronStore } from "../store/sqlite-cron-store";
5
5
  import type { CronMaterializer } from "./cron-materializer";
6
+ /**
7
+ * Session metadata keys that identify the automation run a session belongs
8
+ * to. Clients (e.g. the desktop sidebar) read these to group a schedule's
9
+ * runs together and label each one, so they are part of the session
10
+ * metadata contract; keep them in sync with the readers.
11
+ */
12
+ export declare const RUN_SESSION_METADATA_KEYS: {
13
+ readonly scheduleId: "scheduleId";
14
+ readonly scheduleName: "scheduleName";
15
+ readonly scheduleExecutionId: "scheduleExecutionId";
16
+ readonly scheduleRunNumber: "scheduleRunNumber";
17
+ };
18
+ export declare function buildRunSessionMetadata(spec: Pick<CronSpecRecord, "externalId" | "title">, run: Pick<CronRunRecord, "runId">, runNumber: number | undefined): Record<string, unknown>;
6
19
  export interface CronRunnerOptions {
7
20
  store: SqliteCronStore;
8
21
  materializer: CronMaterializer;
@@ -22,8 +22,16 @@ type HubScheduleTurnResult = {
22
22
  durationMs?: number;
23
23
  }>;
24
24
  };
25
+ export interface HubScheduleStartSessionOptions {
26
+ /**
27
+ * Provenance the runner knows about the automation run that is starting
28
+ * this session (schedule id/name, run id, run number). Handlers merge it
29
+ * into the session metadata so clients can group runs by schedule.
30
+ */
31
+ sessionMetadata?: Record<string, unknown>;
32
+ }
25
33
  export interface HubScheduleRuntimeHandlers {
26
- startSession(request: ChatStartSessionRequest): Promise<{
34
+ startSession(request: ChatStartSessionRequest, options?: HubScheduleStartSessionOptions): Promise<{
27
35
  sessionId: string;
28
36
  startResult?: ChatStartSessionArtifacts;
29
37
  }>;
@@ -198,6 +198,14 @@ export declare class SqliteCronStore {
198
198
  nowMs: number;
199
199
  }): MaterializeScheduleRunResult;
200
200
  getRun(runId: string): CronRunRecord | undefined;
201
+ /**
202
+ * 1-based position of a run among every run ever created for its spec,
203
+ * in creation order. Counts runs of every status (including cancelled and
204
+ * failed ones) so the number is stable: a later cancellation never shifts
205
+ * the numbers already stamped onto earlier sessions. Returns undefined
206
+ * for an unknown run.
207
+ */
208
+ getRunOrdinal(runId: string): number | undefined;
201
209
  insertEventLog(event: AutomationEventEnvelope, options?: {
202
210
  receivedAtIso?: string;
203
211
  }): InsertEventLogResult;
@@ -91,10 +91,17 @@ export declare class NodeHubClient {
91
91
  }
92
92
  export declare function normalizeHubWebSocketUrl(url: string): string;
93
93
  export declare function verifyHubConnection(url: string, options?: Pick<HubClientOptions, "workspaceRoot" | "cwd" | "authToken">): Promise<boolean>;
94
+ export interface HubSessionActivity {
95
+ /** Sessions with at least one live participant attached. */
96
+ activeSessionCount: number;
97
+ /** Distinct client ids attached to those sessions. */
98
+ participantClientCount: number;
99
+ }
94
100
  /**
95
- * Whether any client is attached to a session on the hub - the one signal
96
- * that cannot go stale, because participants are live socket subscriptions
97
- * the hub drops the moment a client's connection closes.
101
+ * Summarize live activity from a `session.list` payload. A session counts as
102
+ * active only while a client is attached to it - the one signal that cannot
103
+ * go stale, because participants are live socket subscriptions the hub drops
104
+ * the moment a client's connection closes.
98
105
  *
99
106
  * Deliberately NOT based on session status: a client that dies without
100
107
  * stopping its session leaves the hub-side runtime behind in a non-terminal
@@ -104,7 +111,17 @@ export declare function verifyHubConnection(url: string, options?: Pick<HubClien
104
111
  * exact moment of a hub swap dies with the old hub - rare, and its next
105
112
  * scheduled tick runs normally on the replacement.
106
113
  */
114
+ export declare function summarizeHubSessionActivity(payload: unknown): HubSessionActivity;
107
115
  export declare function hasActiveHubSessions(payload: unknown): boolean;
116
+ /**
117
+ * Ask a hub how much live work it is serving. Throws when the hub cannot
118
+ * answer (unreachable, auth rejected, or too old to serve `session.list`),
119
+ * because the safe default points in opposite directions per caller: a
120
+ * replacement path treats an unanswerable hub as idle and retires it, while
121
+ * a recovery path treats it as busy and leaves it alone. Callers pick their
122
+ * own fallback instead of inheriting a hidden one.
123
+ */
124
+ export declare function queryHubSessionActivity(url: string, authToken?: string, options?: Pick<HubClientOptions, "workspaceRoot" | "cwd">): Promise<HubSessionActivity>;
108
125
  export declare function localHubHasNoActiveSessions(url: string, authToken?: string, options?: Pick<HubClientOptions, "workspaceRoot" | "cwd">): Promise<boolean>;
109
126
  export declare function resolveCompatibleLocalHubUrl(options?: LocalHubResolutionOptions): Promise<string | undefined>;
110
127
  export declare function ensureCompatibleLocalHubUrl(options?: LocalHubResolutionOptions): Promise<string | undefined>;
@@ -17,6 +17,14 @@ export interface ManagedHubBuildMismatchEvent {
17
17
  hubCoreVersion?: string;
18
18
  /** Build identity this client expects a managed Hub to match. */
19
19
  expectedBuildId: string;
20
+ /**
21
+ * Sessions with live participants on the Hub (best-effort, `outdated_hub`
22
+ * only): the work that replacing the Hub would interrupt. Unset when the
23
+ * Hub cannot answer the query.
24
+ */
25
+ activeSessionCount?: number;
26
+ /** Distinct clients attached to those sessions (best-effort, `outdated_hub` only). */
27
+ participantClientCount?: number;
20
28
  }
21
29
  /**
22
30
  * Probe the managed local Hub once and report whether a live Hub is running