Files
claude-code/src/utils/teamDiscovery.ts
unraid fb41513b32 feat: 添加工具类增强与状态管理改进
- 新增 workflowRuns、remoteTriggerAudit、pipeStatus 等工具
- 增强 permissionSetup: auto mode 和 bypass permissions 始终可用
- 新增多组测试覆盖 (modifiers, teamDiscovery, deepLink 等)
- 修复 parseInt 缺少 radix 参数
- 移除多余 biome-ignore 注释

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 22:38:10 +08:00

79 lines
2.2 KiB
TypeScript

/**
* Team Discovery - Utilities for discovering teams and teammate status
*
* Scans ~/.claude/teams/ to find teams where the current session is the leader.
* Used by the Teams UI in the footer to show team status.
*/
import { type BackendType } from './swarm/backends/types.js'
import { readTeamFile } from './swarm/teamHelpers.js'
export type TeamSummary = {
name: string
memberCount: number
runningCount: number
idleCount: number
}
export type TeammateStatus = {
name: string
agentId: string
agentType?: string
model?: string
prompt?: string
status: 'running' | 'idle' | 'unknown'
color?: string
idleSince?: string // ISO timestamp from idle notification
tmuxPaneId: string
cwd: string
worktreePath?: string
isHidden?: boolean // Whether the pane is currently hidden from the swarm view
backendType?: BackendType // The backend type used for this teammate
mode?: string // Current permission mode for this teammate
}
/**
* Get detailed teammate statuses for a team
* Reads isActive from config to determine status
*/
export function getTeammateStatuses(teamName: string): TeammateStatus[] {
const teamFile = readTeamFile(teamName)
if (!teamFile) {
return []
}
const hiddenPaneIds = new Set(teamFile.hiddenPaneIds ?? [])
const statuses: TeammateStatus[] = []
for (const member of teamFile.members) {
// Exclude team-lead from the list
if (member.name === 'team-lead') {
continue
}
// Read isActive from config, defaulting to true (active) if undefined
const isActive = member.isActive !== false
const status: 'running' | 'idle' = isActive ? 'running' : 'idle'
statuses.push({
name: member.name,
agentId: member.agentId,
agentType: member.agentType,
model: member.model,
prompt: member.prompt,
status,
color: member.color,
tmuxPaneId: member.tmuxPaneId,
cwd: member.cwd,
worktreePath: member.worktreePath,
isHidden: hiddenPaneIds.has(member.tmuxPaneId),
backendType: member.backendType,
mode: member.mode,
})
}
return statuses
}
// Note: For time formatting, use formatRelativeTimeAgo from '../utils/format.js'