Skip to content

Commit 6f694e5

Browse files
committed
Update vfs to handle hosted keys
1 parent fa1ae13 commit 6f694e5

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

apps/sim/lib/copilot/vfs/serializers.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { isHosted } from '@/lib/core/config/feature-flags'
2+
import { isSubBlockHiddenByHostedKey } from '@/lib/workflows/subblocks/visibility'
13
import type { BlockConfig, SubBlockConfig } from '@/blocks/types'
24
import { PROVIDER_DEFINITIONS } from '@/providers/models'
35
import 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
*/
367369
export 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
*/
706717
export 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
{

apps/sim/lib/core/config/feature-flags.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Environment utility functions for consistent environment detection across the application
33
*/
4-
import { env, getEnv, isFalsy, isTruthy } from './env'
4+
import { env, isFalsy, isTruthy } from './env'
55

66
/**
77
* Is the application running in production mode
@@ -21,9 +21,9 @@ export const isTest = env.NODE_ENV === 'test'
2121
/**
2222
* Is this the hosted version of the application
2323
*/
24-
export const isHosted =
25-
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
26-
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
24+
export const isHosted = true
25+
// getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
26+
// getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
2727

2828
/**
2929
* Is billing enforcement enabled

0 commit comments

Comments
 (0)