@cline/core 0.0.38-nightly.1778113663
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/README.md +108 -0
- package/dist/ClineCore.d.ts +282 -0
- package/dist/account/cline-account-service.d.ts +37 -0
- package/dist/account/index.d.ts +3 -0
- package/dist/account/rpc.d.ts +40 -0
- package/dist/account/types.d.ts +98 -0
- package/dist/auth/bounded-ttl-cache.d.ts +13 -0
- package/dist/auth/client.d.ts +30 -0
- package/dist/auth/cline.d.ts +64 -0
- package/dist/auth/codex.d.ts +43 -0
- package/dist/auth/oca.d.ts +28 -0
- package/dist/auth/server.d.ts +54 -0
- package/dist/auth/types.d.ts +103 -0
- package/dist/auth/utils.d.ts +32 -0
- package/dist/cline-core/automation.d.ts +34 -0
- package/dist/cline-core/runtime-services.d.ts +5 -0
- package/dist/cline-core/start-input.d.ts +10 -0
- package/dist/cline-core/telemetry.d.ts +10 -0
- package/dist/cline-core/types.d.ts +221 -0
- package/dist/cron/events/cron-event-ingress.d.ts +37 -0
- package/dist/cron/reports/cron-report-writer.d.ts +40 -0
- package/dist/cron/runner/cron-materializer.d.ts +35 -0
- package/dist/cron/runner/cron-runner.d.ts +45 -0
- package/dist/cron/runner/resource-limiter.d.ts +8 -0
- package/dist/cron/schedule/scheduler.d.ts +12 -0
- package/dist/cron/service/cron-service.d.ts +56 -0
- package/dist/cron/service/schedule-command-service.d.ts +9 -0
- package/dist/cron/service/schedule-service.d.ts +98 -0
- package/dist/cron/specs/cron-reconciler.d.ts +61 -0
- package/dist/cron/specs/cron-spec-parser.d.ts +26 -0
- package/dist/cron/specs/cron-watcher.d.ts +22 -0
- package/dist/cron/store/cron-schema.d.ts +2 -0
- package/dist/cron/store/sqlite-cron-store.d.ts +240 -0
- package/dist/extensions/config/index.d.ts +7 -0
- package/dist/extensions/config/runtime-commands.d.ts +11 -0
- package/dist/extensions/config/skill-frontmatter-toggle.d.ts +11 -0
- package/dist/extensions/config/unified-config-file-watcher.d.ts +77 -0
- package/dist/extensions/config/user-instruction-config-loader.d.ts +64 -0
- package/dist/extensions/config/user-instruction-plugin.d.ts +25 -0
- package/dist/extensions/config/user-instruction-service.d.ts +23 -0
- package/dist/extensions/context/agentic-compaction.d.ts +12 -0
- package/dist/extensions/context/basic-compaction.d.ts +8 -0
- package/dist/extensions/context/compaction-shared.d.ts +60 -0
- package/dist/extensions/context/compaction.d.ts +24 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/mcp/client.d.ts +2 -0
- package/dist/extensions/mcp/config-loader.d.ts +15 -0
- package/dist/extensions/mcp/index.d.ts +8 -0
- package/dist/extensions/mcp/manager.d.ts +23 -0
- package/dist/extensions/mcp/name-transform.d.ts +2 -0
- package/dist/extensions/mcp/policies.d.ts +14 -0
- package/dist/extensions/mcp/tools.d.ts +3 -0
- package/dist/extensions/mcp/types.d.ts +94 -0
- package/dist/extensions/plugin/plugin-config-loader.d.ts +40 -0
- package/dist/extensions/plugin/plugin-load-report.d.ts +18 -0
- package/dist/extensions/plugin/plugin-loader.d.ts +22 -0
- package/dist/extensions/plugin/plugin-module-import.d.ts +4 -0
- package/dist/extensions/plugin/plugin-sandbox.d.ts +36 -0
- package/dist/extensions/plugin/plugin-targeting.d.ts +6 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +1 -0
- package/dist/extensions/tools/constants.d.ts +24 -0
- package/dist/extensions/tools/definitions.d.ts +102 -0
- package/dist/extensions/tools/executors/apply-patch-parser.d.ts +68 -0
- package/dist/extensions/tools/executors/apply-patch.d.ts +28 -0
- package/dist/extensions/tools/executors/bash.d.ts +49 -0
- package/dist/extensions/tools/executors/editor.d.ts +31 -0
- package/dist/extensions/tools/executors/file-read.d.ts +40 -0
- package/dist/extensions/tools/executors/index.d.ts +50 -0
- package/dist/extensions/tools/executors/search.d.ts +50 -0
- package/dist/extensions/tools/executors/web-fetch.d.ts +58 -0
- package/dist/extensions/tools/helpers.d.ts +15 -0
- package/dist/extensions/tools/index.d.ts +59 -0
- package/dist/extensions/tools/model-tool-routing.d.ts +33 -0
- package/dist/extensions/tools/presets.d.ts +132 -0
- package/dist/extensions/tools/runtime.d.ts +24 -0
- package/dist/extensions/tools/schemas.d.ts +241 -0
- package/dist/extensions/tools/team/delegated-agent.d.ts +43 -0
- package/dist/extensions/tools/team/index.d.ts +2 -0
- package/dist/extensions/tools/team/multi-agent.d.ts +230 -0
- package/dist/extensions/tools/team/projections.d.ts +8 -0
- package/dist/extensions/tools/team/runtime.d.ts +4 -0
- package/dist/extensions/tools/team/spawn-agent-tool.d.ts +83 -0
- package/dist/extensions/tools/team/subagent-prompts.d.ts +3 -0
- package/dist/extensions/tools/team/team-tools.d.ts +35 -0
- package/dist/extensions/tools/types.d.ts +254 -0
- package/dist/hooks/checkpoint-hooks.d.ts +45 -0
- package/dist/hooks/hook-extension.d.ts +2 -0
- package/dist/hooks/hook-file-config.d.ts +24 -0
- package/dist/hooks/hook-file-hooks.d.ts +21 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/subprocess-runner.d.ts +21 -0
- package/dist/hooks/subprocess.d.ts +68 -0
- package/dist/hub/client/connect.d.ts +14 -0
- package/dist/hub/client/index.d.ts +88 -0
- package/dist/hub/client/session-client.d.ts +118 -0
- package/dist/hub/client/ui-client.d.ts +45 -0
- package/dist/hub/daemon/entry.d.ts +1 -0
- package/dist/hub/daemon/entry.js +720 -0
- package/dist/hub/daemon/index.d.ts +8 -0
- package/dist/hub/daemon/runtime-handlers.d.ts +12 -0
- package/dist/hub/daemon/start-shared-server.d.ts +18 -0
- package/dist/hub/discovery/defaults.d.ts +16 -0
- package/dist/hub/discovery/index.d.ts +30 -0
- package/dist/hub/discovery/workspace.d.ts +3 -0
- package/dist/hub/index.d.ts +32 -0
- package/dist/hub/index.js +717 -0
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +73 -0
- package/dist/hub/runtime-host/remote-runtime-host.d.ts +9 -0
- package/dist/hub/server/browser-websocket.d.ts +17 -0
- package/dist/hub/server/command-transport.d.ts +7 -0
- package/dist/hub/server/handlers/approval-handlers.d.ts +17 -0
- package/dist/hub/server/handlers/capability-handlers.d.ts +12 -0
- package/dist/hub/server/handlers/client-handlers.d.ts +6 -0
- package/dist/hub/server/handlers/context.d.ts +56 -0
- package/dist/hub/server/handlers/run-handlers.d.ts +5 -0
- package/dist/hub/server/handlers/session-event-projector.d.ts +7 -0
- package/dist/hub/server/handlers/session-handlers.d.ts +20 -0
- package/dist/hub/server/hub-client-contributions.d.ts +19 -0
- package/dist/hub/server/hub-notifications.d.ts +7 -0
- package/dist/hub/server/hub-schedule-events.d.ts +2 -0
- package/dist/hub/server/hub-server-logging.d.ts +2 -0
- package/dist/hub/server/hub-server-options.d.ts +55 -0
- package/dist/hub/server/hub-server-transport.d.ts +34 -0
- package/dist/hub/server/hub-session-records.d.ts +8 -0
- package/dist/hub/server/hub-websocket-server.d.ts +6 -0
- package/dist/hub/server/index.d.ts +4 -0
- package/dist/hub/server/native-transport.d.ts +16 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +715 -0
- package/dist/runtime/capabilities/index.d.ts +2 -0
- package/dist/runtime/capabilities/normalize-runtime-capabilities.d.ts +2 -0
- package/dist/runtime/capabilities/runtime-capabilities.d.ts +6 -0
- package/dist/runtime/config/agent-message-codec.d.ts +6 -0
- package/dist/runtime/config/agent-runtime-config-builder.d.ts +87 -0
- package/dist/runtime/host/history.d.ts +18 -0
- package/dist/runtime/host/host.d.ts +7 -0
- package/dist/runtime/host/local/agent-event-bridge.d.ts +29 -0
- package/dist/runtime/host/local/session-record.d.ts +6 -0
- package/dist/runtime/host/local/session-service-invoker.d.ts +4 -0
- package/dist/runtime/host/local/spawn-tool.d.ts +15 -0
- package/dist/runtime/host/local/user-files.d.ts +1 -0
- package/dist/runtime/host/local-runtime-host.d.ts +119 -0
- package/dist/runtime/host/runtime-host-support.d.ts +20 -0
- package/dist/runtime/host/runtime-host.d.ts +163 -0
- package/dist/runtime/orchestration/runtime-builder.d.ts +6 -0
- package/dist/runtime/orchestration/runtime-event-adapter.d.ts +101 -0
- package/dist/runtime/orchestration/runtime-oauth-token-manager.d.ts +30 -0
- package/dist/runtime/orchestration/session-runtime-orchestrator.d.ts +218 -0
- package/dist/runtime/orchestration/session-runtime.d.ts +58 -0
- package/dist/runtime/orchestration/user-input-builder.d.ts +15 -0
- package/dist/runtime/safety/loop-detection.d.ts +58 -0
- package/dist/runtime/safety/mistake-tracker.d.ts +68 -0
- package/dist/runtime/safety/rules.d.ts +6 -0
- package/dist/runtime/tools/subprocess-sandbox.d.ts +43 -0
- package/dist/runtime/tools/tool-approval.d.ts +9 -0
- package/dist/runtime/turn-queue/pending-prompt-service.d.ts +64 -0
- package/dist/services/agent-events.d.ts +33 -0
- package/dist/services/config.d.ts +2 -0
- package/dist/services/global-settings.d.ts +34 -0
- package/dist/services/llms/cline-recommended-models.d.ts +19 -0
- package/dist/services/llms/configured-provider-registry.d.ts +27 -0
- package/dist/services/llms/handler-factory.d.ts +3 -0
- package/dist/services/llms/provider-defaults.d.ts +28 -0
- package/dist/services/llms/provider-settings.d.ts +247 -0
- package/dist/services/llms/runtime-config.d.ts +3 -0
- package/dist/services/llms/runtime-registry.d.ts +19 -0
- package/dist/services/llms/runtime-types.d.ts +84 -0
- package/dist/services/local-runtime-bootstrap.d.ts +45 -0
- package/dist/services/plugin-tools.d.ts +15 -0
- package/dist/services/providers/local-provider-registry.d.ts +218 -0
- package/dist/services/providers/local-provider-service.d.ts +99 -0
- package/dist/services/providers/model-source.d.ts +3 -0
- package/dist/services/session-artifacts.d.ts +17 -0
- package/dist/services/session-data.d.ts +51 -0
- package/dist/services/session-telemetry.d.ts +15 -0
- package/dist/services/storage/file-team-store.d.ts +28 -0
- package/dist/services/storage/provider-settings-legacy-migration.d.ts +38 -0
- package/dist/services/storage/provider-settings-manager.d.ts +23 -0
- package/dist/services/storage/sqlite-session-store.d.ts +30 -0
- package/dist/services/storage/sqlite-team-store.d.ts +34 -0
- package/dist/services/storage/team-store.d.ts +15 -0
- package/dist/services/telemetry/ITelemetryAdapter.d.ts +54 -0
- package/dist/services/telemetry/OpenTelemetryAdapter.d.ts +43 -0
- package/dist/services/telemetry/OpenTelemetryProvider.d.ts +83 -0
- package/dist/services/telemetry/TelemetryLoggerSink.d.ts +27 -0
- package/dist/services/telemetry/TelemetryService.d.ts +34 -0
- package/dist/services/telemetry/core-events.d.ts +198 -0
- package/dist/services/telemetry/distinct-id.d.ts +1 -0
- package/dist/services/telemetry/index.d.ts +3 -0
- package/dist/services/telemetry/index.js +1 -0
- package/dist/services/usage.d.ts +18 -0
- package/dist/services/workspace/file-indexer.d.ts +5 -0
- package/dist/services/workspace/index.d.ts +4 -0
- package/dist/services/workspace/mention-enricher.d.ts +13 -0
- package/dist/services/workspace/workspace-manager.d.ts +27 -0
- package/dist/services/workspace/workspace-manifest.d.ts +31 -0
- package/dist/services/workspace/workspace-telemetry.d.ts +18 -0
- package/dist/session/checkpoint-restore.d.ts +20 -0
- package/dist/session/models/session-graph.d.ts +15 -0
- package/dist/session/models/session-manifest.d.ts +29 -0
- package/dist/session/models/session-row.d.ts +92 -0
- package/dist/session/services/file-session-service.d.ts +8 -0
- package/dist/session/services/message-builder.d.ts +66 -0
- package/dist/session/services/persistence-service.d.ts +58 -0
- package/dist/session/services/session-service.d.ts +13 -0
- package/dist/session/session-snapshot.d.ts +57 -0
- package/dist/session/session-versioning-service.d.ts +48 -0
- package/dist/session/stores/conversation-store.d.ts +29 -0
- package/dist/session/stores/session-manifest-store.d.ts +21 -0
- package/dist/session/stores/team-persistence-store.d.ts +23 -0
- package/dist/session/team/index.d.ts +2 -0
- package/dist/session/team/team-child-session-manager.d.ts +35 -0
- package/dist/session/team/team-session-coordinator.d.ts +13 -0
- package/dist/settings/index.d.ts +2 -0
- package/dist/settings/settings-service.d.ts +6 -0
- package/dist/settings/types.d.ts +42 -0
- package/dist/types/chat-schema.d.ts +161 -0
- package/dist/types/common.d.ts +19 -0
- package/dist/types/config.d.ts +167 -0
- package/dist/types/events.d.ts +89 -0
- package/dist/types/provider-settings.d.ts +19 -0
- package/dist/types/session.d.ts +116 -0
- package/dist/types/sessions.d.ts +28 -0
- package/dist/types/storage.d.ts +36 -0
- package/dist/types.d.ts +32 -0
- package/dist/version.d.ts +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable spawn_agent tool for delegating tasks to sub-agents.
|
|
3
|
+
*/
|
|
4
|
+
import { type AgentConfig, type AgentEvent, type AgentHooks, type AgentResult, type AgentTool, type AgentToolContext, type BasicLogger, type HookErrorMode, type ITelemetryService, type ToolApprovalRequest, type ToolApprovalResult, type ToolPolicy } from "@cline/shared";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { type DelegatedAgentConfigProvider } from "./delegated-agent";
|
|
7
|
+
type AgentExtension = NonNullable<AgentConfig["extensions"]>[number];
|
|
8
|
+
type AgentFinishReason = AgentResult["finishReason"];
|
|
9
|
+
export declare const SpawnAgentInputSchema: z.ZodObject<{
|
|
10
|
+
systemPrompt: z.ZodString;
|
|
11
|
+
task: z.ZodString;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type SpawnAgentInput = z.infer<typeof SpawnAgentInputSchema>;
|
|
14
|
+
export interface SpawnAgentOutput {
|
|
15
|
+
text: string;
|
|
16
|
+
iterations: number;
|
|
17
|
+
finishReason: AgentFinishReason;
|
|
18
|
+
usage: {
|
|
19
|
+
inputTokens: number;
|
|
20
|
+
outputTokens: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface SubAgentStartContext {
|
|
24
|
+
subAgentId: string;
|
|
25
|
+
conversationId: string;
|
|
26
|
+
parentAgentId: string;
|
|
27
|
+
input: SpawnAgentInput;
|
|
28
|
+
}
|
|
29
|
+
export interface SubAgentEndContext {
|
|
30
|
+
subAgentId: string;
|
|
31
|
+
conversationId: string;
|
|
32
|
+
parentAgentId: string;
|
|
33
|
+
input: SpawnAgentInput;
|
|
34
|
+
result?: SpawnAgentOutput;
|
|
35
|
+
error?: Error;
|
|
36
|
+
}
|
|
37
|
+
export interface SpawnAgentToolConfig {
|
|
38
|
+
configProvider: DelegatedAgentConfigProvider;
|
|
39
|
+
defaultMaxIterations?: number;
|
|
40
|
+
subAgentTools?: AgentTool[];
|
|
41
|
+
createSubAgentTools?: (input: SpawnAgentInput, context: AgentToolContext) => AgentTool[] | Promise<AgentTool[]>;
|
|
42
|
+
onSubAgentEvent?: (event: AgentEvent) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Lifecycle hooks forwarded to spawned sub-agent runs.
|
|
45
|
+
*/
|
|
46
|
+
hooks?: AgentHooks;
|
|
47
|
+
/**
|
|
48
|
+
* Extension list forwarded to spawned sub-agent runs.
|
|
49
|
+
*/
|
|
50
|
+
extensions?: AgentExtension[];
|
|
51
|
+
/**
|
|
52
|
+
* Error handling mode for forwarded lifecycle hooks.
|
|
53
|
+
*/
|
|
54
|
+
hookErrorMode?: HookErrorMode;
|
|
55
|
+
/**
|
|
56
|
+
* Called after a sub-agent instance is created and before it starts running.
|
|
57
|
+
* Errors are ignored so lifecycle observers cannot break task execution.
|
|
58
|
+
*/
|
|
59
|
+
onSubAgentStart?: (context: SubAgentStartContext) => void | Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Called once a sub-agent run finishes (success or error).
|
|
62
|
+
* Errors are ignored so lifecycle observers cannot break task execution.
|
|
63
|
+
*/
|
|
64
|
+
onSubAgentEnd?: (context: SubAgentEndContext) => void | Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Optional per-tool policy for spawned sub-agents.
|
|
67
|
+
*/
|
|
68
|
+
toolPolicies?: Record<string, ToolPolicy>;
|
|
69
|
+
/**
|
|
70
|
+
* Optional approval callback for spawned sub-agent tool calls.
|
|
71
|
+
*/
|
|
72
|
+
requestToolApproval?: (request: ToolApprovalRequest) => Promise<ToolApprovalResult> | ToolApprovalResult;
|
|
73
|
+
/**
|
|
74
|
+
* Optional logger forwarded to spawned sub-agent runs.
|
|
75
|
+
*/
|
|
76
|
+
logger?: BasicLogger;
|
|
77
|
+
telemetry?: ITelemetryService;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create a spawn_agent tool that can run a delegated task with a focused sub-agent.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createSpawnAgentTool(config: SpawnAgentToolConfig): AgentTool<SpawnAgentInput, SpawnAgentOutput>;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DelegatedAgentRuntimeConfig } from "./delegated-agent";
|
|
2
|
+
export declare function buildTeammateSystemPrompt(prompt: string, config: DelegatedAgentRuntimeConfig): string;
|
|
3
|
+
export declare function buildSubAgentSystemPrompt(prompt: string, config: DelegatedAgentRuntimeConfig): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type AgentTool, type TeamRuntimeState, type TeamTeammateSpec } from "@cline/shared";
|
|
2
|
+
import { type DelegatedAgentConfigProvider, type DelegatedAgentRuntimeConfig } from "./delegated-agent";
|
|
3
|
+
import type { AgentTeamsRuntime } from "./multi-agent";
|
|
4
|
+
export type TeamTeammateRuntimeConfig = DelegatedAgentRuntimeConfig;
|
|
5
|
+
export interface CreateAgentTeamsToolsOptions {
|
|
6
|
+
runtime: AgentTeamsRuntime;
|
|
7
|
+
requesterId: string;
|
|
8
|
+
teammateConfigProvider: DelegatedAgentConfigProvider;
|
|
9
|
+
createBaseTools?: () => AgentTool[];
|
|
10
|
+
allowSpawn?: boolean;
|
|
11
|
+
includeSpawnTool?: boolean;
|
|
12
|
+
includeManagementTools?: boolean;
|
|
13
|
+
onLeadToolsUnlocked?: (tools: AgentTool[]) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface BootstrapAgentTeamsOptions {
|
|
16
|
+
runtime: AgentTeamsRuntime;
|
|
17
|
+
teammateConfigProvider: DelegatedAgentConfigProvider;
|
|
18
|
+
createBaseTools?: () => AgentTool[];
|
|
19
|
+
leadAgentId?: string;
|
|
20
|
+
restoredTeammates?: TeamTeammateSpec[];
|
|
21
|
+
restoredFromPersistence?: boolean;
|
|
22
|
+
includeLeadSpawnTool?: boolean;
|
|
23
|
+
includeLeadManagementTools?: boolean;
|
|
24
|
+
onLeadToolsUnlocked?: (tools: AgentTool[]) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface BootstrapAgentTeamsResult {
|
|
27
|
+
tools: AgentTool[];
|
|
28
|
+
restoredFromPersistence: boolean;
|
|
29
|
+
restoredTeammates: string[];
|
|
30
|
+
}
|
|
31
|
+
export declare const TEAM_TOOL_NAMES: readonly ["team_spawn_teammate", "team_shutdown_teammate", "team_status", "team_task", "team_run_task", "team_cancel_run", "team_list_runs", "team_await_runs", "team_send_message", "team_broadcast", "team_read_mailbox", "team_mission_log", "team_cleanup", "team_create_outcome", "team_attach_outcome_fragment", "team_review_outcome_fragment", "team_finalize_outcome", "team_list_outcomes"];
|
|
32
|
+
export declare function bootstrapAgentTeams(options: BootstrapAgentTeamsOptions): BootstrapAgentTeamsResult;
|
|
33
|
+
export declare function createAgentTeamsTools(options: CreateAgentTeamsToolsOptions): AgentTool[];
|
|
34
|
+
export declare function reviveTeamStateDates(state: TeamRuntimeState): TeamRuntimeState;
|
|
35
|
+
export declare function sanitizeTeamName(name: string): string;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Default Tools
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for executors, configuration, and results.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgentToolContext, ImageContent, TextContent } from "@cline/shared";
|
|
7
|
+
import type { ApplyPatchInput, EditFileInput, ReadFileRequest, StructuredCommandInput } from "./schemas";
|
|
8
|
+
/**
|
|
9
|
+
* Result from a single tool operation
|
|
10
|
+
*/
|
|
11
|
+
export interface ToolOperationResult {
|
|
12
|
+
/** The query/input that was executed */
|
|
13
|
+
query: string;
|
|
14
|
+
/** The result content (if successful) */
|
|
15
|
+
result: unknown;
|
|
16
|
+
/** Error message (if failed) */
|
|
17
|
+
error?: string;
|
|
18
|
+
/** Whether the operation succeeded */
|
|
19
|
+
success: boolean;
|
|
20
|
+
/** Duration in MS */
|
|
21
|
+
duration?: number;
|
|
22
|
+
}
|
|
23
|
+
export type FileReadResultContent = string | Array<TextContent | ImageContent>;
|
|
24
|
+
/**
|
|
25
|
+
* Executor for reading files
|
|
26
|
+
*
|
|
27
|
+
* @param request - File path and optional inclusive line range to read
|
|
28
|
+
* @param context - Tool execution context
|
|
29
|
+
* @returns The file content as a string
|
|
30
|
+
*/
|
|
31
|
+
export type FileReadExecutor = (request: ReadFileRequest, context: AgentToolContext) => Promise<FileReadResultContent>;
|
|
32
|
+
/**
|
|
33
|
+
* Executor for searching the codebase
|
|
34
|
+
*
|
|
35
|
+
* @param query - Regex pattern to search for
|
|
36
|
+
* @param cwd - Current working directory for the search
|
|
37
|
+
* @param context - Tool execution context
|
|
38
|
+
* @returns Search results as a formatted string
|
|
39
|
+
*/
|
|
40
|
+
export type SearchExecutor = (query: string, cwd: string, context: AgentToolContext) => Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Executor for running shell commands
|
|
43
|
+
*
|
|
44
|
+
* @param command - Shell command to execute
|
|
45
|
+
* @param cwd - Current working directory for execution
|
|
46
|
+
* @param context - Tool execution context
|
|
47
|
+
* @returns Command output (stdout)
|
|
48
|
+
*/
|
|
49
|
+
export type BashExecutor = (command: string | StructuredCommandInput, cwd: string, context: AgentToolContext) => Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Executor for fetching web content
|
|
52
|
+
*
|
|
53
|
+
* @param url - URL to fetch
|
|
54
|
+
* @param prompt - Analysis prompt for the content
|
|
55
|
+
* @param context - Tool execution context
|
|
56
|
+
* @returns Analyzed/extracted content
|
|
57
|
+
*/
|
|
58
|
+
export type WebFetchExecutor = (url: string, prompt: string, context: AgentToolContext) => Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Executor for editing files
|
|
61
|
+
*
|
|
62
|
+
* @param input - Editor command input
|
|
63
|
+
* @param cwd - Current working directory for filesystem operations
|
|
64
|
+
* @param context - Tool execution context
|
|
65
|
+
* @returns A formatted operation result string
|
|
66
|
+
*/
|
|
67
|
+
export type EditorExecutor = (input: EditFileInput, cwd: string, context: AgentToolContext) => Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Executor for apply_patch operations
|
|
70
|
+
*
|
|
71
|
+
* @param input - apply_patch command payload
|
|
72
|
+
* @param cwd - Current working directory for filesystem operations
|
|
73
|
+
* @param context - Tool execution context
|
|
74
|
+
* @returns A formatted operation result string
|
|
75
|
+
*/
|
|
76
|
+
export type ApplyPatchExecutor = (input: ApplyPatchInput, cwd: string, context: AgentToolContext) => Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* Executor for invoking configured skills
|
|
79
|
+
*
|
|
80
|
+
* @param skill - Skill name to invoke
|
|
81
|
+
* @param args - Optional arguments for the skill
|
|
82
|
+
* @param context - Tool execution context
|
|
83
|
+
* @returns Skill loading/invocation result
|
|
84
|
+
*/
|
|
85
|
+
export type SkillsExecutor = (skill: string, args: string | undefined, context: AgentToolContext) => Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Executor for asking a single follow-up question with selectable options
|
|
88
|
+
*
|
|
89
|
+
* @param question - Single clarifying question for the user
|
|
90
|
+
* @param options - 2-5 selectable answer options
|
|
91
|
+
* @param context - Tool execution context
|
|
92
|
+
* @returns Executor-specific result payload
|
|
93
|
+
*/
|
|
94
|
+
export type AskQuestionExecutor = (question: string, options: string[], context: AgentToolContext) => Promise<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Skill metadata exposed by SkillsExecutor for clients/UI
|
|
97
|
+
*/
|
|
98
|
+
export interface SkillsExecutorSkillMetadata {
|
|
99
|
+
/** Normalized skill id (usually lowercased name) */
|
|
100
|
+
id: string;
|
|
101
|
+
/** Display name for the skill */
|
|
102
|
+
name: string;
|
|
103
|
+
/** Optional short description */
|
|
104
|
+
description?: string;
|
|
105
|
+
/** True when configured but intentionally disabled */
|
|
106
|
+
disabled: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A callable executor that can also expose configured skill metadata.
|
|
110
|
+
*/
|
|
111
|
+
export interface SkillsExecutorWithMetadata {
|
|
112
|
+
(skill: string, args: string | undefined, context: AgentToolContext): Promise<string>;
|
|
113
|
+
configuredSkills?: SkillsExecutorSkillMetadata[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Executor for verifying a user's response to a question
|
|
117
|
+
*
|
|
118
|
+
* @param summary - Summary of the solution ans steps taken
|
|
119
|
+
* @param verified - Boolean indicating if the solution has been verified
|
|
120
|
+
* @param context - Tool execution context
|
|
121
|
+
* @returns Executor-specific result payload
|
|
122
|
+
*/
|
|
123
|
+
export type VerifySubmitExecutor = (summary: string, verified: boolean, context: AgentToolContext) => Promise<string>;
|
|
124
|
+
/**
|
|
125
|
+
* Collection of all tool executors
|
|
126
|
+
*/
|
|
127
|
+
export interface ToolExecutors {
|
|
128
|
+
/** File reading implementation */
|
|
129
|
+
readFile?: FileReadExecutor;
|
|
130
|
+
/** Codebase search implementation */
|
|
131
|
+
search?: SearchExecutor;
|
|
132
|
+
/** Shell command execution implementation */
|
|
133
|
+
bash?: BashExecutor;
|
|
134
|
+
/** Web content fetching implementation */
|
|
135
|
+
webFetch?: WebFetchExecutor;
|
|
136
|
+
/** Filesystem editor implementation */
|
|
137
|
+
editor?: EditorExecutor;
|
|
138
|
+
/** Apply patch implementation */
|
|
139
|
+
applyPatch?: ApplyPatchExecutor;
|
|
140
|
+
/** Skill invocation implementation */
|
|
141
|
+
skills?: SkillsExecutorWithMetadata;
|
|
142
|
+
/** Follow-up question implementation */
|
|
143
|
+
askQuestion?: AskQuestionExecutor;
|
|
144
|
+
/** Final submission implementation */
|
|
145
|
+
submit?: VerifySubmitExecutor;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Names of available default tools
|
|
149
|
+
*/
|
|
150
|
+
export type DefaultToolName = "read_files" | "search_codebase" | "run_commands" | "fetch_web_content" | "apply_patch" | "editor" | "skills" | "ask_question" | "submit_and_exit";
|
|
151
|
+
/**
|
|
152
|
+
* Configuration for enabling/disabling default tools
|
|
153
|
+
*/
|
|
154
|
+
export interface DefaultToolsConfig {
|
|
155
|
+
/**
|
|
156
|
+
* Enable the read_files tool
|
|
157
|
+
* @default true
|
|
158
|
+
*/
|
|
159
|
+
enableReadFiles?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Enable the search_codebase tool
|
|
162
|
+
* @default true
|
|
163
|
+
*/
|
|
164
|
+
enableSearch?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Enable the run_commands tool
|
|
167
|
+
* @default true
|
|
168
|
+
*/
|
|
169
|
+
enableBash?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Enable the fetch_web_content tool
|
|
172
|
+
* @default true
|
|
173
|
+
*/
|
|
174
|
+
enableWebFetch?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Enable the apply_patch tool
|
|
177
|
+
* @default true
|
|
178
|
+
*/
|
|
179
|
+
enableApplyPatch?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Enable the editor tool
|
|
182
|
+
* @default true
|
|
183
|
+
*/
|
|
184
|
+
enableEditor?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Enable the skills tool
|
|
187
|
+
* @default true
|
|
188
|
+
*/
|
|
189
|
+
enableSkills?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Enable the ask_followup_question tool
|
|
192
|
+
* @default true
|
|
193
|
+
*/
|
|
194
|
+
enableAskQuestion?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Enable the submit_and_exit tool
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
enableSubmitAndExit?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Current working directory for tools that need it
|
|
202
|
+
*/
|
|
203
|
+
cwd?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Timeout for file read operations in milliseconds
|
|
206
|
+
* @default 10000
|
|
207
|
+
*/
|
|
208
|
+
fileReadTimeoutMs?: number;
|
|
209
|
+
/**
|
|
210
|
+
* Timeout for bash command execution in milliseconds
|
|
211
|
+
* @default 30000
|
|
212
|
+
*/
|
|
213
|
+
bashTimeoutMs?: number;
|
|
214
|
+
/**
|
|
215
|
+
* Timeout for web fetch operations in milliseconds
|
|
216
|
+
* @default 30000
|
|
217
|
+
*/
|
|
218
|
+
webFetchTimeoutMs?: number;
|
|
219
|
+
/**
|
|
220
|
+
* Timeout for search operations in milliseconds
|
|
221
|
+
* @default 30000
|
|
222
|
+
*/
|
|
223
|
+
searchTimeoutMs?: number;
|
|
224
|
+
/**
|
|
225
|
+
* Timeout for apply_patch operations in milliseconds
|
|
226
|
+
* @default 30000
|
|
227
|
+
*/
|
|
228
|
+
applyPatchTimeoutMs?: number;
|
|
229
|
+
/**
|
|
230
|
+
* Timeout for editor operations in milliseconds
|
|
231
|
+
* @default 30000
|
|
232
|
+
*/
|
|
233
|
+
editorTimeoutMs?: number;
|
|
234
|
+
/**
|
|
235
|
+
* Timeout for skills operations in milliseconds
|
|
236
|
+
* @default 15000
|
|
237
|
+
*/
|
|
238
|
+
skillsTimeoutMs?: number;
|
|
239
|
+
/**
|
|
240
|
+
* Timeout for submit_and_exit operations in milliseconds
|
|
241
|
+
* @default 15000
|
|
242
|
+
*/
|
|
243
|
+
submitTimeoutMs?: number;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Options for creating default tools
|
|
247
|
+
*/
|
|
248
|
+
export interface CreateDefaultToolsOptions extends DefaultToolsConfig {
|
|
249
|
+
/**
|
|
250
|
+
* Executor implementations for the tools
|
|
251
|
+
* Only tools with provided executors will be available
|
|
252
|
+
*/
|
|
253
|
+
executors: ToolExecutors;
|
|
254
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AgentHooks, BasicLogger } from "@cline/shared";
|
|
2
|
+
export interface CheckpointEntry {
|
|
3
|
+
ref: string;
|
|
4
|
+
createdAt: number;
|
|
5
|
+
runCount: number;
|
|
6
|
+
kind?: "stash" | "commit";
|
|
7
|
+
}
|
|
8
|
+
export interface CheckpointMetadata {
|
|
9
|
+
latest: CheckpointEntry;
|
|
10
|
+
history: CheckpointEntry[];
|
|
11
|
+
}
|
|
12
|
+
type CreateCheckpointHooksOptions = {
|
|
13
|
+
cwd: string;
|
|
14
|
+
sessionId: string;
|
|
15
|
+
logger?: BasicLogger;
|
|
16
|
+
readSessionMetadata: () => Promise<Record<string, unknown> | undefined>;
|
|
17
|
+
writeSessionMetadata: (metadata: Record<string, unknown>) => Promise<void> | void;
|
|
18
|
+
/**
|
|
19
|
+
* Optional custom checkpoint implementation. When provided, the built-in
|
|
20
|
+
* git stash/ref logic is skipped entirely and this function is called
|
|
21
|
+
* instead. Return `undefined` to skip writing a checkpoint for that run.
|
|
22
|
+
*/
|
|
23
|
+
createCheckpoint?: (context: {
|
|
24
|
+
cwd: string;
|
|
25
|
+
sessionId: string;
|
|
26
|
+
runCount: number;
|
|
27
|
+
}) => Promise<CheckpointEntry | undefined> | CheckpointEntry | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Starting value for the internal run counter. Use this when a session
|
|
30
|
+
* is created with initial messages (e.g. after a checkpoint restore) so
|
|
31
|
+
* that new checkpoint entries get runCount values that don't collide
|
|
32
|
+
* with entries carried over from the source session.
|
|
33
|
+
*/
|
|
34
|
+
initialRunCount?: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Deletes all private git refs under refs/cline/checkpoints/{sessionId}/ that
|
|
38
|
+
* were created by the checkpoint system to keep stash objects reachable.
|
|
39
|
+
* Errors are swallowed - if the cwd is not a git repo or the refs don't exist,
|
|
40
|
+
* the delete is a no-op.
|
|
41
|
+
*/
|
|
42
|
+
export declare function deleteCheckpointRefs(cwd: string | null | undefined, sessionId: string): Promise<void>;
|
|
43
|
+
export declare function retainCheckpointRefs(cwd: string | null | undefined, sessionId: string, checkpoints: readonly CheckpointEntry[]): Promise<void>;
|
|
44
|
+
export declare function createCheckpointHooks(options: CreateCheckpointHooksOptions): AgentHooks;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HOOKS_CONFIG_DIRECTORY_NAME } from "@cline/shared/storage";
|
|
2
|
+
import type { HookEventName } from "./subprocess";
|
|
3
|
+
export { HOOKS_CONFIG_DIRECTORY_NAME };
|
|
4
|
+
export declare function resolveHooksConfigSearchPaths(workspacePath?: string): string[];
|
|
5
|
+
export declare enum HookConfigFileName {
|
|
6
|
+
TaskStart = "TaskStart",
|
|
7
|
+
TaskResume = "TaskResume",
|
|
8
|
+
TaskCancel = "TaskCancel",
|
|
9
|
+
TaskComplete = "TaskComplete",
|
|
10
|
+
TaskError = "TaskError",
|
|
11
|
+
PreToolUse = "PreToolUse",
|
|
12
|
+
PostToolUse = "PostToolUse",
|
|
13
|
+
UserPromptSubmit = "UserPromptSubmit",
|
|
14
|
+
PreCompact = "PreCompact",
|
|
15
|
+
SessionShutdown = "SessionShutdown"
|
|
16
|
+
}
|
|
17
|
+
export declare const HOOK_CONFIG_FILE_EVENT_MAP: Readonly<Record<HookConfigFileName, HookEventName | undefined>>;
|
|
18
|
+
export declare function toHookConfigFileName(fileName: string): HookConfigFileName | undefined;
|
|
19
|
+
export interface HookConfigFileEntry {
|
|
20
|
+
fileName: HookConfigFileName;
|
|
21
|
+
hookEventName?: HookEventName;
|
|
22
|
+
path: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function listHookConfigFiles(workspacePath?: string): HookConfigFileEntry[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AgentExtension, AgentHooks } from "@cline/shared";
|
|
2
|
+
import { type BasicLogger, type WorkspaceInfo } from "@cline/shared";
|
|
3
|
+
type HookRuntimeOptions = {
|
|
4
|
+
cwd: string;
|
|
5
|
+
workspacePath: string;
|
|
6
|
+
rootSessionId?: string;
|
|
7
|
+
logger?: BasicLogger;
|
|
8
|
+
toolCallTimeoutMs?: number;
|
|
9
|
+
/** Structured git + path metadata forwarded into every hook payload. */
|
|
10
|
+
workspaceInfo?: WorkspaceInfo;
|
|
11
|
+
};
|
|
12
|
+
export declare function getWindowsPythonFallbackCommand(command: string[], platform?: NodeJS.Platform, error?: unknown): string[] | undefined;
|
|
13
|
+
export declare function createHookAuditHooks(options: {
|
|
14
|
+
rootSessionId?: string;
|
|
15
|
+
workspacePath: string;
|
|
16
|
+
workspaceInfo?: WorkspaceInfo;
|
|
17
|
+
}): AgentHooks;
|
|
18
|
+
export declare function createHookConfigFileHooks(options: HookRuntimeOptions): AgentHooks | undefined;
|
|
19
|
+
export declare function createHookConfigFileExtension(options: HookRuntimeOptions): AgentExtension | undefined;
|
|
20
|
+
export declare function mergeAgentHooks(layers: Array<AgentHooks | undefined>): AgentHooks | undefined;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createAgentHooksExtension } from "./hook-extension";
|
|
2
|
+
export { HOOK_CONFIG_FILE_EVENT_MAP, HOOKS_CONFIG_DIRECTORY_NAME, type HookConfigFileEntry, HookConfigFileName, listHookConfigFiles, resolveHooksConfigSearchPaths, toHookConfigFileName, } from "./hook-file-config";
|
|
3
|
+
export { createHookAuditHooks, createHookConfigFileExtension, createHookConfigFileHooks, mergeAgentHooks, } from "./hook-file-hooks";
|
|
4
|
+
export { createSubprocessHooks, type HookEventName, HookEventNameSchema, type HookEventPayload, HookEventPayloadSchema, parseHookEventPayload, type RunHookOptions, type RunHookResult, runHook, type SubprocessHookControl, type SubprocessHooksOptions, } from "./subprocess";
|
|
5
|
+
export { type RunSubprocessEventOptions, type RunSubprocessEventResult, runSubprocessEvent, } from "./subprocess-runner";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface RunSubprocessEventOptions {
|
|
2
|
+
command: string[];
|
|
3
|
+
cwd?: string;
|
|
4
|
+
env?: NodeJS.ProcessEnv;
|
|
5
|
+
detached?: boolean;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
onSpawn?: (event: {
|
|
8
|
+
command: string[];
|
|
9
|
+
pid?: number;
|
|
10
|
+
detached: boolean;
|
|
11
|
+
}) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface RunSubprocessEventResult {
|
|
14
|
+
exitCode: number | null;
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
parsedJson?: unknown;
|
|
18
|
+
parseError?: string;
|
|
19
|
+
timedOut?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function runSubprocessEvent(payload: unknown, options: RunSubprocessEventOptions): Promise<RunSubprocessEventResult | undefined>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type AgentAbortHookPayload, type AgentEndHookPayload, type AgentErrorHookPayload, type AgentHooks, type AgentResumeHookPayload, type AgentStartHookPayload, type HookEventName, HookEventNameSchema, type HookEventPayload, type HookEventPayloadBase, HookEventPayloadSchema, type HookSessionContextProvider, type PostToolUseData, type PreCompactData, type PreCompactHookPayload, type PreToolUseData, type PromptSubmitHookPayload, parseHookEventPayload, type SessionShutdownHookPayload, type TaskCancelData, type TaskCompleteData, type TaskResumeData, type TaskStartData, type ToolCallHookPayload, type ToolResultHookPayload, type UserPromptSubmitData, type WorkspaceInfo } from "@cline/shared";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type RunSubprocessEventResult } from "./subprocess-runner";
|
|
4
|
+
export interface HookOutput {
|
|
5
|
+
contextModification: string;
|
|
6
|
+
cancel: boolean;
|
|
7
|
+
review?: boolean;
|
|
8
|
+
errorMessage: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const HookOutputSchema: z.ZodObject<{
|
|
11
|
+
contextModification: z.ZodOptional<z.ZodString>;
|
|
12
|
+
cancel: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
review: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
errorMessage: z.ZodOptional<z.ZodString>;
|
|
15
|
+
context: z.ZodOptional<z.ZodString>;
|
|
16
|
+
overrideInput: z.ZodOptional<z.ZodUnknown>;
|
|
17
|
+
}, z.core.$loose>;
|
|
18
|
+
export { HookEventNameSchema, HookEventPayloadSchema, parseHookEventPayload };
|
|
19
|
+
export type { AgentAbortHookPayload, AgentEndHookPayload, AgentErrorHookPayload, AgentResumeHookPayload, AgentStartHookPayload, HookEventName, HookEventPayload, HookEventPayloadBase, PostToolUseData, PreCompactData, PreCompactHookPayload, PreToolUseData, PromptSubmitHookPayload, SessionShutdownHookPayload, TaskCancelData, TaskCompleteData, TaskResumeData, TaskStartData, ToolCallHookPayload, ToolResultHookPayload, UserPromptSubmitData, };
|
|
20
|
+
export interface RunHookOptions {
|
|
21
|
+
command?: string[];
|
|
22
|
+
cwd?: string;
|
|
23
|
+
env?: NodeJS.ProcessEnv;
|
|
24
|
+
detached?: boolean;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
onSpawn?: (event: {
|
|
27
|
+
command: string[];
|
|
28
|
+
pid?: number;
|
|
29
|
+
detached: boolean;
|
|
30
|
+
}) => void;
|
|
31
|
+
}
|
|
32
|
+
export type RunHookResult = RunSubprocessEventResult;
|
|
33
|
+
export declare function runHook(payload: HookEventPayload, options?: RunHookOptions): Promise<RunHookResult | undefined>;
|
|
34
|
+
export interface SubprocessHooksOptions {
|
|
35
|
+
command?: string[];
|
|
36
|
+
cwd?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Structured workspace and git metadata forwarded into every hook payload
|
|
39
|
+
* as `workspaceInfo`. Obtained from `generateWorkspaceInfo` at session
|
|
40
|
+
* startup and passed here so hook scripts can inspect branch, commit, and
|
|
41
|
+
* remote without running their own `git` commands.
|
|
42
|
+
*/
|
|
43
|
+
workspaceInfo?: WorkspaceInfo;
|
|
44
|
+
env?: NodeJS.ProcessEnv;
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
onDispatchError?: (error: Error, payload: HookEventPayload) => void;
|
|
47
|
+
onDispatch?: (event: {
|
|
48
|
+
payload: HookEventPayload;
|
|
49
|
+
result?: RunHookResult;
|
|
50
|
+
detached: boolean;
|
|
51
|
+
}) => void;
|
|
52
|
+
onSpawn?: (event: {
|
|
53
|
+
command: string[];
|
|
54
|
+
pid?: number;
|
|
55
|
+
detached: boolean;
|
|
56
|
+
}) => void;
|
|
57
|
+
sessionContext?: HookSessionContextProvider;
|
|
58
|
+
}
|
|
59
|
+
export interface SubprocessHookControl {
|
|
60
|
+
hooks: AgentHooks;
|
|
61
|
+
shutdown: (ctx: {
|
|
62
|
+
agentId: string;
|
|
63
|
+
conversationId: string;
|
|
64
|
+
parentAgentId: string | null;
|
|
65
|
+
reason?: string;
|
|
66
|
+
}) => Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export declare function createSubprocessHooks(options?: SubprocessHooksOptions): SubprocessHookControl;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HubCommandEnvelope, HubReplyEnvelope } from "@cline/shared";
|
|
2
|
+
import { type HubEndpointOverrides } from "../discovery/defaults";
|
|
3
|
+
export interface HubConnection {
|
|
4
|
+
send(envelope: HubCommandEnvelope): Promise<HubReplyEnvelope>;
|
|
5
|
+
close(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface HubCommandRequest extends Omit<HubCommandEnvelope, "version" | "clientId"> {
|
|
8
|
+
version?: HubCommandEnvelope["version"];
|
|
9
|
+
clientId?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function resolveHubUrl(overrides?: HubEndpointOverrides): Promise<string>;
|
|
12
|
+
export declare function connectToHub(url: string): Promise<HubConnection>;
|
|
13
|
+
export declare function probeHubConnection(url: string): Promise<boolean>;
|
|
14
|
+
export declare function sendHubCommand(overrides: HubEndpointOverrides, envelope: HubCommandRequest): Promise<HubReplyEnvelope>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type HubCommandEnvelope, type HubEventEnvelope, type HubReplyEnvelope } from "@cline/shared";
|
|
2
|
+
export interface HubClientOptions {
|
|
3
|
+
url: string;
|
|
4
|
+
clientId?: string;
|
|
5
|
+
clientType?: string;
|
|
6
|
+
displayName?: string;
|
|
7
|
+
workspaceRoot?: string;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
authToken?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface LocalHubResolutionOptions {
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
strategy?: "prefer-hub" | "require-hub";
|
|
14
|
+
workspaceRoot?: string;
|
|
15
|
+
cwd?: string;
|
|
16
|
+
}
|
|
17
|
+
export type HubTransportErrorCode = "hub_connect_timeout" | "hub_connect_failed" | "hub_connection_closed" | "hub_connection_not_open";
|
|
18
|
+
export declare class HubTransportError extends Error {
|
|
19
|
+
readonly code: HubTransportErrorCode;
|
|
20
|
+
readonly details?: {
|
|
21
|
+
closeCode?: number;
|
|
22
|
+
closeReason?: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
constructor(code: HubTransportErrorCode, message: string, details?: {
|
|
25
|
+
closeCode?: number;
|
|
26
|
+
closeReason?: string;
|
|
27
|
+
} | undefined);
|
|
28
|
+
}
|
|
29
|
+
export declare function isHubReconnectableTransportError(error: unknown): error is HubTransportError;
|
|
30
|
+
export declare class HubCommandError extends Error {
|
|
31
|
+
readonly command: HubCommandEnvelope["command"];
|
|
32
|
+
readonly code: string | undefined;
|
|
33
|
+
constructor(command: HubCommandEnvelope["command"], code: string | undefined, message: string);
|
|
34
|
+
}
|
|
35
|
+
export declare function isHubCommandTimeoutError(error: unknown, command?: HubCommandEnvelope["command"]): boolean;
|
|
36
|
+
export declare function rememberRecoverableLocalHubUrl(url: string, authToken?: string): string;
|
|
37
|
+
export declare class NodeHubClient {
|
|
38
|
+
private readonly options;
|
|
39
|
+
private socket;
|
|
40
|
+
private connectPromise;
|
|
41
|
+
private readonly clientId;
|
|
42
|
+
private currentUrl;
|
|
43
|
+
private recoveryPromise;
|
|
44
|
+
private readonly pendingReplies;
|
|
45
|
+
private readonly listeners;
|
|
46
|
+
private readonly subscriptionCounts;
|
|
47
|
+
private reconnectTimer;
|
|
48
|
+
private reconnectAttempt;
|
|
49
|
+
private closedByClient;
|
|
50
|
+
private lastCloseError;
|
|
51
|
+
private sawSocketClose;
|
|
52
|
+
private registered;
|
|
53
|
+
constructor(options: HubClientOptions);
|
|
54
|
+
getClientId(): string;
|
|
55
|
+
getUrl(): string;
|
|
56
|
+
connect(): Promise<void>;
|
|
57
|
+
subscribe(listener: (event: HubEventEnvelope) => void, options?: {
|
|
58
|
+
sessionId?: string;
|
|
59
|
+
}): () => void;
|
|
60
|
+
command(command: HubCommandEnvelope["command"], payload?: Record<string, unknown>, sessionId?: string, options?: {
|
|
61
|
+
timeoutMs?: number | null;
|
|
62
|
+
}): Promise<HubReplyEnvelope>;
|
|
63
|
+
private commandOnce;
|
|
64
|
+
private recoverLocalHubTransport;
|
|
65
|
+
private hasActiveSubscriptions;
|
|
66
|
+
private clearReconnectTimer;
|
|
67
|
+
private scheduleReconnect;
|
|
68
|
+
private reconnectSubscribedTransport;
|
|
69
|
+
close(): void;
|
|
70
|
+
dispose(): Promise<void>;
|
|
71
|
+
private sendFrame;
|
|
72
|
+
private sendSubscriptionFrame;
|
|
73
|
+
private adjustSubscriptionCount;
|
|
74
|
+
private subscriptionKeyForSessionId;
|
|
75
|
+
private subscriptionSessionIdFromKey;
|
|
76
|
+
private handleFrame;
|
|
77
|
+
}
|
|
78
|
+
export declare function normalizeHubWebSocketUrl(url: string): string;
|
|
79
|
+
export declare function verifyHubConnection(url: string, options?: Pick<HubClientOptions, "workspaceRoot" | "cwd" | "authToken">): Promise<boolean>;
|
|
80
|
+
export declare function resolveCompatibleLocalHubUrl(options?: LocalHubResolutionOptions): Promise<string | undefined>;
|
|
81
|
+
export declare function ensureCompatibleLocalHubUrl(options?: LocalHubResolutionOptions): Promise<string | undefined>;
|
|
82
|
+
export declare function requestHubShutdown(url: string, authToken?: string): Promise<boolean>;
|
|
83
|
+
export declare function stopLocalHubServerGracefully(): Promise<boolean>;
|
|
84
|
+
export declare function restartLocalHubIfIdleAfterStartupTimeout(options: {
|
|
85
|
+
url: string;
|
|
86
|
+
workspaceRoot?: string;
|
|
87
|
+
cwd?: string;
|
|
88
|
+
}): Promise<string | undefined>;
|