Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@missionsquad/rosetta-ai",
"version": "1.11.3",
"version": "1.11.4",
"description": "Unified TypeScript SDK for interacting with multiple AI providers (Anthropic, Google, Groq, OpenAI).",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
30 changes: 29 additions & 1 deletion src/core/mapping/google.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ import * as GoogleEmbedMapper from './google.embed.mapper'

export class GoogleMapper implements IProviderMapper {
readonly provider = Provider.Google
private static readonly ALLOWED_SCHEMA_KEYS = new Set([
'anyOf',
'default',
'description',
'enum',
'example',
'format',
'items',
'maxItems',
'maxLength',
'maxProperties',
'maximum',
'minItems',
'minLength',
'minProperties',
'minimum',
'nullable',
'pattern',
'properties',
'propertyOrdering',
'required',
'title',
'type'
])

// --- Parameter Mapping ---
private mapRoleToGoogle(role: RosettaMessage['role']): 'user' | 'model' | 'function' | 'system' {
Expand Down Expand Up @@ -259,9 +283,13 @@ export class GoogleMapper implements IProviderMapper {
delete cleanedSchema.items
}

const prunedSchema = Object.fromEntries(
Object.entries(cleanedSchema).filter(([key]) => GoogleMapper.ALLOWED_SCHEMA_KEYS.has(key))
)

visited.delete(schema); // Clean up visited set for this path

return cleanedSchema;
return prunedSchema;
Comment on lines +286 to +292
}

private findLastToolCallName(history: Content[], _toolCallId: string): string | undefined {
Expand Down
37 changes: 37 additions & 0 deletions tests/unit/core/mapping/google.mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,43 @@ describe('Google Mapper', () => {
expect(functionDecl?.parameters?.properties?.location?.type).toBe('STRING')
})

it('[Easy] should strip non-Google schema keys from tool parameters', () => {
const params: GenerateParams = {
...baseParams,
messages: [{ role: 'user', content: 'Use the tool.' }],
tools: [
{
type: 'function',
function: {
name: 'list_timezones',
description: 'Lists timezones',
parameters: {
type: 'object',
properties: {
region: {
type: 'string',
description: 'Optional timezone region prefix',
optional: true,
examples: ['America']
}
}
} as any
}
}
]
}

const result = mapper.mapToProviderParams(params) as GenerateContentParameters
const functionDecl = result.config?.tools?.[0]?.functionDeclarations?.[0]

expect(functionDecl?.parameters?.properties?.region).toEqual({
type: 'STRING',
description: 'Optional timezone region prefix'
})
expect((functionDecl?.parameters?.properties?.region as any)?.optional).toBeUndefined()
expect((functionDecl?.parameters?.properties?.region as any)?.examples).toBeUndefined()
})

it('[Easy] should map grounding tool', () => {
const params: GenerateParams = {
...baseParams,
Expand Down
Loading