Merge pull request #32 from y574444354/feat/node-compat-polyfill-enhancement
feat: Node.js 兼容性增强与 CoStrict provider 修复
This commit is contained in:
commit
ae0c21765b
|
|
@ -1,211 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"lastScanned": 1776228576231,
|
||||
"projectRoot": "D:\\source_codespace\\geroge\\costrict-repo\\csc",
|
||||
"techStack": {
|
||||
"languages": [
|
||||
{
|
||||
"name": "JavaScript/TypeScript",
|
||||
"version": null,
|
||||
"confidence": "high",
|
||||
"markers": [
|
||||
"package.json"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeScript",
|
||||
"version": null,
|
||||
"confidence": "high",
|
||||
"markers": [
|
||||
"tsconfig.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
"frameworks": [
|
||||
{
|
||||
"name": "react",
|
||||
"version": "19.2.4",
|
||||
"category": "frontend"
|
||||
}
|
||||
],
|
||||
"packageManager": "npm",
|
||||
"runtime": null
|
||||
},
|
||||
"build": {
|
||||
"buildCommand": "npm run build",
|
||||
"testCommand": "npm test",
|
||||
"lintCommand": "npm run lint",
|
||||
"devCommand": "npm run dev",
|
||||
"scripts": {
|
||||
"prebuild": "bun run scripts/generate-skills.ts",
|
||||
"build": "bun run build.ts",
|
||||
"dev": "bun run scripts/dev.ts",
|
||||
"dev:inspect": "bun run scripts/dev-debug.ts",
|
||||
"prepublishOnly": "bun run build",
|
||||
"lint": "biome lint src/",
|
||||
"lint:fix": "biome lint --fix src/",
|
||||
"format": "biome format --write src/",
|
||||
"prepare": "git config core.hooksPath .githooks",
|
||||
"test": "bun test",
|
||||
"check:unused": "knip-bun",
|
||||
"health": "bun run scripts/health-check.ts",
|
||||
"postinstall": "node scripts/postinstall.cjs && node scripts/setup-chrome-mcp.mjs",
|
||||
"docs:dev": "npx mintlify dev",
|
||||
"generate:skills": "bun run scripts/generate-skills.ts",
|
||||
"rcs": "bun run scripts/rcs.ts"
|
||||
}
|
||||
},
|
||||
"conventions": {
|
||||
"namingStyle": null,
|
||||
"importStyle": null,
|
||||
"testPattern": null,
|
||||
"fileOrganization": "type-based"
|
||||
},
|
||||
"structure": {
|
||||
"isMonorepo": true,
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
"packages/@ant/*"
|
||||
],
|
||||
"mainDirectories": [
|
||||
"docs",
|
||||
"scripts",
|
||||
"src",
|
||||
"tests"
|
||||
],
|
||||
"gitBranches": {
|
||||
"defaultBranch": "main",
|
||||
"branchingStrategy": null
|
||||
}
|
||||
},
|
||||
"customNotes": [],
|
||||
"directoryMap": {
|
||||
"docs": {
|
||||
"path": "docs",
|
||||
"purpose": "Documentation",
|
||||
"fileCount": 7,
|
||||
"lastAccessed": 1776228576189,
|
||||
"keyFiles": [
|
||||
"auto-updater.md",
|
||||
"config-list.md",
|
||||
"external-dependencies.md",
|
||||
"favicon.svg",
|
||||
"lsp-integration.md"
|
||||
]
|
||||
},
|
||||
"learn": {
|
||||
"path": "learn",
|
||||
"purpose": null,
|
||||
"fileCount": 5,
|
||||
"lastAccessed": 1776228576191,
|
||||
"keyFiles": [
|
||||
"LEARN.md",
|
||||
"phase-1-qa.md",
|
||||
"phase-1-startup-flow.md",
|
||||
"phase-2-conversation-loop.md",
|
||||
"phase-2-qa.md"
|
||||
]
|
||||
},
|
||||
"packages": {
|
||||
"path": "packages",
|
||||
"purpose": null,
|
||||
"fileCount": 0,
|
||||
"lastAccessed": 1776228576207,
|
||||
"keyFiles": []
|
||||
},
|
||||
"scripts": {
|
||||
"path": "scripts",
|
||||
"purpose": "Build/utility scripts",
|
||||
"fileCount": 10,
|
||||
"lastAccessed": 1776228576208,
|
||||
"keyFiles": [
|
||||
"defines.ts",
|
||||
"dev-debug.ts",
|
||||
"dev.ts",
|
||||
"download-ripgrep.ts",
|
||||
"generate-skills.ts"
|
||||
]
|
||||
},
|
||||
"src": {
|
||||
"path": "src",
|
||||
"purpose": "Source code",
|
||||
"fileCount": 17,
|
||||
"lastAccessed": 1776228576208,
|
||||
"keyFiles": [
|
||||
"commands.ts",
|
||||
"context.ts",
|
||||
"cost-tracker.ts",
|
||||
"costHook.ts",
|
||||
"dialogLaunchers.tsx"
|
||||
]
|
||||
},
|
||||
"tests": {
|
||||
"path": "tests",
|
||||
"purpose": "Test files",
|
||||
"fileCount": 0,
|
||||
"lastAccessed": 1776228576209,
|
||||
"keyFiles": []
|
||||
},
|
||||
"vendor": {
|
||||
"path": "vendor",
|
||||
"purpose": "Third-party code",
|
||||
"fileCount": 0,
|
||||
"lastAccessed": 1776228576209,
|
||||
"keyFiles": []
|
||||
},
|
||||
"src\\components": {
|
||||
"path": "src\\components",
|
||||
"purpose": "UI components",
|
||||
"fileCount": 116,
|
||||
"lastAccessed": 1776228576211,
|
||||
"keyFiles": [
|
||||
"AgentProgressLine.tsx",
|
||||
"AntModelSwitchCallout.tsx",
|
||||
"App.tsx"
|
||||
]
|
||||
},
|
||||
"tests\\mocks": {
|
||||
"path": "tests\\mocks",
|
||||
"purpose": "Mock data",
|
||||
"fileCount": 2,
|
||||
"lastAccessed": 1776228576211,
|
||||
"keyFiles": [
|
||||
"api-responses.ts",
|
||||
"file-system.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"hotPaths": [
|
||||
{
|
||||
"path": "package.json",
|
||||
"accessCount": 6,
|
||||
"lastAccessed": 1776308709974,
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"path": "README.md",
|
||||
"accessCount": 2,
|
||||
"lastAccessed": 1776307986506,
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"path": "src",
|
||||
"accessCount": 1,
|
||||
"lastAccessed": 1776228747216,
|
||||
"type": "directory"
|
||||
},
|
||||
{
|
||||
"path": "C:\\Users\\SXF-Admin\\.claude\\projects\\D--source-codespace-geroge-costrict-repo-csc\\memory\\project_windows_bun_command.md",
|
||||
"accessCount": 1,
|
||||
"lastAccessed": 1776229520309,
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"path": "C:\\Users\\SXF-Admin\\.claude\\projects\\D--source-codespace-geroge-costrict-repo-csc\\memory\\feedback_bun_install_in_session.md",
|
||||
"accessCount": 1,
|
||||
"lastAccessed": 1776229520323,
|
||||
"type": "file"
|
||||
}
|
||||
],
|
||||
"userDirectives": []
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
{"t":0,"agent":"a1b51bb","agent_type":"unknown","event":"agent_stop","success":true}
|
||||
{"t":0,"agent":"a920562","agent_type":"unknown","event":"agent_stop","success":true}
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"t":0,"agent":"a795097","agent_type":"unknown","event":"agent_stop","success":true}
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
{
|
||||
"updatedAt": "2026-04-14T03:12:55.493Z",
|
||||
"missions": [
|
||||
{
|
||||
"id": "session:6b38dce5-cce2-421d-846e-30cf6cd497ff:none",
|
||||
"source": "session",
|
||||
"name": "none",
|
||||
"objective": "Session mission",
|
||||
"createdAt": "2026-04-09T04:02:32.303Z",
|
||||
"updatedAt": "2026-04-09T04:02:53.818Z",
|
||||
"status": "done",
|
||||
"workerCount": 1,
|
||||
"taskCounts": {
|
||||
"total": 1,
|
||||
"pending": 0,
|
||||
"blocked": 0,
|
||||
"inProgress": 0,
|
||||
"completed": 1,
|
||||
"failed": 0
|
||||
},
|
||||
"agents": [
|
||||
{
|
||||
"name": "Explore:a21eb81",
|
||||
"role": "Explore",
|
||||
"ownership": "a21eb8181c593206b",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T04:02:53.818Z"
|
||||
}
|
||||
],
|
||||
"timeline": [
|
||||
{
|
||||
"id": "session-start:a21eb8181c593206b:2026-04-09T04:02:32.303Z",
|
||||
"at": "2026-04-09T04:02:32.303Z",
|
||||
"kind": "update",
|
||||
"agent": "Explore:a21eb81",
|
||||
"detail": "started Explore:a21eb81",
|
||||
"sourceKey": "session-start:a21eb8181c593206b"
|
||||
},
|
||||
{
|
||||
"id": "session-stop:a21eb8181c593206b:2026-04-09T04:02:53.818Z",
|
||||
"at": "2026-04-09T04:02:53.818Z",
|
||||
"kind": "completion",
|
||||
"agent": "Explore:a21eb81",
|
||||
"detail": "completed",
|
||||
"sourceKey": "session-stop:a21eb8181c593206b"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "session:d0afd455-d4ab-400a-97f2-9401ba20e404:none",
|
||||
"source": "session",
|
||||
"name": "none",
|
||||
"objective": "Session mission",
|
||||
"createdAt": "2026-04-09T07:00:16.685Z",
|
||||
"updatedAt": "2026-04-09T08:54:13.110Z",
|
||||
"status": "done",
|
||||
"workerCount": 8,
|
||||
"taskCounts": {
|
||||
"total": 8,
|
||||
"pending": 0,
|
||||
"blocked": 0,
|
||||
"inProgress": 0,
|
||||
"completed": 8,
|
||||
"failed": 0
|
||||
},
|
||||
"agents": [
|
||||
{
|
||||
"name": "Explore:aadbd2f",
|
||||
"role": "Explore",
|
||||
"ownership": "aadbd2fa1ad722276",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T08:22:45.475Z"
|
||||
},
|
||||
{
|
||||
"name": "Explore:ad1ac07",
|
||||
"role": "Explore",
|
||||
"ownership": "ad1ac07efc41075ce",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T07:09:14.177Z"
|
||||
},
|
||||
{
|
||||
"name": "Explore:a3f3288",
|
||||
"role": "Explore",
|
||||
"ownership": "a3f328865e99cb7ba",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T07:11:13.121Z"
|
||||
},
|
||||
{
|
||||
"name": "Explore:a409c86",
|
||||
"role": "Explore",
|
||||
"ownership": "a409c8643a205e3e4",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T07:12:46.725Z"
|
||||
},
|
||||
{
|
||||
"name": "Explore:aca6a8a",
|
||||
"role": "Explore",
|
||||
"ownership": "aca6a8a47201b2e54",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T08:41:39.815Z"
|
||||
},
|
||||
{
|
||||
"name": "Explore:a18f456",
|
||||
"role": "Explore",
|
||||
"ownership": "a18f4561762d2ca34",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T08:48:12.718Z"
|
||||
},
|
||||
{
|
||||
"name": "executor:ab56987",
|
||||
"role": "executor",
|
||||
"ownership": "ab569870c605c758e",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T08:50:46.342Z"
|
||||
},
|
||||
{
|
||||
"name": "executor:a6fa402",
|
||||
"role": "executor",
|
||||
"ownership": "a6fa40274d2ac6090",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-09T08:54:13.110Z"
|
||||
}
|
||||
],
|
||||
"timeline": [
|
||||
{
|
||||
"id": "session-start:ab569870c605c758e:2026-04-09T08:48:43.190Z",
|
||||
"at": "2026-04-09T08:48:43.190Z",
|
||||
"kind": "update",
|
||||
"agent": "executor:ab56987",
|
||||
"detail": "started executor:ab56987",
|
||||
"sourceKey": "session-start:ab569870c605c758e"
|
||||
},
|
||||
{
|
||||
"id": "session-stop:ab569870c605c758e:2026-04-09T08:50:46.342Z",
|
||||
"at": "2026-04-09T08:50:46.342Z",
|
||||
"kind": "completion",
|
||||
"agent": "executor:ab56987",
|
||||
"detail": "completed",
|
||||
"sourceKey": "session-stop:ab569870c605c758e"
|
||||
},
|
||||
{
|
||||
"id": "session-start:a6fa40274d2ac6090:2026-04-09T08:51:49.072Z",
|
||||
"at": "2026-04-09T08:51:49.072Z",
|
||||
"kind": "update",
|
||||
"agent": "executor:a6fa402",
|
||||
"detail": "started executor:a6fa402",
|
||||
"sourceKey": "session-start:a6fa40274d2ac6090"
|
||||
},
|
||||
{
|
||||
"id": "session-stop:a6fa40274d2ac6090:2026-04-09T08:54:13.110Z",
|
||||
"at": "2026-04-09T08:54:13.110Z",
|
||||
"kind": "completion",
|
||||
"agent": "executor:a6fa402",
|
||||
"detail": "completed",
|
||||
"sourceKey": "session-stop:a6fa40274d2ac6090"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "session:0375b005-04be-4064-90ad-ac7b5bdf56df:none",
|
||||
"source": "session",
|
||||
"name": "none",
|
||||
"objective": "Session mission",
|
||||
"createdAt": "2026-04-14T03:06:26.214Z",
|
||||
"updatedAt": "2026-04-14T03:12:55.493Z",
|
||||
"status": "done",
|
||||
"workerCount": 1,
|
||||
"taskCounts": {
|
||||
"total": 1,
|
||||
"pending": 0,
|
||||
"blocked": 0,
|
||||
"inProgress": 0,
|
||||
"completed": 1,
|
||||
"failed": 0
|
||||
},
|
||||
"agents": [
|
||||
{
|
||||
"name": "general-purpose:a9f2b75",
|
||||
"role": "general-purpose",
|
||||
"ownership": "a9f2b750c9c123748",
|
||||
"status": "done",
|
||||
"currentStep": null,
|
||||
"latestUpdate": "completed",
|
||||
"completedSummary": null,
|
||||
"updatedAt": "2026-04-14T03:12:55.493Z"
|
||||
}
|
||||
],
|
||||
"timeline": [
|
||||
{
|
||||
"id": "session-start:a9f2b750c9c123748:2026-04-14T03:06:26.214Z",
|
||||
"at": "2026-04-14T03:06:26.214Z",
|
||||
"kind": "update",
|
||||
"agent": "general-purpose:a9f2b75",
|
||||
"detail": "started general-purpose:a9f2b75",
|
||||
"sourceKey": "session-start:a9f2b750c9c123748"
|
||||
},
|
||||
{
|
||||
"id": "session-start:a9f2b750c9c123748:2026-04-14T03:08:27.269Z",
|
||||
"at": "2026-04-14T03:08:27.269Z",
|
||||
"kind": "update",
|
||||
"agent": "general-purpose:a9f2b75",
|
||||
"detail": "started general-purpose:a9f2b75",
|
||||
"sourceKey": "session-start:a9f2b750c9c123748"
|
||||
},
|
||||
{
|
||||
"id": "session-stop:a9f2b750c9c123748:2026-04-14T03:12:55.493Z",
|
||||
"at": "2026-04-14T03:12:55.493Z",
|
||||
"kind": "completion",
|
||||
"agent": "general-purpose:a9f2b75",
|
||||
"detail": "completed",
|
||||
"sourceKey": "session-stop:a9f2b750c9c123748"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [4.0.6] - 2026-04-16
|
||||
|
||||
### 新功能
|
||||
|
||||
- 去除了运行时bun的依赖
|
||||
|
||||
## [4.0.5] - 2026-04-15
|
||||
|
||||
### 新功能
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "@costrict/csc",
|
||||
"version": "4.0.5-3",
|
||||
"version": "4.0.6",
|
||||
|
||||
"description": "CSC — 多模型终端 AI 编程助手,支持 Anthropic/OpenAI/Gemini/Grok 等多种 API 端点",
|
||||
"description": "CSC — CoStrict多模型终端 AI 编程助手,支持 Anthropic/OpenAI/Gemini/Grok 等多种 API 端点",
|
||||
"type": "module",
|
||||
"author": "claude-code-best <claude-code-best@proton.me>",
|
||||
"repository": {
|
||||
|
|
@ -65,6 +65,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@claude-code-best/mcp-chrome-bridge": "^2.0.7",
|
||||
"undici": "^7.24.6",
|
||||
"ws": "^8.20.0",
|
||||
"yaml": "^2.8.3"
|
||||
},
|
||||
|
|
@ -189,7 +190,6 @@
|
|||
"turndown": "^7.2.2",
|
||||
"type-fest": "^5.5.0",
|
||||
"typescript": "^6.0.2",
|
||||
"undici": "^7.24.6",
|
||||
"url-handler-napi": "workspace:*",
|
||||
"usehooks-ts": "^3.1.1",
|
||||
"vscode-jsonrpc": "^8.2.1",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
export function getMacroDefines(): Record<string, string> {
|
||||
return {
|
||||
"MACRO.VERSION": JSON.stringify("4.0.5.1"),
|
||||
"MACRO.VERSION": JSON.stringify("4.0.6"),
|
||||
"MACRO.BUILD_TIME": JSON.stringify(new Date().toISOString()),
|
||||
"MACRO.FEEDBACK_CHANNEL": JSON.stringify(""),
|
||||
"MACRO.ISSUES_EXPLAINER": JSON.stringify(""),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import { getSettings_DEPRECATED, updateSettingsForSource } from '../utils/settin
|
|||
import { Select } from './CustomSelect/select.js';
|
||||
import { Spinner } from './Spinner.js';
|
||||
import TextInput from './TextInput.js';
|
||||
import { ModelPicker } from './ModelPicker.js';
|
||||
import { useSetAppState } from '../state/AppState.js';
|
||||
|
||||
type Props = {
|
||||
|
|
@ -1260,25 +1259,43 @@ function OAuthStatusMessage({
|
|||
|
||||
case 'costrict_model_select': {
|
||||
const sortedModels = [...oauthStatus.models].sort((a, b) => a.id.localeCompare(b.id));
|
||||
// 直接使用已获取的模型列表渲染选项,避免通用 ModelPicker 因 getAPIProvider() 竞态
|
||||
// 导致显示标准 Anthropic 模型列表而非 CoStrict 动态模型
|
||||
const costrictOptions = sortedModels.map(m => ({
|
||||
value: m.id,
|
||||
label: m.name ?? m.id,
|
||||
description:
|
||||
m.id === 'Auto'
|
||||
? `${Math.round(((m as any).creditDiscount ?? 0) * 100)}% discount`
|
||||
: `${(m as any).creditConsumption ?? '?'}x credit`,
|
||||
}));
|
||||
return (
|
||||
<ModelPicker
|
||||
initial={sortedModels[0]?.id ?? null}
|
||||
headerText="Login successful. Select a CoStrict model to use:"
|
||||
onSelect={model => {
|
||||
const selected = model ?? sortedModels[0]?.id ?? '';
|
||||
process.env.COSTRICT_MODEL = selected;
|
||||
setAppState(prev => ({ ...prev, mainLoopModel: selected, mainLoopModelForSession: null }));
|
||||
setOAuthStatus({ state: 'success' });
|
||||
void onDone();
|
||||
}}
|
||||
onCancel={() => {
|
||||
const selected = sortedModels[0]?.id ?? '';
|
||||
process.env.COSTRICT_MODEL = selected;
|
||||
setAppState(prev => ({ ...prev, mainLoopModel: selected, mainLoopModelForSession: null }));
|
||||
setOAuthStatus({ state: 'success' });
|
||||
void onDone();
|
||||
}}
|
||||
/>
|
||||
<Box flexDirection="column">
|
||||
<Box marginBottom={1} flexDirection="column">
|
||||
<Text color="remember" bold>
|
||||
Select model
|
||||
</Text>
|
||||
<Text dimColor>Login successful. Select a CoStrict model to use:</Text>
|
||||
</Box>
|
||||
<Box flexDirection="column" marginBottom={1}>
|
||||
<Select
|
||||
options={costrictOptions}
|
||||
onChange={(value: string) => {
|
||||
process.env.COSTRICT_MODEL = value;
|
||||
setAppState(prev => ({ ...prev, mainLoopModel: value, mainLoopModelForSession: null }));
|
||||
setOAuthStatus({ state: 'success' });
|
||||
void onDone();
|
||||
}}
|
||||
onCancel={() => {
|
||||
const selected = sortedModels[0]?.id ?? '';
|
||||
process.env.COSTRICT_MODEL = selected;
|
||||
setAppState(prev => ({ ...prev, mainLoopModel: selected, mainLoopModelForSession: null }));
|
||||
setOAuthStatus({ state: 'success' });
|
||||
void onDone();
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ export function ModelPicker({
|
|||
</Text>
|
||||
<Text dimColor>
|
||||
{headerText ??
|
||||
'Switch between Claude models. Applies to this session and future CoStrict sessions. For other/previous model names, specify with --model.'}
|
||||
'Switch between CoStrict models. Applies to this session and future CoStrict sessions. For other/previous model names, specify with --model.'}
|
||||
</Text>
|
||||
{sessionModel && (
|
||||
<Text dimColor>
|
||||
|
|
|
|||
|
|
@ -694,7 +694,7 @@ export async function computeSimpleEnvInfo(
|
|||
knowledgeCutoffMessage,
|
||||
process.env.USER_TYPE === 'ant' && isUndercover()
|
||||
? null
|
||||
: `The most recent Claude model family is Claude 4.5/4.6. Model IDs — Opus 4.6: '${CLAUDE_4_5_OR_4_6_MODEL_IDS.opus}', Sonnet 4.6: '${CLAUDE_4_5_OR_4_6_MODEL_IDS.sonnet}', Haiku 4.5: '${CLAUDE_4_5_OR_4_6_MODEL_IDS.haiku}'. When building AI applications, default to the latest and most capable Claude models.`,
|
||||
: `The most recent Claude model family is Claude 4.5/4.6. Model IDs — Opus 4.6: '${CLAUDE_4_5_OR_4_6_MODEL_IDS.opus}', Sonnet 4.6: '${CLAUDE_4_5_OR_4_6_MODEL_IDS.sonnet}', Haiku 4.5: '${CLAUDE_4_5_OR_4_6_MODEL_IDS.haiku}'. When building AI applications, default to the latest and most capable CoStrict models.`,
|
||||
process.env.USER_TYPE === 'ant' && isUndercover()
|
||||
? null
|
||||
: `Claude Code is available as a CLI in the terminal, desktop app (Mac/Windows), web app (costrict.ai), and IDE extensions (VS Code, JetBrains).`,
|
||||
|
|
|
|||
|
|
@ -136,7 +136,10 @@ export async function* queryModelCoStrict(
|
|||
const adaptedStream = adaptOpenAIStreamToAnthropic(stream, costrictModel)
|
||||
|
||||
const contentBlocks: Record<number, any> = {}
|
||||
// 跟踪已 yield 的 assistant messages,用于 message_delta 时回写 usage
|
||||
const yieldedMessages: AssistantMessage[] = []
|
||||
let partialMessage: any
|
||||
let stopReason: string | null = null
|
||||
let usage = {
|
||||
input_tokens: 0,
|
||||
output_tokens: 0,
|
||||
|
|
@ -194,18 +197,33 @@ export async function* queryModelCoStrict(
|
|||
message: {
|
||||
...partialMessage,
|
||||
content: normalizeContentFromAPI([block], tools, options.agentId),
|
||||
usage,
|
||||
},
|
||||
requestId: undefined,
|
||||
type: 'assistant',
|
||||
uuid: randomUUID(),
|
||||
timestamp: new Date().toISOString(),
|
||||
}
|
||||
yieldedMessages.push(m)
|
||||
yield m
|
||||
break
|
||||
}
|
||||
case 'message_delta': {
|
||||
const deltaUsage = (event as any).usage
|
||||
if (deltaUsage) usage = { ...usage, ...deltaUsage }
|
||||
// 回写 usage 到已 yield 的 assistant messages
|
||||
// 与 Anthropic 原生路径 claude.ts:2298 保持一致
|
||||
for (const msg of yieldedMessages) {
|
||||
msg.message.usage = usage
|
||||
}
|
||||
// 记录 stop_reason,回写到最后的 message
|
||||
if ((event as any).delta?.stop_reason != null) {
|
||||
stopReason = (event as any).delta.stop_reason
|
||||
const lastMsg = yieldedMessages[yieldedMessages.length - 1]
|
||||
if (lastMsg) {
|
||||
lastMsg.message.stop_reason = stopReason
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'message_stop':
|
||||
|
|
|
|||
|
|
@ -144,7 +144,13 @@ export async function countMessagesTokensWithAPI(
|
|||
return withTokenCountVCR(messages, tools, async () => {
|
||||
try {
|
||||
const provider = getAPIProvider()
|
||||
if (provider === 'gemini') {
|
||||
// 非 Anthropic 原生 provider 不支持 countTokens API,直接使用粗略估算
|
||||
if (
|
||||
provider === 'gemini' ||
|
||||
provider === 'openai' ||
|
||||
provider === 'grok' ||
|
||||
provider === 'costrict'
|
||||
) {
|
||||
return roughTokenCountEstimationForAPIRequest(messages, tools)
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +264,13 @@ export async function countTokensViaHaikuFallback(
|
|||
tools: Anthropic.Beta.Messages.BetaToolUnion[],
|
||||
): Promise<number | null> {
|
||||
const provider = getAPIProvider()
|
||||
if (provider === 'gemini') {
|
||||
// 非 Anthropic 原生 provider 不支持 countTokens API,直接使用粗略估算
|
||||
if (
|
||||
provider === 'gemini' ||
|
||||
provider === 'openai' ||
|
||||
provider === 'grok' ||
|
||||
provider === 'costrict'
|
||||
) {
|
||||
return roughTokenCountEstimationForAPIRequest(messages, tools)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ export function modelSupportsAutoMode(model: string): boolean {
|
|||
return true
|
||||
}
|
||||
if (process.env.USER_TYPE === 'ant') {
|
||||
// Denylist: block known-unsupported claude models, allow everything else (ant-internal models etc.)
|
||||
// Denylist: block known-unsupported CoStrict models, allow everything else (ant-internal models etc.)
|
||||
if (m.includes('claude-3-')) return false
|
||||
// claude-*-4 not followed by -[6-9]: blocks bare -4, -4-YYYYMMDD, -4@, -4-0 thru -4-5
|
||||
if (/claude-(opus|sonnet|haiku)-4(?!-[6-9])/.test(m)) return false
|
||||
|
|
|
|||
|
|
@ -380,7 +380,10 @@ function getModelOptionsBase(fastMode = false): ModelOption[] {
|
|||
}
|
||||
|
||||
// CoStrict provider: 从缓存中动态展示 CoStrict 可用模型
|
||||
if (getAPIProvider() === 'costrict') {
|
||||
// 也覆盖其他 provider 但用户已有 CoStrict 凭证的场景(modelType 丢失/竞态)
|
||||
const isCoStrictProvider = getAPIProvider() === 'costrict'
|
||||
const hasCoStrictCreds = hasCoStrictCredentialsSync()
|
||||
if (isCoStrictProvider || hasCoStrictCreds) {
|
||||
// 延迟 require 避免循环依赖,且该模块只在 costrict provider 下加载
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { getCachedCoStrictModels } =
|
||||
|
|
@ -400,82 +403,19 @@ function getModelOptionsBase(fastMode = false): ModelOption[] {
|
|||
}
|
||||
})
|
||||
}
|
||||
// 缓存尚未加载(凭证过期或首次加载中),提示用户重新登录
|
||||
// 缓存尚未加载(启动时预取未完成),显示提示而非标准模型列表
|
||||
return [
|
||||
{
|
||||
value: null,
|
||||
label: 'CoStrict (not logged in)',
|
||||
description: 'Run /login to sign in with CoStrict again',
|
||||
label: 'CoStrict (loading models...)',
|
||||
description:
|
||||
'CoStrict models are being loaded, please try again in a moment',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// PAYG 1P API: Default (Sonnet) + Sonnet 1M + Opus 4.6 + Opus 1M + Haiku
|
||||
if (getAPIProvider() === 'firstParty') {
|
||||
// 当用户未登录 CoStrict 时,只显示推荐登录选项
|
||||
if (!hasCoStrictCredentialsSync()) {
|
||||
return [getCoStrictLoginOption()]
|
||||
}
|
||||
|
||||
const payg1POptions: ModelOption[] = []
|
||||
payg1POptions.push(getDefaultOptionForUser(fastMode))
|
||||
|
||||
if (checkSonnet1mAccess()) {
|
||||
payg1POptions.push(getSonnet46_1MOption())
|
||||
}
|
||||
if (isOpus1mMergeEnabled()) {
|
||||
payg1POptions.push(getMergedOpus1MOption(fastMode))
|
||||
} else {
|
||||
payg1POptions.push(getOpus46Option(fastMode))
|
||||
if (checkOpus1mAccess()) {
|
||||
payg1POptions.push(getOpus46_1MOption(fastMode))
|
||||
}
|
||||
}
|
||||
payg1POptions.push(getHaiku45Option())
|
||||
|
||||
return payg1POptions
|
||||
}
|
||||
|
||||
// PAYG 3P: Default (Sonnet 4.5) + Sonnet (3P custom) or Sonnet 4.6/1M + Opus (3P custom) or Opus 4.1/Opus 4.6/Opus1M + Haiku + Opus 4.1
|
||||
|
||||
// 当用户未登录 CoStrict 时,只显示推荐登录选项
|
||||
if (getAPIProvider() !== 'costrict' && !hasCoStrictCredentialsSync()) {
|
||||
return [getCoStrictLoginOption()]
|
||||
}
|
||||
|
||||
const payg3pOptions: ModelOption[] = []
|
||||
payg3pOptions.push(getDefaultOptionForUser(fastMode))
|
||||
|
||||
const customSonnet = getCustomSonnetOption()
|
||||
if (customSonnet !== undefined) {
|
||||
payg3pOptions.push(customSonnet)
|
||||
} else {
|
||||
// Add Sonnet 4.6 since Sonnet 4.5 is the default
|
||||
payg3pOptions.push(getSonnet46Option())
|
||||
if (checkSonnet1mAccess()) {
|
||||
payg3pOptions.push(getSonnet46_1MOption())
|
||||
}
|
||||
}
|
||||
|
||||
const customOpus = getCustomOpusOption()
|
||||
if (customOpus !== undefined) {
|
||||
payg3pOptions.push(customOpus)
|
||||
} else {
|
||||
// Add Opus 4.1, Opus 4.6 and Opus 4.6 1M
|
||||
payg3pOptions.push(getOpus41Option()) // This is the default opus
|
||||
payg3pOptions.push(getOpus46Option(fastMode))
|
||||
if (checkOpus1mAccess()) {
|
||||
payg3pOptions.push(getOpus46_1MOption(fastMode))
|
||||
}
|
||||
}
|
||||
const customHaiku = getCustomHaikuOption()
|
||||
if (customHaiku !== undefined) {
|
||||
payg3pOptions.push(customHaiku)
|
||||
} else {
|
||||
payg3pOptions.push(getHaikuOption())
|
||||
}
|
||||
|
||||
return payg3pOptions
|
||||
// 用户没有 CoStrict 凭证,显示推荐登录选项
|
||||
return [getCoStrictLoginOption()]
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user