fix: restore repo typecheck after provider request settings change
The required Provider.Request settings field and tsgo's literal narrowing broke typecheck in llm and core; CI missed it because turbo replayed cached typecheck results for packages whose own sources did not change. - anthropic-messages: lower adaptive thinking display with explicit literal branches so tsgo keeps the union type - runner model: annotate providerOptions with its index-signature return type - tests: construct provider requests with the now-required settings field and copy them mutably for plugin drafts
This commit is contained in:
parent
3898cac63d
commit
603fa77705
12 changed files with 32 additions and 18 deletions
|
|
@ -103,7 +103,9 @@ const withDefaults = (model: ModelV2.Info, route: AnyRoute) => {
|
|||
})
|
||||
}
|
||||
|
||||
const providerOptions = (model: ModelV2.Info) => {
|
||||
const providerOptions = (
|
||||
model: ModelV2.Info,
|
||||
): { readonly [key: string]: { readonly [key: string]: unknown } } | undefined => {
|
||||
if (Object.keys(model.request.settings).length === 0) return undefined
|
||||
if (model.api.type !== "aisdk") return undefined
|
||||
if (model.api.package === "@ai-sdk/openai") return { openai: model.request.settings }
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ describe("ConfigAgentPlugin.Plugin", () => {
|
|||
model: { providerID: "anthropic", id: "claude-sonnet", variant: undefined },
|
||||
})
|
||||
expect(reviewer.request).toEqual({
|
||||
settings: {},
|
||||
headers: { first: "one", shared: "last", second: "two" },
|
||||
body: { enabled: true, profile: "review", retries: 2, effort: "high" },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -279,7 +279,11 @@ function agentInfo(value: AgentV2.Info) {
|
|||
return {
|
||||
...value,
|
||||
model: value.model && { ...value.model },
|
||||
request: { headers: { ...value.request.headers }, body: { ...value.request.body } },
|
||||
request: {
|
||||
settings: { ...value.request.settings },
|
||||
headers: { ...value.request.headers },
|
||||
body: { ...value.request.body },
|
||||
},
|
||||
permissions: value.permissions.map((permission) => ({ ...permission })),
|
||||
}
|
||||
}
|
||||
|
|
@ -288,7 +292,11 @@ function providerInfo(value: ProviderV2.MutableInfo) {
|
|||
return {
|
||||
...value,
|
||||
api: { ...value.api, settings: value.api.settings && { ...value.api.settings } },
|
||||
request: { settings: { ...value.request.settings }, headers: { ...value.request.headers }, body: { ...value.request.body } },
|
||||
request: {
|
||||
settings: { ...value.request.settings },
|
||||
headers: { ...value.request.headers },
|
||||
body: { ...value.request.body },
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ describe("AmazonBedrockPlugin", () => {
|
|||
})
|
||||
catalog.provider.update(bedrock.id, (item) => {
|
||||
item.api = bedrock.api
|
||||
item.request = bedrock.request
|
||||
item.request = { settings: {}, headers: {}, body: { endpoint: "https://bedrock.example" } }
|
||||
})
|
||||
})
|
||||
yield* addPlugin()
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ describe("AnthropicPlugin", () => {
|
|||
})
|
||||
catalog.provider.update(item.id, (draft) => {
|
||||
draft.api = item.api
|
||||
draft.request = item.request
|
||||
draft.request = { settings: {}, headers: { Existing: "1" }, body: {} }
|
||||
})
|
||||
})
|
||||
yield* addPlugin()
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ describe("AzurePlugin", () => {
|
|||
})
|
||||
catalog.provider.update(azure.id, (item) => {
|
||||
item.api = azure.api
|
||||
item.request = azure.request
|
||||
item.request = { settings: {}, headers: {}, body: { resourceName: "from-config" } }
|
||||
})
|
||||
catalog.provider.update(ProviderV2.ID.openai, () => {})
|
||||
})
|
||||
|
|
@ -110,7 +110,7 @@ describe("AzurePlugin", () => {
|
|||
})
|
||||
catalog.provider.update(azure.id, (item) => {
|
||||
item.api = azure.api
|
||||
item.request = azure.request
|
||||
item.request = { settings: {}, headers: {}, body: { resourceName: "" } }
|
||||
})
|
||||
})
|
||||
yield* addPlugin()
|
||||
|
|
@ -131,7 +131,7 @@ describe("AzurePlugin", () => {
|
|||
})
|
||||
catalog.provider.update(azure.id, (item) => {
|
||||
item.api = azure.api
|
||||
item.request = azure.request
|
||||
item.request = { settings: {}, headers: {}, body: { resourceName: " " } }
|
||||
})
|
||||
})
|
||||
yield* addPlugin()
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe("KiloPlugin", () => {
|
|||
package: "@ai-sdk/openai-compatible",
|
||||
url: "https://api.kilo.ai/api/gateway",
|
||||
}
|
||||
provider.request = { headers: { Existing: "value" }, body: {} }
|
||||
provider.request = { settings: {}, headers: { Existing: "value" }, body: {} }
|
||||
})
|
||||
catalog.provider.update(ProviderV2.ID.openrouter, () => {})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ describe("LLMGatewayPlugin", () => {
|
|||
package: "@ai-sdk/openai-compatible",
|
||||
url: "https://api.llmgateway.io/v1",
|
||||
}
|
||||
provider.request = { headers: { Existing: "value" }, body: {} }
|
||||
provider.request = { settings: {}, headers: { Existing: "value" }, body: {} }
|
||||
})
|
||||
catalog.provider.update(ProviderV2.ID.openrouter, () => {})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe("NvidiaPlugin", () => {
|
|||
package: "@ai-sdk/openai-compatible",
|
||||
url: "https://integrate.api.nvidia.com/v1",
|
||||
}
|
||||
provider.request = { headers: { Existing: "value" }, body: {} }
|
||||
provider.request = { settings: {}, headers: { Existing: "value" }, body: {} }
|
||||
})
|
||||
catalog.provider.update(ProviderV2.ID.openrouter, () => {})
|
||||
})
|
||||
|
|
@ -80,6 +80,7 @@ describe("NvidiaPlugin", () => {
|
|||
url: "https://integrate.api.nvidia.com/v1",
|
||||
}
|
||||
provider.request = {
|
||||
settings: {},
|
||||
headers: { "X-BILLING-INVOKE-ORIGIN": "CustomOrigin" },
|
||||
body: { baseURL: "https://integrate.api.nvidia.com/v1" },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ describe("OpencodePlugin", () => {
|
|||
cost: cost(1),
|
||||
})
|
||||
catalog.provider.update(provider.id, (draft) => {
|
||||
draft.request = provider.request
|
||||
draft.request = { settings: {}, headers: {}, body: { apiKey: "configured" } }
|
||||
})
|
||||
catalog.model.update(provider.id, model.id, (draft) => {
|
||||
draft.cost = [...model.cost]
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ describe("OpenRouterPlugin", () => {
|
|||
yield* catalog.transform((catalog) => {
|
||||
catalog.provider.update(ProviderV2.ID.openrouter, (provider) => {
|
||||
provider.api = { type: "aisdk", package: "@openrouter/ai-sdk-provider" }
|
||||
provider.request = { headers: { Existing: "value" }, body: {} }
|
||||
provider.request = { settings: {}, headers: { Existing: "value" }, body: {} }
|
||||
})
|
||||
catalog.provider.update(ProviderV2.ID.make("nvidia"), () => {})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -508,11 +508,13 @@ const lowerThinking = Effect.fn("AnthropicMessages.lowerThinking")(function* (re
|
|||
const thinking = anthropicOptions(request)?.thinking
|
||||
if (!ProviderShared.isRecord(thinking)) return undefined
|
||||
if (thinking.type === "adaptive") {
|
||||
const display = thinking.display
|
||||
return {
|
||||
type: "adaptive" as const,
|
||||
...(display === "summarized" || display === "omitted" ? { display } : {}),
|
||||
}
|
||||
const display =
|
||||
thinking.display === "summarized"
|
||||
? ("summarized" as const)
|
||||
: thinking.display === "omitted"
|
||||
? ("omitted" as const)
|
||||
: undefined
|
||||
return { type: "adaptive" as const, ...(display === undefined ? {} : { display }) }
|
||||
}
|
||||
if (thinking.type === "disabled") return { type: "disabled" as const }
|
||||
if (thinking.type !== "enabled") return undefined
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue