# extendify/3.1.3/src/Agent/lib/tool-messages.js

Extendify, version 3.1.3. 32 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.3/code/src/Agent/lib/tool-messages.js
- Raw: https://pluginprobe.com/plugins/extendify/3.1.3/raw/src/Agent/lib/tool-messages.js
- Modified: 2026-07-08T14:57:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.1.3/code/src/Agent/lib/tool-messages.js#L10-L20`.

```javascript
import { makeId } from '@agent/lib/util';

// Providers reject a tool/function name with characters outside this set, and
// ability ids are namespaced with a slash (e.g. woocommerce/products-query).
export const toolName = (id) => id.replace(/[^a-zA-Z0-9_.-]/g, '_');

// The provider rejects a tool result unless it's paired with an assistant
// tool-call sharing its id, so emit both.
export const buildToolMessages = ({ id, inputs, result }) => {
	const toolCallId = makeId();
	const name = toolName(id);
	return [
		{
			role: 'assistant',
			content: [
				{ type: 'tool-call', toolCallId, toolName: name, input: inputs ?? {} },
			],
		},
		{
			role: 'tool',
			content: [
				{
					type: 'tool-result',
					toolCallId,
					toolName: name,
					output: { type: 'json', value: result ?? null },
				},
			],
		},
	];
};

```
