Skip to content

Commit 023f5b5

Browse files
committed
fix(buffer): format nested input documentation
1 parent 61d0717 commit 023f5b5

12 files changed

Lines changed: 629 additions & 42 deletions

File tree

‎apps/docs/content/docs/integrations/buffer.mdx‎

Lines changed: 530 additions & 13 deletions
Large diffs are not rendered by default.

‎apps/sim/tools/buffer/create_idea.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,19 @@ export const bufferCreateIdeaTool: ToolConfig<BufferCreateIdeaParams, BufferIdea
7272
type: 'json',
7373
required: false,
7474
visibility: 'user-or-llm',
75-
description: bufferInputDescription('IdeaContentInput'),
75+
description: bufferInputDescription(
76+
'IdeaContentInput',
77+
'Idea title, text, and media content.'
78+
),
7679
},
7780
group: {
7881
type: 'json',
7982
required: false,
8083
visibility: 'user-or-llm',
81-
description: bufferInputDescription('IdeaGroupInput'),
84+
description: bufferInputDescription(
85+
'IdeaGroupInput',
86+
'Assign the idea to a group and optionally position it after another idea.'
87+
),
8288
},
8389
cta: {
8490
type: 'string',

‎apps/sim/tools/buffer/create_post.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,19 @@ export const bufferCreatePostTool: InternalToolConfig<BufferCreatePostParams, Bu
8585
type: 'json',
8686
required: false,
8787
visibility: 'user-or-llm',
88-
description: `Array of assets: ${bufferInputDescription('AssetInput')}. Choose exactly one variant per asset. Omit when using media. On edit, [] clears attachments and omission preserves them.`,
88+
description: bufferInputDescription(
89+
'AssetInput',
90+
'Array of image, video, or document assets. Choose exactly one variant per asset. Omit when using media.'
91+
),
8992
},
9093
metadata: {
9194
type: 'json',
9295
required: false,
9396
visibility: 'user-or-llm',
94-
description: bufferInputDescription('PostInputMetaData'),
97+
description: bufferInputDescription(
98+
'PostInputMetaData',
99+
'Network-specific settings, including threads, link attachments, and publishing options.'
100+
),
95101
},
96102
aiAssisted: {
97103
type: 'boolean',

‎apps/sim/tools/buffer/edit_post.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ export const bufferEditPostTool: InternalToolConfig<BufferEditPostParams, Buffer
8383
type: 'json',
8484
required: false,
8585
visibility: 'user-or-llm',
86-
description: `Array of assets: ${bufferInputDescription('AssetInput')}. Choose exactly one variant per asset. Omit when using media. On edit, [] clears attachments and omission preserves them.`,
86+
description: bufferInputDescription(
87+
'AssetInput',
88+
'Array of image, video, or document assets. Choose exactly one variant per asset. Omit when using media. An empty array clears attachments; omission preserves them.'
89+
),
8790
},
8891
metadata: {
8992
type: 'json',
9093
required: false,
9194
visibility: 'user-or-llm',
92-
description: bufferInputDescription('PostInputMetaData'),
95+
description: bufferInputDescription(
96+
'PostInputMetaData',
97+
'Network-specific settings, including threads, link attachments, and publishing options.'
98+
),
9399
},
94100
aiAssisted: {
95101
type: 'boolean',

‎apps/sim/tools/buffer/get-aggregated-post-metrics.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ export const bufferGetAggregatedPostMetricsTool: ToolConfig<
6060
type: 'json',
6161
required: false,
6262
visibility: 'user-or-llm',
63-
description: bufferInputDescription('TagComparator'),
63+
description: bufferInputDescription(
64+
'TagComparator',
65+
'Filter metrics by tag IDs or untagged status.'
66+
),
6467
},
6568
},
6669
request: {

‎apps/sim/tools/buffer/get_account.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ export const bufferGetAccountTool: ToolConfig<BufferGetAccountParams, BufferAcco
3232
type: 'json',
3333
required: false,
3434
visibility: 'user-or-llm',
35-
description: bufferInputDescription('OrganizationFilterInput'),
35+
description: bufferInputDescription(
36+
'OrganizationFilterInput',
37+
'Filter account organizations by organization ID.'
38+
),
3639
},
3740
},
3841

‎apps/sim/tools/buffer/get_channels.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export const bufferGetChannelsTool: ToolConfig<BufferGetChannelsParams, BufferCh
4343
type: 'json',
4444
required: false,
4545
visibility: 'user-or-llm',
46-
description: bufferInputDescription('ChannelsFiltersInput'),
46+
description: bufferInputDescription(
47+
'ChannelsFiltersInput',
48+
'Filter channels by locked status or product.'
49+
),
4750
},
4851
},
4952

‎apps/sim/tools/buffer/get_ideas.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@ export const bufferGetIdeasTool: ToolConfig<BufferGetIdeasParams, BufferIdeasRes
6767
type: 'json',
6868
required: false,
6969
visibility: 'user-or-llm',
70-
description: bufferInputDescription('IdeasGroupFilter'),
70+
description: bufferInputDescription('IdeasGroupFilter', 'Filter ideas by group.'),
7171
},
7272
tagsFilter: {
7373
type: 'json',
7474
required: false,
7575
visibility: 'user-or-llm',
76-
description: bufferInputDescription('TagComparator'),
76+
description: bufferInputDescription(
77+
'TagComparator',
78+
'Filter ideas by tag IDs or untagged status.'
79+
),
7780
},
7881
},
7982

‎apps/sim/tools/buffer/get_posts.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,19 @@ export const bufferGetPostsTool: ToolConfig<BufferGetPostsParams, BufferPostsRes
104104
type: 'json',
105105
required: false,
106106
visibility: 'user-or-llm',
107-
description: bufferInputDescription('PostsFiltersInput'),
107+
description: bufferInputDescription(
108+
'PostsFiltersInput',
109+
'Filter posts by status, tags, dates, and other criteria.'
110+
),
108111
},
109112
sort: {
110113
type: 'json',
111114
required: false,
112115
visibility: 'user-or-llm',
113-
description: `Ordered list of sort keys: ${bufferInputDescription('PostSortInput')}. Overrides sortBy/sortDirection.`,
116+
description: bufferInputDescription(
117+
'PostSortInput',
118+
'Ordered array of sort keys. Overrides sortBy and sortDirection.'
119+
),
114120
},
115121
},
116122

‎apps/sim/tools/buffer/schema.ts‎

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,34 @@ export function parseBufferInput(
171171
return result
172172
}
173173

174-
/** Lists the complete nested input contract for structured tool parameters. */
175-
export function bufferInputDescription(type: string): string {
176-
const schema = BUFFER_SCHEMA[type]
177-
if (!schema?.fields) return schema?.values?.join(' | ') ?? type
178-
return `{ ${Object.entries(schema.fields)
179-
.map(([field, wireType]) => {
180-
const nested = baseType(wireType)
181-
const detail = BUFFER_SCHEMA[nested]
182-
return `${field}: ${wireType}${schema.defaults?.includes(field) ? ' (provider default when omitted)' : ''}${detail?.fields || detail?.values ? ` (${bufferInputDescription(nested)})` : ''}`
183-
})
184-
.join('; ')} }`
174+
/** Describes structured inputs with a readable definition for each referenced type. */
175+
export function bufferInputDescription(type: string, description: string): string {
176+
const definitions: string[] = []
177+
const visited = new Set<string>()
178+
179+
function collect(name: string): void {
180+
const schema = BUFFER_SCHEMA[name]
181+
if (visited.has(name) || (!schema?.fields && !schema?.values)) return
182+
visited.add(name)
183+
if (schema.fields) {
184+
const fields = Object.entries(schema.fields).map(
185+
([field, wireType]) =>
186+
` ${field}: ${wireType}${schema.defaults?.includes(field) ? ' # Provider default when omitted' : ''}`
187+
)
188+
if (schema.oneOf) fields.unshift(' # Choose exactly one field')
189+
definitions.push(`input ${name} {\n${fields.join('\n')}\n}`)
190+
for (const wireType of Object.values(schema.fields)) collect(baseType(wireType))
191+
} else if (schema.values) {
192+
definitions.push(
193+
`enum ${name} {\n${schema.values.map((value) => ` ${value}`).join('\n')}\n}`
194+
)
195+
}
196+
}
197+
198+
collect(type)
199+
return definitions.length
200+
? `${description}\n\n\`\`\`graphql\n${definitions.join('\n\n')}\n\`\`\``
201+
: description
185202
}
186203

187204
function parseValue(wireType: string, value: unknown, path: string): unknown {

0 commit comments

Comments
 (0)