@clinebot/shared 0.0.8
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 +48 -0
- package/dist/auth/constants.d.ts +20 -0
- package/dist/connectors/events.d.ts +35 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +92 -0
- package/dist/db/sqlite-db.d.ts +21 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +58 -0
- package/dist/llms/model-id.d.ts +7 -0
- package/dist/llms/tools.d.ts +116 -0
- package/dist/logging/logger.d.ts +8 -0
- package/dist/parse/json.d.ts +2 -0
- package/dist/parse/time.d.ts +8 -0
- package/dist/parse/zod.d.ts +12 -0
- package/dist/prompt/format.d.ts +4 -0
- package/dist/rpc/runtime.d.ts +258 -0
- package/dist/rpc/team-progress.d.ts +53 -0
- package/dist/services/telemetry-config.d.ts +6 -0
- package/dist/services/telemetry.d.ts +102 -0
- package/dist/session/hook-context.d.ts +14 -0
- package/dist/session/records.d.ts +32 -0
- package/dist/session/runtime-config.d.ts +20 -0
- package/dist/session/runtime-env.d.ts +8 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +1 -0
- package/dist/storage/paths.d.ts +28 -0
- package/dist/vcr.d.ts +51 -0
- package/package.json +39 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const MODELS_DEV_PROVIDER_KEY_ENTRIES: ReadonlyArray<{
|
|
2
|
+
modelsDevKey: string;
|
|
3
|
+
generatedProviderId?: string;
|
|
4
|
+
runtimeProviderId?: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const MODELS_DEV_PROVIDER_KEY_MAP: Record<string, string>;
|
|
7
|
+
export declare function resolveProviderModelCatalogKeys(providerId: string): string[];
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and Zod Schemas for the Agent Package
|
|
3
|
+
*
|
|
4
|
+
* This module defines all TypeScript types and Zod validation schemas
|
|
5
|
+
* for agent configuration, tools, events, and results.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
/**
|
|
9
|
+
* Context passed to tool execution functions
|
|
10
|
+
*/
|
|
11
|
+
export interface ToolContext {
|
|
12
|
+
/** Unique identifier for the agent instance */
|
|
13
|
+
agentId: string;
|
|
14
|
+
/** Unique identifier for the current conversation */
|
|
15
|
+
conversationId: string;
|
|
16
|
+
/** Current iteration number in the agentic loop */
|
|
17
|
+
iteration: number;
|
|
18
|
+
/** Abort signal for cancellation */
|
|
19
|
+
abortSignal?: AbortSignal;
|
|
20
|
+
/** Optional metadata for the tool execution */
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export interface ToolPolicy {
|
|
24
|
+
/**
|
|
25
|
+
* Whether the tool can be executed at all.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether this tool can run without asking the client for approval.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
autoApprove?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const ToolContextSchema: z.ZodObject<{
|
|
36
|
+
agentId: z.ZodString;
|
|
37
|
+
conversationId: z.ZodString;
|
|
38
|
+
iteration: z.ZodNumber;
|
|
39
|
+
abortSignal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
|
|
40
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
/**
|
|
43
|
+
* A tool that the agent can use
|
|
44
|
+
*
|
|
45
|
+
* @template TInput - The type of the input to the tool
|
|
46
|
+
* @template TOutput - The type of the output from the tool
|
|
47
|
+
*/
|
|
48
|
+
export interface Tool<TInput = unknown, TOutput = unknown> {
|
|
49
|
+
/** Unique name for the tool */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Human-readable description of what the tool does */
|
|
52
|
+
description: string;
|
|
53
|
+
/** JSON Schema defining the tool's input parameters */
|
|
54
|
+
inputSchema: Record<string, unknown>;
|
|
55
|
+
/** The function that executes the tool */
|
|
56
|
+
execute: (input: TInput, context: ToolContext) => Promise<TOutput>;
|
|
57
|
+
/**
|
|
58
|
+
* Optional timeout in milliseconds for tool execution
|
|
59
|
+
* @default 30000 (30 seconds)
|
|
60
|
+
*/
|
|
61
|
+
timeoutMs?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the tool can be retried on failure
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
retryable?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Maximum number of retries for this tool
|
|
69
|
+
* @default 2
|
|
70
|
+
*/
|
|
71
|
+
maxRetries?: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Record of a tool call execution
|
|
75
|
+
*/
|
|
76
|
+
export interface ToolCallRecord {
|
|
77
|
+
/** Unique identifier for this tool call */
|
|
78
|
+
id: string;
|
|
79
|
+
/** Name of the tool that was called */
|
|
80
|
+
name: string;
|
|
81
|
+
/** Input passed to the tool */
|
|
82
|
+
input: unknown;
|
|
83
|
+
/** Output returned from the tool (if successful) */
|
|
84
|
+
output: unknown;
|
|
85
|
+
/** Error message (if the tool failed) */
|
|
86
|
+
error?: string;
|
|
87
|
+
/** Time taken to execute the tool in milliseconds */
|
|
88
|
+
durationMs: number;
|
|
89
|
+
/** Timestamp when the tool call started */
|
|
90
|
+
startedAt: Date;
|
|
91
|
+
/** Timestamp when the tool call ended */
|
|
92
|
+
endedAt: Date;
|
|
93
|
+
}
|
|
94
|
+
export interface ToolApprovalRequest {
|
|
95
|
+
agentId: string;
|
|
96
|
+
conversationId: string;
|
|
97
|
+
iteration: number;
|
|
98
|
+
toolCallId: string;
|
|
99
|
+
toolName: string;
|
|
100
|
+
input: unknown;
|
|
101
|
+
policy: ToolPolicy;
|
|
102
|
+
}
|
|
103
|
+
export interface ToolApprovalResult {
|
|
104
|
+
approved: boolean;
|
|
105
|
+
reason?: string;
|
|
106
|
+
}
|
|
107
|
+
export declare const ToolCallRecordSchema: z.ZodObject<{
|
|
108
|
+
id: z.ZodString;
|
|
109
|
+
name: z.ZodString;
|
|
110
|
+
input: z.ZodUnknown;
|
|
111
|
+
output: z.ZodUnknown;
|
|
112
|
+
error: z.ZodOptional<z.ZodString>;
|
|
113
|
+
durationMs: z.ZodNumber;
|
|
114
|
+
startedAt: z.ZodDate;
|
|
115
|
+
endedAt: z.ZodDate;
|
|
116
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface BasicLogger {
|
|
2
|
+
debug?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
3
|
+
info?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
4
|
+
warn?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
5
|
+
error?: (message: string, metadata?: Record<string, unknown> & {
|
|
6
|
+
error?: unknown;
|
|
7
|
+
}) => void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a date string and returns a human-readable format.
|
|
3
|
+
* If the input is invalid, it returns the original string or a placeholder.
|
|
4
|
+
*
|
|
5
|
+
* @param dateStr - The date string to parse.
|
|
6
|
+
* @returns A human-readable date string or the original input if invalid.
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatHumanReadableDate(dateStr?: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for working with Zod schemas.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/**
|
|
8
|
+
* Validate input using a Zod schema
|
|
9
|
+
* Throws a formatted error if validation fails
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateWithZod<T>(schema: z.ZodType<T>, input: unknown): T;
|
|
12
|
+
export declare function zodToJsonSchema(schema: z.ZodTypeAny): Record<string, unknown>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function formatFileContentBlock(path: string, content: string): string;
|
|
2
|
+
export declare function formatUserInputBlock(input: string, mode?: "act" | "plan"): string;
|
|
3
|
+
export declare function normalizeUserInput(input?: string): string;
|
|
4
|
+
export declare function xmlTagsRemoval(input?: string, tag?: string): string;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import type { AgentMode, SessionExecutionConfig, SessionPromptConfig } from "../session/runtime-config";
|
|
2
|
+
export type RpcAgentMode = AgentMode;
|
|
3
|
+
export interface RpcSessionStorageOptions {
|
|
4
|
+
homeDir?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RpcChatRuntimeConfigBase extends SessionPromptConfig {
|
|
7
|
+
cwd?: string;
|
|
8
|
+
apiKey: string;
|
|
9
|
+
logger?: RpcChatRuntimeLoggerConfig;
|
|
10
|
+
enableTools: boolean;
|
|
11
|
+
enableSpawn: boolean;
|
|
12
|
+
enableTeams: boolean;
|
|
13
|
+
autoApproveTools?: boolean;
|
|
14
|
+
teamName: string;
|
|
15
|
+
missionStepInterval: number;
|
|
16
|
+
missionTimeIntervalMs: number;
|
|
17
|
+
toolPolicies?: SessionExecutionConfig["toolPolicies"];
|
|
18
|
+
}
|
|
19
|
+
export interface RpcChatRuntimeLoggerConfig {
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
level?: "trace" | "debug" | "info" | "warn" | "error" | "fatal" | "silent";
|
|
22
|
+
destination?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
bindings?: Record<string, string | number | boolean>;
|
|
25
|
+
}
|
|
26
|
+
export interface RpcChatStartSessionRequest extends RpcChatRuntimeConfigBase {
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
workspaceRoot: string;
|
|
29
|
+
provider: string;
|
|
30
|
+
model: string;
|
|
31
|
+
sessions?: RpcSessionStorageOptions;
|
|
32
|
+
initialMessages?: RpcChatMessage[];
|
|
33
|
+
}
|
|
34
|
+
export interface RpcChatStartSessionArtifacts {
|
|
35
|
+
sessionId: string;
|
|
36
|
+
manifestPath: string;
|
|
37
|
+
transcriptPath: string;
|
|
38
|
+
hookPath: string;
|
|
39
|
+
messagesPath: string;
|
|
40
|
+
}
|
|
41
|
+
export interface RpcChatStartSessionResponse {
|
|
42
|
+
sessionId: string;
|
|
43
|
+
startResult?: RpcChatStartSessionArtifacts;
|
|
44
|
+
}
|
|
45
|
+
export interface RpcChatAttachmentFile {
|
|
46
|
+
name: string;
|
|
47
|
+
content: string;
|
|
48
|
+
}
|
|
49
|
+
export interface RpcChatAttachments {
|
|
50
|
+
userImages?: string[];
|
|
51
|
+
userFiles?: RpcChatAttachmentFile[];
|
|
52
|
+
}
|
|
53
|
+
export interface RpcChatMessage {
|
|
54
|
+
role?: string;
|
|
55
|
+
content?: unknown;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
export interface RpcChatRunTurnRequest {
|
|
59
|
+
config: RpcChatStartSessionRequest;
|
|
60
|
+
messages?: RpcChatMessage[];
|
|
61
|
+
prompt: string;
|
|
62
|
+
attachments?: RpcChatAttachments;
|
|
63
|
+
}
|
|
64
|
+
export interface RpcChatToolCallResult {
|
|
65
|
+
name: string;
|
|
66
|
+
input?: unknown;
|
|
67
|
+
output?: unknown;
|
|
68
|
+
error?: string;
|
|
69
|
+
durationMs?: number;
|
|
70
|
+
}
|
|
71
|
+
export interface RpcChatTurnResult {
|
|
72
|
+
text: string;
|
|
73
|
+
usage: {
|
|
74
|
+
inputTokens: number;
|
|
75
|
+
outputTokens: number;
|
|
76
|
+
cacheReadTokens?: number;
|
|
77
|
+
cacheWriteTokens?: number;
|
|
78
|
+
totalCost?: number;
|
|
79
|
+
};
|
|
80
|
+
inputTokens: number;
|
|
81
|
+
outputTokens: number;
|
|
82
|
+
iterations: number;
|
|
83
|
+
finishReason: string;
|
|
84
|
+
messages: RpcChatMessage[];
|
|
85
|
+
toolCalls: RpcChatToolCallResult[];
|
|
86
|
+
}
|
|
87
|
+
export interface RpcProviderModel {
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
supportsAttachments?: boolean;
|
|
91
|
+
supportsVision?: boolean;
|
|
92
|
+
supportsReasoning?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface RpcProviderListItem {
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
models: number | null;
|
|
98
|
+
color: string;
|
|
99
|
+
letter: string;
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
apiKey?: string;
|
|
102
|
+
oauthAccessTokenPresent?: boolean;
|
|
103
|
+
baseUrl?: string;
|
|
104
|
+
defaultModelId?: string;
|
|
105
|
+
authDescription: string;
|
|
106
|
+
baseUrlDescription: string;
|
|
107
|
+
modelList?: RpcProviderModel[];
|
|
108
|
+
}
|
|
109
|
+
export interface RpcProviderCatalogResponse {
|
|
110
|
+
providers: RpcProviderListItem[];
|
|
111
|
+
settingsPath: string;
|
|
112
|
+
}
|
|
113
|
+
export interface RpcProviderModelsResponse {
|
|
114
|
+
providerId: string;
|
|
115
|
+
models: RpcProviderModel[];
|
|
116
|
+
}
|
|
117
|
+
export interface RpcClineAccountOrganization {
|
|
118
|
+
active: boolean;
|
|
119
|
+
memberId: string;
|
|
120
|
+
name: string;
|
|
121
|
+
organizationId: string;
|
|
122
|
+
roles: Array<"admin" | "member" | "owner">;
|
|
123
|
+
}
|
|
124
|
+
export interface RpcClineAccountUser {
|
|
125
|
+
id: string;
|
|
126
|
+
email: string;
|
|
127
|
+
displayName: string;
|
|
128
|
+
photoUrl: string;
|
|
129
|
+
createdAt: string;
|
|
130
|
+
updatedAt: string;
|
|
131
|
+
organizations: RpcClineAccountOrganization[];
|
|
132
|
+
}
|
|
133
|
+
export interface RpcClineAccountBalance {
|
|
134
|
+
balance: number;
|
|
135
|
+
userId: string;
|
|
136
|
+
}
|
|
137
|
+
export interface RpcClineAccountUsageTransaction {
|
|
138
|
+
aiInferenceProviderName: string;
|
|
139
|
+
aiModelName: string;
|
|
140
|
+
aiModelTypeName: string;
|
|
141
|
+
completionTokens: number;
|
|
142
|
+
costUsd: number;
|
|
143
|
+
createdAt: string;
|
|
144
|
+
creditsUsed: number;
|
|
145
|
+
generationId: string;
|
|
146
|
+
id: string;
|
|
147
|
+
metadata: {
|
|
148
|
+
additionalProp1: string;
|
|
149
|
+
additionalProp2: string;
|
|
150
|
+
additionalProp3: string;
|
|
151
|
+
};
|
|
152
|
+
operation?: string;
|
|
153
|
+
organizationId: string;
|
|
154
|
+
promptTokens: number;
|
|
155
|
+
totalTokens: number;
|
|
156
|
+
userId: string;
|
|
157
|
+
}
|
|
158
|
+
export interface RpcClineAccountPaymentTransaction {
|
|
159
|
+
paidAt: string;
|
|
160
|
+
creatorId: string;
|
|
161
|
+
amountCents: number;
|
|
162
|
+
credits: number;
|
|
163
|
+
}
|
|
164
|
+
export interface RpcClineAccountOrganizationBalance {
|
|
165
|
+
balance: number;
|
|
166
|
+
organizationId: string;
|
|
167
|
+
}
|
|
168
|
+
export interface RpcClineAccountOrganizationUsageTransaction {
|
|
169
|
+
aiInferenceProviderName: string;
|
|
170
|
+
aiModelName: string;
|
|
171
|
+
aiModelTypeName: string;
|
|
172
|
+
completionTokens: number;
|
|
173
|
+
costUsd: number;
|
|
174
|
+
createdAt: string;
|
|
175
|
+
creditsUsed: number;
|
|
176
|
+
generationId: string;
|
|
177
|
+
id: string;
|
|
178
|
+
memberDisplayName: string;
|
|
179
|
+
memberEmail: string;
|
|
180
|
+
metadata: {
|
|
181
|
+
additionalProp1: string;
|
|
182
|
+
additionalProp2: string;
|
|
183
|
+
additionalProp3: string;
|
|
184
|
+
};
|
|
185
|
+
operation?: string;
|
|
186
|
+
organizationId: string;
|
|
187
|
+
promptTokens: number;
|
|
188
|
+
totalTokens: number;
|
|
189
|
+
userId: string;
|
|
190
|
+
}
|
|
191
|
+
import type { OAuthProviderId } from "../auth/constants";
|
|
192
|
+
export type RpcOAuthProviderId = OAuthProviderId;
|
|
193
|
+
export type RpcProviderCapability = "reasoning" | "prompt-cache" | "streaming" | "tools" | "vision";
|
|
194
|
+
export interface RpcListProvidersActionRequest {
|
|
195
|
+
action: "listProviders";
|
|
196
|
+
}
|
|
197
|
+
export interface RpcGetProviderModelsActionRequest {
|
|
198
|
+
action: "getProviderModels";
|
|
199
|
+
providerId: string;
|
|
200
|
+
}
|
|
201
|
+
export interface RpcSaveProviderSettingsActionRequest {
|
|
202
|
+
action: "saveProviderSettings";
|
|
203
|
+
providerId: string;
|
|
204
|
+
enabled?: boolean;
|
|
205
|
+
apiKey?: string;
|
|
206
|
+
baseUrl?: string;
|
|
207
|
+
}
|
|
208
|
+
export interface RpcAddProviderActionRequest {
|
|
209
|
+
action: "addProvider";
|
|
210
|
+
providerId: string;
|
|
211
|
+
name: string;
|
|
212
|
+
baseUrl: string;
|
|
213
|
+
apiKey?: string;
|
|
214
|
+
headers?: Record<string, string>;
|
|
215
|
+
timeoutMs?: number;
|
|
216
|
+
models?: string[];
|
|
217
|
+
defaultModelId?: string;
|
|
218
|
+
modelsSourceUrl?: string;
|
|
219
|
+
capabilities?: RpcProviderCapability[];
|
|
220
|
+
}
|
|
221
|
+
export type RpcProviderSettingsActionRequest = RpcListProvidersActionRequest | RpcGetProviderModelsActionRequest | RpcSaveProviderSettingsActionRequest | RpcAddProviderActionRequest;
|
|
222
|
+
export type RpcClineAccountActionRequest = {
|
|
223
|
+
action: "clineAccount";
|
|
224
|
+
operation: "fetchMe";
|
|
225
|
+
} | {
|
|
226
|
+
action: "clineAccount";
|
|
227
|
+
operation: "fetchBalance";
|
|
228
|
+
userId?: string;
|
|
229
|
+
} | {
|
|
230
|
+
action: "clineAccount";
|
|
231
|
+
operation: "fetchUsageTransactions";
|
|
232
|
+
userId?: string;
|
|
233
|
+
} | {
|
|
234
|
+
action: "clineAccount";
|
|
235
|
+
operation: "fetchPaymentTransactions";
|
|
236
|
+
userId?: string;
|
|
237
|
+
} | {
|
|
238
|
+
action: "clineAccount";
|
|
239
|
+
operation: "fetchUserOrganizations";
|
|
240
|
+
} | {
|
|
241
|
+
action: "clineAccount";
|
|
242
|
+
operation: "fetchOrganizationBalance";
|
|
243
|
+
organizationId: string;
|
|
244
|
+
} | {
|
|
245
|
+
action: "clineAccount";
|
|
246
|
+
operation: "fetchOrganizationUsageTransactions";
|
|
247
|
+
organizationId: string;
|
|
248
|
+
memberId?: string;
|
|
249
|
+
} | {
|
|
250
|
+
action: "clineAccount";
|
|
251
|
+
operation: "switchAccount";
|
|
252
|
+
organizationId?: string | null;
|
|
253
|
+
};
|
|
254
|
+
export type RpcProviderActionRequest = RpcProviderSettingsActionRequest | RpcClineAccountActionRequest;
|
|
255
|
+
export interface RpcProviderOAuthLoginResponse {
|
|
256
|
+
provider: RpcOAuthProviderId;
|
|
257
|
+
accessToken: string;
|
|
258
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const RPC_TEAM_PROGRESS_EVENT_TYPE = "runtime.team.progress.v1";
|
|
2
|
+
export declare const RPC_TEAM_LIFECYCLE_EVENT_TYPE = "runtime.team.lifecycle.v1";
|
|
3
|
+
export type TeamProgressMemberRole = "lead" | "teammate";
|
|
4
|
+
export type TeamProgressMemberStatus = "idle" | "running" | "stopped";
|
|
5
|
+
export type TeamProgressTaskStatus = "pending" | "in_progress" | "blocked" | "completed";
|
|
6
|
+
export type TeamProgressRunStatus = "queued" | "running" | "completed" | "failed" | "cancelled" | "interrupted";
|
|
7
|
+
export type TeamProgressOutcomeStatus = "draft" | "in_review" | "finalized";
|
|
8
|
+
export type TeamProgressOutcomeFragmentStatus = "draft" | "reviewed" | "rejected";
|
|
9
|
+
export interface TeamProgressCounts<TStatus extends string> {
|
|
10
|
+
total: number;
|
|
11
|
+
byStatus: Record<TStatus, number>;
|
|
12
|
+
}
|
|
13
|
+
export interface TeamProgressSummary {
|
|
14
|
+
teamName: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
members: TeamProgressCounts<TeamProgressMemberStatus> & {
|
|
17
|
+
leadCount: number;
|
|
18
|
+
teammateCount: number;
|
|
19
|
+
};
|
|
20
|
+
tasks: TeamProgressCounts<TeamProgressTaskStatus> & {
|
|
21
|
+
blockedTaskIds: string[];
|
|
22
|
+
readyTaskIds: string[];
|
|
23
|
+
completionPct: number;
|
|
24
|
+
};
|
|
25
|
+
runs: TeamProgressCounts<TeamProgressRunStatus> & {
|
|
26
|
+
activeRunIds: string[];
|
|
27
|
+
latestRunId?: string;
|
|
28
|
+
};
|
|
29
|
+
outcomes: TeamProgressCounts<TeamProgressOutcomeStatus> & {
|
|
30
|
+
finalizedPct: number;
|
|
31
|
+
missingRequiredSections: string[];
|
|
32
|
+
};
|
|
33
|
+
fragments: TeamProgressCounts<TeamProgressOutcomeFragmentStatus>;
|
|
34
|
+
}
|
|
35
|
+
export interface TeamProgressLifecycleEvent {
|
|
36
|
+
teamName: string;
|
|
37
|
+
sessionId: string;
|
|
38
|
+
eventType: string;
|
|
39
|
+
ts: string;
|
|
40
|
+
agentId?: string;
|
|
41
|
+
taskId?: string;
|
|
42
|
+
runId?: string;
|
|
43
|
+
outcomeId?: string;
|
|
44
|
+
fragmentId?: string;
|
|
45
|
+
message?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface TeamProgressProjectionEvent {
|
|
48
|
+
type: "team_progress_projection";
|
|
49
|
+
version: 1;
|
|
50
|
+
sessionId: string;
|
|
51
|
+
summary: TeamProgressSummary;
|
|
52
|
+
lastEvent: TeamProgressLifecycleEvent;
|
|
53
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OpenTelemetryClientConfig, TelemetryMetadata } from "./telemetry";
|
|
2
|
+
export interface ClineTelemetryServiceConfig extends OpenTelemetryClientConfig {
|
|
3
|
+
metadata: TelemetryMetadata;
|
|
4
|
+
}
|
|
5
|
+
export declare function createClineTelemetryServiceMetadata(overrides?: Partial<TelemetryMetadata>): TelemetryMetadata;
|
|
6
|
+
export declare function createClineTelemetryServiceConfig(configOverrides?: Partial<ClineTelemetryServiceConfig>): ClineTelemetryServiceConfig;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export type TelemetryPrimitive = string | number | boolean | null | undefined;
|
|
2
|
+
export type TelemetryValue = TelemetryPrimitive | TelemetryObject | TelemetryArray;
|
|
3
|
+
export type TelemetryObject = {
|
|
4
|
+
[key: string]: TelemetryValue;
|
|
5
|
+
};
|
|
6
|
+
export type TelemetryArray = Array<TelemetryValue>;
|
|
7
|
+
export type TelemetryProperties = TelemetryObject;
|
|
8
|
+
export interface TelemetryMetadata {
|
|
9
|
+
extension_version: string;
|
|
10
|
+
cline_type: string;
|
|
11
|
+
platform: string;
|
|
12
|
+
platform_version: string;
|
|
13
|
+
os_type: string;
|
|
14
|
+
os_version: string;
|
|
15
|
+
is_dev?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ITelemetryService {
|
|
18
|
+
setDistinctId(distinctId?: string): void;
|
|
19
|
+
setMetadata(metadata: Partial<TelemetryMetadata>): void;
|
|
20
|
+
updateMetadata(metadata: Partial<TelemetryMetadata>): void;
|
|
21
|
+
setCommonProperties(properties: TelemetryProperties): void;
|
|
22
|
+
updateCommonProperties(properties: TelemetryProperties): void;
|
|
23
|
+
isEnabled(): boolean;
|
|
24
|
+
capture(input: {
|
|
25
|
+
event: string;
|
|
26
|
+
properties?: TelemetryProperties;
|
|
27
|
+
}): void;
|
|
28
|
+
captureRequired(event: string, properties?: TelemetryProperties): void;
|
|
29
|
+
recordCounter(name: string, value: number, attributes?: TelemetryProperties, description?: string, required?: boolean): void;
|
|
30
|
+
recordHistogram(name: string, value: number, attributes?: TelemetryProperties, description?: string, required?: boolean): void;
|
|
31
|
+
recordGauge(name: string, value: number | null, attributes?: TelemetryProperties, description?: string, required?: boolean): void;
|
|
32
|
+
flush(): Promise<void>;
|
|
33
|
+
dispose(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export interface OpenTelemetryClientConfig {
|
|
36
|
+
/**
|
|
37
|
+
* Whether telemetry is enabled via OTEL_TELEMETRY_ENABLED
|
|
38
|
+
*/
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Metrics exporter type(s) - can be comma-separated for multiple exporters
|
|
42
|
+
* Examples: "console", "otlp", "prometheus", "console,otlp"
|
|
43
|
+
*/
|
|
44
|
+
metricsExporter?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Logs/events exporter type(s) - can be comma-separated for multiple exporters
|
|
47
|
+
* Examples: "console", "otlp"
|
|
48
|
+
*/
|
|
49
|
+
logsExporter?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Protocol for OTLP exporters. SDK support is currently limited to "http/json".
|
|
52
|
+
*/
|
|
53
|
+
otlpProtocol?: string;
|
|
54
|
+
/**
|
|
55
|
+
* General OTLP endpoint (used if specific endpoints not set)
|
|
56
|
+
*/
|
|
57
|
+
otlpEndpoint?: string;
|
|
58
|
+
/**
|
|
59
|
+
* General OTLP headers
|
|
60
|
+
*/
|
|
61
|
+
otlpHeaders?: Record<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* Metrics-specific OTLP protocol
|
|
64
|
+
*/
|
|
65
|
+
otlpMetricsProtocol?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Metrics-specific OTLP endpoint
|
|
68
|
+
*/
|
|
69
|
+
otlpMetricsEndpoint?: string;
|
|
70
|
+
otlpMetricsHeaders?: Record<string, string>;
|
|
71
|
+
/**
|
|
72
|
+
* Logs-specific OTLP protocol
|
|
73
|
+
*/
|
|
74
|
+
otlpLogsProtocol?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Logs-specific OTLP endpoint
|
|
77
|
+
*/
|
|
78
|
+
otlpLogsEndpoint?: string;
|
|
79
|
+
otlpLogsHeaders?: Record<string, string>;
|
|
80
|
+
/**
|
|
81
|
+
* Metric export interval in milliseconds (for console exporter)
|
|
82
|
+
*/
|
|
83
|
+
metricExportInterval?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Whether to use insecure (non-TLS) connections for gRPC OTLP exporters
|
|
86
|
+
* Set to "true" for local development without TLS
|
|
87
|
+
* Default: false (uses TLS)
|
|
88
|
+
*/
|
|
89
|
+
otlpInsecure?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Maximum batch size for log records (default: 512)
|
|
92
|
+
*/
|
|
93
|
+
logBatchSize?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Maximum time to wait before exporting logs in milliseconds (default: 5000)
|
|
96
|
+
*/
|
|
97
|
+
logBatchTimeout?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Maximum queue size for log records (default: 2048)
|
|
100
|
+
*/
|
|
101
|
+
logMaxQueueSize?: number;
|
|
102
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface HookSessionContext {
|
|
2
|
+
rootSessionId?: string;
|
|
3
|
+
hookLogPath?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface HookSessionContextLookup {
|
|
6
|
+
hookName?: string;
|
|
7
|
+
conversationId?: string;
|
|
8
|
+
agentId?: string;
|
|
9
|
+
parentAgentId?: string | null;
|
|
10
|
+
}
|
|
11
|
+
export type HookSessionContextProvider = HookSessionContext | ((input?: HookSessionContextLookup) => HookSessionContext | undefined);
|
|
12
|
+
export declare function resolveHookSessionContext(provider?: HookSessionContextProvider, input?: HookSessionContextLookup): HookSessionContext | undefined;
|
|
13
|
+
export declare function resolveRootSessionId(context: HookSessionContext | undefined): string | undefined;
|
|
14
|
+
export declare function resolveHookLogPath(context: HookSessionContext | undefined): string | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const SESSION_STATUS_VALUES: readonly ["running", "completed", "failed", "cancelled"];
|
|
2
|
+
export type SharedSessionStatus = (typeof SESSION_STATUS_VALUES)[number];
|
|
3
|
+
export interface SessionLineage {
|
|
4
|
+
parentSessionId?: string;
|
|
5
|
+
agentId?: string;
|
|
6
|
+
parentAgentId?: string;
|
|
7
|
+
conversationId?: string;
|
|
8
|
+
isSubagent: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface SessionRuntimeRecordShape extends SessionLineage {
|
|
11
|
+
source: string;
|
|
12
|
+
pid?: number;
|
|
13
|
+
startedAt: string;
|
|
14
|
+
endedAt?: string | null;
|
|
15
|
+
exitCode?: number | null;
|
|
16
|
+
status: SharedSessionStatus;
|
|
17
|
+
interactive: boolean;
|
|
18
|
+
provider: string;
|
|
19
|
+
model: string;
|
|
20
|
+
cwd: string;
|
|
21
|
+
workspaceRoot: string;
|
|
22
|
+
teamName?: string;
|
|
23
|
+
enableTools: boolean;
|
|
24
|
+
enableSpawn: boolean;
|
|
25
|
+
enableTeams: boolean;
|
|
26
|
+
prompt?: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
transcriptPath?: string;
|
|
29
|
+
hookPath?: string;
|
|
30
|
+
messagesPath?: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ToolPolicy } from "../llms/tools";
|
|
2
|
+
export type AgentMode = "act" | "plan";
|
|
3
|
+
export interface SessionPromptConfig {
|
|
4
|
+
mode?: AgentMode;
|
|
5
|
+
systemPrompt?: string;
|
|
6
|
+
rules?: string;
|
|
7
|
+
maxIterations?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SessionWorkspaceConfig {
|
|
10
|
+
cwd: string;
|
|
11
|
+
workspaceRoot?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SessionExecutionConfig {
|
|
14
|
+
enableTools: boolean;
|
|
15
|
+
teamName?: string;
|
|
16
|
+
missionLogIntervalSteps?: number;
|
|
17
|
+
missionLogIntervalMs?: number;
|
|
18
|
+
maxConsecutiveMistakes?: number;
|
|
19
|
+
toolPolicies?: Record<string, ToolPolicy>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AGENT_CONFIG_DIRECTORY_NAME, CLINE_MCP_SETTINGS_FILE_NAME, ensureHookLogDir, ensureParentDir, HOOKS_CONFIG_DIRECTORY_NAME, RULES_CONFIG_DIRECTORY_NAME, resolveAgentConfigSearchPaths, resolveAgentsConfigDirPath, resolveClineDataDir, resolveDocumentsAgentConfigDirectoryPath, resolveDocumentsClineDirectoryPath, resolveDocumentsHooksDirectoryPath, resolveDocumentsRulesDirectoryPath, resolveDocumentsWorkflowsDirectoryPath, resolveHooksConfigSearchPaths, resolveMcpSettingsPath, resolvePluginConfigSearchPaths, resolveProviderSettingsPath, resolveRulesConfigSearchPaths, resolveSessionDataDir, resolveSkillsConfigSearchPaths, resolveTeamDataDir, resolveWorkflowsConfigSearchPaths, SKILLS_CONFIG_DIRECTORY_NAME, setHomeDir, setHomeDirIfUnset, WORKFLOWS_CONFIG_DIRECTORY_NAME, } from "./paths";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var L=Object.defineProperty;var U=(o)=>o;function W(o,n){this[o]=U.bind(null,n)}var x=(o,n)=>{for(var S in n)L(o,S,{get:n[S],enumerable:!0,configurable:!0,set:W.bind(n,S)})};import{existsSync as _,mkdirSync as O}from"node:fs";import{dirname as R,join as v}from"node:path";var l="agents",E="hooks",g="skills",G="rules",I="workflows",A="plugins",y="cline_mcp_settings.json",D=process?.env?.HOME||"~",F=!1;function Y(o){let n=o.trim();if(!n)return;D=n,F=!0}function b(o){if(F)return;let n=o.trim();if(!n)return;D=n}function N(){return v(D,"Documents","Cline")}function H(){return v(N(),"Agents")}function M(){return v(N(),"Hooks")}function T(){return v(N(),"Rules")}function e(){return v(N(),"Workflows")}function C(){let o=process.env.CLINE_DATA_DIR?.trim();if(o)return o;return v(D,".cline","data")}function j(){let o=process.env.CLINE_SESSION_DATA_DIR?.trim();if(o)return o;return v(C(),"sessions")}function m(){let o=process.env.CLINE_TEAM_DATA_DIR?.trim();if(o)return o;return v(C(),"teams")}function q(){let o=process.env.CLINE_PROVIDER_SETTINGS_PATH?.trim();if(o)return o;return v(C(),"settings","providers.json")}function z(){let o=process.env.CLINE_MCP_SETTINGS_PATH?.trim();if(o)return o;return v(C(),"settings",y)}function s(o){let n=new Set,S=[];for(let u of o){if(!u||n.has(u))continue;n.add(u),S.push(u)}return S}function B(o){if(!o)return[];return[v(o,".clinerules",g),v(o,".cline",g),v(o,".claude",g),v(o,".agents",g)]}function f(){return v(C(),"settings",l)}function J(){return[H(),f()]}function Q(o){return s([o?v(o,".clinerules",E):"",M()])}function V(o){return s([...B(o),v(C(),"settings",g),v(D,".cline",g),v(D,".agents",g)])}function Z(o){return s([o?v(o,".clinerules"):"",v(C(),"settings",G),T()])}function $(o){return s([o?v(o,".clinerules","workflows"):"",v(C(),"settings",I),e()])}function X(o){return s([o?v(o,".clinerules",A):"",v(D,".cline",A),v(D,".agents",A)])}function K(o){let n=R(o);if(!_(n))O(n,{recursive:!0})}function r(o){if(o?.trim())return K(o),R(o);let n=v(C(),"hooks");if(!_(n))O(n,{recursive:!0});return n}export{b as setHomeDirIfUnset,Y as setHomeDir,$ as resolveWorkflowsConfigSearchPaths,m as resolveTeamDataDir,V as resolveSkillsConfigSearchPaths,j as resolveSessionDataDir,Z as resolveRulesConfigSearchPaths,q as resolveProviderSettingsPath,X as resolvePluginConfigSearchPaths,z as resolveMcpSettingsPath,Q as resolveHooksConfigSearchPaths,e as resolveDocumentsWorkflowsDirectoryPath,T as resolveDocumentsRulesDirectoryPath,M as resolveDocumentsHooksDirectoryPath,N as resolveDocumentsClineDirectoryPath,H as resolveDocumentsAgentConfigDirectoryPath,C as resolveClineDataDir,f as resolveAgentsConfigDirPath,J as resolveAgentConfigSearchPaths,K as ensureParentDir,r as ensureHookLogDir,I as WORKFLOWS_CONFIG_DIRECTORY_NAME,g as SKILLS_CONFIG_DIRECTORY_NAME,G as RULES_CONFIG_DIRECTORY_NAME,E as HOOKS_CONFIG_DIRECTORY_NAME,y as CLINE_MCP_SETTINGS_FILE_NAME,l as AGENT_CONFIG_DIRECTORY_NAME};
|