@agent-graph/core
Version:
A lightweight AI Agent orchestration solution
34 lines (33 loc) • 854 B
JavaScript
export class Vertex {
constructor({ id, compute, state, }) {
this.status = 'active';
this.id = id;
this.state = state;
this.compute = compute.bind(this);
this.halt = this.halt.bind(this);
this.wait = this.wait.bind(this);
this.active = this.active.bind(this);
this.setState = this.setState.bind(this);
}
get isActive() {
return this.status === 'active';
}
get isInactive() {
return this.status === 'inactive';
}
get isWaiting() {
return this.status === 'waiting';
}
active() {
this.status = 'active';
}
halt() {
this.status = 'inactive';
}
wait() {
this.status = 'waiting';
}
setState(newState) {
this.state = Object.assign(Object.assign({}, this.state), newState);
}
}