PluginProbe
Extendify / 3.1.3
Extendify v3.1.3
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Agent / lib / tool-messages.js

tool-messages.js in Extendify 3.1.3, at src/Agent/lib/tool-messages.js

32 lines 830 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { makeId } from '@agent/lib/util';
2
3 // Providers reject a tool/function name with characters outside this set, and
4 // ability ids are namespaced with a slash (e.g. woocommerce/products-query).
5 export const toolName = (id) => id.replace(/[^a-zA-Z0-9_.-]/g, '_');
6
7 // The provider rejects a tool result unless it's paired with an assistant
8 // tool-call sharing its id, so emit both.
9 export const buildToolMessages = ({ id, inputs, result }) => {
10 const toolCallId = makeId();
11 const name = toolName(id);
12 return [
13 {
14 role: 'assistant',
15 content: [
16 { type: 'tool-call', toolCallId, toolName: name, input: inputs ?? {} },
17 ],
18 },
19 {
20 role: 'tool',
21 content: [
22 {
23 type: 'tool-result',
24 toolCallId,
25 toolName: name,
26 output: { type: 'json', value: result ?? null },
27 },
28 ],
29 },
30 ];
31 };
32