Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

1.1 KB
Raw Blame
// Operations -> tools.json (Anthropic/OpenAI-style input_schema, see specs/SKILL_SPEC.md).

function paramSchema(parameters) {
	const properties = {};
	const required = [];
	for (const p of parameters) {
		properties[p.name] = {
			...p.schema,
			description: p.description || p.schema?.description || `${p.in} parameter "${p.name}"`,
		};
		if (p.required) required.push(p.name);
	}
	return { properties, required };
}

/**
 * @param {import('./operations.js').listOperations} operations
 * @returns {{tools: Array<{name: string, description: string, input_schema: object}>}}
 */
export function generateTools(operations) {
	const tools = operations.map((op) => {
		const { properties, required } = paramSchema(op.parameters);

		if (op.requestBody) {
			properties.body = {
				...op.requestBody.schema,
				description: op.requestBody.description || 'Request body',
			};
			if (op.requestBody.required) required.push('body');
		}

		return {
			name: op.operationId,
			description: op.description || op.summary || `${op.method} ${op.path}`,
			input_schema: {
				type: 'object',
				properties,
				required,
			},
		};
	});
	return { tools };
}