mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
* add abstraction for schema enrichment, improve agent KB block experience for tags, fix visibility of subblocks * cleanup code * consolidate * fix workflow tool react query * fix deployed context propagation * fix tests
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import {
|
|
buildCanonicalIndex,
|
|
type CanonicalIndex,
|
|
evaluateSubBlockCondition,
|
|
getCanonicalValues,
|
|
isCanonicalPair,
|
|
resolveCanonicalMode,
|
|
type SubBlockCondition,
|
|
} from '@/lib/workflows/subblocks/visibility'
|
|
import type { SubBlockConfig as BlockSubBlockConfig } from '@/blocks/types'
|
|
|
|
export {
|
|
buildCanonicalIndex,
|
|
type CanonicalIndex,
|
|
evaluateSubBlockCondition,
|
|
type SubBlockCondition,
|
|
}
|
|
|
|
export interface ToolParamContext {
|
|
blockType: string
|
|
subBlocks: BlockSubBlockConfig[]
|
|
canonicalIndex: CanonicalIndex
|
|
values: Record<string, unknown>
|
|
}
|
|
|
|
/**
|
|
* Build preview context values for selectors that need dependency resolution.
|
|
* Resolves canonical values so selectors get the correct credential/dependency values.
|
|
*/
|
|
export function buildPreviewContextValues(
|
|
params: Record<string, unknown>,
|
|
context: ToolParamContext
|
|
): Record<string, unknown> {
|
|
const result: Record<string, unknown> = { ...params }
|
|
|
|
for (const [canonicalId, group] of Object.entries(context.canonicalIndex.groupsById)) {
|
|
if (isCanonicalPair(group)) {
|
|
const mode = resolveCanonicalMode(group, context.values)
|
|
const { basicValue, advancedValue } = getCanonicalValues(group, context.values)
|
|
result[canonicalId] =
|
|
mode === 'advanced' ? (advancedValue ?? basicValue) : (basicValue ?? advancedValue)
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|