Skip to content

Commit

Permalink
Allows agents to be recursively instantiated with their childrens
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarlosn committed Nov 18, 2024
1 parent 0cafabb commit c8766e7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/protofy/src/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const AgentSchema = z.object({
name: z.string().optional(), // Optional string
description: z.string().optional(), // Optional string
tags: z.array(z.string()).optional(), // Optional array of strings
children: z.array(z.lazy(() => AgentSchema)).optional(), // Optional array of agents
interface: AgentInterfaceSchema.optional() // Optional interface
})

Expand All @@ -49,9 +50,9 @@ export class Agent {
children: Agent[];
interface: AgentInterface | undefined;
parent: Agent | undefined;
constructor(data: AgentData, children: Agent[] = [], parent: Agent = undefined, ) {
constructor(data: AgentData, parent: Agent = undefined, ) {
this.data = data;
this.children = children;
this.children = data.children && data.children.map(agent => new Agent(agent, this)) || [];
this.interface = data.interface && new AgentInterface(data.interface, this);
this.parent = parent;
}
Expand Down

0 comments on commit c8766e7

Please sign in to comment.