1+ import { isHosted } from '@/lib/core/config/feature-flags'
2+ import { isSubBlockHiddenByHostedKey } from '@/lib/workflows/subblocks/visibility'
13import type { BlockConfig , SubBlockConfig } from '@/blocks/types'
24import { PROVIDER_DEFINITIONS } from '@/providers/models'
35import type { ToolConfig } from '@/tools/types'
@@ -365,16 +367,25 @@ function serializeSubBlock(sb: SubBlockConfig): Record<string, unknown> {
365367 * Serialize a block schema for VFS components/blocks/{type}.json
366368 */
367369export function serializeBlockSchema ( block : BlockConfig ) : string {
368- const subBlocks = block . subBlocks . map ( ( sb ) => {
369- const serialized = serializeSubBlock ( sb )
370+ const hiddenIds = new Set ( block . subBlocks . filter ( isSubBlockHiddenByHostedKey ) . map ( ( sb ) => sb . id ) )
370371
371- // For model comboboxes with function options, inject static model data with hosting info
372- if ( sb . id === 'model' && sb . type === 'combobox' && typeof sb . options === 'function' ) {
373- serialized . options = getStaticModelOptionsForVFS ( )
374- }
372+ const subBlocks = block . subBlocks
373+ . filter ( ( sb ) => ! hiddenIds . has ( sb . id ) )
374+ . map ( ( sb ) => {
375+ const serialized = serializeSubBlock ( sb )
375376
376- return serialized
377- } )
377+ // For model comboboxes with function options, inject static model data with hosting info
378+ if ( sb . id === 'model' && sb . type === 'combobox' && typeof sb . options === 'function' ) {
379+ serialized . options = getStaticModelOptionsForVFS ( )
380+ }
381+
382+ return serialized
383+ } )
384+
385+ const inputs =
386+ block . inputs && hiddenIds . size > 0
387+ ? Object . fromEntries ( Object . entries ( block . inputs ) . filter ( ( [ key ] ) => ! hiddenIds . has ( key ) ) )
388+ : block . inputs
378389
379390 return JSON . stringify (
380391 {
@@ -388,7 +399,7 @@ export function serializeBlockSchema(block: BlockConfig): string {
388399 singleInstance : block . singleInstance || undefined ,
389400 tools : block . tools . access ,
390401 subBlocks,
391- inputs : block . inputs ,
402+ inputs,
392403 outputs : Object . fromEntries (
393404 Object . entries ( block . outputs )
394405 . filter ( ( [ key , val ] ) => key !== 'visualization' && val != null )
@@ -704,6 +715,8 @@ export function serializeSkill(s: {
704715 * Serialize an integration/tool schema for VFS components/integrations/{service}/{operation}.json
705716 */
706717export function serializeIntegrationSchema ( tool : ToolConfig ) : string {
718+ const hostedApiKeyParam = isHosted && tool . hosting ? tool . hosting . apiKeyParam : null
719+
707720 return JSON . stringify (
708721 {
709722 id : tool . id ,
@@ -716,7 +729,7 @@ export function serializeIntegrationSchema(tool: ToolConfig): string {
716729 params : tool . params
717730 ? Object . fromEntries (
718731 Object . entries ( tool . params )
719- . filter ( ( [ , val ] ) => val != null )
732+ . filter ( ( [ key , val ] ) => val != null && key !== hostedApiKeyParam )
720733 . map ( ( [ key , val ] ) => [
721734 key ,
722735 {
0 commit comments