From 87c2ff899f8e61cbeffaa6e703cf71f6c231b401 Mon Sep 17 00:00:00 2001 From: jcarlosn Date: Fri, 22 Nov 2024 12:45:03 +0100 Subject: [PATCH] Adds factory 'createAgent' function --- packages/protofy/src/Agent.ts | 4 ++++ packages/protofy/tests/agent.test.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/protofy/src/Agent.ts b/packages/protofy/src/Agent.ts index 6a9cb9188..94a3532fe 100644 --- a/packages/protofy/src/Agent.ts +++ b/packages/protofy/src/Agent.ts @@ -137,6 +137,10 @@ export class Agent { } } +export function createAgent(data: AgentData, parent?: Agent) { + return new Agent(data, parent); +} + export class AgentInterface { input: AgentIOInterface; output: AgentIOInterface; diff --git a/packages/protofy/tests/agent.test.ts b/packages/protofy/tests/agent.test.ts index f2555bb97..e4edf9a8c 100644 --- a/packages/protofy/tests/agent.test.ts +++ b/packages/protofy/tests/agent.test.ts @@ -1,4 +1,4 @@ -import { Agent } from '../src/Agent'; +import { Agent, createAgent } from '../src/Agent'; import { z } from 'zod'; import { zodToJsonSchema } from 'zod-to-json-schema'; @@ -25,7 +25,7 @@ describe('Agents basic behavior', () => { tags: ['child'] }); - agent = new Agent({ + agent = createAgent({ id: 'getDisplayInfo', name: 'getDisplayInfo', description: 'Get display info of a user',