@cline/core 0.0.60 → 0.0.61

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.
@@ -4,7 +4,7 @@
4
4
  * NOTE: This module uses Node.js crypto and http for the OAuth callback.
5
5
  * It is only intended for CLI use, not browser environments.
6
6
  */
7
- import type { ITelemetryService } from "@cline/shared";
7
+ import { type ITelemetryService } from "@cline/shared";
8
8
  import type { OAuthCredentials, OAuthPrompt } from "./types";
9
9
  export declare const OPENAI_CODEX_OAUTH_CONFIG: {
10
10
  readonly authorizationEndpoint: "https://auth.openai.com/oauth/authorize";
@@ -1,4 +1,4 @@
1
- import type { ITelemetryService } from "@cline/shared";
1
+ import { type ITelemetryService } from "@cline/shared";
2
2
  import type { OAuthCredentials, OAuthLoginCallbacks, OcaOAuthProviderOptions, OcaTokenResolution } from "./types";
3
3
  export declare const DEFAULT_INTERNAL_IDCS_CLIENT_ID = "a8331954c0cf48ba99b5dd223a14c6ea";
4
4
  export declare const DEFAULT_INTERNAL_IDCS_URL = "https://idcs-9dc693e80d9b469480d7afe00e743931.identity.oraclecloud.com";
@@ -16,7 +16,6 @@ export type ParseAuthorizationInputOptions = {
16
16
  allowHashCodeState?: boolean;
17
17
  };
18
18
  export declare function parseAuthorizationInput(input: string, options?: ParseAuthorizationInputOptions): ParsedAuthorizationInput;
19
- export declare function decodeJwtPayload(token?: string): Record<string, unknown> | null;
20
19
  export declare function parseOAuthError(text: string): {
21
20
  code?: string;
22
21
  message?: string;
@@ -1,12 +1,14 @@
1
- import type { ToolResultContent } from "@cline/llms";
1
+ import type { ModelInfo, ToolResultContent } from "@cline/llms";
2
2
  import { CHARS_PER_TOKEN, estimateTokens, type MessageWithMetadata } from "@cline/shared";
3
3
  export { CHARS_PER_TOKEN, estimateTokens };
4
- import type { CoreCompactionContext, CoreCompactionSummarizerConfig } from "../../types/config";
4
+ import type { CoreCompactionSummarizerConfig } from "../../types/config";
5
5
  import type { ProviderConfig } from "../../types/provider-settings";
6
6
  export declare const DEFAULT_MAX_INPUT_TOKENS = 128000;
7
- export declare const DEFAULT_THRESHOLD_RATIO = 0.9;
7
+ /** Estimate the usable input share when only a context window is reported. */
8
+ export declare const CONTEXT_WINDOW_INPUT_RATIO = 0.9;
9
+ /** Compact once the transcript consumes this share of the usable input budget. */
10
+ export declare const COMPACTION_TRIGGER_RATIO = 0.9;
8
11
  export declare const DEFAULT_TARGET_RATIO = 0.7;
9
- export declare const DEFAULT_RESERVE_TOKENS = 16384;
10
12
  export declare const DEFAULT_PRESERVE_RECENT_TOKENS = 20000;
11
13
  export declare const DEFAULT_SUMMARY_MAX_OUTPUT_TOKENS = 1024;
12
14
  export declare const TOOL_RESULT_CHAR_LIMIT = 2000;
@@ -24,6 +26,12 @@ export interface CompactionSummaryMetadata {
24
26
  generatedAt: number;
25
27
  }
26
28
  export type EstimateMessageTokens = (message: MessageWithMetadata) => number;
29
+ /**
30
+ * Resolve the model's usable prompt budget. A reported input limit is
31
+ * authoritative but cannot exceed the context window. When the model only
32
+ * reports a context window, retain a conservative margin for request overhead.
33
+ */
34
+ export declare function resolveEffectiveMaxInputTokens(input: Pick<ModelInfo, "maxInputTokens" | "contextWindow">): number | undefined;
27
35
  export declare function truncateText(text: string, limit: number): string;
28
36
  export declare function flattenToolResultContent(content: ToolResultContent["content"]): string;
29
37
  export declare function truncateToolResultContentForCompaction(content: ToolResultContent["content"]): ToolResultContent["content"];
@@ -59,4 +67,3 @@ export declare function buildSummaryMessage(options: {
59
67
  fileOps: FileOperationSummary;
60
68
  tokensBefore: number;
61
69
  }): MessageWithMetadata;
62
- export declare function getMaxInputTokens(context: Pick<CoreCompactionContext, "maxInputTokens">): number;
@@ -1,5 +1,5 @@
1
1
  import { type SessionCompactionState } from "../../session/models/session-compaction";
2
- import type { CoreCompactionContext, CoreSessionConfig } from "../../types/config";
2
+ import type { CoreCompactionContext, CoreCompactionMode, CoreSessionConfig } from "../../types/config";
3
3
  export interface ContextPipelinePrepareTurnInput {
4
4
  agentId: string;
5
5
  conversationId: string;
@@ -18,9 +18,8 @@ export interface ContextPipelinePrepareTurnResult {
18
18
  systemPrompt?: string;
19
19
  }
20
20
  export type ContextPipelinePrepareTurn = (context: ContextPipelinePrepareTurnInput) => Promise<ContextPipelinePrepareTurnResult | undefined>;
21
- export type ContextCompactionMode = "auto" | "manual";
22
21
  export interface ContextCompactionPrepareTurnOptions {
23
- mode?: ContextCompactionMode;
22
+ mode?: CoreCompactionMode;
24
23
  manualTargetRatio?: number;
25
24
  }
26
25
  /**
@@ -6,6 +6,13 @@
6
6
  * wrapper form used by older prompts.
7
7
  */
8
8
  import type { ApplyPatchExecutor } from "../types";
9
+ import { PatchActionType } from "./apply-patch-parser";
10
+ export interface PatchFileChange {
11
+ type: PatchActionType;
12
+ oldContent?: string;
13
+ newContent?: string;
14
+ movePath?: string;
15
+ }
9
16
  /**
10
17
  * Options for the apply_patch executor
11
18
  */
@@ -22,6 +29,16 @@ export interface ApplyPatchExecutorOptions {
22
29
  */
23
30
  restrictToCwd?: boolean;
24
31
  }
32
+ /**
33
+ * Parse a patch and compute the per-file changes it would apply, without
34
+ * writing anything to disk. Reads the current contents of the files the patch
35
+ * references. Exposed so hosts can preview a patch (e.g. in a diff editor)
36
+ * before the executor applies it.
37
+ */
38
+ export declare function computePatchChanges(patchText: string, cwd: string, options?: ApplyPatchExecutorOptions): Promise<{
39
+ changes: Record<string, PatchFileChange>;
40
+ fuzz: number;
41
+ }>;
25
42
  /**
26
43
  * Create an apply_patch executor using Node.js fs module.
27
44
  */
@@ -12,8 +12,9 @@ import { type EditorExecutorOptions } from "./editor";
12
12
  import { type FileReadExecutorOptions } from "./file-read";
13
13
  import { type SearchExecutorOptions } from "./search";
14
14
  import { type WebFetchExecutorOptions } from "./web-fetch";
15
- export { type ApplyPatchExecutorOptions, createApplyPatchExecutor, } from "./apply-patch";
16
- export { type ShellExecutorOptions, createShellExecutor, } from "./bash";
15
+ export { type ApplyPatchExecutorOptions, computePatchChanges, createApplyPatchExecutor, type PatchFileChange, } from "./apply-patch";
16
+ export { PatchActionType } from "./apply-patch-parser";
17
+ export { CommandExitError, createShellExecutor, type ShellExecutorOptions, } from "./bash";
17
18
  export { createEditorExecutor, type EditorExecutorOptions } from "./editor";
18
19
  export { createFileReadExecutor, type FileReadExecutorOptions, } from "./file-read";
19
20
  export { createSearchExecutor, type SearchExecutorOptions } from "./search";
@@ -6,7 +6,7 @@
6
6
  export { validateWithZod, zodToJsonSchema } from "@cline/shared";
7
7
  export { ALL_DEFAULT_TOOL_NAMES, DefaultToolNames } from "./constants";
8
8
  export { createApplyPatchTool, createAskQuestionTool, createDefaultTools, createEditorTool, createReadFilesTool, createSearchTool, createShellTool, createSkillsTool, createSubmitAndExitTool, createWebFetchTool, } from "./definitions";
9
- export { type ApplyPatchExecutorOptions, createApplyPatchExecutor, createDefaultExecutors, createDefaultShellExecutor, createEditorExecutor, createFileReadExecutor, createSearchExecutor, createShellExecutor, createWebFetchExecutor, type DefaultExecutorsOptions, type EditorExecutorOptions, type FileReadExecutorOptions, type SearchExecutorOptions, type ShellExecutorOptions, type WebFetchExecutorOptions, } from "./executors/index";
9
+ export { type ApplyPatchExecutorOptions, CommandExitError, computePatchChanges, createApplyPatchExecutor, createDefaultExecutors, createDefaultShellExecutor, createEditorExecutor, createFileReadExecutor, createSearchExecutor, createShellExecutor, createWebFetchExecutor, type DefaultExecutorsOptions, type EditorExecutorOptions, type FileReadExecutorOptions, PatchActionType, type PatchFileChange, type SearchExecutorOptions, type ShellExecutorOptions, type WebFetchExecutorOptions, } from "./executors/index";
10
10
  export { MAX_COMMAND_OUTPUT_CHARS, truncateCommandOutput, } from "./executors/output-limits";
11
11
  export { DEFAULT_MODEL_TOOL_ROUTING_RULES, resolveToolRoutingConfig, type ToolRoutingRule, } from "./model-tool-routing";
12
12
  export { createDefaultToolsWithPreset, createToolPoliciesWithPreset, resolveToolPresetName, type ToolPolicyPresetName, type ToolPresetName, ToolPresets, } from "./presets";
@@ -34,26 +34,122 @@ export declare const ReadFilesInputUnionSchema: z.ZodUnion<readonly [z.ZodObject
34
34
  start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
35
35
  end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
36
36
  }, z.core.$strip>>;
37
- }, z.core.$strip>, z.ZodObject<{
37
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
38
38
  path: z.ZodString;
39
39
  start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
40
40
  end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
41
- }, z.core.$strip>, z.ZodArray<z.ZodObject<{
41
+ }, z.core.$strip>, z.ZodPipe<z.ZodObject<{
42
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
43
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
44
+ file_path: z.ZodString;
45
+ }, z.core.$strip>, z.ZodTransform<{
46
+ start_line?: number | null | undefined;
47
+ end_line?: number | null | undefined;
48
+ path: string;
49
+ }, {
50
+ file_path: string;
51
+ start_line?: number | null | undefined;
52
+ end_line?: number | null | undefined;
53
+ }>>, z.ZodPipe<z.ZodObject<{
54
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
55
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
56
+ filePath: z.ZodString;
57
+ }, z.core.$strip>, z.ZodTransform<{
58
+ start_line?: number | null | undefined;
59
+ end_line?: number | null | undefined;
60
+ path: string;
61
+ }, {
62
+ filePath: string;
63
+ start_line?: number | null | undefined;
64
+ end_line?: number | null | undefined;
65
+ }>>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
42
66
  path: z.ZodString;
43
67
  start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
44
68
  end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
45
- }, z.core.$strip>>, z.ZodArray<z.ZodString>, z.ZodString, z.ZodObject<{
46
- files: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
69
+ }, z.core.$strip>, z.ZodPipe<z.ZodObject<{
70
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
71
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
72
+ file_path: z.ZodString;
73
+ }, z.core.$strip>, z.ZodTransform<{
74
+ start_line?: number | null | undefined;
75
+ end_line?: number | null | undefined;
76
+ path: string;
77
+ }, {
78
+ file_path: string;
79
+ start_line?: number | null | undefined;
80
+ end_line?: number | null | undefined;
81
+ }>>, z.ZodPipe<z.ZodObject<{
82
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
83
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
84
+ filePath: z.ZodString;
85
+ }, z.core.$strip>, z.ZodTransform<{
86
+ start_line?: number | null | undefined;
87
+ end_line?: number | null | undefined;
88
+ path: string;
89
+ }, {
90
+ filePath: string;
91
+ start_line?: number | null | undefined;
92
+ end_line?: number | null | undefined;
93
+ }>>]>>, z.ZodArray<z.ZodString>, z.ZodString, z.ZodObject<{
94
+ files: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
47
95
  path: z.ZodString;
48
96
  start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
49
97
  end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
50
- }, z.core.$strip>]>>;
98
+ }, z.core.$strip>, z.ZodPipe<z.ZodObject<{
99
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
100
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
101
+ file_path: z.ZodString;
102
+ }, z.core.$strip>, z.ZodTransform<{
103
+ start_line?: number | null | undefined;
104
+ end_line?: number | null | undefined;
105
+ path: string;
106
+ }, {
107
+ file_path: string;
108
+ start_line?: number | null | undefined;
109
+ end_line?: number | null | undefined;
110
+ }>>, z.ZodPipe<z.ZodObject<{
111
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
112
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
113
+ filePath: z.ZodString;
114
+ }, z.core.$strip>, z.ZodTransform<{
115
+ start_line?: number | null | undefined;
116
+ end_line?: number | null | undefined;
117
+ path: string;
118
+ }, {
119
+ filePath: string;
120
+ start_line?: number | null | undefined;
121
+ end_line?: number | null | undefined;
122
+ }>>]>]>>;
51
123
  }, z.core.$strip>, z.ZodObject<{
52
- files: z.ZodObject<{
124
+ files: z.ZodUnion<readonly [z.ZodObject<{
53
125
  path: z.ZodString;
54
126
  start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
55
127
  end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
56
- }, z.core.$strip>;
128
+ }, z.core.$strip>, z.ZodPipe<z.ZodObject<{
129
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
130
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
131
+ file_path: z.ZodString;
132
+ }, z.core.$strip>, z.ZodTransform<{
133
+ start_line?: number | null | undefined;
134
+ end_line?: number | null | undefined;
135
+ path: string;
136
+ }, {
137
+ file_path: string;
138
+ start_line?: number | null | undefined;
139
+ end_line?: number | null | undefined;
140
+ }>>, z.ZodPipe<z.ZodObject<{
141
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
142
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
143
+ filePath: z.ZodString;
144
+ }, z.core.$strip>, z.ZodTransform<{
145
+ start_line?: number | null | undefined;
146
+ end_line?: number | null | undefined;
147
+ path: string;
148
+ }, {
149
+ filePath: string;
150
+ start_line?: number | null | undefined;
151
+ end_line?: number | null | undefined;
152
+ }>>]>;
57
153
  }, z.core.$strip>, z.ZodObject<{
58
154
  files: z.ZodString;
59
155
  }, z.core.$strip>, z.ZodObject<{
@@ -61,17 +157,65 @@ export declare const ReadFilesInputUnionSchema: z.ZodUnion<readonly [z.ZodObject
61
157
  }, z.core.$strip>, z.ZodObject<{
62
158
  file_paths: z.ZodString;
63
159
  }, z.core.$strip>, z.ZodObject<{
64
- paths: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
160
+ paths: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
65
161
  path: z.ZodString;
66
162
  start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
67
163
  end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
68
- }, z.core.$strip>]>>;
164
+ }, z.core.$strip>, z.ZodPipe<z.ZodObject<{
165
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
166
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
167
+ file_path: z.ZodString;
168
+ }, z.core.$strip>, z.ZodTransform<{
169
+ start_line?: number | null | undefined;
170
+ end_line?: number | null | undefined;
171
+ path: string;
172
+ }, {
173
+ file_path: string;
174
+ start_line?: number | null | undefined;
175
+ end_line?: number | null | undefined;
176
+ }>>, z.ZodPipe<z.ZodObject<{
177
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
178
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
179
+ filePath: z.ZodString;
180
+ }, z.core.$strip>, z.ZodTransform<{
181
+ start_line?: number | null | undefined;
182
+ end_line?: number | null | undefined;
183
+ path: string;
184
+ }, {
185
+ filePath: string;
186
+ start_line?: number | null | undefined;
187
+ end_line?: number | null | undefined;
188
+ }>>]>]>>;
69
189
  }, z.core.$strip>, z.ZodObject<{
70
- paths: z.ZodObject<{
190
+ paths: z.ZodUnion<readonly [z.ZodObject<{
71
191
  path: z.ZodString;
72
192
  start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
73
193
  end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
74
- }, z.core.$strip>;
194
+ }, z.core.$strip>, z.ZodPipe<z.ZodObject<{
195
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
196
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
197
+ file_path: z.ZodString;
198
+ }, z.core.$strip>, z.ZodTransform<{
199
+ start_line?: number | null | undefined;
200
+ end_line?: number | null | undefined;
201
+ path: string;
202
+ }, {
203
+ file_path: string;
204
+ start_line?: number | null | undefined;
205
+ end_line?: number | null | undefined;
206
+ }>>, z.ZodPipe<z.ZodObject<{
207
+ start_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
208
+ end_line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
209
+ filePath: z.ZodString;
210
+ }, z.core.$strip>, z.ZodTransform<{
211
+ start_line?: number | null | undefined;
212
+ end_line?: number | null | undefined;
213
+ path: string;
214
+ }, {
215
+ filePath: string;
216
+ start_line?: number | null | undefined;
217
+ end_line?: number | null | undefined;
218
+ }>>]>;
75
219
  }, z.core.$strip>, z.ZodObject<{
76
220
  paths: z.ZodString;
77
221
  }, z.core.$strip>]>;