Skip to content

Commit ca89e21

Browse files
committed
feat(ai-action-tool-generator): enhance parameter mapping and tool schema generation
refactor(index.ts): simplify AI action invocation and add detailed logging for parameter mappings
1 parent 138eea1 commit ca89e21

File tree

3 files changed

+384
-53
lines changed

3 files changed

+384
-53
lines changed

src/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,11 @@ function getHandler(name: string) {
210210
// Handler for dynamic AI Action tools
211211
async function handleAiActionInvocation(actionId: string, args: any) {
212212
try {
213-
// Get invocation parameters from the tool context
213+
// The getInvocationParams method now handles parameter translation
214214
const params = aiActionToolContext.getInvocationParams(actionId, args)
215215

216216
// Invoke the AI Action
217-
return aiActionHandlers.invokeAiAction({
218-
...params,
219-
variables: args
220-
})
217+
return aiActionHandlers.invokeAiAction(params)
221218
} catch (error) {
222219
return {
223220
isError: true,
@@ -258,6 +255,27 @@ async function loadAiActions() {
258255
// Add each AI Action to the context
259256
for (const action of response.items) {
260257
aiActionToolContext.addAiAction(action)
258+
259+
// Log variable mappings for debugging
260+
if (action.instruction.variables && action.instruction.variables.length > 0) {
261+
// Log ID mappings
262+
const idMappings = aiActionToolContext.getIdMappings(action.sys.id)
263+
if (idMappings && idMappings.size > 0) {
264+
const mappingLog = Array.from(idMappings.entries())
265+
.map(([friendly, original]) => `${friendly} -> ${original}`)
266+
.join(', ')
267+
console.error(`AI Action ${action.name} - Parameter mappings: ${mappingLog}`)
268+
}
269+
270+
// Log path mappings
271+
const pathMappings = aiActionToolContext.getPathMappings(action.sys.id)
272+
if (pathMappings && pathMappings.size > 0) {
273+
const pathMappingLog = Array.from(pathMappings.entries())
274+
.map(([friendly, original]) => `${friendly} -> ${original}`)
275+
.join(', ')
276+
console.error(`AI Action ${action.name} - Path parameter mappings: ${pathMappingLog}`)
277+
}
278+
}
261279
}
262280

263281
console.error(`Loaded ${response.items.length} AI Actions`)

0 commit comments

Comments
 (0)