diff --git a/.changeset/auto-model-capability.md b/.changeset/auto-model-capability.md new file mode 100644 index 0000000000..b28e91b43f --- /dev/null +++ b/.changeset/auto-model-capability.md @@ -0,0 +1,9 @@ +--- +'@truefoundry/trueforge-core': patch +'@truefoundry/trueforge': patch +'@truefoundry/trueforge-ui': patch +'@truefoundry/trueforge-assistant-ui-runtime': patch +'@truefoundry/trueforge-sdk': patch +--- + +`GET /api/v1/capabilities` reports `auto.enabled`: model routing is on for the tenant and the user has a model in every routing cluster. The new-chat model picker offers Auto, which is only selectable when that capability is enabled. Core adds `canRouteEveryCategory`. diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.json index d325015bad..9c84039e70 100644 --- a/.github/fern/openapi/openapi.json +++ b/.github/fern/openapi/openapi.json @@ -344,6 +344,18 @@ }, "type": "object" }, + "AutoCapability": { + "properties": { + "enabled": { + "description": "Whether Auto mode can be selected: the user has at least one model in every routing cluster.", + "type": "boolean" + } + }, + "required": [ + "enabled" + ], + "type": "object" + }, "AvailableMCPServer": { "additionalProperties": false, "properties": { @@ -479,6 +491,9 @@ }, "CapabilitiesData": { "properties": { + "auto": { + "$ref": "#/components/schemas/AutoCapability" + }, "memory": { "$ref": "#/components/schemas/MemoryCapability" }, @@ -503,6 +518,7 @@ "skill", "settings", "web_search", + "auto", "session_sharing" ], "type": "object" diff --git a/docs/openapi.json b/docs/openapi.json index d325015bad..9c84039e70 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -344,6 +344,18 @@ }, "type": "object" }, + "AutoCapability": { + "properties": { + "enabled": { + "description": "Whether Auto mode can be selected: the user has at least one model in every routing cluster.", + "type": "boolean" + } + }, + "required": [ + "enabled" + ], + "type": "object" + }, "AvailableMCPServer": { "additionalProperties": false, "properties": { @@ -479,6 +491,9 @@ }, "CapabilitiesData": { "properties": { + "auto": { + "$ref": "#/components/schemas/AutoCapability" + }, "memory": { "$ref": "#/components/schemas/MemoryCapability" }, @@ -503,6 +518,7 @@ "skill", "settings", "web_search", + "auto", "session_sharing" ], "type": "object" diff --git a/packages/assistant-ui-runtime/src/server/types.ts b/packages/assistant-ui-runtime/src/server/types.ts index 4cf7d53943..6908863e33 100644 --- a/packages/assistant-ui-runtime/src/server/types.ts +++ b/packages/assistant-ui-runtime/src/server/types.ts @@ -601,6 +601,11 @@ export interface AgentBuilderCapabilitiesResponse { webSearch?: { enabled: boolean; reason?: string }; /** Absent when the host does not offer memory, which hides memory settings; `reason` explains a locked toggle. */ memory?: { enabled: boolean; reason?: string }; + /** + * Whether Auto mode can be selected in the model picker. Enabled when model routing is on and the user has a model + * in every routing cluster; absent means Auto mode cannot be selected. + */ + auto?: { enabled: boolean }; /** Finest supported sharing scope; `subject` allows invite-by-user as well as tenant-wide sharing. */ sessionSharing: { granularity: 'tenant' | 'subject' }; }; diff --git a/packages/trueforge-core/src/core/index.ts b/packages/trueforge-core/src/core/index.ts index 8a6455dc59..438cc480b4 100644 --- a/packages/trueforge-core/src/core/index.ts +++ b/packages/trueforge-core/src/core/index.ts @@ -123,6 +123,7 @@ export { OpenAIDecisionModel } from './decision/OpenAIDecisionModel'; export { DEFAULT_ROUTING_QUESTION, type RoutingCategory, type RoutingQuestion } from './modelRouting/question'; export { AUTO_MODEL, + canRouteEveryCategory, createModelRouter, selectModel, type ModelRouterDeps, diff --git a/packages/trueforge-core/src/core/modelRouting/router.ts b/packages/trueforge-core/src/core/modelRouting/router.ts index d046a65ca1..32a012c130 100644 --- a/packages/trueforge-core/src/core/modelRouting/router.ts +++ b/packages/trueforge-core/src/core/modelRouting/router.ts @@ -67,6 +67,13 @@ function isRoutingCategory(category: string): category is RoutingCategory { return Object.hasOwn(ROUTING_CLUSTERS, category); } +/** True when every routing category has a model the user can be routed to. */ +export function canRouteEveryCategory(models: readonly RoutableModel[]): boolean { + return Object.keys(ROUTING_CLUSTERS) + .filter(isRoutingCategory) + .every(category => selectModel({ category, models }) !== undefined); +} + export interface ModelRouterDeps { /** The decision model that categorises the task, e.g. Jev; called on every route. */ classifier: () => Promise; diff --git a/packages/trueforge-sdk/src/api/types/AutoCapability.ts b/packages/trueforge-sdk/src/api/types/AutoCapability.ts new file mode 100644 index 0000000000..e17f1bedcd --- /dev/null +++ b/packages/trueforge-sdk/src/api/types/AutoCapability.ts @@ -0,0 +1,6 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface AutoCapability { + /** Whether Auto mode can be selected: the user has at least one model in every routing cluster. */ + enabled: boolean; +} diff --git a/packages/trueforge-sdk/src/api/types/CapabilitiesData.ts b/packages/trueforge-sdk/src/api/types/CapabilitiesData.ts index 8aab0318cb..7f6478fe4b 100644 --- a/packages/trueforge-sdk/src/api/types/CapabilitiesData.ts +++ b/packages/trueforge-sdk/src/api/types/CapabilitiesData.ts @@ -3,6 +3,7 @@ import type * as TrueForge from "../index.js"; export interface CapabilitiesData { + auto: TrueForge.AutoCapability; memory?: TrueForge.MemoryCapability; sandbox: TrueForge.SandboxCapability; sessionSharing: TrueForge.SessionSharingCapability; diff --git a/packages/trueforge-sdk/src/api/types/index.ts b/packages/trueforge-sdk/src/api/types/index.ts index 846a4b5f26..76d82433c2 100644 --- a/packages/trueforge-sdk/src/api/types/index.ts +++ b/packages/trueforge-sdk/src/api/types/index.ts @@ -12,6 +12,7 @@ export * from "./ApprovalAllow.js"; export * from "./ApprovalDecision.js"; export * from "./ApprovalDeny.js"; export * from "./AskUserQuestionsConfig.js"; +export * from "./AutoCapability.js"; export * from "./AvailableMcpServer.js"; export * from "./AvailableModel.js"; export * from "./AvailableModelProvider.js"; diff --git a/packages/trueforge-sdk/src/serialization/types/AutoCapability.ts b/packages/trueforge-sdk/src/serialization/types/AutoCapability.ts new file mode 100644 index 0000000000..57e754aa87 --- /dev/null +++ b/packages/trueforge-sdk/src/serialization/types/AutoCapability.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as TrueForge from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const AutoCapability: core.serialization.ObjectSchema = + core.serialization.object({ + enabled: core.serialization.boolean(), + }); + +export declare namespace AutoCapability { + export interface Raw { + enabled: boolean; + } +} diff --git a/packages/trueforge-sdk/src/serialization/types/CapabilitiesData.ts b/packages/trueforge-sdk/src/serialization/types/CapabilitiesData.ts index a5e072778e..b701e88dd2 100644 --- a/packages/trueforge-sdk/src/serialization/types/CapabilitiesData.ts +++ b/packages/trueforge-sdk/src/serialization/types/CapabilitiesData.ts @@ -3,6 +3,7 @@ import type * as TrueForge from "../../api/index.js"; import * as core from "../../core/index.js"; import type * as serializers from "../index.js"; +import { AutoCapability } from "./AutoCapability.js"; import { MemoryCapability } from "./MemoryCapability.js"; import { SandboxCapability } from "./SandboxCapability.js"; import { SessionSharingCapability } from "./SessionSharingCapability.js"; @@ -14,6 +15,7 @@ export const CapabilitiesData: core.serialization.ObjectSchema< serializers.CapabilitiesData.Raw, TrueForge.CapabilitiesData > = core.serialization.object({ + auto: AutoCapability, memory: MemoryCapability.optional(), sandbox: SandboxCapability, sessionSharing: core.serialization.property("session_sharing", SessionSharingCapability), @@ -24,6 +26,7 @@ export const CapabilitiesData: core.serialization.ObjectSchema< export declare namespace CapabilitiesData { export interface Raw { + auto: AutoCapability.Raw; memory?: MemoryCapability.Raw | null; sandbox: SandboxCapability.Raw; session_sharing: SessionSharingCapability.Raw; diff --git a/packages/trueforge-sdk/src/serialization/types/index.ts b/packages/trueforge-sdk/src/serialization/types/index.ts index 846a4b5f26..76d82433c2 100644 --- a/packages/trueforge-sdk/src/serialization/types/index.ts +++ b/packages/trueforge-sdk/src/serialization/types/index.ts @@ -12,6 +12,7 @@ export * from "./ApprovalAllow.js"; export * from "./ApprovalDecision.js"; export * from "./ApprovalDeny.js"; export * from "./AskUserQuestionsConfig.js"; +export * from "./AutoCapability.js"; export * from "./AvailableMcpServer.js"; export * from "./AvailableModel.js"; export * from "./AvailableModelProvider.js"; diff --git a/packages/trueforge-sdk/tests/wire/server.test.ts b/packages/trueforge-sdk/tests/wire/server.test.ts index bd35701982..5d45a26108 100644 --- a/packages/trueforge-sdk/tests/wire/server.test.ts +++ b/packages/trueforge-sdk/tests/wire/server.test.ts @@ -11,6 +11,7 @@ describe("ServerClient", () => { const rawResponseBody = { data: { + auto: { enabled: true }, memory: { enabled: true, reason: "reason" }, sandbox: { enabled: true, environments: { enabled: true } }, session_sharing: { granularity: "tenant" }, @@ -38,6 +39,9 @@ describe("ServerClient", () => { const response = await client.server.getCapabilities(); expect(response).toEqual({ data: { + auto: { + enabled: true, + }, memory: { enabled: true, reason: "reason", diff --git a/packages/trueforge-ui/src/atoms/draft/AgentModelEditorContent.tsx b/packages/trueforge-ui/src/atoms/draft/AgentModelEditorContent.tsx index 3f8ed90ea6..ec62eb00bb 100644 --- a/packages/trueforge-ui/src/atoms/draft/AgentModelEditorContent.tsx +++ b/packages/trueforge-ui/src/atoms/draft/AgentModelEditorContent.tsx @@ -169,6 +169,8 @@ export function AgentModelEditorContent({ query="" onQueryChange={onQueryChange} listboxId={listboxId} + autoOption={undefined} + reasoning={undefined} showHeading={false} showSearch={false} onSelect={model => onChange({ ...spec, model: modelForSelection(spec, model) })} @@ -209,6 +211,8 @@ export function AgentModelEditorContent({ query={query} onQueryChange={onQueryChange} listboxId={listboxId} + autoOption={undefined} + reasoning={undefined} showHeading={false} showSearch={false} onSelect={model => onChange({ ...spec, model: modelForSelection(spec, model) })} diff --git a/packages/trueforge-ui/src/atoms/draft/DraftComposerSections.tsx b/packages/trueforge-ui/src/atoms/draft/DraftComposerSections.tsx index fa2ade1655..be1c534926 100644 --- a/packages/trueforge-ui/src/atoms/draft/DraftComposerSections.tsx +++ b/packages/trueforge-ui/src/atoms/draft/DraftComposerSections.tsx @@ -11,7 +11,6 @@ import { auiButtonClass } from '../lib/buttonClasses.js'; import { useCompactLayout } from '../lib/CompactLayoutContext.js'; import { useIsMobile } from '../lib/useIsMobile.js'; import { Tooltip } from '../primitives/Tooltip.js'; -import { DraftReasoningEffortSelector } from './DraftReasoningEffortSelector.js'; export function DraftComposerLeftSection({ disabled, isRunning, onAttach }: ComposerLeftSectionProps) { const shell = useOptionalShellMode(); @@ -83,7 +82,6 @@ export function DraftComposerRightSection({ disabled, isRunning }: ComposerRight return (
{!isBuilder ? : null} -
); } diff --git a/packages/trueforge-ui/src/atoms/draft/DraftModelCatalogPanel.tsx b/packages/trueforge-ui/src/atoms/draft/DraftModelCatalogPanel.tsx index b2d6558ccf..51512ffd37 100644 --- a/packages/trueforge-ui/src/atoms/draft/DraftModelCatalogPanel.tsx +++ b/packages/trueforge-ui/src/atoms/draft/DraftModelCatalogPanel.tsx @@ -1,12 +1,13 @@ 'use client'; -import { useMemo } from 'react'; +import { useMemo, type SyntheticEvent } from 'react'; import { Icon } from '../../icons/Icon.js'; import type { ModelSelection } from '../../server/types.js'; import { cn } from '../lib/cn.js'; import { auiInputClass } from '../lib/inputClasses.js'; import { CatalogLogo } from '../primitives/CatalogLogo.js'; import { Tooltip, type TooltipSide } from '../primitives/Tooltip.js'; +import { AUTO_MODEL, AUTO_MODEL_LABEL, AUTO_MODEL_UNAVAILABLE_HINT } from './autoModel.js'; import { DraftCatalogEmptyState } from './DraftCatalogEmptyState.js'; import { modelMatchesQuery, normalizeModelSearchText } from './modelSearch.js'; @@ -16,6 +17,7 @@ function monogram(value: string): string { } export function displayModelLabel(modelName: string): string { + if (modelName === AUTO_MODEL) return AUTO_MODEL_LABEL; const slash = modelName.lastIndexOf('/'); return slash >= 0 ? modelName.slice(slash + 1) : modelName; } @@ -51,6 +53,56 @@ export function ProviderMark({ logo, label, className }: { logo?: string; label: ); } +export type DraftAutoModelOption = { + enabled: boolean; + onSelect: () => void; +}; + +export type DraftModelReasoningControls = { + /** `undefined` hides the effort label and its edit control for that row. */ + effortLabel: (model: ModelSelection) => string | undefined; + editingName: string | undefined; + onEdit: (model: ModelSelection, row: HTMLElement) => void; +}; + +function ReasoningEffortEditTrigger({ + isEditing, + isPinned, + onEdit, +}: { + isEditing: boolean; + /** Otherwise revealed on row hover or focus (always visible below md, where hover is unreliable). */ + isPinned: boolean; + onEdit: (row: HTMLElement) => void; +}) { + const open = (event: SyntheticEvent) => { + event.preventDefault(); + event.stopPropagation(); + const row = event.currentTarget.closest('[role="option"]'); + if (row) onEdit(row); + }; + // A +
+ + ) : null} {filtered.length === 0 ? ( - + showAuto ? null : ( + + ) ) : ( sections.map((section, sectionIndex) => { const headingId = `${listboxId}-provider-${sectionIndex}`; @@ -164,6 +250,8 @@ export function DraftModelCatalogPanel({ {section.models.map(model => { const active = selectedName ? model.name === selectedName : filtered[0] === model; const warning = model.warning?.trim(); + const effortLabel = showHeading ? reasoning?.effortLabel(model) : undefined; + const isEditing = reasoning?.editingName === model.name; return ( {selectedWarning ? : null} {open ? ( - isMobile || compactLayout ? ( - - {content} + sheet ? ( + (next ? setOpen(true) : close())} aria-label="Select model"> + {effortMenu ?? content} ) : ( -
- {content} +
+
+ {content} +
+ {effortTarget ? ( +
+ {effortMenu} +
+ ) : null}
) ) : null} diff --git a/packages/trueforge-ui/src/atoms/draft/DraftReasoningEffortMenu.tsx b/packages/trueforge-ui/src/atoms/draft/DraftReasoningEffortMenu.tsx new file mode 100644 index 0000000000..a6f490bb7c --- /dev/null +++ b/packages/trueforge-ui/src/atoms/draft/DraftReasoningEffortMenu.tsx @@ -0,0 +1,61 @@ +'use client'; + +import { Icon } from '../../icons/Icon.js'; +import { auiButtonClass } from '../lib/buttonClasses.js'; +import { cn } from '../lib/cn.js'; +import { reasoningEffortLabel } from './reasoningEffort.js'; + +export function DraftReasoningEffortMenu({ + efforts, + current, + onSelect, + onBack, +}: { + efforts: string[]; + /** `undefined` is the "Default" option: no effort is sent. */ + current: string | undefined; + onSelect: (effort: string | undefined) => void; + /** Set when the menu replaces the model list (bottom sheet) instead of opening beside it. */ + onBack: (() => void) | undefined; +}) { + const options = [undefined, ...efforts]; + return ( + <> +
+ {onBack ? ( + + ) : null} +

Reasoning

+
+
+
+ {options.map(effort => { + const active = effort === current; + return ( + + ); + })} +
+ + ); +} diff --git a/packages/trueforge-ui/src/atoms/draft/DraftReasoningEffortSelector.tsx b/packages/trueforge-ui/src/atoms/draft/DraftReasoningEffortSelector.tsx deleted file mode 100644 index c03f0011f5..0000000000 --- a/packages/trueforge-ui/src/atoms/draft/DraftReasoningEffortSelector.tsx +++ /dev/null @@ -1,150 +0,0 @@ -'use client'; - -import { useTrueForgeAgentSpec, useTrueForgeUpdateAgentSpec } from '@truefoundry/trueforge-assistant-ui-runtime'; -import { useEffect, useId, useRef, useState } from 'react'; - -import { Icon } from '../../icons/Icon.js'; -import { auiButtonClass } from '../lib/buttonClasses.js'; -import { cn } from '../lib/cn.js'; -import { useCompactLayout } from '../lib/CompactLayoutContext.js'; -import { useIsMobile } from '../lib/useIsMobile.js'; -import { BottomSheet } from '../primitives/BottomSheet.js'; -import { useDraftCatalog } from './DraftCatalogProvider.js'; -import { hasReasoningEfforts, modelPatchWithReasoningEffort, resolveReasoningEffort } from './reasoningEffort.js'; - -export type DraftReasoningEffortSelectorProps = { - disabled?: boolean; - isRunning?: boolean; -}; - -export function DraftReasoningEffortSelector({ disabled, isRunning }: DraftReasoningEffortSelectorProps) { - const { models, ensureLoaded } = useDraftCatalog(); - const { agentSpec } = useTrueForgeAgentSpec(); - const updateAgentSpec = useTrueForgeUpdateAgentSpec(); - const [open, setOpen] = useState(false); - const containerRef = useRef(null); - const previousModelNameRef = useRef(null); - const menuId = useId(); - const isMobile = useIsMobile(); - const compactLayout = useCompactLayout(); - - const selectedName = agentSpec?.model?.name ?? models[0]?.name ?? ''; - const selected = models.find(m => m.name === selectedName); - const efforts = selected?.properties.reasoningEfforts; - const currentEffort = agentSpec?.model?.params?.reasoningEffort; - // Display fallback only — coerce into the spec on model change / explicit pick. - const resolved = resolveReasoningEffort(efforts, currentEffort); - - useEffect(() => { - // Need catalog to know whether this model exposes reasoning efforts. - ensureLoaded(); - }, [ensureLoaded]); - - useEffect(() => { - if (!open) return; - const handler = (e: MouseEvent) => { - if (containerRef.current && !containerRef.current.contains(e.target as Node)) { - setOpen(false); - } - }; - document.addEventListener('mousedown', handler); - return () => document.removeEventListener('mousedown', handler); - }, [open]); - - // Clear a sticky effort only when the selection changes onto a model with no efforts. - // An effort set while staying on the current model is explicit. - useEffect(() => { - if (!updateAgentSpec || selected === undefined) return; - const previousName = previousModelNameRef.current; - previousModelNameRef.current = selected.name; - if (previousName === null || previousName === selected.name) return; - if (hasReasoningEfforts(efforts) || currentEffort === undefined) return; - updateAgentSpec({ - model: modelPatchWithReasoningEffort(selected.name, agentSpec?.model?.params, undefined), - }); - }, [updateAgentSpec, selected, efforts, currentEffort, agentSpec?.model?.params]); - - if (!hasReasoningEfforts(efforts) || !resolved) return null; - - const content = ( - <> -
-

Reasoning effort

-
-
- {efforts.map(effort => { - const active = effort === resolved; - return ( - - ); - })} -
- - ); - - return ( -
- - - {open ? ( - isMobile || compactLayout ? ( - - {content} - - ) : ( -
- {content} -
- ) - ) : null} -
- ); -} diff --git a/packages/trueforge-ui/src/atoms/draft/DraftSpecPreferenceBridge.tsx b/packages/trueforge-ui/src/atoms/draft/DraftSpecPreferenceBridge.tsx index f6dbe7eeb2..5f21e7ab02 100644 --- a/packages/trueforge-ui/src/atoms/draft/DraftSpecPreferenceBridge.tsx +++ b/packages/trueforge-ui/src/atoms/draft/DraftSpecPreferenceBridge.tsx @@ -16,8 +16,9 @@ import { useServerCapabilities } from '../../server/ServerContext.js'; import { useShellMode } from '../../server/ShellModeContext.js'; import type { AgentSkill, AgentSpec, ConnectorState, ModelSelection } from '../../server/types.js'; import { mountName } from '../lib/mountName.js'; +import { AUTO_MODEL, keepsAutoModel } from './autoModel.js'; import { useDraftCatalog } from './DraftCatalogProvider.js'; -import { modelPatchWithReasoningEffort } from './reasoningEffort.js'; +import { hasReasoningEfforts, modelPatchWithReasoningEffort } from './reasoningEffort.js'; import { skillFamilyId } from './SkillVersionSelector.js'; function readDraftSandboxEnabled(spec: AgentSpec): boolean | undefined { @@ -74,16 +75,20 @@ export function reconcileDraftSpecPreferences({ skills, connectors, skillsEnabled, + isAutoModelKept, }: { agentSpec: AgentSpec; models: ModelSelection[]; skills: AgentSkill[]; connectors: ConnectorState[]; skillsEnabled: boolean | undefined; + isAutoModelKept: boolean; }): Partial { const update: Partial = {}; const selectedModel = agentSpec.model.name.trim(); - if (!models.some(model => model.name === selectedModel)) { + const modelAvailable = + selectedModel === AUTO_MODEL ? isAutoModelKept : models.some(model => model.name === selectedModel); + if (!modelAvailable) { const fallback = models[0]; if (fallback !== undefined) { update.model = modelPatchWithReasoningEffort( @@ -224,6 +229,7 @@ export function DraftSpecPreferenceBridge() { const webSearchEnabled = capabilities?.webSearch?.enabled; // Capabilities omit memory when no provider is configured, which means unavailable. const memoryEnabled = capabilities == null ? undefined : (capabilities.memory?.enabled ?? false); + const isAutoModelKept = keepsAutoModel(capabilities); const prevWebSearchEnabledRef = useRef(webSearchEnabled); const prevMemoryEnabledRef = useRef(memoryEnabled); const { models, skills, connectors, loaded, error, ensureLoaded } = useDraftCatalog(); @@ -237,10 +243,33 @@ export function DraftSpecPreferenceBridge() { // An existing chat or a saved agent keeps the web search it was stored with, matching // the server: the tenant switch gates turning web search on, not keeping it on. const editsStoredSpec = preferenceKind === 'chat' ? draftSessionId != null : boundAgentId != null; + const previousModelNameRef = useRef(null); useEffect(() => { if (isPlainDraft) ensureLoaded(); }, [ensureLoaded, isPlainDraft]); + useEffect(() => { + if (!isMutableDraft) { + previousModelNameRef.current = null; + return; + } + const selected = models.find(model => model.name === agentSpec?.model.name); + if (agentSpec == null || selected === undefined) return; + const previousName = previousModelNameRef.current; + previousModelNameRef.current = selected.name; + // Clear a sticky effort only when the selection changes onto a model with no efforts. + // An effort set while staying on the current model is explicit. + if (!canReconcileLiveSpec || updateAgentSpec == null) return; + if (previousName === null || previousName === selected.name) return; + if ( + hasReasoningEfforts(selected.properties.reasoningEfforts) || + agentSpec.model.params?.reasoningEffort === undefined + ) { + return; + } + updateAgentSpec({ model: modelPatchWithReasoningEffort(selected.name, agentSpec.model.params, undefined) }); + }, [agentSpec, canReconcileLiveSpec, isMutableDraft, models, updateAgentSpec]); + useEffect(() => { if (isPlainDraft && canReconcileLiveSpec && agentSpec != null) { rememberDraftSpec(agentSpec, preferenceKind); @@ -337,6 +366,7 @@ export function DraftSpecPreferenceBridge() { skills, connectors, skillsEnabled: capabilities?.skill.enabled, + isAutoModelKept, }); if (Object.keys(update).length > 0) { updateAgentSpec(update); @@ -348,6 +378,7 @@ export function DraftSpecPreferenceBridge() { connectors, error, isPlainDraft, + isAutoModelKept, loaded, models, skills, diff --git a/packages/trueforge-ui/src/atoms/draft/autoModel.ts b/packages/trueforge-ui/src/atoms/draft/autoModel.ts new file mode 100644 index 0000000000..be87640fb7 --- /dev/null +++ b/packages/trueforge-ui/src/atoms/draft/autoModel.ts @@ -0,0 +1,29 @@ +import type { AgentBuilderCapabilitiesResponse, Model, ModelParams } from '../../server/types.js'; + +/** Spec model name that routes the root thread's model on every turn; same value as trueforge-core's `AUTO_MODEL`. */ +export const AUTO_MODEL = 'auto'; + +/** + * The draft patch that selects Auto. Auto runs on each routed model's own defaults and the server rejects params on + * it, so every param is unset. Each key is listed because `mergeAgentSpec` merges `params` key by key. + */ +export const AUTO_MODEL_PATCH: Model = { + name: AUTO_MODEL, + params: { + maxTokens: undefined, + reasoningEffort: undefined, + temperature: undefined, + topP: undefined, + topK: undefined, + parallelToolCalls: undefined, + } satisfies { [K in keyof Required]: undefined }, +}; + +export const AUTO_MODEL_LABEL = 'Auto'; + +export const AUTO_MODEL_UNAVAILABLE_HINT = 'Auto mode is not available for now'; + +/** Auto stays selected while capabilities load, and is dropped once they say it can't be picked. */ +export function keepsAutoModel(capabilities: AgentBuilderCapabilitiesResponse['data'] | null): boolean { + return capabilities == null || capabilities.auto?.enabled === true; +} diff --git a/packages/trueforge-ui/src/atoms/draft/reasoningEffort.ts b/packages/trueforge-ui/src/atoms/draft/reasoningEffort.ts index 08f06dbe7c..1dd80d2518 100644 --- a/packages/trueforge-ui/src/atoms/draft/reasoningEffort.ts +++ b/packages/trueforge-ui/src/atoms/draft/reasoningEffort.ts @@ -45,6 +45,14 @@ export function hasReasoningEfforts(efforts: ReasoningEfforts): efforts is strin return Array.isArray(efforts) && efforts.length > 0; } +export const DEFAULT_REASONING_EFFORT_LABEL = 'Default'; + +/** `undefined` means no effort is sent, so the provider's default applies. */ +export function reasoningEffortLabel(effort: string | undefined): string { + if (effort === undefined) return DEFAULT_REASONING_EFFORT_LABEL; + return effort.charAt(0).toUpperCase() + effort.slice(1); +} + const DEFAULT_REASONING_EFFORT_PREFERENCE = ['medium', 'high', 'low'] as const; /** Keep current if still listed; otherwise default by preference: "medium", then "high", then "low". */ diff --git a/packages/trueforge-ui/test/atoms/draft/DraftCatalogProvider.test.tsx b/packages/trueforge-ui/test/atoms/draft/DraftCatalogProvider.test.tsx index c29ae1cae7..0131f26b41 100644 --- a/packages/trueforge-ui/test/atoms/draft/DraftCatalogProvider.test.tsx +++ b/packages/trueforge-ui/test/atoms/draft/DraftCatalogProvider.test.tsx @@ -135,6 +135,7 @@ describe('DraftCatalogProvider', () => { skills: [{ id: 'available-skill', name: 'Available skill' }], connectors: [{ id: 'available-mcp', name: 'Available MCP' }], skillsEnabled: true, + isAutoModelKept: false, }); expect(update).toEqual({ @@ -154,6 +155,7 @@ describe('DraftCatalogProvider', () => { skills: [], connectors: [{ id: 'available-mcp', name: 'Available MCP' }], skillsEnabled: true, + isAutoModelKept: false, }); expect(update).toEqual({ mcpServers: [{ name: 'Available MCP' }] }); @@ -169,6 +171,7 @@ describe('DraftCatalogProvider', () => { skills: [{ id: 'skill', name: 'Skill' }], connectors: [], skillsEnabled: false, + isAutoModelKept: false, }); expect(update.skills).toEqual([]); @@ -184,6 +187,7 @@ describe('DraftCatalogProvider', () => { skills: [{ id: 'agent-skill:acme/team/echo:3', name: 'echo' }], connectors: [], skillsEnabled: true, + isAutoModelKept: false, }); expect(update).toEqual({ @@ -202,6 +206,7 @@ describe('DraftCatalogProvider', () => { skills: [{ id: 'agent-skill:acme/team/echo:3', name: 'echo' }], connectors: [], skillsEnabled: true, + isAutoModelKept: false, }); expect(update).toEqual({}); @@ -217,6 +222,7 @@ describe('DraftCatalogProvider', () => { skills: [{ id: 'agent-skill:acme/team/echo:3', name: 'echo' }], connectors: [], skillsEnabled: true, + isAutoModelKept: false, }); expect(update).toEqual({ @@ -235,6 +241,7 @@ describe('DraftCatalogProvider', () => { skills: [], connectors: [], skillsEnabled: false, + isAutoModelKept: false, }); expect(update).toEqual({}); diff --git a/packages/trueforge-ui/test/atoms/draft/DraftComposerSections.test.tsx b/packages/trueforge-ui/test/atoms/draft/DraftComposerSections.test.tsx index 76e9acfb33..daee1018b0 100644 --- a/packages/trueforge-ui/test/atoms/draft/DraftComposerSections.test.tsx +++ b/packages/trueforge-ui/test/atoms/draft/DraftComposerSections.test.tsx @@ -1,5 +1,5 @@ // @vitest-environment jsdom -import { act, fireEvent, render, screen } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { useLayoutEffect, type ReactNode } from 'react'; import { beforeEach, describe, expect, it, vi } from 'vitest'; @@ -8,7 +8,7 @@ import { DraftComposerLeftSection, DraftComposerRightSection } from '@/atoms/dra import { CompactLayoutProvider } from '@/atoms/lib/CompactLayoutContext.js'; import { ServerProvider } from '@/server/ServerContext.js'; import { ShellModeProvider, useShellMode } from '@/server/ShellModeContext.js'; -import type { AgentSpec, ModelSelection } from '@/server/types.js'; +import type { AgentSpec } from '@/server/types.js'; import { createMockAgentUIServer } from '../../server/mockServer.js'; let agentSpec: AgentSpec; @@ -85,16 +85,16 @@ describe('draft composer sections', () => { expect(onAttach).toHaveBeenCalledTimes(1); }); - it('composes model and reasoning selectors in the right section', async () => { + it('composes the model selector, which owns reasoning effort, in the right section', async () => { render(); expect(await screen.findByRole('button', { name: 'Select model' })).toHaveTextContent('gpt-4.1'); - expect(await screen.findByTitle('Select reasoning effort')).toHaveTextContent('high'); + expect(screen.queryByTitle('Select reasoning effort')).not.toBeInTheDocument(); // Without shell builder mode, left chrome is Tools — not Agent config. expect(screen.queryByRole('button', { name: 'Agent config' })).not.toBeInTheDocument(); }); - it('keeps only the reasoning selector in the builder composer', async () => { + it('keeps model and reasoning controls out of the builder composer', () => { render( @@ -103,8 +103,8 @@ describe('draft composer sections', () => { , ); - expect(await screen.findByTitle('Select reasoning effort')).toHaveTextContent('high'); expect(screen.queryByRole('button', { name: 'Select model' })).not.toBeInTheDocument(); + expect(screen.queryByTitle('Select reasoning effort')).not.toBeInTheDocument(); }); it('shows the Agent config trigger only in compact builder layouts', () => { @@ -143,54 +143,14 @@ describe('draft composer sections', () => { expect(screen.getByText('Config open')).toBeInTheDocument(); }); - it('keeps an explicit reasoning effort when the model lists none', async () => { - agentSpec = { model: { name: 'openai/plain', params: { reasoningEffort: 'minimal' } } }; - let resolveModels: (models: ModelSelection[]) => void = () => {}; - const modelsReady = new Promise(resolve => { - resolveModels = resolve; - }); - const server = createMockAgentUIServer({ - getModels: () => modelsReady, - }); - - render( - - - - - - - - - , - ); - - await act(async () => { - resolveModels([ - { - id: 'plain', - name: 'openai/plain', - provider: { name: 'OpenAI' }, - properties: {}, - }, - ]); - await modelsReady; - }); - - expect(updateAgentSpec).not.toHaveBeenCalled(); - expect(screen.queryByTitle('Select reasoning effort')).not.toBeInTheDocument(); - }); - it('propagates disabled and running state to composed controls', async () => { const { rerender } = render(); expect(screen.getByRole('button', { name: 'Tools (4)' })).toBeDisabled(); expect(await screen.findByRole('button', { name: 'Select model' })).toBeDisabled(); - expect(await screen.findByTitle('Select reasoning effort')).toBeDisabled(); rerender(); expect(screen.getByRole('button', { name: 'Tools (4)' })).toBeDisabled(); expect(await screen.findByRole('button', { name: 'Select model' })).toBeDisabled(); - expect(await screen.findByTitle('Select reasoning effort')).toBeDisabled(); }); }); diff --git a/packages/trueforge-ui/test/atoms/draft/DraftModelSelector.test.tsx b/packages/trueforge-ui/test/atoms/draft/DraftModelSelector.test.tsx index 641050cede..7c7f153b3e 100644 --- a/packages/trueforge-ui/test/atoms/draft/DraftModelSelector.test.tsx +++ b/packages/trueforge-ui/test/atoms/draft/DraftModelSelector.test.tsx @@ -143,7 +143,15 @@ describe('DraftModelSelector', () => { fireEvent.click(trigger); const listbox = screen.getByRole('listbox', { name: 'Select model' }); - expect(within(listbox).getAllByRole('option')).toHaveLength(2); + expect( + within(listbox) + .getAllByRole('option') + .map(option => option.textContent), + ).toEqual([ + expect.stringContaining('Auto'), + expect.stringContaining('gpt-4.1'), + expect.stringContaining('claude-3.7-sonnet'), + ]); expect(within(listbox).getByText(/128K context/)).toBeInTheDocument(); const providerGroups = within(listbox).getAllByRole('group'); expect(providerGroups).toHaveLength(2); @@ -200,6 +208,119 @@ describe('DraftModelSelector', () => { }); }); + it('shows row efforts and sets one from the Reasoning menu, selecting that model', async () => { + renderSelector(); + + const trigger = await screen.findByRole('button', { name: 'Select model' }); + await waitFor(() => expect(trigger).toHaveTextContent('gpt-4.1')); + fireEvent.click(trigger); + + const listbox = screen.getByRole('listbox', { name: 'Select model' }); + const plain = within(listbox).getByRole('option', { name: /gpt-4.1/i }); + expect(within(plain).queryByRole('button', { name: 'Edit reasoning effort' })).toBeNull(); + const reasoning = within(listbox).getByRole('option', { name: /claude-3.7-sonnet/i }); + expect(reasoning).toHaveTextContent('High'); + + fireEvent.click(within(reasoning).getByRole('button', { name: 'Edit reasoning effort' })); + expect(updateAgentSpec).not.toHaveBeenCalled(); + const menu = screen.getByRole('menu', { name: 'Reasoning effort' }); + expect( + within(menu) + .getAllByRole('menuitemradio') + .map(item => item.textContent), + ).toEqual(['Default', 'Low', 'High']); + expect(within(menu).getByRole('menuitemradio', { name: 'High' })).toHaveAttribute('aria-checked', 'true'); + + fireEvent.click(within(menu).getByRole('menuitemradio', { name: 'Low' })); + expect(updateAgentSpec).toHaveBeenCalledWith({ + model: { name: 'anthropic/claude-3.7-sonnet', params: { maxTokens: 512, reasoningEffort: 'low' } }, + }); + expect(trigger).toHaveAttribute('aria-expanded', 'false'); + }); + + it("shows the selected model's reasoning effort next to its name", async () => { + agentSpec = { model: { name: 'anthropic/claude-3.7-sonnet', params: { reasoningEffort: 'high' } } }; + renderSelector(); + + const trigger = await screen.findByRole('button', { name: 'Select model' }); + await waitFor(() => expect(trigger).toHaveTextContent('claude-3.7-sonnetHigh')); + }); + + it('shows no reasoning effort for a selected model without efforts', async () => { + renderSelector(); + + const trigger = await screen.findByRole('button', { name: 'Select model' }); + await waitFor(() => expect(trigger).toHaveTextContent('gpt-4.1')); + expect(trigger).not.toHaveTextContent('Medium'); + }); + + it('clears reasoningEffort when Default is chosen', async () => { + agentSpec = { model: { name: 'anthropic/claude-3.7-sonnet', params: { maxTokens: 512, reasoningEffort: 'high' } } }; + renderSelector(); + + const trigger = await screen.findByRole('button', { name: 'Select model' }); + await waitFor(() => expect(trigger).toHaveTextContent('claude-3.7-sonnet')); + fireEvent.click(trigger); + fireEvent.click(screen.getByRole('button', { name: 'Edit reasoning effort' })); + fireEvent.click(screen.getByRole('menuitemradio', { name: 'Default' })); + + expect(updateAgentSpec).toHaveBeenCalledWith({ + model: { name: 'anthropic/claude-3.7-sonnet', params: { maxTokens: 512, reasoningEffort: undefined } }, + }); + }); + + describe('with Auto available', () => { + const withAuto: Partial = { + getModels: async () => models, + getCapabilities: async () => ({ + data: { + sandbox: { enabled: true, environments: { enabled: true } }, + skill: { enabled: true }, + sessionSharing: tenantSessionSharing, + settings: allSettingsSections(true), + auto: { enabled: true }, + }, + }), + }; + + it('unsets every model param when Auto is selected', async () => { + renderSelector({}, withAuto); + + const trigger = await screen.findByRole('button', { name: 'Select model' }); + await waitFor(() => expect(trigger).toHaveTextContent('gpt-4.1')); + fireEvent.click(trigger); + const auto = await screen.findByRole('option', { name: /Auto/ }); + await waitFor(() => expect(auto).toBeEnabled()); + fireEvent.click(auto); + + expect(updateAgentSpec).toHaveBeenCalledWith({ + model: { + name: 'auto', + params: { + maxTokens: undefined, + reasoningEffort: undefined, + temperature: undefined, + topP: undefined, + topK: undefined, + parallelToolCalls: undefined, + }, + }, + }); + }); + + it('shows no empty state when the search only matches Auto', async () => { + renderSelector({}, withAuto); + + const trigger = await screen.findByRole('button', { name: 'Select model' }); + await waitFor(() => expect(trigger).toHaveTextContent('gpt-4.1')); + fireEvent.click(trigger); + fireEvent.change(screen.getByPlaceholderText('Search models'), { target: { value: 'auto' } }); + + expect(screen.getByRole('option', { name: /Auto/ })).toBeInTheDocument(); + expect(screen.queryByText('No models')).toBeNull(); + }); + }); + it('uses the first catalog model when the runtime has no draft spec', async () => { agentSpec = undefined; renderSelector(); diff --git a/packages/trueforge-ui/test/atoms/draft/DraftSpecPreferenceBridge.test.tsx b/packages/trueforge-ui/test/atoms/draft/DraftSpecPreferenceBridge.test.tsx index aec5c33ef4..ce969963c9 100644 --- a/packages/trueforge-ui/test/atoms/draft/DraftSpecPreferenceBridge.test.tsx +++ b/packages/trueforge-ui/test/atoms/draft/DraftSpecPreferenceBridge.test.tsx @@ -221,3 +221,36 @@ describe('DraftSpecPreferenceBridge memory', () => { await expectMemoryUntouched(); }); }); + +describe('DraftSpecPreferenceBridge reasoning effort', () => { + it('clears a sticky effort only once the selection moves onto a model without efforts', async () => { + agentSpec = { model: { name: 'plain', params: { reasoningEffort: 'high' } } }; + draftSessionId = undefined; + const server = createMockAgentUIServer({ + getModels: async () => [ + { id: 'reasoning', name: 'reasoning', provider: { name: 'P' }, properties: { reasoningEfforts: ['high'] } }, + { id: 'plain', name: 'plain', provider: { name: 'P' }, properties: {} }, + ], + }); + const tree = () => ( + + + + + + ); + const { rerender } = render(tree()); + await new Promise(resolve => setTimeout(resolve, 50)); + const clearsEffort = expect.objectContaining({ + model: { name: 'plain', params: { reasoningEffort: undefined } }, + }); + expect(updateAgentSpec).not.toHaveBeenCalledWith(clearsEffort); + + agentSpec = { model: { name: 'reasoning', params: { reasoningEffort: 'high' } } }; + rerender(tree()); + agentSpec = { model: { name: 'plain', params: { reasoningEffort: 'high' } } }; + rerender(tree()); + + await waitFor(() => expect(updateAgentSpec).toHaveBeenCalledWith(clearsEffort)); + }); +}); diff --git a/packages/trueforge/src/apis/capabilities.ts b/packages/trueforge/src/apis/capabilities.ts index 1e44ffcecd..824ccc916a 100644 --- a/packages/trueforge/src/apis/capabilities.ts +++ b/packages/trueforge/src/apis/capabilities.ts @@ -1,12 +1,16 @@ import { OpenAPIHono } from '@hono/zod-openapi'; +import { canRouteEveryCategory } from '@truefoundry/trueforge-core/core'; +import type { Context } from 'hono'; import type { Logger } from 'winston'; import { areCatalogSettingsAvailable, hasAdminRole, type ResolveRequestContext } from '../auth/identity'; +import { enabledTenantModelRouting, trueFoundryModelRouting } from '../config'; import { isMemoryEnabledForTenant, isWebSearchEnabledForTenant, type IConfigurationStore, } from '../db/configurationStore'; import type { IMemoryProviderStore } from '../db/memoryProviderStore'; +import type { IModelProviderStore } from '../db/modelProviderStore'; import type { ISandboxEnvironmentStore } from '../db/sandboxEnvironmentStore'; import type { WithTransaction } from '../db/transaction'; import type { IUserStore } from '../db/userStore'; @@ -61,11 +65,29 @@ function settingsCapability({ }; } +/** + * Auto needs model routing on for the tenant and a model the user has in every routing cluster. A failed listing + * fails the request, so clients keep their last known capabilities instead of dropping a selected Auto. + */ +async function isAutoModelAvailable({ + tenant_id, + store, +}: { + tenant_id: string; + store: IModelProviderStore; +}): Promise { + if (enabledTenantModelRouting(trueFoundryModelRouting(), tenant_id) === undefined) { + return false; + } + return canRouteEveryCategory(await store.listModels({ tenant_id, has_catalog_info: true })); +} + export function createCapabilitiesRouter(deps: { sandboxEnvironmentStore: ISandboxEnvironmentStore; webSearchProviderStore: IWebSearchProviderStore; configurationStore: IConfigurationStore; memoryProviderStore: IMemoryProviderStore; + resolveModelProviderStore: (c: Context) => IModelProviderStore; userStore: IUserStore; withTransaction: WithTransaction; logger: Logger; @@ -88,7 +110,7 @@ export function createCapabilitiesRouter(deps: { (await deps.sandboxEnvironmentStore.getDefaultEnvironment({ tenant_id: requestContext.tenant_id }))?.version .status, ); - const [hasProvider, tenantAllowsWebSearch, tenantAllowsMemory, hasMemoryProvider] = await Promise.all([ + const [hasProvider, tenantAllowsWebSearch, tenantAllowsMemory, hasMemoryProvider, autoEnabled] = await Promise.all([ hasConfiguredWebSearchProvider({ tenant_id: requestContext.tenant_id, store: deps.webSearchProviderStore, @@ -105,6 +127,10 @@ export function createCapabilitiesRouter(deps: { tenant_id: requestContext.tenant_id, store: deps.memoryProviderStore, }), + isAutoModelAvailable({ + tenant_id: requestContext.tenant_id, + store: deps.resolveModelProviderStore(c), + }), ]); const webSearchResponse: { enabled: boolean; reason?: string } = { @@ -146,6 +172,7 @@ export function createCapabilitiesRouter(deps: { }), web_search: webSearchResponse, ...(memoryResponse && { memory: memoryResponse }), + auto: { enabled: autoEnabled }, session_sharing: sessionSharing, }, }, diff --git a/packages/trueforge/src/app.ts b/packages/trueforge/src/app.ts index c61daf9849..2eca2075c3 100644 --- a/packages/trueforge/src/app.ts +++ b/packages/trueforge/src/app.ts @@ -411,6 +411,7 @@ export function createServerApp(deps: ServerDeps) { webSearchProviderStore: deps.webSearchProviderStore, configurationStore: deps.configurationStore, memoryProviderStore: deps.memoryProviderStore, + resolveModelProviderStore: c => deps.resolveModelProviderStore({ c }), userStore: deps.userStore, withTransaction: deps.withTransaction, logger: deps.logger, diff --git a/packages/trueforge/src/routes/capabilityRoutes.ts b/packages/trueforge/src/routes/capabilityRoutes.ts index 7115f64ce5..b34ea602ee 100644 --- a/packages/trueforge/src/routes/capabilityRoutes.ts +++ b/packages/trueforge/src/routes/capabilityRoutes.ts @@ -63,6 +63,14 @@ const MemoryCapabilitySchema = z .describe('Present only when the tenant has a memory provider; absent means memory settings are hidden.') .openapi('MemoryCapability'); +const AutoCapabilitySchema = z + .object({ + enabled: z + .boolean() + .describe('Whether Auto mode can be selected: the user has at least one model in every routing cluster.'), + }) + .openapi('AutoCapability'); + const SessionSharingCapabilitySchema = z .object({ granularity: z @@ -82,6 +90,7 @@ const CapabilitiesDataSchema = z settings: SettingsCapabilitySchema, web_search: WebSearchCapabilitySchema, memory: MemoryCapabilitySchema.optional(), + auto: AutoCapabilitySchema, session_sharing: SessionSharingCapabilitySchema, }) .openapi('CapabilitiesData'); diff --git a/packages/trueforge/tests/unit/apis/capabilities.test.ts b/packages/trueforge/tests/unit/apis/capabilities.test.ts index 70a7b82e82..911cfc3812 100644 --- a/packages/trueforge/tests/unit/apis/capabilities.test.ts +++ b/packages/trueforge/tests/unit/apis/capabilities.test.ts @@ -14,6 +14,7 @@ import type { IConfigurationStore } from '../../../src/db/configurationStore'; import type { IMemoryProviderStore } from '../../../src/db/memoryProviderStore'; import type { ISandboxEnvironmentStore, SandboxEnvironmentWithVersion } from '../../../src/db/sandboxEnvironmentStore'; import { createSqliteDb } from '../../../src/db/sqlite/client'; +import { SqliteModelProviderStore } from '../../../src/db/sqlite/model-provider-store/SqliteModelProviderStore'; import { EmptyUserStore, type IUserStore } from '../../../src/db/userStore'; import type { IWebSearchProviderStore } from '../../../src/db/webSearchProviderStore'; import { setCachedLocalSandboxSupport } from '../../../src/sandbox/localRuntime'; @@ -149,6 +150,7 @@ describe('capabilities routers', () => { webSearchProviderStore: webSearchStore ?? emptyWebSearchStore, configurationStore, memoryProviderStore: memoryStore, + resolveModelProviderStore: () => new SqliteModelProviderStore(db), userStore, withTransaction: (() => { const run = (callback: (trx: never) => Promise): Promise => @@ -182,6 +184,7 @@ describe('capabilities routers', () => { settings: ALL_SETTINGS_ON, web_search: { enabled: false, reason: NO_PROVIDER_REASON }, memory: { enabled: true }, + auto: { enabled: false }, session_sharing: { granularity: 'tenant' }, }, }); @@ -296,6 +299,7 @@ describe('capabilities routers', () => { settings: ALL_SETTINGS_ON, web_search: { enabled: false, reason: NO_PROVIDER_REASON }, memory: { enabled: true }, + auto: { enabled: false }, session_sharing: { granularity: 'tenant' }, }, }); @@ -315,6 +319,7 @@ describe('capabilities routers', () => { settings: ALL_SETTINGS_ON, web_search: { enabled: false, reason: NO_PROVIDER_REASON }, memory: { enabled: true }, + auto: { enabled: false }, session_sharing: { granularity: 'tenant' }, }, }); @@ -528,6 +533,7 @@ describe('capabilities routers', () => { webSearchProviderStore: emptyWebSearchStore, configurationStore: allOnConfigurationStore, memoryProviderStore: zepMemoryStore, + resolveModelProviderStore: () => new SqliteModelProviderStore(db), userStore: new EmptyUserStore(), withTransaction: (() => { const run = (callback: (trx: never) => Promise): Promise => @@ -557,6 +563,7 @@ describe('capabilities routers', () => { settings: ALL_SETTINGS_ON, web_search: { enabled: false, reason: NO_PROVIDER_REASON }, memory: { enabled: true }, + auto: { enabled: false }, session_sharing: { granularity: 'tenant' }, }, }); @@ -578,6 +585,7 @@ describe('capabilities routers', () => { settings: ALL_SETTINGS_OFF, web_search: { enabled: false, reason: NO_PROVIDER_REASON }, memory: { enabled: true }, + auto: { enabled: false }, session_sharing: { granularity: 'tenant' }, }, }); diff --git a/python/trueforge_sdk/src/trueforge_sdk/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/__init__.py index 9366c3bfe4..ebfb432715 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/__init__.py +++ b/python/trueforge_sdk/src/trueforge_sdk/__init__.py @@ -21,6 +21,7 @@ ApprovalDecision, ApprovalDeny, AskUserQuestionsConfig, + AutoCapability, AvailableMcpServer, AvailableModel, AvailableModelProvider, @@ -355,6 +356,7 @@ "ApprovalDeny": ".types", "AskUserQuestionsConfig": ".types", "AsyncTrueForge": ".client", + "AutoCapability": ".types", "AvailableMcpServer": ".types", "AvailableModel": ".types", "AvailableModelProvider": ".types", @@ -710,6 +712,7 @@ def __dir__(): "ApprovalDeny", "AskUserQuestionsConfig", "AsyncTrueForge", + "AutoCapability", "AvailableMcpServer", "AvailableModel", "AvailableModelProvider", diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py index 2ce7a59229..4733c782cf 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py +++ b/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py @@ -20,6 +20,7 @@ from .approval_decision import ApprovalDecision from .approval_deny import ApprovalDeny from .ask_user_questions_config import AskUserQuestionsConfig + from .auto_capability import AutoCapability from .available_mcp_server import AvailableMcpServer from .available_model import AvailableModel from .available_model_provider import AvailableModelProvider @@ -319,6 +320,7 @@ "ApprovalDecision": ".approval_decision", "ApprovalDeny": ".approval_deny", "AskUserQuestionsConfig": ".ask_user_questions_config", + "AutoCapability": ".auto_capability", "AvailableMcpServer": ".available_mcp_server", "AvailableModel": ".available_model", "AvailableModelProvider": ".available_model_provider", @@ -642,6 +644,7 @@ def __dir__(): "ApprovalDecision", "ApprovalDeny", "AskUserQuestionsConfig", + "AutoCapability", "AvailableMcpServer", "AvailableModel", "AvailableModelProvider", diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/auto_capability.py b/python/trueforge_sdk/src/trueforge_sdk/types/auto_capability.py new file mode 100644 index 0000000000..c2bf54ef52 --- /dev/null +++ b/python/trueforge_sdk/src/trueforge_sdk/types/auto_capability.py @@ -0,0 +1,22 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class AutoCapability(UncheckedBaseModel): + enabled: bool = pydantic.Field() + """ + Whether Auto mode can be selected: the user has at least one model in every routing cluster. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + extra = pydantic.Extra.allow diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/capabilities_data.py b/python/trueforge_sdk/src/trueforge_sdk/types/capabilities_data.py index a39d94d4a2..4ced6d0f1c 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/types/capabilities_data.py +++ b/python/trueforge_sdk/src/trueforge_sdk/types/capabilities_data.py @@ -5,6 +5,7 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +from .auto_capability import AutoCapability from .memory_capability import MemoryCapability from .sandbox_capability import SandboxCapability from .session_sharing_capability import SessionSharingCapability @@ -14,6 +15,7 @@ class CapabilitiesData(UncheckedBaseModel): + auto: AutoCapability memory: typing.Optional[MemoryCapability] = None sandbox: SandboxCapability session_sharing: SessionSharingCapability