-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
62 lines (56 loc) · 1.89 KB
/
index.ts
File metadata and controls
62 lines (56 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* Agent registry — maps agent names to their boot functions.
*
* To add a new agent:
* 1. Create `src/agents/<name>.ts` exporting an async `boot()` function
* 2. Import and register it in the `AGENTS` map below
* 3. Add the name to the `AgentName` union in `src/agents/interface.ts`
*/
import type { AgentName, Agent, AgentBootOptions } from "./interface.js";
import { boot as bootPlanner, type PlannerAgent } from "./planner.js";
import { boot as bootExecutor, type ExecutorAgent } from "./executor.js";
import { boot as bootSpec, type SpecAgent } from "./spec.js";
import { boot as bootCommit, type CommitAgent } from "./commit.js";
type BootFn = (opts: AgentBootOptions) => Promise<Agent>;
const AGENTS: Record<AgentName, BootFn> = {
planner: bootPlanner,
executor: bootExecutor,
spec: bootSpec,
commit: bootCommit,
};
/**
* All registered agent names — useful for CLI help text and validation.
* Safe to cast: Object.keys() on a Record<AgentName, …> always returns AgentName values.
*/
export const AGENT_NAMES: readonly AgentName[] = Object.keys(AGENTS) as AgentName[];
/**
* Boot an agent by name.
*
* @throws if the agent name is not registered.
*/
export async function bootAgent(
name: AgentName,
opts: AgentBootOptions
): Promise<Agent> {
const bootFn = AGENTS[name];
if (!bootFn) {
throw new Error(
`Unknown agent "${name}". Available: ${AGENT_NAMES.join(", ")}`
);
}
return bootFn(opts);
}
/**
* Type-safe boot functions for specific agent roles.
* Prefer these over the generic `bootAgent()` when you know the role at compile time.
*/
export { bootPlanner, bootExecutor, bootSpec, bootCommit };
export type { PlannerAgent, ExecutorAgent, SpecAgent, CommitAgent };
export type { AgentName, Agent, AgentBootOptions } from "./interface.js";
export type {
AgentResult,
AgentErrorCode,
PlannerData,
ExecutorData,
SpecData,
} from "./types.js";