@cjhyy/code-shell 0.1.0-alpha.3 → 0.1.5
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/CHANGELOG.md +77 -0
- package/dist/anthropic-IBTI4WL2.cjs +10 -0
- package/dist/anthropic-PRZZKHEZ.js +10 -0
- package/dist/arena/index.cjs +7 -6
- package/dist/arena/index.js +6 -5
- package/dist/arena/model-presets.d.ts +10 -1
- package/dist/{arena-HHDYYVHJ.cjs → arena-KBQOPLFV.cjs} +25 -23
- package/dist/{arena-ENHBHB2W.js → arena-O2L4TN6A.js} +9 -7
- package/dist/{chunk-SW3L7HIM.js → chunk-2EP3CLEN.js} +2 -2
- package/dist/{chunk-EL2RL5DG.cjs → chunk-2YW4FPFG.cjs} +2 -2
- package/dist/chunk-3OA5G4TM.js +47 -0
- package/dist/chunk-52LGZKT3.cjs +47 -0
- package/dist/{chunk-KOGV6PDQ.cjs → chunk-55XGPMAP.cjs} +44 -9
- package/dist/chunk-5ECBT4YA.js +450 -0
- package/dist/{chunk-YD7XTI7T.cjs → chunk-6QVAYW7C.cjs} +116 -28
- package/dist/{chunk-SCDKLTN3.js → chunk-6S4BJ65N.js} +5 -4
- package/dist/{chunk-ZLPJJZUW.js → chunk-76HYEPDM.js} +2 -2
- package/dist/{chunk-TDXBHD24.js → chunk-76W334S4.js} +2 -2
- package/dist/{chunk-GZBD6QRS.cjs → chunk-7EG3V4JY.cjs} +13 -12
- package/dist/{chunk-LMEKCQX4.js → chunk-7JVTYEEC.js} +6 -6
- package/dist/{chunk-ID6EJUHP.js → chunk-7K6SDRRF.js} +1262 -212
- package/dist/{chunk-5C5HIOML.js → chunk-7Y6S3OCX.js} +109 -21
- package/dist/{chunk-VIPLU4RY.cjs → chunk-A5LCRPDP.cjs} +4 -4
- package/dist/{chunk-F5BS3GUC.js → chunk-BSW22MPA.js} +39 -4
- package/dist/{chunk-VWFET3MG.cjs → chunk-BUU5PZK2.cjs} +1474 -423
- package/dist/{chunk-HOXQLX5R.cjs → chunk-BWTOS5BH.cjs} +444 -103
- package/dist/{chunk-ZRVPCXI7.js → chunk-BXCY2FSE.js} +2 -1
- package/dist/{chunk-Y7TSCDF6.js → chunk-C5YQBIRK.js} +347 -6
- package/dist/{chunk-C7C7ZZY4.cjs → chunk-HEKQCI7B.cjs} +10 -10
- package/dist/{chunk-JHXNOB5G.cjs → chunk-HS2MFNUC.cjs} +6 -6
- package/dist/{chunk-JHNCK7JP.cjs → chunk-IK4EWJBP.cjs} +4 -3
- package/dist/{chunk-M2QI5X3X.cjs → chunk-JMR33QVF.cjs} +2 -2
- package/dist/{chunk-YAFCN7ZW.cjs → chunk-KOVYSDHZ.cjs} +15 -15
- package/dist/{chunk-IJSHQGMP.cjs → chunk-KS3RYAYL.cjs} +4 -4
- package/dist/{chunk-DI7RDLOS.js → chunk-MD32R22I.js} +7 -4
- package/dist/chunk-MY5XHADU.cjs +216 -0
- package/dist/{chunk-OP57WUWQ.cjs → chunk-NUNC3VFB.cjs} +6 -6
- package/dist/{chunk-BF4LXLQV.cjs → chunk-QRM7IF2S.cjs} +133 -175
- package/dist/chunk-R47ROHGL.cjs +298 -0
- package/dist/{chunk-OUC2DFA7.js → chunk-RMYKO74M.js} +3 -3
- package/dist/{chunk-FUOKLKR2.js → chunk-SFXHZSRF.js} +1 -1
- package/dist/{chunk-2EUAE7AY.js → chunk-SIHHIQLO.js} +2 -2
- package/dist/{chunk-3CAZIWUA.cjs → chunk-SNT563K3.cjs} +9 -9
- package/dist/{chunk-SK62UVS6.js → chunk-T6VYG46N.js} +1 -1
- package/dist/{chunk-3QR52LL5.cjs → chunk-TUY2T5KP.cjs} +2 -2
- package/dist/{chunk-I57ZD5IQ.js → chunk-VIAGTYYW.js} +1 -1
- package/dist/{chunk-X2DNIMPC.cjs → chunk-VYL4EFRC.cjs} +32 -32
- package/dist/chunk-W22P377T.js +299 -0
- package/dist/chunk-WASS5YWB.js +215 -0
- package/dist/{chunk-FPFTIKEJ.js → chunk-XDIQWQJ4.js} +132 -174
- package/dist/{chunk-BUJ5KYCI.cjs → chunk-YIQBXAYU.cjs} +13 -13
- package/dist/{chunk-REFCCVDM.js → chunk-YJ77GQK5.js} +2 -2
- package/dist/chunk-YUI524OE.cjs +450 -0
- package/dist/{chunk-M2SVOKC6.js → chunk-ZBPSQCPU.js} +6 -6
- package/dist/cli/commands/builtin/export-md.d.ts +19 -0
- package/dist/cli/commands/builtin/init/detect.d.ts +25 -0
- package/dist/cli/commands/builtin/init/index.d.ts +19 -0
- package/dist/cli/main.cjs +2343 -1447
- package/dist/cli/main.js +2476 -1580
- package/dist/cli/migrate-models.d.ts +45 -0
- package/dist/cli/onboarding.d.ts +110 -5
- package/dist/cli/updater.d.ts +51 -4
- package/dist/client-base-HTF236ZD.cjs +9 -0
- package/dist/client-base-QKRKCOWB.js +9 -0
- package/dist/{compaction-YNWCEF7B.js → compaction-6VU2T643.js} +4 -2
- package/dist/compaction-OKUNTCA7.cjs +33 -0
- package/dist/context/compaction.d.ts +35 -3
- package/dist/context/manager.d.ts +40 -3
- package/dist/context/tool-result-storage.d.ts +96 -0
- package/dist/devtools-T2NIZBJK.cjs +6 -0
- package/dist/{devtools-IRQQPIRY.js → devtools-YXWHOVKR.js} +1 -1
- package/dist/engine/engine.d.ts +40 -0
- package/dist/engine/turn-loop.d.ts +6 -0
- package/dist/export-md-RXDW6F5W.cjs +135 -0
- package/dist/export-md-XXKZANW5.js +135 -0
- package/dist/file-history-KYPE3ECT.cjs +7 -0
- package/dist/file-history-LF4F7X26.js +7 -0
- package/dist/index.cjs +42 -22
- package/dist/index.d.ts +5 -2
- package/dist/index.js +40 -20
- package/dist/llm/client-base.d.ts +1 -1
- package/dist/llm/model-cache.d.ts +21 -0
- package/dist/llm/model-fetcher.d.ts +29 -0
- package/dist/llm/model-pool.d.ts +13 -0
- package/dist/llm/provider-catalog.d.ts +30 -0
- package/dist/llm/provider-kinds.d.ts +21 -0
- package/dist/llm/types.d.ts +8 -0
- package/dist/logging/session-recorder.d.ts +77 -0
- package/dist/manager-C2IUXKRC.js +7 -0
- package/dist/manager-YYKWYTRM.cjs +7 -0
- package/dist/mcp-manager-QMKWPBZ4.js +8 -0
- package/dist/mcp-manager-Z3OKI74O.cjs +8 -0
- package/dist/memory-5LWZ6FI2.cjs +9 -0
- package/dist/{memory-EPFDBPII.js → memory-VIJLBAMQ.js} +2 -2
- package/dist/model-cache-5KIYL5SL.js +13 -0
- package/dist/model-cache-OED3IM4R.cjs +13 -0
- package/dist/model-fetcher-HKGICACL.js +8 -0
- package/dist/model-fetcher-UR6WJOQP.cjs +8 -0
- package/dist/openai-JR2WEKOF.js +10 -0
- package/dist/openai-YBTOET4O.cjs +10 -0
- package/dist/openrouter-models-OU4GRZQY.cjs +15 -0
- package/dist/{openrouter-models-2FM3H4SQ.js → openrouter-models-TGKDKY52.js} +2 -2
- package/dist/openrouter-sync-BBHUM3R6.cjs +11 -0
- package/dist/{openrouter-sync-SO3AWEAM.js → openrouter-sync-UXUSJCIR.js} +3 -3
- package/dist/product/index.cjs +17 -15
- package/dist/product/index.js +16 -14
- package/dist/protocol/server.d.ts +3 -1
- package/dist/protocol/types.d.ts +36 -2
- package/dist/run/index.cjs +17 -15
- package/dist/run/index.js +16 -14
- package/dist/services/index.d.ts +0 -1
- package/dist/session-manager-Q22BBMD3.js +8 -0
- package/dist/session-manager-XODQVL3C.cjs +8 -0
- package/dist/settings/schema.d.ts +267 -42
- package/dist/{tool-summary-RYNR4DDB.cjs → tool-summary-63DPIS7G.cjs} +4 -4
- package/dist/{tool-summary-2RUFL5QK.js → tool-summary-NP5CDBKG.js} +2 -2
- package/dist/tool-system/builtin/ask-user.d.ts +9 -1
- package/dist/tool-system/context.d.ts +31 -2
- package/dist/tool-system/executor.d.ts +4 -0
- package/dist/tool-system/investigation-guard.d.ts +37 -0
- package/dist/types.d.ts +13 -2
- package/dist/ui/components/AskUserPrompt.d.ts +8 -1
- package/dist/ui/components/DiffLine.d.ts +33 -0
- package/dist/ui/components/ModelManager.d.ts +34 -1
- package/dist/ui/components/OnboardingPrompt.d.ts +10 -1
- package/dist/ui/components/ProviderModelFlow.d.ts +58 -0
- package/dist/ui/components/UpdateBanner.d.ts +1 -0
- package/dist/updater-QW473OF4.cjs +17 -0
- package/dist/updater-VFUAHCVY.js +17 -0
- package/dist/utils/semver.d.ts +1 -0
- package/dist/utils/task-sanitizer.d.ts +6 -0
- package/package.json +1 -1
- package/dist/anthropic-P5VETAFI.cjs +0 -10
- package/dist/anthropic-W2GU3D76.js +0 -10
- package/dist/chunk-75E4BBFC.js +0 -224
- package/dist/chunk-FV2ARONZ.cjs +0 -224
- package/dist/client-base-TOVE25FA.js +0 -9
- package/dist/client-base-VDDIADAC.cjs +0 -9
- package/dist/compaction-D3KV2NWY.cjs +0 -31
- package/dist/devtools-WTC3NFNE.cjs +0 -6
- package/dist/file-history-HZWO2WQ5.js +0 -7
- package/dist/file-history-UQQILIY7.cjs +0 -7
- package/dist/manager-FWLOVEEK.cjs +0 -7
- package/dist/manager-GEXJLOIS.js +0 -7
- package/dist/mcp-manager-37GQLFGX.js +0 -8
- package/dist/mcp-manager-U77NEXBY.cjs +0 -8
- package/dist/memory-ADGOWADP.cjs +0 -9
- package/dist/openai-RXU5URYI.js +0 -10
- package/dist/openai-SQW4H2K4.cjs +0 -10
- package/dist/openrouter-models-PLCWZZYE.cjs +0 -15
- package/dist/openrouter-sync-K2WK3A2A.cjs +0 -11
- package/dist/services/compact.d.ts +0 -56
- package/dist/session-manager-HRSKENKB.cjs +0 -8
- package/dist/session-manager-NEKFEHF3.js +0 -8
- package/dist/updater-J7L7R6BY.cjs +0 -185
- package/dist/updater-LDBNYCAO.js +0 -185
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-MD32R22I.js";
|
|
4
|
+
|
|
5
|
+
// src/settings/manager.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
import {
|
|
8
|
+
readFileSync,
|
|
9
|
+
existsSync,
|
|
10
|
+
mkdirSync,
|
|
11
|
+
writeFileSync,
|
|
12
|
+
renameSync,
|
|
13
|
+
copyFileSync
|
|
14
|
+
} from "fs";
|
|
15
|
+
import { join, dirname } from "path";
|
|
16
|
+
import { homedir } from "os";
|
|
17
|
+
|
|
18
|
+
// src/settings/schema.ts
|
|
19
|
+
init_esm_shims();
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
var SettingsSchema = z.object({
|
|
22
|
+
agent: z.object({
|
|
23
|
+
// Use z.string() instead of z.enum() to allow custom presets registered via registerPreset()
|
|
24
|
+
preset: z.string().default("terminal-coding"),
|
|
25
|
+
enabledBuiltinTools: z.array(z.string()).default([]),
|
|
26
|
+
disabledBuiltinTools: z.array(z.string()).default([]),
|
|
27
|
+
customSystemPrompt: z.string().optional(),
|
|
28
|
+
appendSystemPrompt: z.string().optional()
|
|
29
|
+
}).default({}),
|
|
30
|
+
/**
|
|
31
|
+
* Primary source of truth for the active model is settings.activeKey
|
|
32
|
+
* (points at models[].key). settings.model is a derived mirror of that
|
|
33
|
+
* entry kept in sync for legacy boot paths (cli/main.ts, repl.ts, etc.)
|
|
34
|
+
* which read provider/name/apiKey/baseUrl directly. Writers must update
|
|
35
|
+
* both — appendOnboardingResult does this in one shot.
|
|
36
|
+
*/
|
|
37
|
+
activeKey: z.string().optional(),
|
|
38
|
+
/**
|
|
39
|
+
* Toggle background auto-update. When true (default), code-shell checks
|
|
40
|
+
* npm for newer versions and — if the npm global prefix is writable —
|
|
41
|
+
* installs the update in the background on process exit so the next
|
|
42
|
+
* launch picks it up.
|
|
43
|
+
* Can also be disabled via env var `DISABLE_AUTOUPDATER=1`.
|
|
44
|
+
*/
|
|
45
|
+
autoUpdates: z.boolean().default(true),
|
|
46
|
+
model: z.object({
|
|
47
|
+
provider: z.string().default("openai"),
|
|
48
|
+
name: z.string().default("anthropic/claude-opus-4-6"),
|
|
49
|
+
apiKey: z.string().optional(),
|
|
50
|
+
baseUrl: z.string().default("https://openrouter.ai/api/v1"),
|
|
51
|
+
temperature: z.number().min(0).max(2).default(0.3),
|
|
52
|
+
maxTokens: z.number().default(8192)
|
|
53
|
+
}).default({}),
|
|
54
|
+
providers: z.array(
|
|
55
|
+
z.object({
|
|
56
|
+
key: z.string(),
|
|
57
|
+
label: z.string().optional(),
|
|
58
|
+
kind: z.enum([
|
|
59
|
+
"openai",
|
|
60
|
+
"anthropic",
|
|
61
|
+
"deepseek",
|
|
62
|
+
"xai",
|
|
63
|
+
"mistral",
|
|
64
|
+
"groq",
|
|
65
|
+
"google",
|
|
66
|
+
"openrouter",
|
|
67
|
+
"ollama",
|
|
68
|
+
"custom"
|
|
69
|
+
]),
|
|
70
|
+
baseUrl: z.string(),
|
|
71
|
+
apiKey: z.string().optional(),
|
|
72
|
+
protocol: z.enum(["openai-compat", "anthropic-style"]).optional(),
|
|
73
|
+
modelsPath: z.string().optional()
|
|
74
|
+
})
|
|
75
|
+
).default([]),
|
|
76
|
+
models: z.array(
|
|
77
|
+
z.object({
|
|
78
|
+
key: z.string(),
|
|
79
|
+
label: z.string().optional(),
|
|
80
|
+
providerKey: z.string().optional(),
|
|
81
|
+
model: z.string(),
|
|
82
|
+
maxOutputTokens: z.number().optional(),
|
|
83
|
+
maxContextTokens: z.number().optional(),
|
|
84
|
+
/**
|
|
85
|
+
* Which LLM client to use ("openai" or "anthropic"). New name —
|
|
86
|
+
* the legacy field is `provider`, which we still accept and
|
|
87
|
+
* fold into `protocol` below so old configs keep working.
|
|
88
|
+
* NOT the brand/vendor — that's providerKey above.
|
|
89
|
+
*/
|
|
90
|
+
protocol: z.string().optional(),
|
|
91
|
+
provider: z.string().optional(),
|
|
92
|
+
baseUrl: z.string().optional(),
|
|
93
|
+
apiKey: z.string().optional()
|
|
94
|
+
}).transform((m) => {
|
|
95
|
+
const effective = m.protocol ?? m.provider;
|
|
96
|
+
return {
|
|
97
|
+
...m,
|
|
98
|
+
protocol: effective,
|
|
99
|
+
provider: effective
|
|
100
|
+
};
|
|
101
|
+
})
|
|
102
|
+
).default([]),
|
|
103
|
+
permissions: z.object({
|
|
104
|
+
defaultMode: z.enum(["default", "acceptEdits", "dontAsk", "bypassPermissions", "auto", "plan"]).default("default"),
|
|
105
|
+
rules: z.array(
|
|
106
|
+
z.object({
|
|
107
|
+
tool: z.string(),
|
|
108
|
+
argsPattern: z.record(z.string()).optional(),
|
|
109
|
+
decision: z.enum(["allow", "deny", "ask"]),
|
|
110
|
+
reason: z.string().optional()
|
|
111
|
+
})
|
|
112
|
+
).default([])
|
|
113
|
+
}).default({}),
|
|
114
|
+
context: z.object({
|
|
115
|
+
maxTokens: z.number().default(2e5),
|
|
116
|
+
compactAtRatio: z.number().default(0.6),
|
|
117
|
+
summarizeAtRatio: z.number().default(0.8)
|
|
118
|
+
}).default({}),
|
|
119
|
+
session: z.object({
|
|
120
|
+
storageDir: z.string().optional(),
|
|
121
|
+
maxHistory: z.number().default(100)
|
|
122
|
+
}).default({}),
|
|
123
|
+
mcpServers: z.record(
|
|
124
|
+
z.object({
|
|
125
|
+
name: z.string(),
|
|
126
|
+
command: z.string().optional(),
|
|
127
|
+
args: z.array(z.string()).optional(),
|
|
128
|
+
env: z.record(z.string()).optional(),
|
|
129
|
+
url: z.string().optional(),
|
|
130
|
+
transport: z.enum(["stdio", "sse", "streamable-http", "inprocess"]).optional(),
|
|
131
|
+
headers: z.record(z.string()).optional()
|
|
132
|
+
})
|
|
133
|
+
).default({}),
|
|
134
|
+
instructions: z.object({
|
|
135
|
+
fileName: z.string().default("CODESHELL.md"),
|
|
136
|
+
scanDirs: z.array(z.string()).default([]),
|
|
137
|
+
compatFileNames: z.array(z.string()).default(["CLAUDE.md", "AGENTS.md"]),
|
|
138
|
+
ignoreGitBoundary: z.boolean().default(false)
|
|
139
|
+
}).default({}),
|
|
140
|
+
arena: z.object({
|
|
141
|
+
participants: z.array(
|
|
142
|
+
z.union([
|
|
143
|
+
// Short form: just a model pool key
|
|
144
|
+
z.string(),
|
|
145
|
+
// Full form: explicit config (backward compat)
|
|
146
|
+
z.object({
|
|
147
|
+
name: z.string(),
|
|
148
|
+
model: z.string(),
|
|
149
|
+
provider: z.string().optional(),
|
|
150
|
+
apiKey: z.string().optional(),
|
|
151
|
+
baseUrl: z.string().optional()
|
|
152
|
+
})
|
|
153
|
+
])
|
|
154
|
+
).default([])
|
|
155
|
+
}).default({}),
|
|
156
|
+
search: z.object({
|
|
157
|
+
provider: z.enum(["serper", "tavily", "searxng"]).default("serper"),
|
|
158
|
+
apiKey: z.string().optional(),
|
|
159
|
+
baseUrl: z.string().optional()
|
|
160
|
+
}).default({}),
|
|
161
|
+
output: z.object({
|
|
162
|
+
format: z.enum(["text", "json", "jsonl", "stream-json"]).default("text")
|
|
163
|
+
}).default({})
|
|
164
|
+
}).passthrough();
|
|
165
|
+
function validateSettings(raw) {
|
|
166
|
+
return SettingsSchema.parse(raw);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/cli/migrate-models.ts
|
|
170
|
+
init_esm_shims();
|
|
171
|
+
var BASEURL_KIND_PATTERNS = [
|
|
172
|
+
[/deepseek\.com/i, "deepseek"],
|
|
173
|
+
[/anthropic\.com/i, "anthropic"],
|
|
174
|
+
[/openai\.com/i, "openai"],
|
|
175
|
+
[/x\.ai/i, "xai"],
|
|
176
|
+
[/mistral\.ai/i, "mistral"],
|
|
177
|
+
[/groq\.com/i, "groq"],
|
|
178
|
+
[/generativelanguage\.googleapis/i, "google"],
|
|
179
|
+
[/openrouter\.ai/i, "openrouter"],
|
|
180
|
+
[/localhost:11434|127\.0\.0\.1:11434/i, "ollama"]
|
|
181
|
+
];
|
|
182
|
+
function inferKind(baseUrl) {
|
|
183
|
+
if (!baseUrl) return "custom";
|
|
184
|
+
for (const [re, kind] of BASEURL_KIND_PATTERNS) {
|
|
185
|
+
if (re.test(baseUrl)) return kind;
|
|
186
|
+
}
|
|
187
|
+
return "custom";
|
|
188
|
+
}
|
|
189
|
+
function makeFingerprint(m) {
|
|
190
|
+
return `${m.provider ?? ""}|${m.baseUrl ?? ""}|${m.apiKey ?? ""}`;
|
|
191
|
+
}
|
|
192
|
+
function deriveKey(base, used) {
|
|
193
|
+
if (!used.has(base)) return base;
|
|
194
|
+
for (let i = 2; ; i++) {
|
|
195
|
+
const candidate = `${base}-${i}`;
|
|
196
|
+
if (!used.has(candidate)) return candidate;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function deriveProviderModelKey(providerKind, modelId, used) {
|
|
200
|
+
const slash = modelId.lastIndexOf("/");
|
|
201
|
+
const base = slash >= 0 ? modelId.slice(slash + 1) : modelId;
|
|
202
|
+
const prefix = providerKind.toLowerCase();
|
|
203
|
+
const candidate = base.toLowerCase().startsWith(`${prefix}-`) ? base : `${prefix}-${base}`;
|
|
204
|
+
if (!used.has(candidate)) return candidate;
|
|
205
|
+
for (let i = 2; ; i++) {
|
|
206
|
+
const k = `${candidate}-${i}`;
|
|
207
|
+
if (!used.has(k)) return k;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function migrateModels(input) {
|
|
211
|
+
if (input.models.length === 0) {
|
|
212
|
+
return {
|
|
213
|
+
providers: input.providers,
|
|
214
|
+
models: [],
|
|
215
|
+
changed: false
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const hasProvidersSection = input.providers.length > 0;
|
|
219
|
+
const keyCounts = /* @__PURE__ */ new Map();
|
|
220
|
+
for (const m of input.models) keyCounts.set(m.key, (keyCounts.get(m.key) ?? 0) + 1);
|
|
221
|
+
const needsMigration = input.models.some(
|
|
222
|
+
(m) => !m.providerKey || (keyCounts.get(m.key) ?? 0) > 1
|
|
223
|
+
);
|
|
224
|
+
if (!needsMigration) {
|
|
225
|
+
return {
|
|
226
|
+
providers: input.providers,
|
|
227
|
+
models: input.models.map((m) => ({
|
|
228
|
+
key: m.key,
|
|
229
|
+
label: m.label,
|
|
230
|
+
providerKey: m.providerKey ?? "",
|
|
231
|
+
model: m.model,
|
|
232
|
+
maxOutputTokens: m.maxOutputTokens,
|
|
233
|
+
maxContextTokens: m.maxContextTokens,
|
|
234
|
+
provider: m.provider,
|
|
235
|
+
baseUrl: m.baseUrl,
|
|
236
|
+
apiKey: m.apiKey
|
|
237
|
+
})),
|
|
238
|
+
changed: false
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const fingerprintToKey = /* @__PURE__ */ new Map();
|
|
242
|
+
const newProviders = [];
|
|
243
|
+
const usedProviderKeys = new Set(input.providers.map((p) => p.key));
|
|
244
|
+
for (const p of input.providers) {
|
|
245
|
+
const fp = `${""}|${p.baseUrl}|${p.apiKey ?? ""}`;
|
|
246
|
+
fingerprintToKey.set(fp, p.key);
|
|
247
|
+
}
|
|
248
|
+
for (const m of input.models) {
|
|
249
|
+
const fp = makeFingerprint(m);
|
|
250
|
+
const existingByUrl = input.providers.find((p) => p.baseUrl === (m.baseUrl ?? ""));
|
|
251
|
+
if (existingByUrl) {
|
|
252
|
+
fingerprintToKey.set(fp, existingByUrl.key);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (fingerprintToKey.has(fp)) continue;
|
|
256
|
+
const kind = inferKind(m.baseUrl);
|
|
257
|
+
const key = deriveKey(kind, usedProviderKeys);
|
|
258
|
+
usedProviderKeys.add(key);
|
|
259
|
+
fingerprintToKey.set(fp, key);
|
|
260
|
+
newProviders.push({
|
|
261
|
+
key,
|
|
262
|
+
kind,
|
|
263
|
+
baseUrl: m.baseUrl ?? "",
|
|
264
|
+
apiKey: m.apiKey
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
const usedModelKeys = /* @__PURE__ */ new Set();
|
|
268
|
+
const newModels = input.models.map((m) => {
|
|
269
|
+
const providerKey = fingerprintToKey.get(makeFingerprint(m));
|
|
270
|
+
const collides = (keyCounts.get(m.key) ?? 0) > 1;
|
|
271
|
+
let key = m.key;
|
|
272
|
+
if (collides) {
|
|
273
|
+
const kind = inferKind(m.baseUrl);
|
|
274
|
+
key = deriveProviderModelKey(kind, m.model, usedModelKeys);
|
|
275
|
+
}
|
|
276
|
+
if (usedModelKeys.has(key)) {
|
|
277
|
+
const kind = inferKind(m.baseUrl);
|
|
278
|
+
key = deriveProviderModelKey(kind, m.model, usedModelKeys);
|
|
279
|
+
}
|
|
280
|
+
usedModelKeys.add(key);
|
|
281
|
+
return {
|
|
282
|
+
key,
|
|
283
|
+
label: m.label,
|
|
284
|
+
providerKey,
|
|
285
|
+
provider: m.provider,
|
|
286
|
+
model: m.model,
|
|
287
|
+
baseUrl: m.baseUrl,
|
|
288
|
+
apiKey: m.apiKey,
|
|
289
|
+
maxOutputTokens: m.maxOutputTokens,
|
|
290
|
+
maxContextTokens: m.maxContextTokens
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
const seen = /* @__PURE__ */ new Set();
|
|
294
|
+
const deduped = newModels.filter((m) => {
|
|
295
|
+
const fp = `${m.key}|${m.model}`;
|
|
296
|
+
if (seen.has(fp)) return false;
|
|
297
|
+
seen.add(fp);
|
|
298
|
+
return true;
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
providers: hasProvidersSection ? [...input.providers, ...newProviders] : newProviders,
|
|
302
|
+
models: deduped,
|
|
303
|
+
changed: true
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// src/settings/manager.ts
|
|
308
|
+
function userHome() {
|
|
309
|
+
return process.env.HOME ?? homedir();
|
|
310
|
+
}
|
|
311
|
+
var SettingsManager = class {
|
|
312
|
+
constructor(cwd = process.cwd()) {
|
|
313
|
+
this.cwd = cwd;
|
|
314
|
+
}
|
|
315
|
+
sources = [];
|
|
316
|
+
merged = null;
|
|
317
|
+
/**
|
|
318
|
+
* Load settings from all sources.
|
|
319
|
+
*/
|
|
320
|
+
load(flagOverrides) {
|
|
321
|
+
this.sources = [];
|
|
322
|
+
this.loadJsonFile(join(userHome(), ".code-shell", "settings.managed.json"), "managed", 0);
|
|
323
|
+
this.loadJsonFile(join(userHome(), ".code-shell", "settings.json"), "user", 1);
|
|
324
|
+
this.loadJsonFile(join(userHome(), ".claude", "settings.json"), "user", 1);
|
|
325
|
+
this.loadJsonFile(join(this.cwd, ".code-shell", "settings.json"), "project", 2);
|
|
326
|
+
this.loadJsonFile(join(this.cwd, ".claude", "settings.json"), "project", 2);
|
|
327
|
+
this.loadJsonFile(join(this.cwd, ".code-shell", "settings.local.json"), "local", 3);
|
|
328
|
+
this.loadJsonFile(join(this.cwd, ".claude", "settings.local.json"), "local", 3);
|
|
329
|
+
if (flagOverrides && Object.keys(flagOverrides).length > 0) {
|
|
330
|
+
this.sources.push({ name: "flag", priority: 4, data: flagOverrides });
|
|
331
|
+
}
|
|
332
|
+
this.sources.sort((a, b) => a.priority - b.priority);
|
|
333
|
+
const raw = this.deepMerge();
|
|
334
|
+
const userPath = join(userHome(), ".code-shell", "settings.json");
|
|
335
|
+
if (existsSync(userPath)) {
|
|
336
|
+
try {
|
|
337
|
+
const userRaw = JSON.parse(readFileSync(userPath, "utf-8"));
|
|
338
|
+
const result = migrateModels({
|
|
339
|
+
providers: userRaw.providers ?? [],
|
|
340
|
+
models: userRaw.models ?? []
|
|
341
|
+
});
|
|
342
|
+
if (result.changed) {
|
|
343
|
+
copyFileSync(userPath, `${userPath}.bak`);
|
|
344
|
+
const migrated = {
|
|
345
|
+
...userRaw,
|
|
346
|
+
providers: result.providers,
|
|
347
|
+
models: result.models
|
|
348
|
+
};
|
|
349
|
+
writeFileSync(userPath, JSON.stringify(migrated, null, 2), "utf-8");
|
|
350
|
+
const userSource = this.sources.find((s) => s.name === "user");
|
|
351
|
+
if (userSource) userSource.data = migrated;
|
|
352
|
+
const remerged = this.deepMerge();
|
|
353
|
+
this.merged = validateSettings(remerged);
|
|
354
|
+
return this.merged;
|
|
355
|
+
}
|
|
356
|
+
} catch {
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
this.merged = validateSettings(raw);
|
|
360
|
+
return this.merged;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Get current effective settings.
|
|
364
|
+
*/
|
|
365
|
+
get() {
|
|
366
|
+
if (!this.merged) return this.load();
|
|
367
|
+
return this.merged;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Invalidate cached merge.
|
|
371
|
+
*/
|
|
372
|
+
invalidate() {
|
|
373
|
+
this.merged = null;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Persist a single setting (dotted key path) to the user-level config file
|
|
377
|
+
* at ~/.code-shell/settings.json. Other sources (project / local /
|
|
378
|
+
* managed) are intentionally untouched: writing back to project/local
|
|
379
|
+
* would surprise version control, and managed is read-only.
|
|
380
|
+
*
|
|
381
|
+
* The merged cache is invalidated so the next get() picks up the change.
|
|
382
|
+
*/
|
|
383
|
+
saveUserSetting(key, value) {
|
|
384
|
+
const path = join(userHome(), ".code-shell", "settings.json");
|
|
385
|
+
let current = {};
|
|
386
|
+
if (existsSync(path)) {
|
|
387
|
+
try {
|
|
388
|
+
const raw = readFileSync(path, "utf-8");
|
|
389
|
+
const parsed = JSON.parse(raw);
|
|
390
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
391
|
+
current = parsed;
|
|
392
|
+
}
|
|
393
|
+
} catch {
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const parts = key.split(".");
|
|
397
|
+
let target = current;
|
|
398
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
399
|
+
const seg = parts[i];
|
|
400
|
+
const next = target[seg];
|
|
401
|
+
if (!next || typeof next !== "object" || Array.isArray(next)) {
|
|
402
|
+
target[seg] = {};
|
|
403
|
+
}
|
|
404
|
+
target = target[seg];
|
|
405
|
+
}
|
|
406
|
+
target[parts[parts.length - 1]] = value;
|
|
407
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
408
|
+
const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
409
|
+
writeFileSync(tmp, JSON.stringify(current, null, 2), "utf-8");
|
|
410
|
+
renameSync(tmp, path);
|
|
411
|
+
this.invalidate();
|
|
412
|
+
}
|
|
413
|
+
loadJsonFile(path, name, priority) {
|
|
414
|
+
if (!existsSync(path)) return;
|
|
415
|
+
try {
|
|
416
|
+
const content = readFileSync(path, "utf-8");
|
|
417
|
+
const data = JSON.parse(content);
|
|
418
|
+
if (typeof data === "object" && data !== null) {
|
|
419
|
+
this.sources.push({ name, priority, data });
|
|
420
|
+
}
|
|
421
|
+
} catch {
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
deepMerge() {
|
|
425
|
+
let result = {};
|
|
426
|
+
for (const source of this.sources) {
|
|
427
|
+
result = merge(result, source.data);
|
|
428
|
+
}
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
function merge(base, override) {
|
|
433
|
+
const result = { ...base };
|
|
434
|
+
for (const [key, value] of Object.entries(override)) {
|
|
435
|
+
if (value === null) {
|
|
436
|
+
delete result[key];
|
|
437
|
+
} else if (typeof value === "object" && !Array.isArray(value) && typeof result[key] === "object" && !Array.isArray(result[key]) && result[key] !== null) {
|
|
438
|
+
result[key] = merge(result[key], value);
|
|
439
|
+
} else {
|
|
440
|
+
result[key] = value;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return result;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export {
|
|
447
|
+
SettingsSchema,
|
|
448
|
+
validateSettings,
|
|
449
|
+
SettingsManager
|
|
450
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkKS3RYAYLcjs = require('./chunk-KS3RYAYL.cjs');
|
|
6
6
|
|
|
7
7
|
// src/context/token-counter.ts
|
|
8
8
|
function estimateStringTokens(text) {
|
|
@@ -48,10 +48,10 @@ function estimateBlockTokens(block) {
|
|
|
48
48
|
return tokens;
|
|
49
49
|
}
|
|
50
50
|
var RATIOS;
|
|
51
|
-
var init_token_counter =
|
|
51
|
+
var init_token_counter = _chunkKS3RYAYLcjs.__esm.call(void 0, {
|
|
52
52
|
"src/context/token-counter.ts"() {
|
|
53
53
|
"use strict";
|
|
54
|
-
|
|
54
|
+
_chunkKS3RYAYLcjs.init_cjs_shims.call(void 0, );
|
|
55
55
|
RATIOS = {
|
|
56
56
|
english: 4,
|
|
57
57
|
// ~4 chars per token for English prose
|
|
@@ -69,7 +69,8 @@ var init_token_counter = _chunkIJSHQGMPcjs.__esm.call(void 0, {
|
|
|
69
69
|
|
|
70
70
|
// src/context/compaction.ts
|
|
71
71
|
var compaction_exports = {};
|
|
72
|
-
|
|
72
|
+
_chunkKS3RYAYLcjs.__export.call(void 0, compaction_exports, {
|
|
73
|
+
COMPACTABLE_TOOL_NAMES: () => COMPACTABLE_TOOL_NAMES,
|
|
73
74
|
adjustIndexToPreserveAPIInvariants: () => adjustIndexToPreserveAPIInvariants,
|
|
74
75
|
applySummaryCompaction: () => applySummaryCompaction,
|
|
75
76
|
applyToolResultBudget: () => applyToolResultBudget,
|
|
@@ -143,35 +144,108 @@ function windowCompact(messages, keepLastN) {
|
|
|
143
144
|
if (startIndex <= 1) return messages;
|
|
144
145
|
return [messages[0], ...messages.slice(startIndex)];
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
const
|
|
147
|
+
function buildToolUseIdToNameMap(messages) {
|
|
148
|
+
const map = /* @__PURE__ */ new Map();
|
|
149
|
+
for (const msg of messages) {
|
|
150
|
+
if (!Array.isArray(msg.content)) continue;
|
|
151
|
+
for (const block of msg.content) {
|
|
152
|
+
if (block.type === "tool_use" && block.id && block.name) {
|
|
153
|
+
map.set(block.id, block.name);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return map;
|
|
158
|
+
}
|
|
159
|
+
function summarizeToolCallArgs(toolName, input) {
|
|
160
|
+
if (!input || typeof input !== "object") return "";
|
|
161
|
+
const pick = (keys) => {
|
|
162
|
+
const parts = [];
|
|
163
|
+
for (const key of keys) {
|
|
164
|
+
const v = input[key];
|
|
165
|
+
if (typeof v === "string" && v.length > 0) {
|
|
166
|
+
parts.push(`${key}=${v.length > 80 ? v.slice(0, 77) + "..." : v}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return parts.join(" ");
|
|
170
|
+
};
|
|
171
|
+
switch (toolName) {
|
|
172
|
+
case "Read":
|
|
173
|
+
case "Write":
|
|
174
|
+
case "Edit":
|
|
175
|
+
case "NotebookEdit":
|
|
176
|
+
return pick(["file_path", "path", "notebook_path"]);
|
|
177
|
+
case "Glob":
|
|
178
|
+
case "Grep":
|
|
179
|
+
return pick(["pattern", "path", "glob"]);
|
|
180
|
+
case "Bash":
|
|
181
|
+
case "PowerShell":
|
|
182
|
+
case "REPL":
|
|
183
|
+
return pick(["command"]);
|
|
184
|
+
case "WebFetch":
|
|
185
|
+
case "WebSearch":
|
|
186
|
+
return pick(["url", "query"]);
|
|
187
|
+
default: {
|
|
188
|
+
const json = JSON.stringify(input);
|
|
189
|
+
return json.length > 100 ? json.slice(0, 97) + "..." : json;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function microcompact(messages, options = {}) {
|
|
194
|
+
const keepRecentN = _nullishCoalesce(options.keepRecentN, () => ( 5));
|
|
195
|
+
const compactable = _nullishCoalesce(options.compactableTools, () => ( COMPACTABLE_TOOL_NAMES));
|
|
196
|
+
const idToName = buildToolUseIdToNameMap(messages);
|
|
197
|
+
const idToInput = /* @__PURE__ */ new Map();
|
|
198
|
+
for (const msg of messages) {
|
|
199
|
+
if (!Array.isArray(msg.content)) continue;
|
|
200
|
+
for (const block of msg.content) {
|
|
201
|
+
if (block.type === "tool_use" && block.id) {
|
|
202
|
+
idToInput.set(block.id, block.input);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let compactableRoundCount = 0;
|
|
207
|
+
const indicesToTouch = [];
|
|
149
208
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
150
209
|
const msg = messages[i];
|
|
151
|
-
if (Array.isArray(msg.content))
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
210
|
+
if (!Array.isArray(msg.content)) continue;
|
|
211
|
+
const hasEligible = msg.content.some(
|
|
212
|
+
(b) => b.type === "tool_result" && b.tool_use_id != null && compactable.has(_nullishCoalesce(idToName.get(b.tool_use_id), () => ( ""))) && typeof b.content === "string" && !b.content.startsWith("[Old tool result cleared")
|
|
213
|
+
);
|
|
214
|
+
if (!hasEligible) continue;
|
|
215
|
+
compactableRoundCount++;
|
|
216
|
+
if (compactableRoundCount > keepRecentN) {
|
|
217
|
+
indicesToTouch.push(i);
|
|
159
218
|
}
|
|
160
219
|
}
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
220
|
+
if (indicesToTouch.length === 0) return messages;
|
|
221
|
+
const touchSet = new Set(indicesToTouch);
|
|
222
|
+
const clearedToolNames = /* @__PURE__ */ new Set();
|
|
223
|
+
let clearedBlocks = 0;
|
|
224
|
+
const result = messages.map((msg, i) => {
|
|
225
|
+
if (!touchSet.has(i) || !Array.isArray(msg.content)) return msg;
|
|
165
226
|
return {
|
|
166
227
|
...msg,
|
|
167
228
|
content: msg.content.map((block) => {
|
|
168
|
-
if (block.type
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return block;
|
|
229
|
+
if (block.type !== "tool_result" || !block.tool_use_id) return block;
|
|
230
|
+
const toolName = idToName.get(block.tool_use_id);
|
|
231
|
+
if (!toolName || !compactable.has(toolName)) return block;
|
|
232
|
+
if (typeof block.content !== "string") return block;
|
|
233
|
+
if (block.content.startsWith("[Old tool result cleared")) return block;
|
|
234
|
+
const argsSummary = summarizeToolCallArgs(toolName, idToInput.get(block.tool_use_id));
|
|
235
|
+
const fingerprint = argsSummary ? `[Old tool result cleared \u2014 ${toolName} ${argsSummary}]` : `[Old tool result cleared \u2014 ${toolName}]`;
|
|
236
|
+
clearedToolNames.add(toolName);
|
|
237
|
+
clearedBlocks++;
|
|
238
|
+
return { ...block, content: fingerprint };
|
|
172
239
|
})
|
|
173
240
|
};
|
|
174
241
|
});
|
|
242
|
+
if (clearedBlocks > 0) {
|
|
243
|
+
_optionalChain([options, 'access', _ => _.onClear, 'optionalCall', _2 => _2({
|
|
244
|
+
clearedRounds: indicesToTouch.length,
|
|
245
|
+
toolNames: [...clearedToolNames].sort()
|
|
246
|
+
})]);
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
175
249
|
}
|
|
176
250
|
function applyToolResultBudget(messages, maxTotalChars = 1e5) {
|
|
177
251
|
return messages.map((msg) => {
|
|
@@ -200,9 +274,10 @@ function applyToolResultBudget(messages, maxTotalChars = 1e5) {
|
|
|
200
274
|
const newContent = msg.content.map((block, i) => {
|
|
201
275
|
if (!toTruncate.has(i)) return block;
|
|
202
276
|
const preview = typeof block.content === "string" ? block.content.slice(0, 500) : "";
|
|
277
|
+
const sizeKb = (block.content.length / 1e3).toFixed(0);
|
|
203
278
|
return {
|
|
204
279
|
...block,
|
|
205
|
-
content: `Output too large (${
|
|
280
|
+
content: `Output too large (${sizeKb}KB) \u2014 truncated to fit the per-message budget. Re-run the originating tool if you need the full output.
|
|
206
281
|
|
|
207
282
|
Preview (first 500 chars):
|
|
208
283
|
${preview}`
|
|
@@ -325,10 +400,22 @@ function extractReferencedFilePaths(messages) {
|
|
|
325
400
|
}
|
|
326
401
|
return [...paths];
|
|
327
402
|
}
|
|
328
|
-
var
|
|
403
|
+
var COMPACTABLE_TOOL_NAMES;
|
|
404
|
+
var init_compaction = _chunkKS3RYAYLcjs.__esm.call(void 0, {
|
|
329
405
|
"src/context/compaction.ts"() {
|
|
330
|
-
|
|
406
|
+
_chunkKS3RYAYLcjs.init_cjs_shims.call(void 0, );
|
|
331
407
|
init_token_counter();
|
|
408
|
+
COMPACTABLE_TOOL_NAMES = exports.COMPACTABLE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
409
|
+
"Read",
|
|
410
|
+
"Glob",
|
|
411
|
+
"Grep",
|
|
412
|
+
"Bash",
|
|
413
|
+
"PowerShell",
|
|
414
|
+
"NotebookEdit",
|
|
415
|
+
"WebFetch",
|
|
416
|
+
"WebSearch",
|
|
417
|
+
"REPL"
|
|
418
|
+
]);
|
|
332
419
|
}
|
|
333
420
|
});
|
|
334
421
|
|
|
@@ -347,4 +434,5 @@ var init_compaction = _chunkIJSHQGMPcjs.__esm.call(void 0, {
|
|
|
347
434
|
|
|
348
435
|
|
|
349
436
|
|
|
350
|
-
|
|
437
|
+
|
|
438
|
+
exports.estimateTokens = estimateTokens; exports.adjustIndexToPreserveAPIInvariants = adjustIndexToPreserveAPIInvariants; exports.snipCompact = snipCompact; exports.windowCompact = windowCompact; exports.COMPACTABLE_TOOL_NAMES = COMPACTABLE_TOOL_NAMES; exports.microcompact = microcompact; exports.applyToolResultBudget = applyToolResultBudget; exports.truncateToolResult = truncateToolResult; exports.buildSummarizationPrompt = buildSummarizationPrompt; exports.applySummaryCompaction = applySummaryCompaction; exports.groupMessagesByApiRound = groupMessagesByApiRound; exports.dropOldestRounds = dropOldestRounds; exports.extractReferencedFilePaths = extractReferencedFilePaths; exports.compaction_exports = compaction_exports; exports.init_compaction = init_compaction;
|
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
ContextLimitError,
|
|
3
3
|
LLMError,
|
|
4
4
|
LLMRateLimitError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SFXHZSRF.js";
|
|
6
6
|
import {
|
|
7
7
|
logger
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-BXCY2FSE.js";
|
|
9
9
|
import {
|
|
10
10
|
init_esm_shims
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MD32R22I.js";
|
|
12
12
|
|
|
13
13
|
// src/llm/client-base.ts
|
|
14
14
|
init_esm_shims();
|
|
@@ -45,7 +45,8 @@ var LLMClientBase = class _LLMClientBase {
|
|
|
45
45
|
totalTokens: 0,
|
|
46
46
|
requestCount: 0
|
|
47
47
|
};
|
|
48
|
-
recordUsage(usage) {
|
|
48
|
+
recordUsage(usage, options) {
|
|
49
|
+
if (options?.recordUsage === false) return;
|
|
49
50
|
this.usage.records.push(usage);
|
|
50
51
|
this.usage.totalPromptTokens += usage.promptTokens;
|
|
51
52
|
this.usage.totalCompletionTokens += usage.completionTokens;
|