@cerebriline/core 4.100.246 → 4.100.248
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/assets/prompt-templates/claude.md +2 -0
- package/assets/prompt-templates/deepseek.md +1 -0
- package/assets/prompt-templates/default.md +2 -1
- package/assets/prompt-templates/kimi-k3.md +1 -0
- package/assets/prompt-templates/kimi.md +1 -0
- package/assets/prompt-templates/minimax.md +2 -0
- package/assets/prompt-templates/nemotron.md +1 -0
- package/assets/skills/browser-automation/SKILL.md +113 -0
- package/dist/ClineCore.d.ts +9 -0
- package/dist/account/index.d.ts +1 -0
- package/dist/account/telemetry.d.ts +22 -0
- package/dist/cloud/api.d.ts +122 -0
- package/dist/cloud/controller.d.ts +172 -0
- package/dist/cloud/index.d.ts +9 -0
- package/dist/cloud/index.js +21 -0
- package/dist/cloud/models.d.ts +9 -0
- package/dist/cloud/repositories.d.ts +21 -0
- package/dist/cloud/snapshots.d.ts +22 -0
- package/dist/cloud/state.d.ts +13 -0
- package/dist/cloud/types.d.ts +84 -0
- package/dist/cron/events/cron-event-ingress.d.ts +4 -2
- package/dist/cron/runner/cron-runner.d.ts +5 -2
- package/dist/cron/service/cron-service.d.ts +2 -1
- package/dist/cron/service/schedule-service.d.ts +2 -1
- package/dist/cron/store/sqlite-cron-store.d.ts +7 -1
- package/dist/extensions/composio/composio-meta-tools.d.ts +39 -0
- package/dist/extensions/composio/composio-tools-extension.d.ts +13 -0
- package/dist/extensions/context/agentic-compaction.d.ts +1 -1
- package/dist/extensions/context/cap-thoughts.d.ts +39 -0
- package/dist/extensions/context/capped-thinking.d.ts +14 -0
- package/dist/extensions/context/compaction-shared.d.ts +122 -1
- package/dist/extensions/context/compaction.d.ts +75 -3
- package/dist/extensions/context/continuation-compaction.d.ts +18 -0
- package/dist/extensions/mcp/client.d.ts +1 -1
- package/dist/extensions/tools/definitions.d.ts +5 -5
- package/dist/extensions/tools/executors/bash.d.ts +26 -0
- package/dist/extensions/tools/executors/index.d.ts +1 -1
- package/dist/extensions/tools/index.d.ts +1 -1
- package/dist/extensions/tools/task-progress.d.ts +37 -0
- package/dist/extensions/tools/team/index.d.ts +1 -0
- package/dist/extensions/tools/team/multi-agent.d.ts +48 -0
- package/dist/extensions/tools/team/persistence-policy.d.ts +56 -0
- package/dist/extensions/tools/team/runtime.d.ts +1 -1
- package/dist/extensions/tools/team/sanitize-team-name.d.ts +5 -0
- package/dist/extensions/tools/team/team-tools.d.ts +1 -1
- package/dist/hooks/checkpoint-hooks.d.ts +23 -1
- package/dist/hooks/hook-file-hooks.d.ts +27 -0
- package/dist/hooks/subprocess-runner.d.ts +23 -0
- package/dist/hooks/subprocess.d.ts +10 -0
- package/dist/hub/client/index.d.ts +42 -3
- package/dist/hub/client/session-client.d.ts +0 -3
- package/dist/hub/daemon/bind-diagnostics.d.ts +16 -0
- package/dist/hub/daemon/entry.js +689 -636
- package/dist/hub/daemon/index.d.ts +17 -8
- package/dist/hub/discovery/index.d.ts +1 -0
- package/dist/hub/index.js +680 -628
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +4 -2
- package/dist/hub/server/handlers/session-handlers.d.ts +6 -1
- package/dist/index.d.ts +21 -11
- package/dist/index.js +1071 -999
- package/dist/remote/remote-environments.d.ts +155 -0
- package/dist/remote/remote-helper-entry.d.ts +1 -0
- package/dist/remote/remote-helper-entry.js +5 -0
- package/dist/remote/remote-helper.d.ts +29 -0
- package/dist/remote/remote-helper.js +4 -0
- package/dist/remote/shell-path.d.ts +88 -0
- package/dist/runtime/host/local-runtime-host.d.ts +2 -2
- package/dist/runtime/host/runtime-host.d.ts +13 -1
- package/dist/runtime/orchestration/oauth-refresh-lock.d.ts +6 -0
- package/dist/runtime/orchestration/session-runtime-orchestrator.d.ts +7 -0
- package/dist/runtime/orchestration/team-persistence-writer.d.ts +65 -0
- package/dist/runtime/safety/rules.d.ts +11 -0
- package/dist/runtime/turn-queue/pending-prompt-service.d.ts +1 -0
- package/dist/services/agent-events.d.ts +1 -0
- package/dist/services/cloud-handoff/git-preflight.d.ts +24 -0
- package/dist/services/cloud-handoff/index.d.ts +4 -0
- package/dist/services/cloud-handoff/metadata.d.ts +7 -0
- package/dist/services/cloud-handoff/transcript.d.ts +5 -0
- package/dist/services/cloud-handoff/types.d.ts +35 -0
- package/dist/services/feature-flags/FeatureFlagsService.d.ts +2 -0
- package/dist/services/feature-flags/cline-account-feature-flags.d.ts +5 -0
- package/dist/services/llms/cline-recommended-models.d.ts +1 -0
- package/dist/services/llms/handler-factory.d.ts +12 -0
- package/dist/services/llms/provider-defaults.d.ts +1 -1
- package/dist/services/llms/provider-settings.d.ts +19 -17
- package/dist/services/local-runtime-bootstrap.d.ts +7 -0
- package/dist/services/mcp-install.d.ts +9 -0
- package/dist/services/plugin-commands.d.ts +28 -0
- package/dist/services/providers/local-provider-registry.d.ts +8 -3
- package/dist/services/providers/local-provider-service.d.ts +20 -10
- package/dist/services/providers/model-source.d.ts +6 -1
- package/dist/services/providers/provider-config-fields.d.ts +11 -0
- package/dist/services/session-import/claude-code.d.ts +1 -1
- package/dist/services/session-import/paths.d.ts +9 -0
- package/dist/services/storage/file-team-store.d.ts +10 -4
- package/dist/services/storage/sqlite-team-store.d.ts +48 -5
- package/dist/services/storage/team-store.d.ts +1 -0
- package/dist/services/telemetry/core-events.d.ts +97 -5
- package/dist/services/telemetry/index.d.ts +1 -0
- package/dist/services/telemetry/index.js +1 -1
- package/dist/services/telemetry/scoped-telemetry.d.ts +31 -0
- package/dist/services/workspace/workspace-manifest.d.ts +34 -0
- package/dist/services/workspace/workspace-telemetry.d.ts +5 -0
- package/dist/session/fork-metadata.d.ts +7 -0
- package/dist/session/models/session-compaction.d.ts +8 -1
- package/dist/session/services/message-builder.d.ts +8 -1
- package/dist/session/services/persistence-service.d.ts +4 -1
- package/dist/session/services/tool-result-cache.d.ts +30 -0
- package/dist/session/session-versioning-service.d.ts +8 -0
- package/dist/session/stores/session-manifest-store.d.ts +2 -4
- package/dist/session/team/team-session-coordinator.d.ts +3 -1
- package/dist/tasks/task-tool.d.ts +2 -2
- package/dist/types/config.d.ts +7 -0
- package/dist/types/provider-settings.d.ts +11 -0
- package/dist/types/session.d.ts +2 -0
- package/dist/types/storage.d.ts +22 -1
- package/package.json +16 -4
- package/dist/cron/runner/resource-limiter.d.ts +0 -8
- package/dist/services/storage/team-events-retention.d.ts +0 -25
|
@@ -6,6 +6,25 @@
|
|
|
6
6
|
import { type AgentConfig, type AgentEvent, type AgentResult, type AppendMissionLogInput, type AttachTeamOutcomeFragmentInput, type CreateTeamOutcomeInput, type CreateTeamTaskInput, type MissionLogEntry, type ReviewTeamOutcomeFragmentInput, type RouteToTeammateOptions, type TeamAgentSampling, type TeamMailboxMessage, type TeamMemberSnapshot, TeamMessageType, type TeammateLifecycleSpec, type TeamOutcome, type TeamOutcomeFragment, type TeamRunRecord, type TeamRunStatus, type TeamRuntimeSnapshot, type TeamRuntimeState, type TeamTask, type TeamTaskListItem, type TeamTaskStatus } from "@cerebriline/shared";
|
|
7
7
|
import { SessionRuntime } from "../../../runtime/orchestration/session-runtime-orchestrator";
|
|
8
8
|
import { type HandedRevision } from "./delegated-sandboxes";
|
|
9
|
+
/**
|
|
10
|
+
* Incremental change set produced by `AgentTeamsRuntime.drainStateDelta()`.
|
|
11
|
+
* Only entities mutated since the previous drain are included, so the cost of
|
|
12
|
+
* persisting it is proportional to what changed, not to team history.
|
|
13
|
+
*/
|
|
14
|
+
export interface TeamRuntimeStateDelta {
|
|
15
|
+
teamId: string;
|
|
16
|
+
teamName: string;
|
|
17
|
+
/** When true, the store must drop all persisted entities before applying. */
|
|
18
|
+
reset: boolean;
|
|
19
|
+
/** Members are few and cheap; always included in full. */
|
|
20
|
+
members: TeamMemberSnapshot[];
|
|
21
|
+
tasks: TeamTask[];
|
|
22
|
+
mailbox: TeamMailboxMessage[];
|
|
23
|
+
missionLog: MissionLogEntry[];
|
|
24
|
+
runs: TeamRunRecord[];
|
|
25
|
+
outcomes: TeamOutcome[];
|
|
26
|
+
outcomeFragments: TeamOutcomeFragment[];
|
|
27
|
+
}
|
|
9
28
|
export { type AppendMissionLogInput, type AttachTeamOutcomeFragmentInput, type CreateTeamOutcomeInput, type CreateTeamTaskInput, type MissionLogEntry, type MissionLogKind, type ReviewTeamOutcomeFragmentInput, type RouteToTeammateOptions, type TeamMailboxMessage, type TeamMemberSnapshot, TeamMessageType, type TeammateLifecycleSpec, type TeamOutcome, type TeamOutcomeFragment, type TeamOutcomeFragmentStatus, type TeamOutcomeStatus, type TeamRunRecord, type TeamRunStatus, type TeamRuntimeSnapshot, type TeamRuntimeState, type TeamTask, type TeamTaskListItem, type TeamTaskStatus, } from "@cerebriline/shared";
|
|
10
29
|
export interface TeamMemberConfig extends AgentConfig {
|
|
11
30
|
role?: string;
|
|
@@ -123,6 +142,11 @@ export interface AgentTeamsRuntimeOptions {
|
|
|
123
142
|
missionLogIntervalMs?: number;
|
|
124
143
|
maxConcurrentRuns?: number;
|
|
125
144
|
onTeamEvent?: (event: TeamEvent) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Called when persisted state changes without a team event (mailbox read
|
|
147
|
+
* receipts, cleanup), so a persistence writer can schedule a flush.
|
|
148
|
+
*/
|
|
149
|
+
onStateDirty?: () => void;
|
|
126
150
|
/**
|
|
127
151
|
* The teammates' private workspaces, when the host sandboxes them. A
|
|
128
152
|
* teammate's toolset opens its workspace when it is spawned; the runtime
|
|
@@ -199,6 +223,7 @@ export declare class AgentTeamsRuntime {
|
|
|
199
223
|
private readonly teamName;
|
|
200
224
|
private readonly sessionId?;
|
|
201
225
|
private readonly onTeamEvent?;
|
|
226
|
+
private readonly onStateDirty?;
|
|
202
227
|
private readonly members;
|
|
203
228
|
private readonly tasks;
|
|
204
229
|
private readonly missionLog;
|
|
@@ -211,6 +236,7 @@ export declare class AgentTeamsRuntime {
|
|
|
211
236
|
private outcomeCounter;
|
|
212
237
|
private outcomeFragmentCounter;
|
|
213
238
|
private readonly runs;
|
|
239
|
+
private dirty;
|
|
214
240
|
private readonly runQueue;
|
|
215
241
|
private queuedRunDispatchTimer;
|
|
216
242
|
private readonly outcomes;
|
|
@@ -360,5 +386,27 @@ export declare class AgentTeamsRuntime {
|
|
|
360
386
|
private formatProgressErrorActivity;
|
|
361
387
|
private recordProgressStep;
|
|
362
388
|
private buildMailboxNotification;
|
|
389
|
+
/**
|
|
390
|
+
* Record which persisted entity an event mutated. Every durable state
|
|
391
|
+
* change flows through `emitEvent`, so this is the single point that keeps
|
|
392
|
+
* the dirty set in sync with the in-memory maps.
|
|
393
|
+
*/
|
|
394
|
+
private markDirtyFromEvent;
|
|
395
|
+
/** True when there are unpersisted changes. */
|
|
396
|
+
hasPendingStateDelta(): boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Return entities mutated since the last drain and clear the dirty set.
|
|
399
|
+
* Ids whose entity no longer exists are skipped (a `reset` covers removal).
|
|
400
|
+
*/
|
|
401
|
+
drainStateDelta(): TeamRuntimeStateDelta;
|
|
402
|
+
/**
|
|
403
|
+
* Put a drained delta back so a failed write is retried by the next flush.
|
|
404
|
+
* Entities are re-read at drain time, so only ids and the reset flag matter.
|
|
405
|
+
*/
|
|
406
|
+
requeueStateDelta(delta: TeamRuntimeStateDelta): void;
|
|
407
|
+
private notifyStateDirty;
|
|
408
|
+
/** Mark the whole state dirty (used after hydrate/cleanup or a migration). */
|
|
409
|
+
markAllStateDirty(reset?: boolean): void;
|
|
410
|
+
private exportMembers;
|
|
363
411
|
private emitEvent;
|
|
364
412
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type AgentResult, type LegacyAgentUsage } from "@cerebriline/shared";
|
|
2
|
+
import type { TeamEvent } from "./multi-agent";
|
|
3
|
+
/**
|
|
4
|
+
* Persistence policy for team events.
|
|
5
|
+
*
|
|
6
|
+
* Team events fall into two classes:
|
|
7
|
+
* - **durable**: they mutate team state that must survive a restart
|
|
8
|
+
* (tasks, mailbox, mission log, run lifecycle, outcomes, membership).
|
|
9
|
+
* - **telemetry**: high-frequency liveness signals (streamed agent chunks,
|
|
10
|
+
* run heartbeats/activity). These are forwarded to live UIs only and are
|
|
11
|
+
* never written to disk.
|
|
12
|
+
*
|
|
13
|
+
* The switch is exhaustive so adding a new `TeamMessageType` fails to compile
|
|
14
|
+
* until it is classified here.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isDurableTeamEvent(event: TeamEvent): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Durable events that should be flushed to storage immediately instead of
|
|
19
|
+
* waiting for the batch window: terminal run states and membership changes,
|
|
20
|
+
* where losing the write on a crash would leave recovery in a wrong state.
|
|
21
|
+
*/
|
|
22
|
+
export declare function shouldFlushTeamEventImmediately(event: TeamEvent): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Compact form of an `AgentResult` kept on team run records. Contains exactly
|
|
25
|
+
* the fields consumed by run summaries; the full transcript (messages, tool
|
|
26
|
+
* calls) already lives in the teammate's session storage.
|
|
27
|
+
*/
|
|
28
|
+
export interface TeamRunResultRecord {
|
|
29
|
+
text: string;
|
|
30
|
+
iterations: number;
|
|
31
|
+
finishReason: AgentResult["finishReason"];
|
|
32
|
+
durationMs: number;
|
|
33
|
+
usage: LegacyAgentUsage;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Upstream's upper bound for final text kept on a run record (4,000 there).
|
|
37
|
+
*
|
|
38
|
+
* Not applied on this fork: the run record is where a teammate's answer comes
|
|
39
|
+
* from when the lead awaits it, and a long one is filed whole as a report the
|
|
40
|
+
* lead reads with `read_agent_report`. Cut here, the report ended at
|
|
41
|
+
* character 4,000 with "..." and said it was "the end of the report". The
|
|
42
|
+
* record still drops the transcript and the tool calls, which is where the
|
|
43
|
+
* size was.
|
|
44
|
+
*/
|
|
45
|
+
export declare const TEAM_RUN_RESULT_TEXT_LIMIT: number;
|
|
46
|
+
/**
|
|
47
|
+
* Reduce a full (or legacy persisted) agent result to a `TeamRunResultRecord`.
|
|
48
|
+
* Accepts `unknown` because persisted rows written by older versions may hold
|
|
49
|
+
* a full `AgentResult` with dates serialized as strings.
|
|
50
|
+
*/
|
|
51
|
+
export declare function toTeamRunResultRecord(result: unknown): TeamRunResultRecord | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Strip heavy payloads (full transcripts, tool calls) from an event before it
|
|
54
|
+
* is appended to the durable event log.
|
|
55
|
+
*/
|
|
56
|
+
export declare function toPersistableTeamEvent(event: TeamEvent): unknown;
|
|
@@ -2,5 +2,5 @@ export { type AgentSlotGate, type AgentSlotGateRegistry, agentEndpointKey, agent
|
|
|
2
2
|
export { buildDelegatedAgentConfig, createDelegatedAgent, createDelegatedAgentConfigProvider, type DelegatedAgentConfigProvider, type DelegatedAgentConnectionConfig, type DelegatedAgentKind, type DelegatedAgentRuntimeConfig, type DelegatedPrepareTurnTarget, } from "./delegated-agent";
|
|
3
3
|
export { buildSubagentLayout, pinConversationHead, SUBAGENT_BASE_PROMPT, type SubagentKnowledge, type SubagentLayout, } from "./subagent-layout";
|
|
4
4
|
export { createSpawnAgentTool, type SpawnAgentInput, type SpawnAgentOutput, type SpawnAgentToolConfig, type SubAgentEndContext, type SubAgentStartContext, } from "./spawn-agent-tool";
|
|
5
|
-
export { type AgentTask, AgentTeam, AgentTeamsRuntime, type AgentTeamsRuntimeOptions, createAgentTeam, createWorkerReviewerTeam, type SpawnTeammateOptions, type TaskResult, type TeamEvent, type TeamMemberConfig, } from "./multi-agent";
|
|
5
|
+
export { type AgentTask, AgentTeam, AgentTeamsRuntime, type AgentTeamsRuntimeOptions, createAgentTeam, createWorkerReviewerTeam, type SpawnTeammateOptions, type TaskResult, type TeamEvent, type TeamMemberConfig, type TeamRuntimeStateDelta, } from "./multi-agent";
|
|
6
6
|
export { type BootstrapAgentTeamsOptions, type BootstrapAgentTeamsResult, bootstrapAgentTeams, type CreateAgentTeamsToolsOptions, createAgentTeamsTools, reviveTeamStateDates, sanitizeTeamName, type TeamTeammateRuntimeConfig, } from "./team-tools";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { sanitizeTeamName } from "./sanitize-team-name";
|
|
1
2
|
import { type AgentTool, type TeamTeammateSpec } from "@cerebriline/shared";
|
|
2
3
|
import { type DelegatedAgentConfigProvider, type DelegatedAgentRuntimeConfig } from "./delegated-agent";
|
|
3
4
|
import type { AgentTeamsRuntime } from "./multi-agent";
|
|
@@ -53,4 +54,3 @@ export declare const TEAMMATE_TEAM_TOOL_NAMES: ReadonlySet<string>;
|
|
|
53
54
|
export declare function bootstrapAgentTeams(options: BootstrapAgentTeamsOptions): BootstrapAgentTeamsResult;
|
|
54
55
|
export declare function createAgentTeamsTools(options: CreateAgentTeamsToolsOptions): AgentTool[];
|
|
55
56
|
export { reviveTeamStateDates } from "./team-state-dates";
|
|
56
|
-
export declare function sanitizeTeamName(name: string): string;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import type { AgentHooks, BasicLogger } from "@cerebriline/shared";
|
|
1
|
+
import type { AgentHooks, BasicLogger, ITelemetryService } from "@cerebriline/shared";
|
|
2
2
|
export declare function isCheckpointStashMessage(message: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Per-session scratch directory holding the persistent `GIT_INDEX_FILE` used
|
|
5
|
+
* to snapshot untracked files. Persisting the index across turns lets git's
|
|
6
|
+
* stat cache skip re-reading (and re-hashing) untracked files that have not
|
|
7
|
+
* changed since the previous checkpoint — without it, every turn re-hashes
|
|
8
|
+
* every untracked byte in the workspace.
|
|
9
|
+
*
|
|
10
|
+
* Lives under the user's Cline data dir (never the world-shared OS tmpdir:
|
|
11
|
+
* the index and pathspec files enumerate workspace paths) and is keyed by a
|
|
12
|
+
* hash of cwd + session id: hashing avoids sanitization collisions between
|
|
13
|
+
* distinct ids, and folding in cwd keeps a session restored against a
|
|
14
|
+
* different workspace from inheriting a foreign index. Removed by
|
|
15
|
+
* `deleteCheckpointRefs` and by the age-based reaper.
|
|
16
|
+
*/
|
|
17
|
+
export declare function checkpointScratchDir(cwd: string, sessionId: string): string;
|
|
3
18
|
export interface CheckpointEntry {
|
|
4
19
|
ref: string;
|
|
5
20
|
createdAt: number;
|
|
@@ -26,6 +41,13 @@ type CreateCheckpointHooksOptions = {
|
|
|
26
41
|
sessionId: string;
|
|
27
42
|
runCount: number;
|
|
28
43
|
}) => Promise<CheckpointEntry | undefined> | CheckpointEntry | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Emits one `checkpoint.snapshot` event per built-in snapshot attempt so
|
|
46
|
+
* snapshot cost and degradations (HEAD fallbacks, skipped turns) are
|
|
47
|
+
* observable in the field, not only in local logs. Properties carry
|
|
48
|
+
* outcome and duration — never file paths or contents.
|
|
49
|
+
*/
|
|
50
|
+
telemetry?: Pick<ITelemetryService, "capture">;
|
|
29
51
|
};
|
|
30
52
|
/**
|
|
31
53
|
* Deletes all private git refs under refs/cline/checkpoints/{sessionId}/ that
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { AgentExtension, AgentHooks, BasicLogger, WorkspaceInfo } from "@cerebriline/shared";
|
|
2
|
+
import { type HookEventName } from "./subprocess";
|
|
3
|
+
/**
|
|
4
|
+
* Reports how long a fire-and-forget hook actually ran, once per hook. Hosts
|
|
5
|
+
* use it to learn the real runtime distribution of detached hooks —
|
|
6
|
+
* unmeasurable while nothing awaits them — before deciding to run any of them
|
|
7
|
+
* blocking. `exited: false` is a censored observation (the hook was still
|
|
8
|
+
* running after the observation window, so it ran at least `durationMs`),
|
|
9
|
+
* which is what keeps the sample from covering only hooks that finish.
|
|
10
|
+
*/
|
|
11
|
+
export type HookRuntimeObserver = (event: {
|
|
12
|
+
hookName: HookEventName;
|
|
13
|
+
durationMs: number;
|
|
14
|
+
exitCode: number | null;
|
|
15
|
+
exited: boolean;
|
|
16
|
+
}) => void;
|
|
2
17
|
type HookRuntimeOptions = {
|
|
3
18
|
cwd: string;
|
|
4
19
|
workspacePath: string;
|
|
@@ -7,6 +22,18 @@ type HookRuntimeOptions = {
|
|
|
7
22
|
toolCallTimeoutMs?: number;
|
|
8
23
|
/** Keep asynchronous hooks attached until exit. Intended for deterministic tests. */
|
|
9
24
|
detachAsyncHooks?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Run agent_start/agent_resume hooks blocking, honoring their control
|
|
27
|
+
* output (cancel, contextModification). Off by default: these hooks have
|
|
28
|
+
* always been fire-and-forget with stdio ignored, so an existing
|
|
29
|
+
* long-running script would otherwise stall every run start until the
|
|
30
|
+
* timeout. A host that flips this on must tell hook authors that
|
|
31
|
+
* long-running run-start hooks need to background themselves (spawn a
|
|
32
|
+
* detached child and exit).
|
|
33
|
+
*/
|
|
34
|
+
blockingRunStartHooks?: boolean;
|
|
35
|
+
/** Observes how long detached hooks run. See {@link HookRuntimeObserver}. */
|
|
36
|
+
onHookRuntime?: HookRuntimeObserver;
|
|
10
37
|
/** Structured git + path metadata forwarded into every hook payload. */
|
|
11
38
|
workspaceInfo?: WorkspaceInfo;
|
|
12
39
|
};
|
|
@@ -9,6 +9,29 @@ export interface RunSubprocessEventOptions {
|
|
|
9
9
|
pid?: number;
|
|
10
10
|
detached: boolean;
|
|
11
11
|
}) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Reports a detached hook's runtime exactly once. The run never waits on
|
|
14
|
+
* this: detached hooks are fire-and-forget by contract, and this only
|
|
15
|
+
* observes them so hosts can measure how long they actually take.
|
|
16
|
+
*
|
|
17
|
+
* `exited: true` means the hook finished and `durationMs` is its runtime.
|
|
18
|
+
* `exited: false` is a censored observation: the hook was still running
|
|
19
|
+
* after the observation window, and `durationMs` is that window, so read
|
|
20
|
+
* it as "ran at least this long" and count these separately — the
|
|
21
|
+
* case that matters most, since those are the hooks that would stall a
|
|
22
|
+
* blocking run. Without it the sample would only contain hooks that
|
|
23
|
+
* finished.
|
|
24
|
+
*
|
|
25
|
+
* Nothing is reported if the parent exits before either happens.
|
|
26
|
+
*/
|
|
27
|
+
onDetachedSettled?: (event: {
|
|
28
|
+
command: string[];
|
|
29
|
+
durationMs: number;
|
|
30
|
+
exitCode: number | null;
|
|
31
|
+
exited: boolean;
|
|
32
|
+
}) => void;
|
|
33
|
+
/** Overrides the censoring window for `onDetachedSettled`. */
|
|
34
|
+
detachedObservationMs?: number;
|
|
12
35
|
}
|
|
13
36
|
export interface RunSubprocessEventResult {
|
|
14
37
|
exitCode: number | null;
|
|
@@ -49,6 +49,16 @@ export interface SubprocessHooksOptions {
|
|
|
49
49
|
workspaceInfo?: WorkspaceInfo;
|
|
50
50
|
env?: NodeJS.ProcessEnv;
|
|
51
51
|
timeoutMs?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Run agent_start/agent_resume hooks blocking, honoring their control
|
|
54
|
+
* output (cancel, contextModification). Off by default: these hooks have
|
|
55
|
+
* always been fire-and-forget with stdio ignored, so an existing
|
|
56
|
+
* long-running script would otherwise stall every run start until the
|
|
57
|
+
* timeout. A host that flips this on must tell hook authors that
|
|
58
|
+
* long-running run-start hooks need to background themselves (spawn a
|
|
59
|
+
* detached child and exit).
|
|
60
|
+
*/
|
|
61
|
+
blockingRunStartHooks?: boolean;
|
|
52
62
|
onDispatchError?: (error: Error, payload: HookEventPayload) => void;
|
|
53
63
|
onDispatch?: (event: {
|
|
54
64
|
payload: HookEventPayload;
|
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import { type HubClientRegistration, type HubCommandEnvelope, type HubEventEnvelope, type HubReplyEnvelope } from "@cerebriline/shared";
|
|
2
2
|
import { type HubOwnerContext } from "../discovery";
|
|
3
|
+
type HubCommandOptions = {
|
|
4
|
+
timeoutMs?: number | null;
|
|
5
|
+
/** Synchronous local guard, checked after connection before each dispatch. */
|
|
6
|
+
beforeDispatch?: () => void;
|
|
7
|
+
/** Observes this attempt's correlation id after the local guard, before sending.
|
|
8
|
+
* Dispatch alone does not confirm that the server accepted the command. */
|
|
9
|
+
onDispatch?: (requestId: string) => void;
|
|
10
|
+
};
|
|
3
11
|
export interface HubClientOptions {
|
|
4
12
|
url: string;
|
|
5
13
|
clientId?: string;
|
|
6
14
|
clientType?: string;
|
|
7
15
|
displayName?: string;
|
|
16
|
+
/** Version reported to the hub; defaults to the @cline/core version. */
|
|
17
|
+
clientVersion?: string;
|
|
18
|
+
/** Additional registration metadata; version and pid are owned by the client. */
|
|
19
|
+
metadata?: Record<string, unknown>;
|
|
8
20
|
workspaceRoot?: string;
|
|
9
21
|
cwd?: string;
|
|
22
|
+
/** Hub token sent with the `cline-hub-auth.*` WebSocket subprotocol. */
|
|
10
23
|
authToken?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Resolves HTTP headers for each new WebSocket, including reconnects.
|
|
26
|
+
* This Node-only transport option is mutually exclusive with `authToken`.
|
|
27
|
+
* Resolver failures are surfaced by `connect()` and `getConnectionError()`;
|
|
28
|
+
* `Sec-WebSocket-Protocol` must be configured through `authToken` instead.
|
|
29
|
+
*/
|
|
30
|
+
resolveConnectionHeaders?: () => Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>;
|
|
11
31
|
capabilities?: HubClientRegistration["capabilities"];
|
|
12
32
|
}
|
|
13
33
|
export interface LocalHubResolutionOptions {
|
|
@@ -15,6 +35,11 @@ export interface LocalHubResolutionOptions {
|
|
|
15
35
|
strategy?: "prefer-hub" | "require-hub";
|
|
16
36
|
workspaceRoot?: string;
|
|
17
37
|
cwd?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Called with the error when starting a detached Hub fails. The function
|
|
40
|
+
* still resolves `undefined` in that case; this lets a caller report why.
|
|
41
|
+
*/
|
|
42
|
+
onStartupError?: (error: unknown) => void;
|
|
18
43
|
}
|
|
19
44
|
export type HubTransportErrorCode = "hub_connect_timeout" | "hub_connect_failed" | "hub_connection_closed" | "hub_connection_not_open";
|
|
20
45
|
export declare class HubTransportError extends Error {
|
|
@@ -36,6 +61,19 @@ export declare class HubCommandError extends Error {
|
|
|
36
61
|
}
|
|
37
62
|
export declare function isHubCommandTimeoutError(error: unknown, command?: HubCommandEnvelope["command"]): boolean;
|
|
38
63
|
export declare function rememberRecoverableLocalHubUrl(url: string, authToken?: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Keep a local hub's token for the connections this process makes to it,
|
|
66
|
+
* without marking the hub as one this process may restart.
|
|
67
|
+
*
|
|
68
|
+
* A hub on an explicit endpoint (`CLINE_HUB_PORT`, or a host/port the caller
|
|
69
|
+
* passed) is not "recoverable", and that used to mean its token was not kept
|
|
70
|
+
* either. The caller that had just started it got back a URL, connected with
|
|
71
|
+
* no token and was refused: "WebSocket connection to
|
|
72
|
+
* 'ws://127.0.0.1:25499/hub' failed: Connection ended", on every first start
|
|
73
|
+
* (solidPC and eleven2go, 2026-10-11, three of three). The second start
|
|
74
|
+
* worked because it found the discovery record, which carries the token.
|
|
75
|
+
*/
|
|
76
|
+
export declare function rememberLocalHubAuthToken(url: string, authToken?: string): void;
|
|
39
77
|
export declare class NodeHubClient {
|
|
40
78
|
private readonly options;
|
|
41
79
|
private socket;
|
|
@@ -57,6 +95,7 @@ export declare class NodeHubClient {
|
|
|
57
95
|
private reconnectTimer;
|
|
58
96
|
private reconnectAttempt;
|
|
59
97
|
private closedByClient;
|
|
98
|
+
private connectGeneration;
|
|
60
99
|
private lastCloseError;
|
|
61
100
|
private sawSocketClose;
|
|
62
101
|
private registered;
|
|
@@ -68,12 +107,11 @@ export declare class NodeHubClient {
|
|
|
68
107
|
getConnectionError(): HubTransportError | null;
|
|
69
108
|
updateCapabilities(capabilities: NonNullable<HubClientRegistration["capabilities"]>): Promise<void>;
|
|
70
109
|
connect(): Promise<void>;
|
|
110
|
+
private openSocket;
|
|
71
111
|
subscribe(listener: (event: HubEventEnvelope) => void, options?: {
|
|
72
112
|
sessionId?: string;
|
|
73
113
|
}): () => void;
|
|
74
|
-
command(command: HubCommandEnvelope["command"], payload?: Record<string, unknown>, sessionId?: string, options?:
|
|
75
|
-
timeoutMs?: number | null;
|
|
76
|
-
}): Promise<HubReplyEnvelope>;
|
|
114
|
+
command(command: HubCommandEnvelope["command"], payload?: Record<string, unknown>, sessionId?: string, options?: HubCommandOptions): Promise<HubReplyEnvelope>;
|
|
77
115
|
private commandOnce;
|
|
78
116
|
private recoverLocalHubTransport;
|
|
79
117
|
private hasActiveSubscriptions;
|
|
@@ -144,3 +182,4 @@ export declare function restartLocalHubIfIdleAfterStartupTimeout(options: {
|
|
|
144
182
|
workspaceRoot?: string;
|
|
145
183
|
cwd?: string;
|
|
146
184
|
}): Promise<string | undefined>;
|
|
185
|
+
export {};
|
|
@@ -56,11 +56,8 @@ export interface HubTeamProgressHandlers {
|
|
|
56
56
|
onError?: (error: Error) => void;
|
|
57
57
|
}
|
|
58
58
|
export declare class HubSessionClient {
|
|
59
|
-
private readonly options;
|
|
60
59
|
private readonly client;
|
|
61
|
-
private metadataApplied;
|
|
62
60
|
constructor(options: HubSessionClientOptions);
|
|
63
|
-
private ensureMetadataApplied;
|
|
64
61
|
connect(): Promise<void>;
|
|
65
62
|
private taskCommand;
|
|
66
63
|
close(): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort description of who holds the Hub port when the daemon dies with
|
|
3
|
+
* `EADDRINUSE`. The daemon takes the owner instance lock before binding, so an
|
|
4
|
+
* occupant on the port is never a live Hub for this owner; these details tell
|
|
5
|
+
* us what it actually is (an older pre-lock Hub, a leaked handle, another
|
|
6
|
+
* owner context, or an unrelated program) so the fix can target that case.
|
|
7
|
+
*/
|
|
8
|
+
import type { TelemetryProperties } from "@cerebriline/shared";
|
|
9
|
+
/** `lsof -Fpc` emits `p<pid>` then `c<command>` per process. */
|
|
10
|
+
export declare function parseLsofOwners(output: string): string[];
|
|
11
|
+
/** Telemetry context for a `hub.daemon.startup` failure caused by `EADDRINUSE`. */
|
|
12
|
+
export declare function describeAddressInUse(error: unknown, endpoint: {
|
|
13
|
+
host: string;
|
|
14
|
+
port: number;
|
|
15
|
+
pathname: string;
|
|
16
|
+
}): Promise<TelemetryProperties>;
|