diff --git a/build.ts b/build.ts index c54d09260..9502906d0 100644 --- a/build.ts +++ b/build.ts @@ -1,7 +1,6 @@ import { readdir, readFile, writeFile, cp } from 'fs/promises' import { join } from 'path' -import { getMacroDefines } from './scripts/defines.ts' -import { DEFAULT_BUILD_FEATURES } from './scripts/defines.ts' +import { getMacroDefines, DEFAULT_BUILD_FEATURES } from './scripts/defines.ts' const outdir = 'dist' @@ -52,6 +51,26 @@ for (const file of files) { } } +// Step 3.5: Replace feature('FLAG_NAME') with true/false at build time +// Bun.build does not natively replace feature flags, so we do it manually here +// to match the behavior of vite-plugin-feature-flags.ts. +const FEATURE_CALL_RE = /feature\s*\(\s*['"]([\w]+)['"]\s*\)/g +let featureReplaced = 0 +for (const file of files) { + if (!file.endsWith('.js')) continue + const filePath = join(outdir, file) + const content = await readFile(filePath, 'utf-8') + let matchCount = 0 + const transformed = content.replace(FEATURE_CALL_RE, (match, flagName) => { + matchCount++ + return features.includes(flagName) ? 'true' : 'false' + }) + if (matchCount > 0) { + await writeFile(filePath, transformed) + featureReplaced += matchCount + } +} + // Also patch unguarded globalThis.Bun destructuring from third-party deps // (e.g. @anthropic-ai/sandbox-runtime) so Node.js doesn't crash at import time. let bunPatched = 0 @@ -72,7 +91,7 @@ for (const file of files) { BUN_DESTRUCTURE.lastIndex = 0 console.log( - `Bundled ${result.outputs.length} files to ${outdir}/ (patched ${patched} for import.meta.require, ${bunPatched} for Bun destructure)`, + `Bundled ${result.outputs.length} files to ${outdir}/ (patched ${patched} for import.meta.require, ${bunPatched} for Bun destructure, ${featureReplaced} feature flags)`, ) // Step 4: Copy native .node addon files (audio-capture) and vendored binaries (ripgrep) diff --git a/src/buddy/useBuddyNotification.tsx b/src/buddy/useBuddyNotification.tsx index 2df078e79..534c1b835 100644 --- a/src/buddy/useBuddyNotification.tsx +++ b/src/buddy/useBuddyNotification.tsx @@ -15,11 +15,8 @@ export function isBuddyTeaserWindow(): boolean { } export function isBuddyLive(): boolean { - if (process.env.USER_TYPE === 'ant') return true - const d = new Date() - return ( - d.getFullYear() > 2026 || (d.getFullYear() === 2026 && d.getMonth() >= 3) - ) + // BUDDY 功能已默认启用,不再受日期限制 + return true } function RainbowText({ text }: { text: string }): React.ReactNode { diff --git a/src/utils/model/model.ts b/src/utils/model/model.ts index 368b0f3d6..a45328c3e 100644 --- a/src/utils/model/model.ts +++ b/src/utils/model/model.ts @@ -153,8 +153,9 @@ export function getDefaultOpusModel(): ModelName { // @[MODEL LAUNCH]: Update the default Sonnet model (3P providers may lag so keep defaults unchanged). export function getDefaultSonnetModel(): ModelName { const provider = getAPIProvider() - // CoStrict has no sonnet alias — use the main loop model to stay on the same provider - if (provider === 'costrict') return getMainLoopModel() + // CoStrict has no sonnet alias — return a concrete default to avoid recursive + // resolution (getMainLoopModel → getDefaultMainLoopModel → getDefaultSonnetModel). + if (provider === 'costrict') return getModelStrings().sonnet46 // For OpenAI provider, check OPENAI_DEFAULT_SONNET_MODEL first if (provider === 'openai' && process.env.OPENAI_DEFAULT_SONNET_MODEL) { return process.env.OPENAI_DEFAULT_SONNET_MODEL @@ -177,8 +178,9 @@ export function getDefaultSonnetModel(): ModelName { // @[MODEL LAUNCH]: Update the default Haiku model (3P providers may lag so keep defaults unchanged). export function getDefaultHaikuModel(): ModelName { const provider = getAPIProvider() - // CoStrict has no haiku alias — use the main loop model to stay on the same provider - if (provider === 'costrict') return getMainLoopModel() + // CoStrict has no haiku alias — return a concrete default to avoid recursive + // resolution (getMainLoopModel → getDefaultMainLoopModel → getDefaultHaikuModel). + if (provider === 'costrict') return getModelStrings().haiku45 // For OpenAI provider, check OPENAI_DEFAULT_HAIKU_MODEL first if (provider === 'openai' && process.env.OPENAI_DEFAULT_HAIKU_MODEL) { return process.env.OPENAI_DEFAULT_HAIKU_MODEL