mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-18 04:42:30 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
export type NamespaceIdentity = { namespace: string; name: string };
|
|
|
|
/**
|
|
* Return a string-valued copy only when the complete map is an alias ledger.
|
|
*
|
|
* The legacy `_toolNameMap` side channel can carry either response aliases or
|
|
* namespace identities. Checking every value before copying keeps those two
|
|
* contracts separate and gives callers a real `Map<string, string>` instead of
|
|
* asserting an identity map into the alias shape.
|
|
*/
|
|
export function toToolNameAliasMap(
|
|
map: ReadonlyMap<string, unknown> | null
|
|
): Map<string, string> | null {
|
|
if (!map || map.size === 0) return null;
|
|
|
|
const aliases = new Map<string, string>();
|
|
for (const [wireName, originalName] of map) {
|
|
if (typeof originalName !== "string") return null;
|
|
aliases.set(wireName, originalName);
|
|
}
|
|
return aliases;
|
|
}
|
|
|
|
/**
|
|
* Extract the #7936 request-tool identity map from the translated body and
|
|
* strip both side channels before dispatch.
|
|
*
|
|
* #9780 — prefer the dedicated `_namespaceToolIdentityMap`: on a pivot the
|
|
* openai->claude/gemini step publishes its own alias `Map<string, string>` on
|
|
* `_toolNameMap`, so that property alone can yield aliases instead of
|
|
* identities. The `_toolNameMap` read stays as the fallback for the non-pivot
|
|
* producers (executors/base.ts, cliproxyapi.ts, antigravity).
|
|
*/
|
|
export function extractRequestToolIdentityMap(
|
|
translatedBody: Record<string, unknown>
|
|
): Map<string, NamespaceIdentity> | null {
|
|
const namespaceIdentityMap = translatedBody._namespaceToolIdentityMap;
|
|
const requestToolIdentityMap =
|
|
namespaceIdentityMap instanceof Map
|
|
? namespaceIdentityMap
|
|
: translatedBody._toolNameMap instanceof Map
|
|
? translatedBody._toolNameMap
|
|
: null;
|
|
delete translatedBody._namespaceToolIdentityMap;
|
|
delete translatedBody._toolNameMap;
|
|
return requestToolIdentityMap as Map<string, NamespaceIdentity> | null;
|
|
}
|