@cjhyy/code-shell 0.1.0-alpha.3 → 0.1.6
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 +107 -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-ENHBHB2W.js → arena-2LTLIXOL.js} +9 -7
- package/dist/{arena-HHDYYVHJ.cjs → arena-ADB7DRFI.cjs} +25 -23
- package/dist/{chunk-EL2RL5DG.cjs → chunk-2YW4FPFG.cjs} +2 -2
- package/dist/chunk-3OA5G4TM.js +47 -0
- package/dist/{chunk-FPFTIKEJ.js → chunk-3QO25N6E.js} +131 -173
- package/dist/chunk-3SBSUOWZ.js +447 -0
- package/dist/chunk-52LGZKT3.cjs +47 -0
- package/dist/{chunk-KOGV6PDQ.cjs → chunk-55XGPMAP.cjs} +44 -9
- 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-7BI3V74Y.cjs +447 -0
- package/dist/{chunk-GZBD6QRS.cjs → chunk-7EG3V4JY.cjs} +13 -12
- package/dist/{chunk-LMEKCQX4.js → chunk-7JVTYEEC.js} +6 -6
- package/dist/{chunk-SW3L7HIM.js → chunk-7QIM3BKD.js} +2 -2
- package/dist/{chunk-5C5HIOML.js → chunk-7Y6S3OCX.js} +109 -21
- package/dist/{chunk-REFCCVDM.js → chunk-ABRRONJ7.js} +2 -2
- package/dist/{chunk-F5BS3GUC.js → chunk-BSW22MPA.js} +39 -4
- package/dist/{chunk-ZRVPCXI7.js → chunk-BXCY2FSE.js} +2 -1
- package/dist/{chunk-Y7TSCDF6.js → chunk-BZ5TNE7L.js} +347 -6
- package/dist/{chunk-X2DNIMPC.cjs → chunk-DDB6QOKJ.cjs} +32 -32
- package/dist/{chunk-C7C7ZZY4.cjs → chunk-HEKQCI7B.cjs} +10 -10
- package/dist/{chunk-JHNCK7JP.cjs → chunk-IK4EWJBP.cjs} +4 -3
- package/dist/{chunk-3CAZIWUA.cjs → chunk-ILHE7XLT.cjs} +9 -9
- package/dist/{chunk-M2QI5X3X.cjs → chunk-JMR33QVF.cjs} +2 -2
- package/dist/{chunk-TDXBHD24.js → chunk-KAQHULYN.js} +2 -2
- package/dist/chunk-KE4EQOWA.js +294 -0
- 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-MV7YI4WO.cjs +293 -0
- package/dist/chunk-MY5XHADU.cjs +216 -0
- package/dist/{chunk-OP57WUWQ.cjs → chunk-NUNC3VFB.cjs} +6 -6
- package/dist/{chunk-ID6EJUHP.js → chunk-PKGRTCCY.js} +1307 -212
- package/dist/{chunk-OUC2DFA7.js → chunk-QARL3IDQ.js} +3 -3
- package/dist/{chunk-VIPLU4RY.cjs → chunk-S754JHLR.cjs} +4 -4
- package/dist/{chunk-FUOKLKR2.js → chunk-SFXHZSRF.js} +1 -1
- package/dist/{chunk-2EUAE7AY.js → chunk-SIHHIQLO.js} +2 -2
- package/dist/{chunk-SK62UVS6.js → chunk-T6VYG46N.js} +1 -1
- package/dist/{chunk-JHXNOB5G.cjs → chunk-TNLGBJYS.cjs} +6 -6
- package/dist/{chunk-3QR52LL5.cjs → chunk-TUY2T5KP.cjs} +2 -2
- package/dist/{chunk-VWFET3MG.cjs → chunk-UXOCVJJ6.cjs} +1519 -424
- package/dist/{chunk-I57ZD5IQ.js → chunk-VIAGTYYW.js} +1 -1
- package/dist/chunk-WASS5YWB.js +215 -0
- package/dist/{chunk-HOXQLX5R.cjs → chunk-WZJV6DJC.cjs} +444 -103
- package/dist/{chunk-BUJ5KYCI.cjs → chunk-YIQBXAYU.cjs} +13 -13
- package/dist/{chunk-BF4LXLQV.cjs → chunk-YKIAELDZ.cjs} +132 -174
- 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 +2372 -1453
- package/dist/cli/main.js +2502 -1583
- package/dist/cli/migrate-models.d.ts +45 -0
- package/dist/cli/onboarding.d.ts +110 -5
- package/dist/cli/updater.d.ts +59 -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 +47 -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 +38 -18
- 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-D65VFAPX.js +7 -0
- package/dist/manager-TTF5VHJC.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-2FM3H4SQ.js → openrouter-models-H56GHBHN.js} +2 -2
- package/dist/openrouter-models-TWUFWZ5T.cjs +15 -0
- package/dist/openrouter-sync-5VMGN6C2.cjs +11 -0
- package/dist/{openrouter-sync-SO3AWEAM.js → openrouter-sync-ALEMF5IU.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 +46 -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-I7QBW4DP.cjs +17 -0
- package/dist/updater-NVME5S3Z.js +17 -0
- package/dist/utils/semver.d.ts +1 -0
- package/dist/utils/task-sanitizer.d.ts +6 -0
- package/package.json +2 -1
- package/skills-builtin/codeshell-help.md +135 -0
- 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,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isStale,
|
|
3
|
+
readCache,
|
|
4
|
+
writeCache
|
|
5
|
+
} from "./chunk-3OA5G4TM.js";
|
|
6
|
+
import {
|
|
7
|
+
init_esm_shims
|
|
8
|
+
} from "./chunk-MD32R22I.js";
|
|
9
|
+
|
|
10
|
+
// src/llm/model-fetcher.ts
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
import { readFileSync, existsSync } from "fs";
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
14
|
+
import { dirname, join } from "path";
|
|
15
|
+
|
|
16
|
+
// src/llm/provider-kinds.ts
|
|
17
|
+
init_esm_shims();
|
|
18
|
+
var NON_CHAT_PATTERNS = /(?:^|[-_/])(?:embed(?:ding)?|whisper|tts|audio|image|dall-?e|moderation|rerank|guard|vision-only)(?:$|[-_/])/i;
|
|
19
|
+
var isChatLike = (id) => !NON_CHAT_PATTERNS.test(id);
|
|
20
|
+
var bearer = (k) => k ? { Authorization: `Bearer ${k}` } : {};
|
|
21
|
+
var PROVIDER_KINDS = {
|
|
22
|
+
openai: {
|
|
23
|
+
label: "OpenAI",
|
|
24
|
+
defaultBaseUrl: "https://api.openai.com/v1",
|
|
25
|
+
modelsPath: "/models",
|
|
26
|
+
protocol: "openai-compat",
|
|
27
|
+
authHeader: bearer,
|
|
28
|
+
chatFilter: isChatLike
|
|
29
|
+
},
|
|
30
|
+
anthropic: {
|
|
31
|
+
label: "Anthropic",
|
|
32
|
+
defaultBaseUrl: "https://api.anthropic.com/v1",
|
|
33
|
+
modelsPath: "/models",
|
|
34
|
+
protocol: "anthropic-style",
|
|
35
|
+
authHeader: (k) => k ? { "x-api-key": k, "anthropic-version": "2023-06-01" } : { "anthropic-version": "2023-06-01" },
|
|
36
|
+
chatFilter: isChatLike
|
|
37
|
+
},
|
|
38
|
+
deepseek: {
|
|
39
|
+
label: "DeepSeek",
|
|
40
|
+
defaultBaseUrl: "https://api.deepseek.com/v1",
|
|
41
|
+
modelsPath: "/models",
|
|
42
|
+
protocol: "openai-compat",
|
|
43
|
+
authHeader: bearer,
|
|
44
|
+
chatFilter: isChatLike
|
|
45
|
+
},
|
|
46
|
+
xai: {
|
|
47
|
+
label: "xAI (Grok)",
|
|
48
|
+
defaultBaseUrl: "https://api.x.ai/v1",
|
|
49
|
+
modelsPath: "/models",
|
|
50
|
+
protocol: "openai-compat",
|
|
51
|
+
authHeader: bearer,
|
|
52
|
+
chatFilter: isChatLike
|
|
53
|
+
},
|
|
54
|
+
mistral: {
|
|
55
|
+
label: "Mistral",
|
|
56
|
+
defaultBaseUrl: "https://api.mistral.ai/v1",
|
|
57
|
+
modelsPath: "/models",
|
|
58
|
+
protocol: "openai-compat",
|
|
59
|
+
authHeader: bearer,
|
|
60
|
+
chatFilter: isChatLike
|
|
61
|
+
},
|
|
62
|
+
groq: {
|
|
63
|
+
label: "Groq",
|
|
64
|
+
defaultBaseUrl: "https://api.groq.com/openai/v1",
|
|
65
|
+
modelsPath: "/models",
|
|
66
|
+
protocol: "openai-compat",
|
|
67
|
+
authHeader: bearer,
|
|
68
|
+
chatFilter: isChatLike
|
|
69
|
+
},
|
|
70
|
+
google: {
|
|
71
|
+
label: "Google Gemini",
|
|
72
|
+
defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta",
|
|
73
|
+
modelsPath: "/models",
|
|
74
|
+
protocol: "gemini",
|
|
75
|
+
authHeader: () => ({}),
|
|
76
|
+
authQuery: (k) => k ? { key: k } : {},
|
|
77
|
+
chatFilter: (id) => isChatLike(id) && /gemini/i.test(id)
|
|
78
|
+
},
|
|
79
|
+
openrouter: {
|
|
80
|
+
label: "OpenRouter",
|
|
81
|
+
defaultBaseUrl: "https://openrouter.ai/api/v1",
|
|
82
|
+
modelsPath: "/models",
|
|
83
|
+
protocol: "openai-compat",
|
|
84
|
+
authHeader: bearer,
|
|
85
|
+
chatFilter: isChatLike
|
|
86
|
+
},
|
|
87
|
+
ollama: {
|
|
88
|
+
label: "Ollama (local)",
|
|
89
|
+
defaultBaseUrl: "http://localhost:11434",
|
|
90
|
+
modelsPath: "/api/tags",
|
|
91
|
+
protocol: "ollama",
|
|
92
|
+
authHeader: () => ({}),
|
|
93
|
+
chatFilter: isChatLike
|
|
94
|
+
},
|
|
95
|
+
custom: {
|
|
96
|
+
label: "Custom",
|
|
97
|
+
defaultBaseUrl: "",
|
|
98
|
+
modelsPath: "/models",
|
|
99
|
+
protocol: "openai-compat",
|
|
100
|
+
authHeader: bearer,
|
|
101
|
+
chatFilter: isChatLike
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function getKindMeta(kind) {
|
|
105
|
+
return PROVIDER_KINDS[kind] ?? PROVIDER_KINDS.custom;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/llm/model-fetcher.ts
|
|
109
|
+
var HERE = dirname(fileURLToPath(import.meta.url));
|
|
110
|
+
var OPENROUTER_SNAPSHOT = join(HERE, "..", "data", "openrouter-models.json");
|
|
111
|
+
async function fetchModelList(provider, opts) {
|
|
112
|
+
const meta = getKindMeta(provider.kind);
|
|
113
|
+
if (!opts.refresh) {
|
|
114
|
+
const cached = readCache(opts.cacheDir, provider.key);
|
|
115
|
+
if (cached && !isStale(cached)) return { ...cached, fromCache: true };
|
|
116
|
+
}
|
|
117
|
+
if (provider.kind === "openrouter") {
|
|
118
|
+
return loadOpenRouterSnapshot(provider.key, opts.cacheDir);
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const path = provider.modelsPath ?? meta.modelsPath;
|
|
122
|
+
const url = new URL(joinUrl(provider.baseUrl, path));
|
|
123
|
+
const headers = meta.authHeader(provider.apiKey ?? "");
|
|
124
|
+
if (meta.authQuery) {
|
|
125
|
+
const q = meta.authQuery(provider.apiKey ?? "");
|
|
126
|
+
for (const [k, v] of Object.entries(q)) url.searchParams.set(k, v);
|
|
127
|
+
}
|
|
128
|
+
const res = await fetch(url.toString(), {
|
|
129
|
+
headers: { Accept: "application/json", ...headers },
|
|
130
|
+
signal: AbortSignal.timeout(opts.timeoutMs ?? 2e4)
|
|
131
|
+
});
|
|
132
|
+
if (!res.ok) {
|
|
133
|
+
return errorResult(provider.key, opts.cacheDir, `HTTP ${res.status}`);
|
|
134
|
+
}
|
|
135
|
+
const payload = await res.json();
|
|
136
|
+
const raw = normalize(payload, meta.protocol);
|
|
137
|
+
const filtered = raw.filter((m) => meta.chatFilter(m.id));
|
|
138
|
+
const file = writeCache(opts.cacheDir, provider.key, filtered);
|
|
139
|
+
return file;
|
|
140
|
+
} catch (err) {
|
|
141
|
+
const msg = err.message || String(err);
|
|
142
|
+
return errorResult(provider.key, opts.cacheDir, msg);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function normalize(payload, protocol) {
|
|
146
|
+
switch (protocol) {
|
|
147
|
+
case "ollama": {
|
|
148
|
+
const p = payload;
|
|
149
|
+
return (p.models ?? []).map((m) => ({ id: m.name, contextLength: 0, maxOutputTokens: 0 }));
|
|
150
|
+
}
|
|
151
|
+
case "anthropic-style": {
|
|
152
|
+
const p = payload;
|
|
153
|
+
return (p.data ?? []).map((m) => ({
|
|
154
|
+
id: m.id,
|
|
155
|
+
contextLength: m.context_window ?? 2e5,
|
|
156
|
+
maxOutputTokens: m.max_output_tokens ?? 0
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
case "gemini": {
|
|
160
|
+
const p = payload;
|
|
161
|
+
return (p.models ?? []).map((m) => ({
|
|
162
|
+
id: m.name.replace(/^models\//, ""),
|
|
163
|
+
contextLength: m.inputTokenLimit ?? 0,
|
|
164
|
+
maxOutputTokens: m.outputTokenLimit ?? 0
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
case "openai-compat": {
|
|
168
|
+
const p = payload;
|
|
169
|
+
return (p.data ?? []).map((m) => ({
|
|
170
|
+
id: m.id,
|
|
171
|
+
contextLength: m.context_window ?? m.context_length ?? 0,
|
|
172
|
+
maxOutputTokens: m.max_completion_tokens ?? 0
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const _exhaustive = protocol;
|
|
177
|
+
return _exhaustive;
|
|
178
|
+
}
|
|
179
|
+
function loadOpenRouterSnapshot(providerKey, cacheDir) {
|
|
180
|
+
if (!existsSync(OPENROUTER_SNAPSHOT)) {
|
|
181
|
+
return errorResult(providerKey, cacheDir, "openrouter snapshot missing");
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const snapshot = JSON.parse(
|
|
185
|
+
readFileSync(OPENROUTER_SNAPSHOT, "utf-8")
|
|
186
|
+
);
|
|
187
|
+
const models = (snapshot.models ?? []).map((m) => ({
|
|
188
|
+
id: m.id,
|
|
189
|
+
contextLength: m.contextLength ?? 0,
|
|
190
|
+
maxOutputTokens: m.maxOutputTokens ?? 0
|
|
191
|
+
}));
|
|
192
|
+
return writeCache(cacheDir, providerKey, models);
|
|
193
|
+
} catch (err) {
|
|
194
|
+
return errorResult(providerKey, cacheDir, err.message);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function errorResult(providerKey, cacheDir, error) {
|
|
198
|
+
const stale = readCache(cacheDir, providerKey);
|
|
199
|
+
if (stale) return { ...stale, error, fromCache: true };
|
|
200
|
+
return {
|
|
201
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
202
|
+
providerKey,
|
|
203
|
+
models: [],
|
|
204
|
+
error
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function joinUrl(base, path) {
|
|
208
|
+
if (!base) return path;
|
|
209
|
+
return `${base.replace(/\/$/, "")}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export {
|
|
213
|
+
PROVIDER_KINDS,
|
|
214
|
+
fetchModelList
|
|
215
|
+
};
|