Repository navigation
feat: providers followups — lane credentials + agent-reported provider registry (#2336) - #2344
Conversation
ACP-native agents (pi) POST their configured providers to the proxy (POST /__bili/agent-providers); recipes merge UNDER file recipes at request-apply time (file wins on name collision). Inline keys ride the request rail (target.apiKey XOR credentialRef, file world still rejects plaintext). Web GET exposes the registry without secrets; per-field PUT now validates chain expansion too (gap: it never did).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2500-pr.2344.1f49d1dThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2344.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…2344) The lane-credential table rows were hand-edited into the generated CONFIGURATION index; docs-sync regenerates from website/config-reference seeds and dropped them, failing the gate. Add the two seed entries and commit the regenerated output (rows now stable; backticks normalized out of desc cells per generator rule).
[bot] 🏷 #2344 核对完成(未重做工作):按 [PR] 流程拉取分支、对照 #2336 已批设计逐项审代码与行为、跑定向测试、查 CI。发现一处 CI 红灯(docs-sync)已直接在分支上修掉(见下)。 七问1. 是什么问题:非缺陷——#2163 统一 providers 字典蓝图的两项推迟设计落地:① operator 向 lane 主通道注入自有凭据( 2. 什么原因导致:不适用(功能项)。设计演进产物:#2163 蓝图 ① 已随 #2167 落地,②③ 因动凭据流被显式推迟到 #2336。 3. 怎么修复的:
4. 是否有回归问题:审过的既有行为逐项结论——
5. 是否破坏缓存:不涉及(prefix-cache/persist/重试游标均不受影响,见 4)。 6. 是否改了设计方向:无转向——完全落在统一字典方向内(单一名词表、gap-fill 合并序、凭据引用模式);③ 额外强化边界:agent 影响力封顶具名字典。 7. 是否引入了新的配置: 验证证据
收工判定代码方向、边界、披露均符合 #2336 已批设计,定向验证全绿,diff 干净(17 文件每一行都服务于本 PR 目的)。待 |
[bot] 🏷 跟进:CI 已出结果——head
收工判定维持不变:可合并(凭据流工作按档留给人工合并;我不会代合)。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.113-master.589bf4f # this exact build
npm install -g billion-context@master # always the newest merged build
|
Implements both followups from #2336 on top of the providers dictionary that landed in #2167.
① Lane credentials —
providers[URL].apiKeyEnv / credentialRefA provider route (URL-prefix entry) may now carry exactly one credential reference; on every forwarded request the proxy overrides the auth headers for that lane:
x-api-key/x-goog-api-keypresent → replaced in kindauthorizationpresent → replaced only when it is a Bearer scheme (anything else is signature-owned, e.g. AWS SigV4 — kept + warned)authorization: Bearer <key>AuthorizationApplied once on the shared
headersobject inforward()after the resign block, so every egress (initial request, role-retry, refold, compress-loop, continuation) inherits it.bindaliases inherit viafillRouteGaps. Web PUT validates via the existing per-entryparseRouteEntrypass (invalid → 400, #1909-style strict).③ Agent-reported provider registry (fallback layer)
ACP-native agents report their own configured providers to the proxy once per process (
POST /__bili/agent-providers): name, baseUrl, api, resolved key, model list. The pi extension (reportAgentProviders) sanitizes before sending: OAuth providers,auth.json("stored") credentials, endpoints pointing back at the proxy itself (origin comparison — the env-base form ofdetectProxyBasematches every URL), unmapped wire apis (bedrock/vertex/mistral/pi-messages), and name/shape violations are skipped.Core side (
src/agent-providers.ts): strictparseAgentProviderReportvalidation, in-memory per-agent registry, merged UNDER file recipes at both consumption points ({ ...agentProviderRecipes(), ...opts.namedProviders }inserver.tsreqConfig +admin.tsplugin manifest) — file wins on name collision (a file recipe shadows that provider's agent contribution entirely, including its models).Inline keys ride the request rail:
ExternalSummaryTarget.apiKey(XOR withcredentialRef), accepted only viaparseExternalSummarySettings(value, { inlineKeys: true })— the rail switch used by theConfiguredSummaryPlanctor; the file world still rejects plaintext keys. Keys never persist, never leave GET responses, never enter logs.Web surface: GET
/__bili/configaddsagentProviders(agent + provider/model names only, no keys, no baseUrl); the summary panel offers agent models in the target dropdown with an(agent)badge.Bug fixed in passing: the per-field PUT branch never validated chain expansion (an unknown ref saved with 200 — only the whole-file branch did). Both branches now reject unresolvable enabled chains with 400, with the agent layer merged in.
config surface
providers[URL].apiKeyEnv/providers[URL].credentialRef(lane credential override; exactly one; [feature] configurable wire-path table (per-provider custom paths) - Claude Desktop's claude.ai private protocol as motivating case #1909-style strict validation). Considered: reusing named-recipe fields on URL entries (rejected — route entries and recipes have different validation grammars;parseRouteEntrynow parses credentials only for non-recipe-shaped values); a separatelanestable (rejected — the providers table is the single routing surface by design).Testing
tests/lane-credentials.test.ts(12): apply rules (bearer ci / non-bearer preserved+warn / x-api-key / x-goog / inject-when-absent), resolution (env / longest-prefix routing / warn-once re-arm / secret via store), parse (double-cred throw / bad names / recipe-shape skip), full-chain against a fake upstream.tests/agent-providers.test.ts(8): report parse+normalize, 16-entry reject table, registry merge/status leak-proofing, inline-key rail (file rejects / inlineKeys accepts / XOR), endpoint + GET/PUT contract through a real server (agent-only ref saves; file-name shadowing 400s; unknown ref 400s), inline key dials verbatim, pi-side reporting (skip rules, POST shape, retry/done semantics).PiSubagentChildSignalthat turns the unused-export gate red on current master (verified on a2d2895 pre-fix).Fixes #2336