mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 12:54:55 +00:00
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { Type } from '@sinclair/typebox'
|
|
import { type AgentTool } from '@earendil-works/pi-agent-core'
|
|
import { executeAgentToolWorkflow } from './utils'
|
|
|
|
const listAutofillFieldsSchema = Type.Object({
|
|
parent: Type.String({
|
|
description:
|
|
'The parent folder ID whose project autofillable metadata fields to list. This parameter is required.',
|
|
}),
|
|
})
|
|
|
|
export function createListAutofillFieldsTool(
|
|
userId: string,
|
|
): AgentTool<typeof listAutofillFieldsSchema> {
|
|
return {
|
|
name: 'list_autofill_fields',
|
|
label: 'List Autofill Fields',
|
|
description:
|
|
'List the AI-autofillable metadata fields defined for the project of a parent folder, including their types and available options. ' +
|
|
'Use this before creating a file or version so you can pass relevant context (e.g. the model or prompt used to generate the asset) to create_file/create_version.',
|
|
parameters: listAutofillFieldsSchema,
|
|
execute: async (_toolCallId, params) => {
|
|
const result = await executeAgentToolWorkflow({
|
|
toolName: 'list_autofill_fields',
|
|
args: params,
|
|
userId,
|
|
assetId: params.parent,
|
|
})
|
|
return {
|
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
details: result,
|
|
}
|
|
},
|
|
}
|
|
}
|