@agent-link/agent 0.1.84 → 0.1.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/claude.d.ts +18 -1
- package/dist/claude.js +118 -104
- package/dist/claude.js.map +1 -1
- package/dist/connection.js +5 -104
- package/dist/connection.js.map +1 -1
- package/dist/directory-handlers.d.ts +18 -0
- package/dist/directory-handlers.js +103 -0
- package/dist/directory-handlers.js.map +1 -0
- package/dist/team-naming.d.ts +35 -0
- package/dist/team-naming.js +119 -0
- package/dist/team-naming.js.map +1 -0
- package/dist/team-persistence.d.ts +39 -0
- package/dist/team-persistence.js +191 -0
- package/dist/team-persistence.js.map +1 -0
- package/dist/team-templates.d.ts +12 -0
- package/dist/team-templates.js +149 -0
- package/dist/team-templates.js.map +1 -0
- package/dist/team-types.d.ts +115 -0
- package/dist/team-types.js +3 -0
- package/dist/team-types.js.map +1 -0
- package/dist/team.d.ts +8 -157
- package/dist/team.js +69 -559
- package/dist/team.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Team template definitions — predefined agent roles and lead instructions.
|
|
3
|
+
*/
|
|
4
|
+
// ── Template definitions ────────────────────────────────────────────────
|
|
5
|
+
const TEMPLATE_AGENTS = {
|
|
6
|
+
'code-review': {
|
|
7
|
+
'security-reviewer': {
|
|
8
|
+
description: 'Security expert focused on cryptographic, auth, and injection vulnerabilities',
|
|
9
|
+
prompt: 'You are a security reviewer. Analyze code for vulnerabilities including injection attacks, authentication/authorization flaws, cryptographic issues, and data exposure risks. Provide specific file/line references and severity ratings.',
|
|
10
|
+
tools: ['Read', 'Grep', 'Glob'],
|
|
11
|
+
},
|
|
12
|
+
'quality-reviewer': {
|
|
13
|
+
description: 'Code quality expert focused on maintainability, patterns, and best practices',
|
|
14
|
+
prompt: 'You are a code quality reviewer. Analyze code structure, naming conventions, error handling, test coverage, and adherence to best practices. Identify code smells, unnecessary complexity, and improvement opportunities.',
|
|
15
|
+
tools: ['Read', 'Grep', 'Glob'],
|
|
16
|
+
},
|
|
17
|
+
'performance-reviewer': {
|
|
18
|
+
description: 'Performance expert focused on efficiency, resource usage, and scalability',
|
|
19
|
+
prompt: 'You are a performance reviewer. Identify performance bottlenecks, memory leaks, inefficient algorithms, unnecessary allocations, and scalability concerns. Suggest concrete optimizations with benchmarks where possible.',
|
|
20
|
+
tools: ['Read', 'Grep', 'Glob'],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
'full-stack': {
|
|
24
|
+
'backend-dev': {
|
|
25
|
+
description: 'Backend developer for API endpoints, database, and server-side logic',
|
|
26
|
+
prompt: 'You are a backend developer. Implement server-side features including API endpoints, data models, business logic, and integrations. Write clean, tested, production-ready code.',
|
|
27
|
+
tools: ['Read', 'Write', 'Edit', 'Grep', 'Glob', 'Bash'],
|
|
28
|
+
},
|
|
29
|
+
'frontend-dev': {
|
|
30
|
+
description: 'Frontend developer for UI components, styling, and client-side logic',
|
|
31
|
+
prompt: 'You are a frontend developer. Build user interface components, handle state management, implement responsive layouts, and ensure good UX. Follow the project\'s existing patterns and framework conventions.',
|
|
32
|
+
tools: ['Read', 'Write', 'Edit', 'Grep', 'Glob', 'Bash'],
|
|
33
|
+
},
|
|
34
|
+
'test-engineer': {
|
|
35
|
+
description: 'Test engineer for unit tests, integration tests, and quality assurance',
|
|
36
|
+
prompt: 'You are a test engineer. Write comprehensive tests (unit, integration, E2E) for new and existing code. Ensure edge cases are covered, mocks are appropriate, and tests are maintainable.',
|
|
37
|
+
tools: ['Read', 'Write', 'Edit', 'Grep', 'Glob', 'Bash'],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
'debug': {
|
|
41
|
+
'hypothesis-a': {
|
|
42
|
+
description: 'Debug investigator exploring the first hypothesis',
|
|
43
|
+
prompt: 'You are a debugging specialist. Investigate the bug by exploring one specific hypothesis. Read relevant code, trace execution paths, check logs, and report your findings with evidence.',
|
|
44
|
+
tools: ['Read', 'Grep', 'Glob', 'Bash'],
|
|
45
|
+
},
|
|
46
|
+
'hypothesis-b': {
|
|
47
|
+
description: 'Debug investigator exploring an alternative hypothesis',
|
|
48
|
+
prompt: 'You are a debugging specialist. Investigate the bug by exploring an alternative hypothesis different from other investigators. Read relevant code, trace execution paths, check logs, and report your findings with evidence.',
|
|
49
|
+
tools: ['Read', 'Grep', 'Glob', 'Bash'],
|
|
50
|
+
},
|
|
51
|
+
'hypothesis-c': {
|
|
52
|
+
description: 'Debug investigator exploring a third hypothesis',
|
|
53
|
+
prompt: 'You are a debugging specialist. Investigate the bug by exploring yet another hypothesis different from the other investigators. Think creatively about less obvious causes. Report findings with evidence.',
|
|
54
|
+
tools: ['Read', 'Grep', 'Glob', 'Bash'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
'custom': {
|
|
58
|
+
'worker-1': {
|
|
59
|
+
description: 'General-purpose development agent',
|
|
60
|
+
prompt: 'You are a skilled software engineer. Complete the assigned task thoroughly and report your results.',
|
|
61
|
+
tools: ['Read', 'Write', 'Edit', 'Grep', 'Glob', 'Bash'],
|
|
62
|
+
},
|
|
63
|
+
'worker-2': {
|
|
64
|
+
description: 'General-purpose development agent',
|
|
65
|
+
prompt: 'You are a skilled software engineer. Complete the assigned task thoroughly and report your results.',
|
|
66
|
+
tools: ['Read', 'Write', 'Edit', 'Grep', 'Glob', 'Bash'],
|
|
67
|
+
},
|
|
68
|
+
'worker-3': {
|
|
69
|
+
description: 'General-purpose development agent',
|
|
70
|
+
prompt: 'You are a skilled software engineer. Complete the assigned task thoroughly and report your results.',
|
|
71
|
+
tools: ['Read', 'Write', 'Edit', 'Grep', 'Glob', 'Bash'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
const TEMPLATE_LEAD_INSTRUCTIONS = {
|
|
76
|
+
'code-review': `You are a team lead coordinating a code review.
|
|
77
|
+
|
|
78
|
+
Instructions:
|
|
79
|
+
1. First, analyze the codebase to understand its structure and what needs reviewing
|
|
80
|
+
2. Use the Agent tool to spawn each reviewer IN PARALLEL (multiple Agent calls simultaneously)
|
|
81
|
+
3. Give each reviewer specific, detailed instructions referencing exact files and directories to review
|
|
82
|
+
4. After all reviewers complete, synthesize their findings into a unified summary with prioritized action items
|
|
83
|
+
|
|
84
|
+
Important:
|
|
85
|
+
- When calling the Agent tool, use a descriptive role-based name (e.g., "Security Reviewer", "Quality Analyst", "Performance Auditor") instead of generic names. The name should reflect the agent's specialty.
|
|
86
|
+
- Spawn agents in parallel for efficiency. Each agent should focus on their specialty area.`,
|
|
87
|
+
'full-stack': `You are a team lead coordinating full-stack development.
|
|
88
|
+
|
|
89
|
+
Instructions:
|
|
90
|
+
1. First, analyze the codebase to understand the architecture, existing patterns, and what needs building
|
|
91
|
+
2. Break the task into backend, frontend, and test subtasks, and analyze dependencies between them
|
|
92
|
+
3. Define clear interfaces, API contracts, and data schemas before spawning any agents
|
|
93
|
+
4. Spawn independent subtasks IN PARALLEL using the Agent tool. If a subtask depends on another's output (e.g., frontend needs the API built first, tests need the implementation), wait for the dependency to complete, then spawn the dependent agent with the prior result as context
|
|
94
|
+
5. Provide each agent with specific, detailed instructions including file paths and shared contracts
|
|
95
|
+
6. After all agents complete, review their work and provide a summary of what was built
|
|
96
|
+
|
|
97
|
+
Important:
|
|
98
|
+
- When calling the Agent tool, use a descriptive role-based name (e.g., "Backend Engineer", "Frontend Engineer", "Test Engineer") instead of generic names. The name should reflect the agent's responsibility.
|
|
99
|
+
- Maximize parallelism for truly independent tasks, but respect dependencies. Do not spawn all agents simultaneously if some need others' output first.`,
|
|
100
|
+
'debug': `You are a team lead coordinating a debugging investigation.
|
|
101
|
+
|
|
102
|
+
Instructions:
|
|
103
|
+
1. First, analyze the bug report and relevant code to understand the problem space
|
|
104
|
+
2. Formulate 3 distinct hypotheses about the root cause
|
|
105
|
+
3. Use the Agent tool to assign each hypothesis to a different investigator IN PARALLEL
|
|
106
|
+
4. Give each investigator specific areas of code to examine and tests to run
|
|
107
|
+
5. After all investigators complete, compare their findings and synthesize a diagnosis with a recommended fix
|
|
108
|
+
|
|
109
|
+
Important:
|
|
110
|
+
- When calling the Agent tool, use a descriptive name that reflects the hypothesis being investigated (e.g., "Race Condition Investigator", "Memory Leak Analyst", "Config Error Detective") instead of generic names.
|
|
111
|
+
- Each investigator should explore a DIFFERENT hypothesis. Avoid overlap.`,
|
|
112
|
+
'custom': `You are a team lead coordinating a development task.
|
|
113
|
+
|
|
114
|
+
Instructions:
|
|
115
|
+
1. First, analyze the codebase and the user's request to understand what needs to be done
|
|
116
|
+
2. Break the task into subtasks and analyze dependencies between them
|
|
117
|
+
3. Spawn independent tasks IN PARALLEL using the Agent tool for efficiency
|
|
118
|
+
4. If a task depends on another's output (e.g., implementation needs a design doc, tests need the implementation), wait for the dependency to complete first, then spawn the dependent task with the prior result as context
|
|
119
|
+
5. Give each worker specific, detailed instructions
|
|
120
|
+
6. After all workers complete, review their work and provide a summary
|
|
121
|
+
|
|
122
|
+
Important:
|
|
123
|
+
- When calling the Agent tool, use a descriptive role-based name (e.g., "Designer", "Developer", "Tester", "Architect") instead of generic names like "Agent 1". The name should reflect what the agent does.
|
|
124
|
+
- Maximize parallelism for truly independent tasks, but respect dependencies. For example, if one agent writes a design doc and another implements it, spawn the doc agent first, wait for its result, then spawn the implementation agent with the doc content.`,
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Build the agents definition JSON for the --agents CLI flag.
|
|
128
|
+
*/
|
|
129
|
+
export function buildAgentsDef(template) {
|
|
130
|
+
const key = template && TEMPLATE_AGENTS[template] ? template : 'custom';
|
|
131
|
+
return { ...TEMPLATE_AGENTS[key] };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Build the lead prompt that instructs the Lead to use Agent tool.
|
|
135
|
+
*/
|
|
136
|
+
export function buildLeadPrompt(config, agentsDef) {
|
|
137
|
+
const template = config.template || 'custom';
|
|
138
|
+
const instructions = TEMPLATE_LEAD_INSTRUCTIONS[template] || TEMPLATE_LEAD_INSTRUCTIONS['custom'];
|
|
139
|
+
const agentList = Object.entries(agentsDef)
|
|
140
|
+
.map(([id, def]) => `- ${id}: ${def.description}`)
|
|
141
|
+
.join('\n');
|
|
142
|
+
return `${instructions}
|
|
143
|
+
|
|
144
|
+
Available agents (use the Agent tool to delegate to them):
|
|
145
|
+
${agentList}
|
|
146
|
+
|
|
147
|
+
User's request: "${config.instruction}"`;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=team-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-templates.js","sourceRoot":"","sources":["../src/team-templates.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export interface TeamConfig {
|
|
2
|
+
instruction: string;
|
|
3
|
+
template?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface AgentRole {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
color: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TaskItem {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
status: 'pending' | 'active' | 'done' | 'failed';
|
|
15
|
+
assignee: string | null;
|
|
16
|
+
toolUseId: string | null;
|
|
17
|
+
agentTaskId: string | null;
|
|
18
|
+
dependencies: string[];
|
|
19
|
+
createdAt: number;
|
|
20
|
+
updatedAt: number;
|
|
21
|
+
}
|
|
22
|
+
export interface TeamState {
|
|
23
|
+
teamId: string;
|
|
24
|
+
title: string;
|
|
25
|
+
config: TeamConfig;
|
|
26
|
+
workDir: string;
|
|
27
|
+
conversationId: string;
|
|
28
|
+
claudeSessionId: string | null;
|
|
29
|
+
agents: Map<string, AgentTeammate>;
|
|
30
|
+
tasks: TaskItem[];
|
|
31
|
+
feed: TeamFeedEntry[];
|
|
32
|
+
status: 'planning' | 'running' | 'summarizing' | 'completed' | 'failed';
|
|
33
|
+
leadStatus: string;
|
|
34
|
+
summary: string | null;
|
|
35
|
+
totalCost: number;
|
|
36
|
+
durationMs: number;
|
|
37
|
+
createdAt: number;
|
|
38
|
+
}
|
|
39
|
+
export interface AgentTeammate {
|
|
40
|
+
role: AgentRole;
|
|
41
|
+
toolUseId: string | null;
|
|
42
|
+
agentTaskId: string | null;
|
|
43
|
+
status: 'starting' | 'working' | 'done' | 'error';
|
|
44
|
+
currentTaskId: string | null;
|
|
45
|
+
messages: TeamAgentMessage[];
|
|
46
|
+
}
|
|
47
|
+
export interface TeamAgentMessage {
|
|
48
|
+
id: number;
|
|
49
|
+
role: 'assistant' | 'tool' | 'user';
|
|
50
|
+
content?: string;
|
|
51
|
+
toolName?: string;
|
|
52
|
+
toolInput?: string;
|
|
53
|
+
toolOutput?: string;
|
|
54
|
+
hasResult?: boolean;
|
|
55
|
+
timestamp: number;
|
|
56
|
+
}
|
|
57
|
+
export interface TeamFeedEntry {
|
|
58
|
+
timestamp: number;
|
|
59
|
+
agentId: string;
|
|
60
|
+
type: 'task_started' | 'task_completed' | 'task_failed' | 'tool_call' | 'status_change' | 'lead_activity';
|
|
61
|
+
content: string;
|
|
62
|
+
}
|
|
63
|
+
export interface TeamStateSerialized {
|
|
64
|
+
teamId: string;
|
|
65
|
+
title: string;
|
|
66
|
+
config: TeamConfig;
|
|
67
|
+
workDir?: string;
|
|
68
|
+
conversationId: string;
|
|
69
|
+
claudeSessionId: string | null;
|
|
70
|
+
agents: Array<{
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
color: string;
|
|
74
|
+
toolUseId: string | null;
|
|
75
|
+
agentTaskId: string | null;
|
|
76
|
+
status: string;
|
|
77
|
+
currentTaskId: string | null;
|
|
78
|
+
messages?: TeamAgentMessage[];
|
|
79
|
+
}>;
|
|
80
|
+
tasks: TaskItem[];
|
|
81
|
+
feed: TeamFeedEntry[];
|
|
82
|
+
status: string;
|
|
83
|
+
leadStatus: string;
|
|
84
|
+
summary: string | null;
|
|
85
|
+
totalCost: number;
|
|
86
|
+
durationMs: number;
|
|
87
|
+
createdAt: number;
|
|
88
|
+
}
|
|
89
|
+
export interface TeamSummaryInfo {
|
|
90
|
+
teamId: string;
|
|
91
|
+
title: string;
|
|
92
|
+
status: string;
|
|
93
|
+
template: string | undefined;
|
|
94
|
+
agentCount: number;
|
|
95
|
+
taskCount: number;
|
|
96
|
+
totalCost: number;
|
|
97
|
+
workDir?: string;
|
|
98
|
+
createdAt: number;
|
|
99
|
+
}
|
|
100
|
+
export type SendFn = (msg: Record<string, unknown>) => void;
|
|
101
|
+
export type HandleChatFn = (conversationId: string | undefined, prompt: string, workDir: string, options?: {
|
|
102
|
+
resumeSessionId?: string;
|
|
103
|
+
extraArgs?: string[];
|
|
104
|
+
}) => void;
|
|
105
|
+
export type CancelExecutionFn = (conversationId?: string) => void;
|
|
106
|
+
export type SetOutputObserverFn = (fn: (conversationId: string, msg: Record<string, unknown>) => boolean | void) => void;
|
|
107
|
+
export type ClearOutputObserverFn = () => void;
|
|
108
|
+
export type SetCloseObserverFn = (fn: (conversationId: string, exitCode: number | null, resultReceived: boolean) => void) => void;
|
|
109
|
+
export type ClearCloseObserverFn = () => void;
|
|
110
|
+
export interface AgentDef {
|
|
111
|
+
description: string;
|
|
112
|
+
prompt: string;
|
|
113
|
+
tools: string[];
|
|
114
|
+
}
|
|
115
|
+
export type AgentsDefMap = Record<string, AgentDef>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-types.js","sourceRoot":"","sources":["../src/team-types.ts"],"names":[],"mappings":"AAAA,2EAA2E"}
|
package/dist/team.d.ts
CHANGED
|
@@ -6,102 +6,11 @@
|
|
|
6
6
|
* output stream to extract UI state (agent list, task board, activity feed)
|
|
7
7
|
* while the Lead Claude process drives all planning/execution autonomously.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
color: string;
|
|
17
|
-
}
|
|
18
|
-
export interface TaskItem {
|
|
19
|
-
id: string;
|
|
20
|
-
title: string;
|
|
21
|
-
description: string;
|
|
22
|
-
status: 'pending' | 'active' | 'done' | 'failed';
|
|
23
|
-
assignee: string | null;
|
|
24
|
-
toolUseId: string | null;
|
|
25
|
-
agentTaskId: string | null;
|
|
26
|
-
dependencies: string[];
|
|
27
|
-
createdAt: number;
|
|
28
|
-
updatedAt: number;
|
|
29
|
-
}
|
|
30
|
-
export interface TeamState {
|
|
31
|
-
teamId: string;
|
|
32
|
-
title: string;
|
|
33
|
-
config: TeamConfig;
|
|
34
|
-
conversationId: string;
|
|
35
|
-
claudeSessionId: string | null;
|
|
36
|
-
agents: Map<string, AgentTeammate>;
|
|
37
|
-
tasks: TaskItem[];
|
|
38
|
-
feed: TeamFeedEntry[];
|
|
39
|
-
status: 'planning' | 'running' | 'summarizing' | 'completed' | 'failed';
|
|
40
|
-
leadStatus: string;
|
|
41
|
-
summary: string | null;
|
|
42
|
-
totalCost: number;
|
|
43
|
-
durationMs: number;
|
|
44
|
-
createdAt: number;
|
|
45
|
-
}
|
|
46
|
-
export interface AgentTeammate {
|
|
47
|
-
role: AgentRole;
|
|
48
|
-
toolUseId: string | null;
|
|
49
|
-
agentTaskId: string | null;
|
|
50
|
-
status: 'starting' | 'working' | 'done' | 'error';
|
|
51
|
-
currentTaskId: string | null;
|
|
52
|
-
messages: TeamAgentMessage[];
|
|
53
|
-
}
|
|
54
|
-
export interface TeamAgentMessage {
|
|
55
|
-
id: number;
|
|
56
|
-
role: 'assistant' | 'tool' | 'user';
|
|
57
|
-
content?: string;
|
|
58
|
-
toolName?: string;
|
|
59
|
-
toolInput?: string;
|
|
60
|
-
toolOutput?: string;
|
|
61
|
-
hasResult?: boolean;
|
|
62
|
-
timestamp: number;
|
|
63
|
-
}
|
|
64
|
-
export interface TeamFeedEntry {
|
|
65
|
-
timestamp: number;
|
|
66
|
-
agentId: string;
|
|
67
|
-
type: 'task_started' | 'task_completed' | 'task_failed' | 'tool_call' | 'status_change' | 'lead_activity';
|
|
68
|
-
content: string;
|
|
69
|
-
}
|
|
70
|
-
export interface TeamStateSerialized {
|
|
71
|
-
teamId: string;
|
|
72
|
-
title: string;
|
|
73
|
-
config: TeamConfig;
|
|
74
|
-
conversationId: string;
|
|
75
|
-
claudeSessionId: string | null;
|
|
76
|
-
agents: Array<{
|
|
77
|
-
id: string;
|
|
78
|
-
name: string;
|
|
79
|
-
color: string;
|
|
80
|
-
toolUseId: string | null;
|
|
81
|
-
agentTaskId: string | null;
|
|
82
|
-
status: string;
|
|
83
|
-
currentTaskId: string | null;
|
|
84
|
-
messages?: TeamAgentMessage[];
|
|
85
|
-
}>;
|
|
86
|
-
tasks: TaskItem[];
|
|
87
|
-
feed: TeamFeedEntry[];
|
|
88
|
-
status: string;
|
|
89
|
-
leadStatus: string;
|
|
90
|
-
summary: string | null;
|
|
91
|
-
totalCost: number;
|
|
92
|
-
durationMs: number;
|
|
93
|
-
createdAt: number;
|
|
94
|
-
}
|
|
95
|
-
type SendFn = (msg: Record<string, unknown>) => void;
|
|
96
|
-
type HandleChatFn = (conversationId: string | undefined, prompt: string, workDir: string, options?: {
|
|
97
|
-
resumeSessionId?: string;
|
|
98
|
-
extraArgs?: string[];
|
|
99
|
-
}) => void;
|
|
100
|
-
type CancelExecutionFn = (conversationId?: string) => void;
|
|
101
|
-
type SetOutputObserverFn = (fn: (conversationId: string, msg: Record<string, unknown>) => boolean | void) => void;
|
|
102
|
-
type ClearOutputObserverFn = () => void;
|
|
103
|
-
type SetCloseObserverFn = (fn: (conversationId: string, exitCode: number | null, resultReceived: boolean) => void) => void;
|
|
104
|
-
type ClearCloseObserverFn = () => void;
|
|
9
|
+
export type { TeamConfig, AgentRole, TaskItem, TeamState, AgentTeammate, TeamAgentMessage, TeamFeedEntry, TeamStateSerialized, TeamSummaryInfo, AgentDef, AgentsDefMap, } from './team-types.js';
|
|
10
|
+
export { buildAgentsDef, buildLeadPrompt } from './team-templates.js';
|
|
11
|
+
export { getNextAgentColor, classifyRole, pickCharacter, deriveAgentDisplayName, deriveTaskTitle } from './team-naming.js';
|
|
12
|
+
export { serializeTeam, deserializeTeam, persistTeam, persistTeamDebounced, loadTeam, listTeams, deleteTeam, renameTeam, } from './team-persistence.js';
|
|
13
|
+
import type { TeamConfig, TeamState, AgentTeammate, TeamAgentMessage, TeamFeedEntry, SendFn, HandleChatFn, CancelExecutionFn, SetOutputObserverFn, ClearOutputObserverFn, SetCloseObserverFn, ClearCloseObserverFn } from './team-types.js';
|
|
105
14
|
export declare function setTeamSendFn(fn: SendFn): void;
|
|
106
15
|
/**
|
|
107
16
|
* Inject claude.ts dependencies to avoid circular imports.
|
|
@@ -120,15 +29,11 @@ export declare function getActiveTeam(): TeamState | null;
|
|
|
120
29
|
* Create a new team. Returns the TeamState.
|
|
121
30
|
* Does NOT start the Lead process — the caller (team lifecycle functions) does that.
|
|
122
31
|
*/
|
|
123
|
-
export declare function createTeamState(config: TeamConfig, conversationId: string): TeamState;
|
|
32
|
+
export declare function createTeamState(config: TeamConfig, conversationId: string, workDir: string): TeamState;
|
|
124
33
|
/**
|
|
125
34
|
* Clear the active team (used on dissolve/complete).
|
|
126
35
|
*/
|
|
127
36
|
export declare function clearActiveTeam(): void;
|
|
128
|
-
/**
|
|
129
|
-
* Get the next color for an agent (based on current count).
|
|
130
|
-
*/
|
|
131
|
-
export declare function getNextAgentColor(team: TeamState): string;
|
|
132
37
|
/**
|
|
133
38
|
* Register a subagent when Lead calls the Agent tool.
|
|
134
39
|
*/
|
|
@@ -160,68 +65,15 @@ export declare function addFeedEntry(team: TeamState, agentId: string, type: Tea
|
|
|
160
65
|
/**
|
|
161
66
|
* Mark a task as done/failed.
|
|
162
67
|
*/
|
|
163
|
-
export declare function updateTaskStatus(team: TeamState, taskId: string, status: 'done' | 'failed'): TaskItem | null;
|
|
68
|
+
export declare function updateTaskStatus(team: TeamState, taskId: string, status: 'done' | 'failed'): import('./team-types.js').TaskItem | null;
|
|
164
69
|
/**
|
|
165
70
|
* Check if all subagent tasks are completed.
|
|
166
71
|
*/
|
|
167
72
|
export declare function allSubagentsDone(team: TeamState): boolean;
|
|
168
73
|
/**
|
|
169
|
-
*
|
|
170
|
-
*/
|
|
171
|
-
export declare function serializeTeam(team: TeamState, includeMessages?: boolean): TeamStateSerialized;
|
|
172
|
-
/**
|
|
173
|
-
* Persist team state to disk (atomic write: tmp → rename).
|
|
174
|
-
*/
|
|
175
|
-
export declare function persistTeam(team: TeamState): void;
|
|
176
|
-
/**
|
|
177
|
-
* Debounced persist — coalesces rapid state changes into a single write.
|
|
178
|
-
* Flushes after 500ms of quiet.
|
|
179
|
-
*/
|
|
180
|
-
export declare function persistTeamDebounced(team: TeamState): void;
|
|
181
|
-
/**
|
|
182
|
-
* Flush all pending debounced persists immediately.
|
|
74
|
+
* Wrapper for flushPendingPersists that passes activeTeam.
|
|
183
75
|
*/
|
|
184
76
|
export declare function flushPendingPersists(): void;
|
|
185
|
-
/**
|
|
186
|
-
* Load a team from disk by teamId.
|
|
187
|
-
*/
|
|
188
|
-
export declare function loadTeam(teamId: string): TeamState | null;
|
|
189
|
-
/**
|
|
190
|
-
* Summary info for listing teams.
|
|
191
|
-
*/
|
|
192
|
-
export interface TeamSummaryInfo {
|
|
193
|
-
teamId: string;
|
|
194
|
-
title: string;
|
|
195
|
-
status: string;
|
|
196
|
-
template: string | undefined;
|
|
197
|
-
agentCount: number;
|
|
198
|
-
taskCount: number;
|
|
199
|
-
totalCost: number;
|
|
200
|
-
createdAt: number;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* List all persisted teams, sorted by createdAt descending (newest first).
|
|
204
|
-
*/
|
|
205
|
-
export declare function listTeams(): TeamSummaryInfo[];
|
|
206
|
-
/**
|
|
207
|
-
* Delete a persisted team file.
|
|
208
|
-
*/
|
|
209
|
-
export declare function deleteTeam(teamId: string): boolean;
|
|
210
|
-
export declare function renameTeam(teamId: string, newTitle: string): boolean;
|
|
211
|
-
interface AgentDef {
|
|
212
|
-
description: string;
|
|
213
|
-
prompt: string;
|
|
214
|
-
tools: string[];
|
|
215
|
-
}
|
|
216
|
-
type AgentsDefMap = Record<string, AgentDef>;
|
|
217
|
-
/**
|
|
218
|
-
* Build the agents definition JSON for the --agents CLI flag.
|
|
219
|
-
*/
|
|
220
|
-
export declare function buildAgentsDef(template?: string): AgentsDefMap;
|
|
221
|
-
/**
|
|
222
|
-
* Build the lead prompt that instructs the Lead to use Agent tool.
|
|
223
|
-
*/
|
|
224
|
-
export declare function buildLeadPrompt(config: TeamConfig, agentsDef: AgentsDefMap): string;
|
|
225
77
|
/**
|
|
226
78
|
* Output observer callback for the Lead's stdout stream.
|
|
227
79
|
* Registered via setOutputObserver() when a team is active.
|
|
@@ -247,4 +99,3 @@ export declare function dissolveTeam(): void;
|
|
|
247
99
|
* Marks the team as completed, persists state, and notifies clients.
|
|
248
100
|
*/
|
|
249
101
|
export declare function completeTeam(summary?: string): void;
|
|
250
|
-
export {};
|