单一 VSIX:把 Augment 的 8 个 LLM 数据面端点按路由转到 BYOK(支持 Streaming + tool use),其它端点保持官方行为;支持运行时一键回滚(无需 Rust/外部服务)。
默认 relay:https://acemcp.heroman.wtf/relay/。使用官方 /get-models 合并与官方上下文注入前,请先到 https://acemcp.heroman.wtf/login 自行注册并填写自己的 API Token;本项目不再内置或随机分配 key。
rolling)下载 augment.vscode-augment.*-byok.*.vsix... → Install from VSIX... → Reload WindowBYOK: Open Config Panelproviders[] → Save(Base URL 会按 type 自动填充默认值)BYOK: Enable(runtimeEnabled=true 才会接管 8 个端点)byok:<providerId>:<modelId>(由 /get-models 注入)配置存储:VS Code extension globalState(含 Key/Token;不参与 Sync)。字段与约束见本文“配置系统”与“routing.rules(端点路由规则)”;示例见 config.example.json。
可选:面板支持 Self Test(一键验证 models/chat/chat-stream + 工具链路)。
常用命令:
- BYOK: Enable / BYOK: Disable (Rollback)
- BYOK: Reload Config
- BYOK: Import Config / BYOK: Export Config
- BYOK: Clear History Summary Cache
openai_compatible:POST {baseUrl}/chat/completions(SSE)openai_responses:POST {baseUrl}/responses(SSE,支持 incomplete_details.reason→stop_reason)anthropic:POST {baseUrl}/messages(SSE)gemini_ai_studio:.../v1beta/models/<model>:streamGenerateContent?alt=sse协议适配细节(工具/stop_reason/用量/兜底/常见网关差异)见本文“Provider 支持矩阵”。
callApi(4):/get-models、/chat、/completion、/chat-input-completioncallApiStream(4):/chat-stream、/prompt-enhancer、/next-edit-stream、/generate-commit-message-stream当前上游
augment/vscode-augment@0.871.0已无/edit、/generate-conversation-title、/next_edit_loc、/instruction-stream与/smart-paste-stream,因此默认 BYOK 覆盖矩阵同步收敛为 8 个端点。
完整端点范围(48/8)见本文“端点覆盖(48 / 8)与路由策略”。
apiKey/headers;不要把 Bearer 前缀重复写入(apiKey 会自动加 Bearer,headers.authorization 则应完整填写)。baseUrl 很可能少了 /v1(OpenAI/Anthropic 兼容端点通常要求)。text/event-stream;建议直接在面板跑 Self Test 定位(models / chat / chat-stream)。system: invalid type: string:多见于“Anthropic 兼容代理”实现差异;已内置 blocks 兼容兜底重试(仍失败时请确认 baseUrl 指向 /messages 且代理支持 SSE)。Save(热更新只影响后续请求)且 BYOK: Enable(runtimeEnabled=true)。前置:Node.js 20+、Python 运行时、可访问 Marketplace(优先 python3;Windows 可用 py -3;否则回退 python)
npm run check:fastnpm run upstream:analyze(一次)→ npm run checknpm run build:vsix(产物:dist/augment.vscode-augment.<upstreamVersion>-byok.<buildId>.vsix)说明:这里的“修改”指本仓库在构建
*.byok.vsix时对上游 Augment VSIX 的补丁/替换点 + BYOK 运行时代码新增能力。
状态标记:[x]已实现;[-]部分实现/依赖条件(条目内注明);[ ]未实现(明确不做 / 未来可能做)。
*.vsix,无需 Rust/外部代理服务runtimeEnabled=false 即回到官方链路)augment.advanced.* settings:构建期移除贡献点 + 运行时不读取/不写入globalState(含 Key/Token,不参与 Sync)augment-byok.runtimeEnabled.v1 加入 Sync,方便“跨设备一键回滚”disabled 兜底)tools/build/build-vsix.js.cache/upstream/*.vsix,解包到 .cache/work/*build-vsix --skip-downloadpayload/extension/out/byok/* 覆盖到上游 extension/out/byok/*tools/lib/upstream-vsix.js(build / analyze / contracts 共用)tools/lib/byok-workflow.js(避免构建脚本与合约脚本漂移)dist/augment.vscode-augment.<upstreamVersion>-byok.<buildId>.vsixupstream.lock.json / dist/upstream.lock.jsondist/endpoint-coverage.report.md(LLM 端点覆盖矩阵).cache/reports/upstream-analysis.json(由 npm run upstream:analyze 生成)dist/upstream.lock.json 会复制为 dist.upstream.lock.json(仅用于 Release assets)extension/out/extension.js 中注入 BYOK bootstraptools/patch/patch-extension-entry.jsaugment-interceptor payload,不做机器指纹/会话伪造类逻辑tools/patch/patch-webview-history-summary-node.jshistory_summary_node/HISTORY_SUMMARY/history_end 的 common-webviews/assets/*.jshistoryonly 实测正常;构建期固定执行,不再暴露额外环境变量TEXT/text_node 改写,避免多 bundle 场景漏补丁tooluseonly 与 toolusefix 都会导致主面板空白,相关 patch/开关/测试已从主线删除__augment_byok_ marker 的 patched JS 改名并重写 common-webviews/* 引用,避免 VS Code/WebView 复用旧缓存extension/out/extension.js 中注入 ./byok/runtime/bootstraptools/patch/patch-extension-entry.jstools/patch/patch-expose-upstream.jsglobalThis,不改变官方业务逻辑completionURL/apiToken 来源从 VS Code settings 改为 globalStatetools/patch/patch-official-overrides.jsruntimeEnabled=true 时,Model Picker 只展示 byok:*(避免“选了官方但 BYOK 实际忽略”的错觉)tools/patch/patch-model-picker-byok-only.jstools/patch/patch-disable-chat-history-truncation.jsruntimeEnabled=true 时生效(关闭 BYOK 不改变官方行为)callApi / callApiStream 方法开头注入一次性拦截tools/patch/patch-callapi-shim.jsmaybeHandleCallApi*() 返回 undefined → 回落到官方原生逻辑(软回滚关键)arguments[5]/[10],不读取上游 config token、不 stringify completionURL、不原地修改 bodybyok | official | disabledBYOK: Enable/Disable/Reload/Open Panel/Import/Export/Clear Cacheaugment.advanced.* settings 贡献点:避免误读/误写上游高级设置tools/patch/patch-package-json-commands.jsautoAuth=0 guard:构建产物中命中 autoAuth 字符串直接失败tools/patch/guard-no-autoauth.jsnode --check:对关键注入后的 JS 做语法检查(避免产物不可加载)tools/check/node-check-js.jstools/check/byok-contracts/main.jstools/check/byok-contracts/check-callapi-shim.jstools/check/byok-contracts/check-protocol-enums.jstools/check/byok-contracts/check-augment-protocol-shapes.jsaugment-byok.runtimeEnabled.v1augment-byok.config.v1(含 Key/Token;不参与 Sync)augment-byok.historySummaryCache.v1(不参与 Sync)runtimeEnabled=false 时 maybeHandleCallApi*() 直接返回 undefined/空 stream → 官方逻辑接管BYOK: Disable (Rollback)(不清空配置,仅切换运行时)BYOK: EnableSave 后对“后续请求”生效(不需要 Reload Window)BYOK: Open Config PanelretainContextWhenHidden=true(减少频繁重建导致的状态丢失)localResourceRoots=[out/byok/ui/config-panel]Reload:丢弃未保存修改,回到 last-good configBYOK: Export Config(可选脱敏/包含 secrets)include secrets(用于备份/迁移)redact secrets(敏感字段替换为 <redacted>,用于分享模板)BYOK: Import Config(可选 merge/replace)Merge (preserve existing secrets)(导入但保留当前已存密钥:当导入字段为空或 <redacted>)Replace (overwrite everything)(完全覆盖,密钥也会被覆盖/清空)version=1base_url / history_summary 等)"/chat-stream?x=1" → "/chat-stream")__proto__ / prototype / constructor 等不安全 key(配置与 UI 消息均做 hasOwnProperty 防护)requestDefaults 中的 BYOK 内部 key 会在发往上游前剥离(避免污染上游请求)official.completionUrl:默认 https://acemcp.heroman.wtf/relay/(可切私有租户)official.apiToken:默认空;到 https://acemcp.heroman.wtf/login 自行注册并填写自己的 API Token;清空则会跳过官方 /get-models 与上下文注入并输出一次降级提示agents/codebase-retrieval / search-external-sources / context-canvas/listmode=byok 生效id / type / baseUrl / models[] / defaultModel / apiKey? / headers? / requestDefaults? / underlyingModelMapping?underlyingModelMapping.titleGeneration/summary:仅在 silent=true 且命中“标题生成/对话总结”内部请求时覆盖当前 provider 的模型选择byok:<providerId>:<modelId>tools/gen/sync-provider-types.js):openai_compatibleopenai_responsesanthropicgemini_ai_studiorouting.rules[endpoint]={ mode, providerId?, model? }mode=byok:走 BYOK(仅对 8 个 LLM 数据面端点提供语义实现)mode=official:强制走官方(即使 runtimeEnabled=true 也不接管)mode=disabled:直接 no-op(callApi 返回 {},callApiStream 返回空 stream)providers[].requestDefaults 未配置任何 max tokens 字段时:BYOK 会自动注入 max_output_tokensmax_output_tokens 为 canonical,provider 映射层会转换到各自字段(例如 Gemini 的 generationConfig.maxOutputTokens)generationConfig.maxOutputTokens),避免不同映射优先级绕过historySummary.enabled:默认 false(显式开启才生效)historySummary.providerId/model:可空(仅控制“摘要生成模型”;为空时 fallback 到当前 provider/model)history + message + prefix/selected_code/suffix/diff(UTF-8 bytes)triggerOnHistorySizeChars(默认 800000)triggerStrategy=auto|ratio|chars(推荐 auto)triggerOnContextRatio / targetContextRatio(默认约 0.70 / 0.55,触发阈值自动钳制在 0.60~0.80)contextWindowTokensDefault / contextWindowTokensOverrides(override:最长子串、大小写不敏感)gpt-5.3-codex=400000、gpt-5.2=400000、claude-4.6-opus=1000000、gemini-3-pro=1000000、kimi-k2=128000historyTailSizeCharsToExclude(按 UTF-8 bytes 估算)+ minTailExchangesmaxTokens / timeoutSeconds / maxSummarizationInputChars(按 UTF-8 bytes 估算)rollingSummary=true + cacheTtlMs(对话维度缓存,减少重复 summarization)chat_history 含旧 summary 仍允许刷新summaryNodeRequestMessageTemplate + abridgedHistoryParamsend_part_full 中的 tool_result / tool_use input 会中间截断(保留尾部引用 id),防止单个工具输出撑爆上下文npm run upstream:analyze → .cache/reports/upstream-analysis.jsonnpm run report:coverage → dist/endpoint-coverage.report.mdcallApi(4):/get-models、/chat、/completion、/chat-input-completioncallApiStream(4):/chat-stream、/prompt-enhancer、/next-edit-stream、/generate-commit-message-streamtools/report/llm-endpoints-spec.jsnpm run gen:llm-endpoints(更新 UI + 默认 routing rules + official delegation)byok:* model override,也保持 official,不进入 BYOK 执行路径/get-models 外,目标 provider 未配置 baseUrl + 可用 auth/headers + 已知 type 时,路由保持 official/get-models(模型注册 + feature_flags 注入)providers[].models → byok:<providerId>:<modelId>default_model 为空且 models=[]/get-models 获取基础 flags(用于兼容上游 model registry)feature_flags 中的 model registry 相关字段(避免冲突/双注册)$ claude mcp add Augment-BYOK \
-- python -m otcore.mcp_server <graph>