Skip to content

Commit

Permalink
Rename AgentInterface to AgentIOInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarlosn committed Nov 18, 2024
1 parent 9cc401d commit 8b66c21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
25 changes: 13 additions & 12 deletions packages/protofy/src/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const AgentProtocolSchema = z.object({
}).catchall(z.any()).optional(), // Allow any other properties in config
});

const AgentInterfaceSchema = z.object({
const AgentIOSchema = z.object({
shape: z.custom<SchemaObject>((value) => {
// Use Ajv to validate the value
return validateSchemaObject(value);
Expand All @@ -29,21 +29,22 @@ 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

protocol: AgentProtocolSchema.optional(),
input: AgentInterfaceSchema.optional(),
output: AgentInterfaceSchema.optional()
input: AgentIOSchema.optional(),
output: AgentIOSchema.optional()
})

// Infer the TypeScript type
export type AgentData = z.infer<typeof AgentSchema>;
export type AgentProtocolData = z.infer<typeof AgentProtocolSchema>;
export type AgentInterfaceData = z.infer<typeof AgentInterfaceSchema>;
export type AgentIOData = z.infer<typeof AgentIOSchema>;

export class Agent {
data: AgentData;
children: Agent[];
input: AgentInterface | undefined;
output: AgentInterface | undefined;
input: AgentIOInterface | undefined;
output: AgentIOInterface | undefined;
parent: Agent | undefined;
constructor(data: AgentData, children: Agent[] = [], parent: Agent = undefined, ) {
this.data = data;
Expand Down Expand Up @@ -118,11 +119,11 @@ export class Agent {
}
}

export class AgentInterface {
export class AgentIOInterface {
shape: SchemaObject;
protocol: AgentProtocolData;
agent: Agent;
constructor(data: AgentInterfaceData, agent: Agent) {
constructor(data: AgentIOData, agent: Agent) {
this.shape = data.shape;
this.protocol = data.protocol;
this.agent = agent;
Expand All @@ -143,14 +144,14 @@ export class AgentInterface {
}
}

export class AgentInputInterface extends AgentInterface {
constructor(data: AgentInterfaceData, agent: Agent) {
export class AgentInputInterface extends AgentIOInterface {
constructor(data: AgentIOData, agent: Agent) {
super(data, agent);
}
}

export class AgentOutputInterface extends AgentInterface {
constructor(data: AgentInterfaceData, agent: Agent) {
export class AgentOutputInterface extends AgentIOInterface {
constructor(data: AgentIOData, agent: Agent) {
super(data, agent);
}
}
5 changes: 2 additions & 3 deletions packages/protofy/src/protocols/function.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { AgentInterface } from "../Agent";
import { AgentIOInterface } from "../Agent";

//function runner
export default (interf: AgentInterface) => {
export default (interf: AgentIOInterface) => {
//check if the interface is a function
if(interf.getProtocol().type !== 'function') {
throw new Error('Error: Invalid protocol type, expected function')
}




}

0 comments on commit 8b66c21

Please sign in to comment.