diff --git a/packages/agent/src/activities/agent.ts b/packages/agent/src/activities/agent.ts index dbe59f8f..c5dbb016 100644 --- a/packages/agent/src/activities/agent.ts +++ b/packages/agent/src/activities/agent.ts @@ -409,6 +409,7 @@ export interface AutofillAiParams { export async function autofillAiActivity(params: AutofillAiParams) { const prompt = 'Analyze the provided images and extract metadata.' const toolSchema = fieldsToTypeBoxSchema(params.fields) + console.log('==== autofill schema', toolSchema) let capturedData: Record | null = null const autofillTool: AgentTool = { diff --git a/packages/agent/src/index.ts b/packages/agent/src/index.ts index 0fe3cef4..28ff9d2b 100644 --- a/packages/agent/src/index.ts +++ b/packages/agent/src/index.ts @@ -324,19 +324,18 @@ export function fieldsToTypeBoxSchema(fields: AutofillField[]) { switch (f.config.type) { case 'text': case 'longText': - schema = Type.String({ title: fieldName }) + schema = Type.String() break case 'number': case 'rating': - schema = Type.Number({ title: fieldName }) + schema = Type.Number() break case 'toggle': - schema = Type.Boolean({ title: fieldName }) + schema = Type.Boolean() break case 'select': { const options = f.config.select?.options || [] schema = Type.String({ - title: fieldName, enum: options.map((o) => o.id), }) if (options.length > 0) { @@ -353,7 +352,6 @@ export function fieldsToTypeBoxSchema(fields: AutofillField[]) { Type.String({ enum: options.map((o) => o.id), }), - { title: fieldName }, ) if (options.length > 0) { const optionMapStr = options.map((o) => `"${o.id}" (${o.displayName})`).join(', ') @@ -364,7 +362,7 @@ export function fieldsToTypeBoxSchema(fields: AutofillField[]) { break } default: - schema = Type.String({ title: fieldName }) + schema = Type.String() } if (!schema.description) { diff --git a/packages/agent/src/schema-conversion.test.ts b/packages/agent/src/schema-conversion.test.ts index 48d7ceec..320ec323 100644 --- a/packages/agent/src/schema-conversion.test.ts +++ b/packages/agent/src/schema-conversion.test.ts @@ -9,10 +9,8 @@ describe('fieldsToTypeBoxSchema', () => { ] const schema = fieldsToTypeBoxSchema(fields) expect(schema.properties.f1.type).toBe('string') - expect(schema.properties.f1.title).toBe('Title') expect(schema.properties.f1.description).toBe('Title: The title') expect(schema.properties.f2.type).toBe('string') - expect(schema.properties.f2.title).toBe('Desc') expect(schema.properties.f2.description).toBe('Desc') }) @@ -23,16 +21,13 @@ describe('fieldsToTypeBoxSchema', () => { ] const schema = fieldsToTypeBoxSchema(fields) expect(schema.properties.f1.type).toBe('number') - expect(schema.properties.f1.title).toBe('Price') expect(schema.properties.f2.type).toBe('number') - expect(schema.properties.f2.title).toBe('Rating') }) it('converts toggle fields', () => { const fields: AutofillField[] = [{ id: 'f1', config: { name: 'Active', type: 'toggle' } }] const schema = fieldsToTypeBoxSchema(fields) expect(schema.properties.f1.type).toBe('boolean') - expect(schema.properties.f1.title).toBe('Active') }) it('converts select fields with enums and option descriptions', () => { @@ -54,7 +49,6 @@ describe('fieldsToTypeBoxSchema', () => { ] const schema = fieldsToTypeBoxSchema(fields) expect(schema.properties.f1.type).toBe('string') - expect(schema.properties.f1.title).toBe('Species') expect(schema.properties.f1.enum).toEqual(['opt1', 'opt2']) expect(schema.properties.f1.description).toBe( 'Species: Species of animal [Allowed options: "opt1" (Option 1), "opt2" (Option 2)]', @@ -79,7 +73,6 @@ describe('fieldsToTypeBoxSchema', () => { ] const schema = fieldsToTypeBoxSchema(fields) expect(schema.properties.f1.type).toBe('array') - expect(schema.properties.f1.title).toBe('Tags') expect(schema.properties.f1.items.enum).toEqual(['opt1', 'opt2']) expect(schema.properties.f1.description).toBe( 'Tags [Allowed options: "opt1" (Tag 1), "opt2" (Tag 2)]', @@ -93,6 +86,5 @@ describe('fieldsToTypeBoxSchema', () => { ] const schema = fieldsToTypeBoxSchema(fields) expect(schema.properties.f1.type).toBe('string') - expect(schema.properties.f1.title).toBe('Unknown') }) })