import { action, defineAgent, node, prompt } from '@simple-ai-lab/sdk';
import { z } from 'zod';
const lookup = action.http({
key: 'lookup-account',
name: 'Lookup account',
description: 'Fetch an account',
input: z.object({
account_id: z.string().describe('The account identifier from the caller'),
}),
output: z.object({ account_name: z.string() }),
outputMappings: { account_name: '{{ httpResponse.body.name }}' },
request: {
method: 'GET',
url: 'https://example.com/accounts/{{ inputs.account_id }}',
},
});
export default defineAgent({
key: 'support',
name: 'Support',
branch: 'main',
nodes: [
node.prompt({
key: 'root',
name: 'Root',
root: true,
prompt: prompt.inline('Help the caller.'),
actions: [
action.callable({
key: 'lookup-action',
action: lookup,
name: 'lookup_account',
description: 'Look up an account',
inputs: {
account_id: action.fromAgent('The account identifier'),
},
// Action output name -> Agent parameter name
outputParameters: { account_name: 'customer_account_name' },
}),
],
}),
],
});