@clinebot/shared 0.0.20 → 0.0.22
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/dist/index.browser.d.ts +4 -1
- package/dist/index.browser.js +21 -21
- package/dist/index.d.ts +4 -1
- package/dist/index.js +27 -27
- package/dist/parse/shell.d.ts +2 -0
- package/dist/parse/string.d.ts +1 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/storage/index.js +1 -1
- package/package.json +2 -3
- package/src/auth/constants.ts +0 -41
- package/src/connectors/adapters.ts +0 -152
- package/src/connectors/events.ts +0 -73
- package/src/db/index.ts +0 -14
- package/src/db/sqlite-db.ts +0 -329
- package/src/index.browser.ts +0 -187
- package/src/index.ts +0 -187
- package/src/llms/model-id.ts +0 -154
- package/src/llms/tools.ts +0 -137
- package/src/logging/logger.ts +0 -9
- package/src/parse/json.ts +0 -43
- package/src/parse/time.ts +0 -21
- package/src/parse/zod.ts +0 -23
- package/src/prompt/format.ts +0 -22
- package/src/remote-config/constants.ts +0 -5
- package/src/remote-config/schema.test.ts +0 -1004
- package/src/remote-config/schema.ts +0 -263
- package/src/rpc/index.ts +0 -4
- package/src/rpc/runtime.ts +0 -317
- package/src/rpc/team-progress.ts +0 -71
- package/src/services/telemetry-config.ts +0 -55
- package/src/services/telemetry.ts +0 -141
- package/src/session/hook-context.ts +0 -54
- package/src/session/records.ts +0 -40
- package/src/session/runtime-config.ts +0 -24
- package/src/session/runtime-env.ts +0 -8
- package/src/storage/index.ts +0 -37
- package/src/storage/paths.test.ts +0 -99
- package/src/storage/paths.ts +0 -400
- package/src/vcr.ts +0 -717
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
export type TelemetryPrimitive = string | number | boolean | null | undefined;
|
|
2
|
-
|
|
3
|
-
export type TelemetryValue =
|
|
4
|
-
| TelemetryPrimitive
|
|
5
|
-
| TelemetryObject
|
|
6
|
-
| TelemetryArray;
|
|
7
|
-
|
|
8
|
-
export type TelemetryObject = { [key: string]: TelemetryValue };
|
|
9
|
-
|
|
10
|
-
export type TelemetryArray = Array<TelemetryValue>;
|
|
11
|
-
|
|
12
|
-
export type TelemetryProperties = TelemetryObject;
|
|
13
|
-
|
|
14
|
-
export interface TelemetryMetadata {
|
|
15
|
-
extension_version: string;
|
|
16
|
-
cline_type: string;
|
|
17
|
-
platform: string;
|
|
18
|
-
platform_version: string;
|
|
19
|
-
os_type: string;
|
|
20
|
-
os_version: string;
|
|
21
|
-
is_dev?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ITelemetryService {
|
|
25
|
-
setDistinctId(distinctId?: string): void;
|
|
26
|
-
setMetadata(metadata: Partial<TelemetryMetadata>): void;
|
|
27
|
-
updateMetadata(metadata: Partial<TelemetryMetadata>): void;
|
|
28
|
-
setCommonProperties(properties: TelemetryProperties): void;
|
|
29
|
-
updateCommonProperties(properties: TelemetryProperties): void;
|
|
30
|
-
isEnabled(): boolean;
|
|
31
|
-
capture(input: { event: string; properties?: TelemetryProperties }): void;
|
|
32
|
-
captureRequired(event: string, properties?: TelemetryProperties): void;
|
|
33
|
-
recordCounter(
|
|
34
|
-
name: string,
|
|
35
|
-
value: number,
|
|
36
|
-
attributes?: TelemetryProperties,
|
|
37
|
-
description?: string,
|
|
38
|
-
required?: boolean,
|
|
39
|
-
): void;
|
|
40
|
-
recordHistogram(
|
|
41
|
-
name: string,
|
|
42
|
-
value: number,
|
|
43
|
-
attributes?: TelemetryProperties,
|
|
44
|
-
description?: string,
|
|
45
|
-
required?: boolean,
|
|
46
|
-
): void;
|
|
47
|
-
recordGauge(
|
|
48
|
-
name: string,
|
|
49
|
-
value: number | null,
|
|
50
|
-
attributes?: TelemetryProperties,
|
|
51
|
-
description?: string,
|
|
52
|
-
required?: boolean,
|
|
53
|
-
): void;
|
|
54
|
-
flush(): Promise<void>;
|
|
55
|
-
dispose(): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface OpenTelemetryClientConfig {
|
|
59
|
-
/**
|
|
60
|
-
* Whether telemetry is enabled via OTEL_TELEMETRY_ENABLED
|
|
61
|
-
*/
|
|
62
|
-
enabled: boolean;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Metrics exporter type(s) - can be comma-separated for multiple exporters
|
|
66
|
-
* Examples: "console", "otlp", "prometheus", "console,otlp"
|
|
67
|
-
*/
|
|
68
|
-
metricsExporter?: string;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Logs/events exporter type(s) - can be comma-separated for multiple exporters
|
|
72
|
-
* Examples: "console", "otlp"
|
|
73
|
-
*/
|
|
74
|
-
logsExporter?: string;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Protocol for OTLP exporters. SDK support is currently limited to "http/json".
|
|
78
|
-
*/
|
|
79
|
-
otlpProtocol?: string;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* General OTLP endpoint (used if specific endpoints not set)
|
|
83
|
-
*/
|
|
84
|
-
otlpEndpoint?: string;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* General OTLP headers
|
|
88
|
-
*/
|
|
89
|
-
otlpHeaders?: Record<string, string>;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Metrics-specific OTLP protocol
|
|
93
|
-
*/
|
|
94
|
-
otlpMetricsProtocol?: string;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Metrics-specific OTLP endpoint
|
|
98
|
-
*/
|
|
99
|
-
otlpMetricsEndpoint?: string;
|
|
100
|
-
|
|
101
|
-
otlpMetricsHeaders?: Record<string, string>;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Logs-specific OTLP protocol
|
|
105
|
-
*/
|
|
106
|
-
otlpLogsProtocol?: string;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Logs-specific OTLP endpoint
|
|
110
|
-
*/
|
|
111
|
-
otlpLogsEndpoint?: string;
|
|
112
|
-
|
|
113
|
-
otlpLogsHeaders?: Record<string, string>;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Metric export interval in milliseconds (for console exporter)
|
|
117
|
-
*/
|
|
118
|
-
metricExportInterval?: number;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Whether to use insecure (non-TLS) connections for gRPC OTLP exporters
|
|
122
|
-
* Set to "true" for local development without TLS
|
|
123
|
-
* Default: false (uses TLS)
|
|
124
|
-
*/
|
|
125
|
-
otlpInsecure?: boolean;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Maximum batch size for log records (default: 512)
|
|
129
|
-
*/
|
|
130
|
-
logBatchSize?: number;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Maximum time to wait before exporting logs in milliseconds (default: 5000)
|
|
134
|
-
*/
|
|
135
|
-
logBatchTimeout?: number;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Maximum queue size for log records (default: 2048)
|
|
139
|
-
*/
|
|
140
|
-
logMaxQueueSize?: number;
|
|
141
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export interface HookSessionContext {
|
|
2
|
-
rootSessionId?: string;
|
|
3
|
-
hookLogPath?: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface HookSessionContextLookup {
|
|
7
|
-
hookName?: string;
|
|
8
|
-
conversationId?: string;
|
|
9
|
-
agentId?: string;
|
|
10
|
-
parentAgentId?: string | null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type HookSessionContextProvider =
|
|
14
|
-
| HookSessionContext
|
|
15
|
-
| ((input?: HookSessionContextLookup) => HookSessionContext | undefined);
|
|
16
|
-
|
|
17
|
-
function normalized(value: string | undefined): string | undefined {
|
|
18
|
-
const trimmed = value?.trim();
|
|
19
|
-
return trimmed ? trimmed : undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function resolveHookSessionContext(
|
|
23
|
-
provider?: HookSessionContextProvider,
|
|
24
|
-
input?: HookSessionContextLookup,
|
|
25
|
-
): HookSessionContext | undefined {
|
|
26
|
-
if (!provider) {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
const context = typeof provider === "function" ? provider(input) : provider;
|
|
30
|
-
if (!context) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
const rootSessionId = normalized(context.rootSessionId);
|
|
34
|
-
const hookLogPath = normalized(context.hookLogPath);
|
|
35
|
-
if (!rootSessionId && !hookLogPath) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
rootSessionId,
|
|
40
|
-
hookLogPath,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function resolveRootSessionId(
|
|
45
|
-
context: HookSessionContext | undefined,
|
|
46
|
-
): string | undefined {
|
|
47
|
-
return normalized(context?.rootSessionId);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function resolveHookLogPath(
|
|
51
|
-
context: HookSessionContext | undefined,
|
|
52
|
-
): string | undefined {
|
|
53
|
-
return normalized(context?.hookLogPath);
|
|
54
|
-
}
|
package/src/session/records.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export const SESSION_STATUS_VALUES = [
|
|
2
|
-
"running",
|
|
3
|
-
"completed",
|
|
4
|
-
"failed",
|
|
5
|
-
"cancelled",
|
|
6
|
-
] as const;
|
|
7
|
-
|
|
8
|
-
export type SharedSessionStatus = (typeof SESSION_STATUS_VALUES)[number];
|
|
9
|
-
|
|
10
|
-
export interface SessionLineage {
|
|
11
|
-
parentSessionId?: string;
|
|
12
|
-
agentId?: string;
|
|
13
|
-
parentAgentId?: string;
|
|
14
|
-
conversationId?: string;
|
|
15
|
-
isSubagent: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface SessionRuntimeRecordShape extends SessionLineage {
|
|
19
|
-
source: string;
|
|
20
|
-
pid?: number;
|
|
21
|
-
startedAt: string;
|
|
22
|
-
endedAt?: string | null;
|
|
23
|
-
exitCode?: number | null;
|
|
24
|
-
status: SharedSessionStatus;
|
|
25
|
-
interactive: boolean;
|
|
26
|
-
provider: string;
|
|
27
|
-
model: string;
|
|
28
|
-
cwd: string;
|
|
29
|
-
workspaceRoot: string;
|
|
30
|
-
teamName?: string;
|
|
31
|
-
enableTools: boolean;
|
|
32
|
-
enableSpawn: boolean;
|
|
33
|
-
enableTeams: boolean;
|
|
34
|
-
prompt?: string;
|
|
35
|
-
metadata?: Record<string, unknown>;
|
|
36
|
-
transcriptPath?: string;
|
|
37
|
-
hookPath?: string;
|
|
38
|
-
messagesPath?: string;
|
|
39
|
-
updatedAt: string;
|
|
40
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ToolPolicy } from "../llms/tools";
|
|
2
|
-
|
|
3
|
-
export type AgentMode = "act" | "plan";
|
|
4
|
-
|
|
5
|
-
export interface SessionPromptConfig {
|
|
6
|
-
mode?: AgentMode;
|
|
7
|
-
systemPrompt?: string;
|
|
8
|
-
rules?: string;
|
|
9
|
-
maxIterations?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface SessionWorkspaceConfig {
|
|
13
|
-
cwd: string;
|
|
14
|
-
workspaceRoot?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SessionExecutionConfig {
|
|
18
|
-
enableTools: boolean;
|
|
19
|
-
teamName?: string;
|
|
20
|
-
missionLogIntervalSteps?: number;
|
|
21
|
-
missionLogIntervalMs?: number;
|
|
22
|
-
maxConsecutiveMistakes?: number;
|
|
23
|
-
toolPolicies?: Record<string, ToolPolicy>;
|
|
24
|
-
}
|
package/src/storage/index.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
AGENT_CONFIG_DIRECTORY_NAME,
|
|
3
|
-
CLINE_MCP_SETTINGS_FILE_NAME,
|
|
4
|
-
discoverPluginModulePaths,
|
|
5
|
-
ensureHookLogDir,
|
|
6
|
-
ensureParentDir,
|
|
7
|
-
HOOKS_CONFIG_DIRECTORY_NAME,
|
|
8
|
-
isPluginModulePath,
|
|
9
|
-
RULES_CONFIG_DIRECTORY_NAME,
|
|
10
|
-
resolveAgentConfigSearchPaths,
|
|
11
|
-
resolveAgentsConfigDirPath,
|
|
12
|
-
resolveClineDataDir,
|
|
13
|
-
resolveClineDir,
|
|
14
|
-
resolveConfiguredPluginModulePaths,
|
|
15
|
-
resolveDocumentsAgentConfigDirectoryPath,
|
|
16
|
-
resolveDocumentsClineDirectoryPath,
|
|
17
|
-
resolveDocumentsHooksDirectoryPath,
|
|
18
|
-
resolveDocumentsPluginsDirectoryPath,
|
|
19
|
-
resolveDocumentsRulesDirectoryPath,
|
|
20
|
-
resolveDocumentsWorkflowsDirectoryPath,
|
|
21
|
-
resolveHooksConfigSearchPaths,
|
|
22
|
-
resolveMcpSettingsPath,
|
|
23
|
-
resolvePluginConfigSearchPaths,
|
|
24
|
-
resolvePluginModuleEntries,
|
|
25
|
-
resolveProviderSettingsPath,
|
|
26
|
-
resolveRulesConfigSearchPaths,
|
|
27
|
-
resolveSessionDataDir,
|
|
28
|
-
resolveSkillsConfigSearchPaths,
|
|
29
|
-
resolveTeamDataDir,
|
|
30
|
-
resolveWorkflowsConfigSearchPaths,
|
|
31
|
-
SKILLS_CONFIG_DIRECTORY_NAME,
|
|
32
|
-
setClineDir,
|
|
33
|
-
setClineDirIfUnset,
|
|
34
|
-
setHomeDir,
|
|
35
|
-
setHomeDirIfUnset,
|
|
36
|
-
WORKFLOWS_CONFIG_DIRECTORY_NAME,
|
|
37
|
-
} from "./paths";
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
3
|
-
import {
|
|
4
|
-
AGENT_CONFIG_DIRECTORY_NAME,
|
|
5
|
-
CLINE_MCP_SETTINGS_FILE_NAME,
|
|
6
|
-
resolveAgentsConfigDirPath,
|
|
7
|
-
resolveClineDataDir,
|
|
8
|
-
resolveMcpSettingsPath,
|
|
9
|
-
resolveProviderSettingsPath,
|
|
10
|
-
resolveSessionDataDir,
|
|
11
|
-
resolveTeamDataDir,
|
|
12
|
-
} from "./paths";
|
|
13
|
-
|
|
14
|
-
type EnvSnapshot = {
|
|
15
|
-
CLINE_DATA_DIR: string | undefined;
|
|
16
|
-
CLINE_MCP_SETTINGS_PATH: string | undefined;
|
|
17
|
-
CLINE_PROVIDER_SETTINGS_PATH: string | undefined;
|
|
18
|
-
CLINE_SESSION_DATA_DIR: string | undefined;
|
|
19
|
-
CLINE_TEAM_DATA_DIR: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function captureEnv(): EnvSnapshot {
|
|
23
|
-
return {
|
|
24
|
-
CLINE_DATA_DIR: process.env.CLINE_DATA_DIR,
|
|
25
|
-
CLINE_MCP_SETTINGS_PATH: process.env.CLINE_MCP_SETTINGS_PATH,
|
|
26
|
-
CLINE_PROVIDER_SETTINGS_PATH: process.env.CLINE_PROVIDER_SETTINGS_PATH,
|
|
27
|
-
CLINE_SESSION_DATA_DIR: process.env.CLINE_SESSION_DATA_DIR,
|
|
28
|
-
CLINE_TEAM_DATA_DIR: process.env.CLINE_TEAM_DATA_DIR,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function restoreEnv(snapshot: EnvSnapshot): void {
|
|
33
|
-
process.env.CLINE_DATA_DIR = snapshot.CLINE_DATA_DIR;
|
|
34
|
-
process.env.CLINE_MCP_SETTINGS_PATH = snapshot.CLINE_MCP_SETTINGS_PATH;
|
|
35
|
-
process.env.CLINE_PROVIDER_SETTINGS_PATH =
|
|
36
|
-
snapshot.CLINE_PROVIDER_SETTINGS_PATH;
|
|
37
|
-
process.env.CLINE_SESSION_DATA_DIR = snapshot.CLINE_SESSION_DATA_DIR;
|
|
38
|
-
process.env.CLINE_TEAM_DATA_DIR = snapshot.CLINE_TEAM_DATA_DIR;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
describe("storage path resolution", () => {
|
|
42
|
-
let snapshot: EnvSnapshot = captureEnv();
|
|
43
|
-
|
|
44
|
-
afterEach(() => {
|
|
45
|
-
restoreEnv(snapshot);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("uses CLINE_DATA_DIR as-is when set", () => {
|
|
49
|
-
snapshot = captureEnv();
|
|
50
|
-
process.env.CLINE_DATA_DIR = "/tmp/cline-data";
|
|
51
|
-
|
|
52
|
-
expect(resolveClineDataDir()).toBe("/tmp/cline-data");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("falls back to CLINE_DATA_DIR/sessions for session storage", () => {
|
|
56
|
-
snapshot = captureEnv();
|
|
57
|
-
delete process.env.CLINE_SESSION_DATA_DIR;
|
|
58
|
-
process.env.CLINE_DATA_DIR = "/tmp/cline-data";
|
|
59
|
-
|
|
60
|
-
expect(resolveSessionDataDir()).toBe(join("/tmp/cline-data", "sessions"));
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("falls back to CLINE_DATA_DIR/teams for team storage", () => {
|
|
64
|
-
snapshot = captureEnv();
|
|
65
|
-
delete process.env.CLINE_TEAM_DATA_DIR;
|
|
66
|
-
process.env.CLINE_DATA_DIR = "/tmp/cline-data";
|
|
67
|
-
|
|
68
|
-
expect(resolveTeamDataDir()).toBe(join("/tmp/cline-data", "teams"));
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("falls back to CLINE_DATA_DIR/settings/providers.json for provider settings", () => {
|
|
72
|
-
snapshot = captureEnv();
|
|
73
|
-
delete process.env.CLINE_PROVIDER_SETTINGS_PATH;
|
|
74
|
-
process.env.CLINE_DATA_DIR = "/tmp/cline-data";
|
|
75
|
-
|
|
76
|
-
expect(resolveProviderSettingsPath()).toBe(
|
|
77
|
-
join("/tmp/cline-data", "settings", "providers.json"),
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("falls back to CLINE_DATA_DIR/settings/cline_mcp_settings.json for MCP settings", () => {
|
|
82
|
-
snapshot = captureEnv();
|
|
83
|
-
delete process.env.CLINE_MCP_SETTINGS_PATH;
|
|
84
|
-
process.env.CLINE_DATA_DIR = "/tmp/cline-data";
|
|
85
|
-
|
|
86
|
-
expect(resolveMcpSettingsPath()).toBe(
|
|
87
|
-
join("/tmp/cline-data", "settings", CLINE_MCP_SETTINGS_FILE_NAME),
|
|
88
|
-
);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("falls back to CLINE_DATA_DIR/settings/agents for agent configs", () => {
|
|
92
|
-
snapshot = captureEnv();
|
|
93
|
-
process.env.CLINE_DATA_DIR = "/tmp/cline-data";
|
|
94
|
-
|
|
95
|
-
expect(resolveAgentsConfigDirPath()).toBe(
|
|
96
|
-
join("/tmp/cline-data", "settings", AGENT_CONFIG_DIRECTORY_NAME),
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
});
|