@clinebot/core 0.0.0
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 +88 -0
- package/dist/account/cline-account-service.d.ts +34 -0
- package/dist/account/index.d.ts +3 -0
- package/dist/account/rpc.d.ts +38 -0
- package/dist/account/types.d.ts +74 -0
- package/dist/agents/agent-config-loader.d.ts +18 -0
- package/dist/agents/agent-config-parser.d.ts +25 -0
- package/dist/agents/hooks-config-loader.d.ts +23 -0
- package/dist/agents/index.d.ts +11 -0
- package/dist/agents/plugin-config-loader.d.ts +22 -0
- package/dist/agents/plugin-loader.d.ts +9 -0
- package/dist/agents/plugin-sandbox.d.ts +12 -0
- package/dist/agents/unified-config-file-watcher.d.ts +77 -0
- package/dist/agents/user-instruction-config-loader.d.ts +63 -0
- package/dist/auth/client.d.ts +11 -0
- package/dist/auth/cline.d.ts +41 -0
- package/dist/auth/codex.d.ts +39 -0
- package/dist/auth/oca.d.ts +22 -0
- package/dist/auth/server.d.ts +22 -0
- package/dist/auth/types.d.ts +72 -0
- package/dist/auth/utils.d.ts +32 -0
- package/dist/chat/chat-schema.d.ts +145 -0
- package/dist/default-tools/constants.d.ts +23 -0
- package/dist/default-tools/definitions.d.ts +96 -0
- package/dist/default-tools/executors/apply-patch-parser.d.ts +68 -0
- package/dist/default-tools/executors/apply-patch.d.ts +26 -0
- package/dist/default-tools/executors/bash.d.ts +49 -0
- package/dist/default-tools/executors/editor.d.ts +31 -0
- package/dist/default-tools/executors/file-read.d.ts +40 -0
- package/dist/default-tools/executors/index.d.ts +44 -0
- package/dist/default-tools/executors/search.d.ts +50 -0
- package/dist/default-tools/executors/web-fetch.d.ts +58 -0
- package/dist/default-tools/index.d.ts +57 -0
- package/dist/default-tools/presets.d.ts +124 -0
- package/dist/default-tools/schemas.d.ts +121 -0
- package/dist/default-tools/types.d.ts +237 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +220 -0
- package/dist/input/file-indexer.d.ts +5 -0
- package/dist/input/index.d.ts +4 -0
- package/dist/input/mention-enricher.d.ts +12 -0
- package/dist/mcp/config-loader.d.ts +15 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/manager.d.ts +24 -0
- package/dist/mcp/types.d.ts +66 -0
- package/dist/runtime/hook-file-hooks.d.ts +18 -0
- package/dist/runtime/rules.d.ts +5 -0
- package/dist/runtime/runtime-builder.d.ts +5 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts +19 -0
- package/dist/runtime/session-runtime.d.ts +36 -0
- package/dist/runtime/tool-approval.d.ts +9 -0
- package/dist/runtime/workflows.d.ts +13 -0
- package/dist/server/index.d.ts +47 -0
- package/dist/server/index.js +641 -0
- package/dist/session/default-session-manager.d.ts +77 -0
- package/dist/session/rpc-session-service.d.ts +12 -0
- package/dist/session/runtime-oauth-token-manager.d.ts +28 -0
- package/dist/session/session-artifacts.d.ts +19 -0
- package/dist/session/session-graph.d.ts +15 -0
- package/dist/session/session-host.d.ts +21 -0
- package/dist/session/session-manager.d.ts +50 -0
- package/dist/session/session-manifest.d.ts +30 -0
- package/dist/session/session-service.d.ts +113 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts +30 -0
- package/dist/session/unified-session-persistence-service.d.ts +93 -0
- package/dist/session/workspace-manager.d.ts +28 -0
- package/dist/session/workspace-manifest.d.ts +25 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts +13 -0
- package/dist/storage/provider-settings-manager.d.ts +20 -0
- package/dist/storage/sqlite-session-store.d.ts +29 -0
- package/dist/storage/sqlite-team-store.d.ts +31 -0
- package/dist/storage/team-store.d.ts +2 -0
- package/dist/team/index.d.ts +1 -0
- package/dist/team/projections.d.ts +8 -0
- package/dist/types/common.d.ts +10 -0
- package/dist/types/config.d.ts +37 -0
- package/dist/types/events.d.ts +54 -0
- package/dist/types/provider-settings.d.ts +20 -0
- package/dist/types/sessions.d.ts +9 -0
- package/dist/types/storage.d.ts +37 -0
- package/dist/types/workspace.d.ts +7 -0
- package/dist/types.d.ts +26 -0
- package/package.json +63 -0
- package/src/account/cline-account-service.test.ts +101 -0
- package/src/account/cline-account-service.ts +267 -0
- package/src/account/index.ts +20 -0
- package/src/account/rpc.test.ts +62 -0
- package/src/account/rpc.ts +172 -0
- package/src/account/types.ts +80 -0
- package/src/agents/agent-config-loader.test.ts +234 -0
- package/src/agents/agent-config-loader.ts +107 -0
- package/src/agents/agent-config-parser.ts +191 -0
- package/src/agents/hooks-config-loader.ts +97 -0
- package/src/agents/index.ts +84 -0
- package/src/agents/plugin-config-loader.test.ts +91 -0
- package/src/agents/plugin-config-loader.ts +160 -0
- package/src/agents/plugin-loader.test.ts +102 -0
- package/src/agents/plugin-loader.ts +105 -0
- package/src/agents/plugin-sandbox.test.ts +120 -0
- package/src/agents/plugin-sandbox.ts +471 -0
- package/src/agents/unified-config-file-watcher.test.ts +196 -0
- package/src/agents/unified-config-file-watcher.ts +483 -0
- package/src/agents/user-instruction-config-loader.test.ts +158 -0
- package/src/agents/user-instruction-config-loader.ts +438 -0
- package/src/auth/client.test.ts +40 -0
- package/src/auth/client.ts +25 -0
- package/src/auth/cline.test.ts +130 -0
- package/src/auth/cline.ts +414 -0
- package/src/auth/codex.test.ts +170 -0
- package/src/auth/codex.ts +466 -0
- package/src/auth/oca.test.ts +215 -0
- package/src/auth/oca.ts +546 -0
- package/src/auth/server.ts +216 -0
- package/src/auth/types.ts +78 -0
- package/src/auth/utils.test.ts +128 -0
- package/src/auth/utils.ts +247 -0
- package/src/chat/chat-schema.ts +82 -0
- package/src/default-tools/constants.ts +35 -0
- package/src/default-tools/definitions.test.ts +233 -0
- package/src/default-tools/definitions.ts +632 -0
- package/src/default-tools/executors/apply-patch-parser.ts +520 -0
- package/src/default-tools/executors/apply-patch.ts +359 -0
- package/src/default-tools/executors/bash.ts +205 -0
- package/src/default-tools/executors/editor.ts +231 -0
- package/src/default-tools/executors/file-read.test.ts +25 -0
- package/src/default-tools/executors/file-read.ts +94 -0
- package/src/default-tools/executors/index.ts +75 -0
- package/src/default-tools/executors/search.ts +278 -0
- package/src/default-tools/executors/web-fetch.ts +259 -0
- package/src/default-tools/index.ts +161 -0
- package/src/default-tools/presets.test.ts +63 -0
- package/src/default-tools/presets.ts +168 -0
- package/src/default-tools/schemas.ts +228 -0
- package/src/default-tools/types.ts +324 -0
- package/src/index.ts +119 -0
- package/src/input/file-indexer.d.ts +11 -0
- package/src/input/file-indexer.test.ts +87 -0
- package/src/input/file-indexer.ts +280 -0
- package/src/input/index.ts +7 -0
- package/src/input/mention-enricher.test.ts +82 -0
- package/src/input/mention-enricher.ts +119 -0
- package/src/mcp/config-loader.test.ts +238 -0
- package/src/mcp/config-loader.ts +219 -0
- package/src/mcp/index.ts +26 -0
- package/src/mcp/manager.test.ts +106 -0
- package/src/mcp/manager.ts +262 -0
- package/src/mcp/types.ts +88 -0
- package/src/runtime/hook-file-hooks.test.ts +106 -0
- package/src/runtime/hook-file-hooks.ts +736 -0
- package/src/runtime/index.ts +27 -0
- package/src/runtime/rules.ts +34 -0
- package/src/runtime/runtime-builder.team-persistence.test.ts +203 -0
- package/src/runtime/runtime-builder.test.ts +215 -0
- package/src/runtime/runtime-builder.ts +515 -0
- package/src/runtime/runtime-parity.test.ts +132 -0
- package/src/runtime/sandbox/subprocess-sandbox.ts +207 -0
- package/src/runtime/session-runtime.ts +44 -0
- package/src/runtime/tool-approval.ts +104 -0
- package/src/runtime/workflows.test.ts +119 -0
- package/src/runtime/workflows.ts +54 -0
- package/src/server/index.ts +282 -0
- package/src/session/default-session-manager.e2e.test.ts +354 -0
- package/src/session/default-session-manager.test.ts +816 -0
- package/src/session/default-session-manager.ts +1286 -0
- package/src/session/index.ts +37 -0
- package/src/session/rpc-session-service.ts +189 -0
- package/src/session/runtime-oauth-token-manager.test.ts +137 -0
- package/src/session/runtime-oauth-token-manager.ts +265 -0
- package/src/session/session-artifacts.ts +106 -0
- package/src/session/session-graph.ts +90 -0
- package/src/session/session-host.ts +190 -0
- package/src/session/session-manager.ts +56 -0
- package/src/session/session-manifest.ts +29 -0
- package/src/session/session-service.team-persistence.test.ts +48 -0
- package/src/session/session-service.ts +610 -0
- package/src/session/sqlite-rpc-session-backend.ts +303 -0
- package/src/session/unified-session-persistence-service.ts +781 -0
- package/src/session/workspace-manager.ts +98 -0
- package/src/session/workspace-manifest.ts +100 -0
- package/src/storage/artifact-store.ts +1 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/provider-settings-legacy-migration.test.ts +175 -0
- package/src/storage/provider-settings-legacy-migration.ts +637 -0
- package/src/storage/provider-settings-manager.test.ts +111 -0
- package/src/storage/provider-settings-manager.ts +129 -0
- package/src/storage/session-store.ts +1 -0
- package/src/storage/sqlite-session-store.ts +270 -0
- package/src/storage/sqlite-team-store.ts +443 -0
- package/src/storage/team-store.ts +5 -0
- package/src/team/index.ts +4 -0
- package/src/team/projections.ts +285 -0
- package/src/types/common.ts +14 -0
- package/src/types/config.ts +64 -0
- package/src/types/events.ts +46 -0
- package/src/types/index.ts +24 -0
- package/src/types/provider-settings.ts +43 -0
- package/src/types/sessions.ts +16 -0
- package/src/types/storage.ts +64 -0
- package/src/types/workspace.ts +7 -0
- package/src/types.ts +127 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export interface OAuthPrompt {
|
|
2
|
+
message: string;
|
|
3
|
+
defaultValue?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface OAuthCredentials {
|
|
6
|
+
access: string;
|
|
7
|
+
refresh: string;
|
|
8
|
+
/**
|
|
9
|
+
* Expiration timestamp in milliseconds since epoch.
|
|
10
|
+
*/
|
|
11
|
+
expires: number;
|
|
12
|
+
/**
|
|
13
|
+
* Optional provider-specific account identifier.
|
|
14
|
+
*/
|
|
15
|
+
accountId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Optional email for display/telemetry.
|
|
18
|
+
*/
|
|
19
|
+
email?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Provider-specific metadata (user info, provider hint, etc).
|
|
22
|
+
*/
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export interface OAuthLoginCallbacks {
|
|
26
|
+
onAuth: (info: {
|
|
27
|
+
url: string;
|
|
28
|
+
instructions?: string;
|
|
29
|
+
}) => void;
|
|
30
|
+
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
|
|
31
|
+
onProgress?: (message: string) => void;
|
|
32
|
+
onManualCodeInput?: () => Promise<string>;
|
|
33
|
+
}
|
|
34
|
+
export interface OAuthProviderInterface {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
usesCallbackServer: boolean;
|
|
38
|
+
login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials>;
|
|
39
|
+
refreshToken(credentials: OAuthCredentials): Promise<OAuthCredentials>;
|
|
40
|
+
getApiKey(credentials: OAuthCredentials): string;
|
|
41
|
+
}
|
|
42
|
+
export type OcaMode = "internal" | "external";
|
|
43
|
+
export interface OcaOAuthEnvironmentConfig {
|
|
44
|
+
clientId: string;
|
|
45
|
+
idcsUrl: string;
|
|
46
|
+
scopes: string;
|
|
47
|
+
baseUrl: string;
|
|
48
|
+
}
|
|
49
|
+
export interface OcaOAuthConfig {
|
|
50
|
+
internal: OcaOAuthEnvironmentConfig;
|
|
51
|
+
external: OcaOAuthEnvironmentConfig;
|
|
52
|
+
}
|
|
53
|
+
export interface OcaClientMetadata {
|
|
54
|
+
client?: string;
|
|
55
|
+
clientVersion?: string;
|
|
56
|
+
clientIde?: string;
|
|
57
|
+
clientIdeVersion?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface OcaOAuthProviderOptions {
|
|
60
|
+
config?: Partial<OcaOAuthConfig>;
|
|
61
|
+
mode?: OcaMode | (() => OcaMode);
|
|
62
|
+
callbackPath?: string;
|
|
63
|
+
callbackPorts?: number[];
|
|
64
|
+
requestTimeoutMs?: number;
|
|
65
|
+
refreshBufferMs?: number;
|
|
66
|
+
retryableTokenGraceMs?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface OcaTokenResolution {
|
|
69
|
+
forceRefresh?: boolean;
|
|
70
|
+
refreshBufferMs?: number;
|
|
71
|
+
retryableTokenGraceMs?: number;
|
|
72
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { OAuthCallbackPayload } from "./server.js";
|
|
2
|
+
import type { OAuthCredentials } from "./types.js";
|
|
3
|
+
export declare function getProofKey(): Promise<{
|
|
4
|
+
verifier: string;
|
|
5
|
+
challenge: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function normalizeBaseUrl(value: string): string;
|
|
8
|
+
export declare function resolveUrl(baseUrl: string, path: string): string;
|
|
9
|
+
export type ParsedAuthorizationInput = {
|
|
10
|
+
code?: string;
|
|
11
|
+
state?: string;
|
|
12
|
+
provider?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ParseAuthorizationInputOptions = {
|
|
15
|
+
includeProvider?: boolean;
|
|
16
|
+
allowHashCodeState?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function parseAuthorizationInput(input: string, options?: ParseAuthorizationInputOptions): ParsedAuthorizationInput;
|
|
19
|
+
export declare function decodeJwtPayload(token?: string): Record<string, unknown> | null;
|
|
20
|
+
export declare function parseOAuthError(text: string): {
|
|
21
|
+
code?: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function isCredentialLikelyExpired(credentials: Pick<OAuthCredentials, "expires">, refreshBufferMs: number): boolean;
|
|
25
|
+
export declare function resolveAuthorizationCodeInput(input: {
|
|
26
|
+
waitForCallback: () => Promise<OAuthCallbackPayload | null>;
|
|
27
|
+
cancelWait: () => void;
|
|
28
|
+
onManualCodeInput?: () => Promise<string>;
|
|
29
|
+
parseOptions?: ParseAuthorizationInputOptions;
|
|
30
|
+
}): Promise<ParsedAuthorizationInput & {
|
|
31
|
+
error?: string;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ChatSessionConfigSchema: z.ZodObject<{
|
|
3
|
+
workspaceRoot: z.ZodString;
|
|
4
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
5
|
+
provider: z.ZodString;
|
|
6
|
+
model: z.ZodString;
|
|
7
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
8
|
+
act: "act";
|
|
9
|
+
plan: "plan";
|
|
10
|
+
}>>;
|
|
11
|
+
apiKey: z.ZodString;
|
|
12
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
13
|
+
rules: z.ZodOptional<z.ZodString>;
|
|
14
|
+
maxIterations: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
enableTools: z.ZodBoolean;
|
|
16
|
+
enableSpawn: z.ZodBoolean;
|
|
17
|
+
enableTeams: z.ZodBoolean;
|
|
18
|
+
autoApproveTools: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
teamName: z.ZodString;
|
|
20
|
+
missionStepInterval: z.ZodNumber;
|
|
21
|
+
missionTimeIntervalMs: z.ZodNumber;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const ChatSessionStatusSchema: z.ZodEnum<{
|
|
24
|
+
error: "error";
|
|
25
|
+
idle: "idle";
|
|
26
|
+
starting: "starting";
|
|
27
|
+
running: "running";
|
|
28
|
+
stopping: "stopping";
|
|
29
|
+
completed: "completed";
|
|
30
|
+
cancelled: "cancelled";
|
|
31
|
+
failed: "failed";
|
|
32
|
+
}>;
|
|
33
|
+
export declare const ChatMessageRoleSchema: z.ZodEnum<{
|
|
34
|
+
error: "error";
|
|
35
|
+
user: "user";
|
|
36
|
+
assistant: "assistant";
|
|
37
|
+
tool: "tool";
|
|
38
|
+
system: "system";
|
|
39
|
+
status: "status";
|
|
40
|
+
}>;
|
|
41
|
+
export declare const ChatMessageSchema: z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
44
|
+
role: z.ZodEnum<{
|
|
45
|
+
error: "error";
|
|
46
|
+
user: "user";
|
|
47
|
+
assistant: "assistant";
|
|
48
|
+
tool: "tool";
|
|
49
|
+
system: "system";
|
|
50
|
+
status: "status";
|
|
51
|
+
}>;
|
|
52
|
+
content: z.ZodString;
|
|
53
|
+
createdAt: z.ZodNumber;
|
|
54
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
55
|
+
stream: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
stdout: "stdout";
|
|
57
|
+
stderr: "stderr";
|
|
58
|
+
}>>;
|
|
59
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
60
|
+
iteration: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
hookEventName: z.ZodOptional<z.ZodString>;
|
|
64
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export declare const ChatSummarySchema: z.ZodObject<{
|
|
69
|
+
toolCalls: z.ZodNumber;
|
|
70
|
+
tokensIn: z.ZodNumber;
|
|
71
|
+
tokensOut: z.ZodNumber;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export declare const ChatViewStateSchema: z.ZodObject<{
|
|
74
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
75
|
+
status: z.ZodEnum<{
|
|
76
|
+
error: "error";
|
|
77
|
+
idle: "idle";
|
|
78
|
+
starting: "starting";
|
|
79
|
+
running: "running";
|
|
80
|
+
stopping: "stopping";
|
|
81
|
+
completed: "completed";
|
|
82
|
+
cancelled: "cancelled";
|
|
83
|
+
failed: "failed";
|
|
84
|
+
}>;
|
|
85
|
+
config: z.ZodObject<{
|
|
86
|
+
workspaceRoot: z.ZodString;
|
|
87
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
88
|
+
provider: z.ZodString;
|
|
89
|
+
model: z.ZodString;
|
|
90
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
91
|
+
act: "act";
|
|
92
|
+
plan: "plan";
|
|
93
|
+
}>>;
|
|
94
|
+
apiKey: z.ZodString;
|
|
95
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
96
|
+
rules: z.ZodOptional<z.ZodString>;
|
|
97
|
+
maxIterations: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
enableTools: z.ZodBoolean;
|
|
99
|
+
enableSpawn: z.ZodBoolean;
|
|
100
|
+
enableTeams: z.ZodBoolean;
|
|
101
|
+
autoApproveTools: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
teamName: z.ZodString;
|
|
103
|
+
missionStepInterval: z.ZodNumber;
|
|
104
|
+
missionTimeIntervalMs: z.ZodNumber;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
107
|
+
id: z.ZodString;
|
|
108
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
109
|
+
role: z.ZodEnum<{
|
|
110
|
+
error: "error";
|
|
111
|
+
user: "user";
|
|
112
|
+
assistant: "assistant";
|
|
113
|
+
tool: "tool";
|
|
114
|
+
system: "system";
|
|
115
|
+
status: "status";
|
|
116
|
+
}>;
|
|
117
|
+
content: z.ZodString;
|
|
118
|
+
createdAt: z.ZodNumber;
|
|
119
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
stream: z.ZodOptional<z.ZodEnum<{
|
|
121
|
+
stdout: "stdout";
|
|
122
|
+
stderr: "stderr";
|
|
123
|
+
}>>;
|
|
124
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
125
|
+
iteration: z.ZodOptional<z.ZodNumber>;
|
|
126
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
127
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
128
|
+
hookEventName: z.ZodOptional<z.ZodString>;
|
|
129
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
}, z.core.$strip>>;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
rawTranscript: z.ZodString;
|
|
134
|
+
error: z.ZodNullable<z.ZodString>;
|
|
135
|
+
summary: z.ZodObject<{
|
|
136
|
+
toolCalls: z.ZodNumber;
|
|
137
|
+
tokensIn: z.ZodNumber;
|
|
138
|
+
tokensOut: z.ZodNumber;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
export type ChatSessionConfig = z.infer<typeof ChatSessionConfigSchema>;
|
|
142
|
+
export type ChatSessionStatus = z.infer<typeof ChatSessionStatusSchema>;
|
|
143
|
+
export type ChatMessage = z.infer<typeof ChatMessageSchema>;
|
|
144
|
+
export type ChatSummary = z.infer<typeof ChatSummarySchema>;
|
|
145
|
+
export type ChatViewState = z.infer<typeof ChatViewStateSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for Default Tools
|
|
3
|
+
*
|
|
4
|
+
* Tool name constants and utility arrays.
|
|
5
|
+
*/
|
|
6
|
+
import type { DefaultToolName } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Constants for default tool names
|
|
9
|
+
*/
|
|
10
|
+
export declare const DefaultToolNames: {
|
|
11
|
+
readonly READ_FILES: "read_files";
|
|
12
|
+
readonly SEARCH_CODEBASE: "search_codebase";
|
|
13
|
+
readonly RUN_COMMANDS: "run_commands";
|
|
14
|
+
readonly FETCH_WEB_CONTENT: "fetch_web_content";
|
|
15
|
+
readonly APPLY_PATCH: "apply_patch";
|
|
16
|
+
readonly EDITOR: "editor";
|
|
17
|
+
readonly SKILLS: "skills";
|
|
18
|
+
readonly ASK: "ask_question";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Array of all default tool names
|
|
22
|
+
*/
|
|
23
|
+
export declare const ALL_DEFAULT_TOOL_NAMES: DefaultToolName[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Tool Definitions
|
|
3
|
+
*
|
|
4
|
+
* Factory functions for creating the default tools.
|
|
5
|
+
*/
|
|
6
|
+
import { type Tool } from "@clinebot/agents";
|
|
7
|
+
import { type ApplyPatchInput, type AskQuestionInput, type EditFileInput, type FetchWebContentInput, type ReadFilesInput, type RunCommandsInput, type SearchCodebaseInput, type SkillsInput } from "./schemas.js";
|
|
8
|
+
import type { ApplyPatchExecutor, AskQuestionExecutor, BashExecutor, CreateDefaultToolsOptions, DefaultToolsConfig, EditorExecutor, FileReadExecutor, SearchExecutor, SkillsExecutor, ToolOperationResult, WebFetchExecutor } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Create the read_files tool
|
|
11
|
+
*
|
|
12
|
+
* Reads the content of one or more files from the filesystem.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createReadFilesTool(executor: FileReadExecutor, config?: Pick<DefaultToolsConfig, "fileReadTimeoutMs">): Tool<ReadFilesInput, ToolOperationResult[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Create the search_codebase tool
|
|
17
|
+
*
|
|
18
|
+
* Performs regex pattern searches across the codebase.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createSearchTool(executor: SearchExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "searchTimeoutMs">): Tool<SearchCodebaseInput, ToolOperationResult[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Create the run_commands tool
|
|
23
|
+
*
|
|
24
|
+
* Executes shell commands in the project directory.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createBashTool(executor: BashExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "bashTimeoutMs">): Tool<RunCommandsInput, ToolOperationResult[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Create the fetch_web_content tool
|
|
29
|
+
*
|
|
30
|
+
* Fetches content from URLs and analyzes them using provided prompts.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createWebFetchTool(executor: WebFetchExecutor, config?: Pick<DefaultToolsConfig, "webFetchTimeoutMs">): Tool<FetchWebContentInput, ToolOperationResult[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Create the apply_patch tool
|
|
35
|
+
*
|
|
36
|
+
* Applies the legacy Cline patch format to one or more files.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createApplyPatchTool(executor: ApplyPatchExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "applyPatchTimeoutMs">): Tool<ApplyPatchInput, ToolOperationResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Create the editor tool
|
|
41
|
+
*
|
|
42
|
+
* Supports controlled filesystem edits with create, replace, and insert commands.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createEditorTool(executor: EditorExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "editorTimeoutMs">): Tool<EditFileInput, ToolOperationResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Create the skills tool
|
|
47
|
+
*
|
|
48
|
+
* Invokes a configured skill by name and optional arguments.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createSkillsTool(executor: SkillsExecutor, config?: Pick<DefaultToolsConfig, "skillsTimeoutMs">): Tool<SkillsInput, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Create the ask_question tool
|
|
53
|
+
*
|
|
54
|
+
* Asks the user a single clarifying question with 2-5 selectable options.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createAskQuestionTool(executor: AskQuestionExecutor, config?: Pick<DefaultToolsConfig, "askQuestionTimeoutMs">): Tool<AskQuestionInput, string>;
|
|
57
|
+
/**
|
|
58
|
+
* Create a set of default tools for an agent
|
|
59
|
+
*
|
|
60
|
+
* This function creates the default tools based on the provided configuration
|
|
61
|
+
* and executors. Only tools that are enabled AND have an executor provided
|
|
62
|
+
* will be included in the returned array.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { Agent } from "@clinebot/agents"
|
|
67
|
+
* import { createDefaultTools } from "@clinebot/core/server"
|
|
68
|
+
* import * as fs from "fs/promises"
|
|
69
|
+
* import { exec } from "child_process"
|
|
70
|
+
*
|
|
71
|
+
* const tools = createDefaultTools({
|
|
72
|
+
* executors: {
|
|
73
|
+
* readFile: async (path) => fs.readFile(path, "utf-8"),
|
|
74
|
+
* bash: async (cmd, cwd) => {
|
|
75
|
+
* return new Promise((resolve, reject) => {
|
|
76
|
+
* exec(cmd, { cwd }, (err, stdout, stderr) => {
|
|
77
|
+
* if (err) reject(new Error(stderr || err.message))
|
|
78
|
+
* else resolve(stdout)
|
|
79
|
+
* })
|
|
80
|
+
* })
|
|
81
|
+
* },
|
|
82
|
+
* },
|
|
83
|
+
* enableReadFiles: true,
|
|
84
|
+
* enableBash: true,
|
|
85
|
+
* enableSearch: false, // Disabled
|
|
86
|
+
* enableWebFetch: false, // Disabled
|
|
87
|
+
* cwd: "/path/to/project",
|
|
88
|
+
* })
|
|
89
|
+
*
|
|
90
|
+
* const agent = new Agent({
|
|
91
|
+
* // ... provider config
|
|
92
|
+
* tools,
|
|
93
|
+
* })
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function createDefaultTools(options: CreateDefaultToolsOptions): Tool[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply Patch parser and patch model types.
|
|
3
|
+
*
|
|
4
|
+
* This parser supports the Cline apply_patch format used by the legacy runtime.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PATCH_MARKERS: {
|
|
7
|
+
readonly BEGIN: "*** Begin Patch";
|
|
8
|
+
readonly END: "*** End Patch";
|
|
9
|
+
readonly ADD: "*** Add File: ";
|
|
10
|
+
readonly UPDATE: "*** Update File: ";
|
|
11
|
+
readonly DELETE: "*** Delete File: ";
|
|
12
|
+
readonly MOVE: "*** Move to: ";
|
|
13
|
+
readonly SECTION: "@@";
|
|
14
|
+
readonly END_FILE: "*** End of File";
|
|
15
|
+
};
|
|
16
|
+
export declare const BASH_WRAPPERS: readonly ["%%bash", "apply_patch", "EOF", "```"];
|
|
17
|
+
export declare enum PatchActionType {
|
|
18
|
+
ADD = "add",
|
|
19
|
+
DELETE = "delete",
|
|
20
|
+
UPDATE = "update"
|
|
21
|
+
}
|
|
22
|
+
export interface PatchChunk {
|
|
23
|
+
origIndex: number;
|
|
24
|
+
delLines: string[];
|
|
25
|
+
insLines: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface PatchAction {
|
|
28
|
+
type: PatchActionType;
|
|
29
|
+
newFile?: string;
|
|
30
|
+
chunks: PatchChunk[];
|
|
31
|
+
movePath?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PatchWarning {
|
|
34
|
+
path: string;
|
|
35
|
+
chunkIndex?: number;
|
|
36
|
+
message: string;
|
|
37
|
+
context?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface Patch {
|
|
40
|
+
actions: Record<string, PatchAction>;
|
|
41
|
+
warnings?: PatchWarning[];
|
|
42
|
+
}
|
|
43
|
+
export declare class DiffError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
export declare class PatchParser {
|
|
47
|
+
private readonly lines;
|
|
48
|
+
private readonly currentFiles;
|
|
49
|
+
private patch;
|
|
50
|
+
private index;
|
|
51
|
+
private fuzz;
|
|
52
|
+
private currentPath?;
|
|
53
|
+
constructor(lines: string[], currentFiles: Record<string, string>);
|
|
54
|
+
parse(): {
|
|
55
|
+
patch: Patch;
|
|
56
|
+
fuzz: number;
|
|
57
|
+
};
|
|
58
|
+
private addWarning;
|
|
59
|
+
private skipBeginSentinel;
|
|
60
|
+
private hasMoreLines;
|
|
61
|
+
private isEndMarker;
|
|
62
|
+
private parseNextAction;
|
|
63
|
+
private checkDuplicate;
|
|
64
|
+
private parseUpdate;
|
|
65
|
+
private parseUpdateFile;
|
|
66
|
+
private parseDelete;
|
|
67
|
+
private parseAdd;
|
|
68
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply Patch Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for the legacy apply_patch format.
|
|
5
|
+
*/
|
|
6
|
+
import type { ApplyPatchExecutor } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the apply_patch executor
|
|
9
|
+
*/
|
|
10
|
+
export interface ApplyPatchExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* File encoding used for read/write operations
|
|
13
|
+
* @default "utf-8"
|
|
14
|
+
*/
|
|
15
|
+
encoding?: BufferEncoding;
|
|
16
|
+
/**
|
|
17
|
+
* Restrict relative-path file operations to paths inside cwd.
|
|
18
|
+
* Absolute paths are always accepted as-is.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
restrictToCwd?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create an apply_patch executor using Node.js fs module.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createApplyPatchExecutor(options?: ApplyPatchExecutorOptions): ApplyPatchExecutor;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bash Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for running shell commands using Node.js spawn.
|
|
5
|
+
*/
|
|
6
|
+
import type { BashExecutor } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the bash executor
|
|
9
|
+
*/
|
|
10
|
+
export interface BashExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Shell to use for execution
|
|
13
|
+
* @default "/bin/bash" on Unix, "cmd.exe" on Windows
|
|
14
|
+
*/
|
|
15
|
+
shell?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Timeout for command execution in milliseconds
|
|
18
|
+
* @default 30000 (30 seconds)
|
|
19
|
+
*/
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum output size in bytes
|
|
23
|
+
* @default 1_000_000 (1MB)
|
|
24
|
+
*/
|
|
25
|
+
maxOutputBytes?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Environment variables to add/override
|
|
28
|
+
*/
|
|
29
|
+
env?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to combine stdout and stderr
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
combineOutput?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a bash executor using Node.js spawn
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const bash = createBashExecutor({
|
|
42
|
+
* timeoutMs: 60000, // 1 minute timeout
|
|
43
|
+
* shell: "/bin/zsh",
|
|
44
|
+
* })
|
|
45
|
+
*
|
|
46
|
+
* const output = await bash("ls -la", "/path/to/project", context)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function createBashExecutor(options?: BashExecutorOptions): BashExecutor;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for filesystem editing operations.
|
|
5
|
+
*/
|
|
6
|
+
import type { EditorExecutor } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the editor executor
|
|
9
|
+
*/
|
|
10
|
+
export interface EditorExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* File encoding used for read/write operations
|
|
13
|
+
* @default "utf-8"
|
|
14
|
+
*/
|
|
15
|
+
encoding?: BufferEncoding;
|
|
16
|
+
/**
|
|
17
|
+
* Restrict relative-path file operations to paths inside cwd.
|
|
18
|
+
* Absolute paths are always accepted as-is.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
restrictToCwd?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum number of diff lines in str_replace output
|
|
24
|
+
* @default 200
|
|
25
|
+
*/
|
|
26
|
+
maxDiffLines?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create an editor executor using Node.js fs module
|
|
30
|
+
*/
|
|
31
|
+
export declare function createEditorExecutor(options?: EditorExecutorOptions): EditorExecutor;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Read Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for reading files using Node.js fs module.
|
|
5
|
+
*/
|
|
6
|
+
import type { FileReadExecutor } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the file read executor
|
|
9
|
+
*/
|
|
10
|
+
export interface FileReadExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Maximum file size to read in bytes
|
|
13
|
+
* @default 10_000_000 (10MB)
|
|
14
|
+
*/
|
|
15
|
+
maxFileSizeBytes?: number;
|
|
16
|
+
/**
|
|
17
|
+
* File encoding
|
|
18
|
+
* @default "utf-8"
|
|
19
|
+
*/
|
|
20
|
+
encoding?: BufferEncoding;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to include line numbers in output
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
includeLineNumbers?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a file read executor using Node.js fs module
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const readFile = createFileReadExecutor({
|
|
33
|
+
* maxFileSizeBytes: 5_000_000, // 5MB limit
|
|
34
|
+
* includeLineNumbers: true,
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const content = await readFile("/path/to/file.ts", context)
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createFileReadExecutor(options?: FileReadExecutorOptions): FileReadExecutor;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Executor Implementations
|
|
3
|
+
*
|
|
4
|
+
* This module provides ready-to-use implementations of the tool executors
|
|
5
|
+
* using Node.js built-in modules. These can be used directly or as references
|
|
6
|
+
* for custom implementations.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolExecutors } from "../types.js";
|
|
9
|
+
export { type ApplyPatchExecutorOptions, createApplyPatchExecutor, } from "./apply-patch.js";
|
|
10
|
+
export { type BashExecutorOptions, createBashExecutor } from "./bash.js";
|
|
11
|
+
export { createEditorExecutor, type EditorExecutorOptions } from "./editor.js";
|
|
12
|
+
export { createFileReadExecutor, type FileReadExecutorOptions, } from "./file-read.js";
|
|
13
|
+
export { createSearchExecutor, type SearchExecutorOptions } from "./search.js";
|
|
14
|
+
export { createWebFetchExecutor, type WebFetchExecutorOptions, } from "./web-fetch.js";
|
|
15
|
+
/**
|
|
16
|
+
* Options for creating default executors
|
|
17
|
+
*/
|
|
18
|
+
export interface DefaultExecutorsOptions {
|
|
19
|
+
fileRead?: import("./file-read.js").FileReadExecutorOptions;
|
|
20
|
+
search?: import("./search.js").SearchExecutorOptions;
|
|
21
|
+
bash?: import("./bash.js").BashExecutorOptions;
|
|
22
|
+
webFetch?: import("./web-fetch.js").WebFetchExecutorOptions;
|
|
23
|
+
applyPatch?: import("./apply-patch.js").ApplyPatchExecutorOptions;
|
|
24
|
+
editor?: import("./editor.js").EditorExecutorOptions;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create all default executors with optional configuration
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createDefaultTools, createDefaultExecutors } from "@clinebot/core/server"
|
|
32
|
+
*
|
|
33
|
+
* const executors = createDefaultExecutors({
|
|
34
|
+
* bash: { timeoutMs: 60000 },
|
|
35
|
+
* search: { maxResults: 50 },
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* const tools = createDefaultTools({
|
|
39
|
+
* executors,
|
|
40
|
+
* cwd: "/path/to/project",
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function createDefaultExecutors(options?: DefaultExecutorsOptions): ToolExecutors;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for searching the codebase using regex.
|
|
5
|
+
*/
|
|
6
|
+
import type { SearchExecutor } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the search executor
|
|
9
|
+
*/
|
|
10
|
+
export interface SearchExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* File extensions to include in search (without dot)
|
|
13
|
+
* @default common code extensions
|
|
14
|
+
*/
|
|
15
|
+
includeExtensions?: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Directories to exclude from search
|
|
18
|
+
* @default ["node_modules", ".git", "dist", "build", ".next", "coverage"]
|
|
19
|
+
*/
|
|
20
|
+
excludeDirs?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of results to return
|
|
23
|
+
* @default 100
|
|
24
|
+
*/
|
|
25
|
+
maxResults?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Number of context lines before and after match
|
|
28
|
+
* @default 2
|
|
29
|
+
*/
|
|
30
|
+
contextLines?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Maximum depth to traverse
|
|
33
|
+
* @default 20
|
|
34
|
+
*/
|
|
35
|
+
maxDepth?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a search executor using regex pattern matching
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const search = createSearchExecutor({
|
|
43
|
+
* maxResults: 50,
|
|
44
|
+
* contextLines: 3,
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* const results = await search("function\\s+handleClick", "/path/to/project", context)
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function createSearchExecutor(options?: SearchExecutorOptions): SearchExecutor;
|