interface TaskConfigObj {
id: string;
agentId: string;
steps: TaskConfigObj[];
}
class TaskConfig extends Context.Tag('Task/config')<TaskConfig, TaskConfigObj>() {}
class Task extends Effect.Service<Task>()('Task', {
effect: Effect.gen(function* () {
const { id, agentId, steps } = yield* TaskConfig;
const solve = Effect.gen(function* () {
for (const step of steps) {
const isOwnStep = !step.agentId || step.agentId === agentId;
yield* isOwnStep ? solveOwnStep(step) : delegateStep(step);
}
});
const solveOwnStep = Effect.fn(function* (step: TaskConfigObj) {
yield* Effect.log(`Agent ${agentId} is solving own step`);
});
const delegateStep = Effect.fn(function* (step: TaskConfigObj) {
yield* Effect.log(`Agent ${agentId} is delegating step`);
/**
* Here I'd need to instantiate another task with task config of "step",
* and yield a call to solve
*/
});
return {
id,
solve,
};
}),
}) {}
interface TaskConfigObj {
id: string;
agentId: string;
steps: TaskConfigObj[];
}
class TaskConfig extends Context.Tag('Task/config')<TaskConfig, TaskConfigObj>() {}
class Task extends Effect.Service<Task>()('Task', {
effect: Effect.gen(function* () {
const { id, agentId, steps } = yield* TaskConfig;
const solve = Effect.gen(function* () {
for (const step of steps) {
const isOwnStep = !step.agentId || step.agentId === agentId;
yield* isOwnStep ? solveOwnStep(step) : delegateStep(step);
}
});
const solveOwnStep = Effect.fn(function* (step: TaskConfigObj) {
yield* Effect.log(`Agent ${agentId} is solving own step`);
});
const delegateStep = Effect.fn(function* (step: TaskConfigObj) {
yield* Effect.log(`Agent ${agentId} is delegating step`);
/**
* Here I'd need to instantiate another task with task config of "step",
* and yield a call to solve
*/
});
return {
id,
solve,
};
}),
}) {}