mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-29 06:13:46 +00:00
feat(hub,web,cli): add Agent Team (sessions-as-teammates)
Hub
- independent teams.db (own user_version ladder); feature gate default OFF,
so a disabled hub never creates the file and team routes simply do not exist
- /api/teams: list/detail/by-session/memory/messages/spawn/tasks,
human message channel, team rename/archive/delete
- team runtime: spawn members via the existing runner RPC (worktree/yolo
options), peer message routing (mention/dm push, broadcast pull-only),
budgets (max members, message rate, reply chain depth), member-offline
announcements that wake the lead or escalate to the human
- team-attention notifications: in-app toast when visible, web push otherwise
- team memory dir {HAPI_HOME}/teams/<id>/ with charter.md template; read-only
browse API with path-traversal guards
CLI
- MCP tools: team_status / team_read / team_send / spawn_peer (claude, codex
bridge and ACP flavors); spawn_peer stays behind manual approval
- HAPI_TEAM_* env for spawned members; system-prompt block for Claude/Codex;
assignment brief carries team rules for flavors without prompt injection
- RUNNER_CAPABILITIES.agentTeam advertised to the hub
Web
- team group chat route with folded peer threads, key/task filters,
human composer, member/decision/system message cards
- side panel: live member status, interactive task board (create/status/
assignee), team memory browser, budget
- team create / add-member / settings dialogs; sidebar team section;
hub settings toggle for the feature (restart to apply)
- SSE team-updated invalidation
Zero impact when disabled: no teams.db, no routes, no tool or prompt changes.
This commit is contained in:
+80
-3
@@ -60,7 +60,11 @@ export type CreateSessionResponse = z.infer<typeof CreateSessionResponseSchema>
|
||||
export const HubSettingsResponseSchema = z.object({
|
||||
sessionSummaryContract: z.boolean(),
|
||||
/** Show compact AGENT_NOTIFY_SUMMARY in chat (default off / hide). */
|
||||
sessionSummaryInChat: z.boolean()
|
||||
sessionSummaryInChat: z.boolean(),
|
||||
/** Persisted Agent Team feature gate (applies after a hub restart). */
|
||||
teamsEnabled: z.boolean().optional(),
|
||||
/** Whether the running hub process currently has teams enabled. */
|
||||
teamsEnabledActive: z.boolean().optional()
|
||||
})
|
||||
|
||||
export type HubSettingsResponse = z.infer<typeof HubSettingsResponseSchema>
|
||||
@@ -68,10 +72,13 @@ export type HubSettingsResponse = z.infer<typeof HubSettingsResponseSchema>
|
||||
export const UpdateHubSettingsRequestSchema = z
|
||||
.object({
|
||||
sessionSummaryContract: z.boolean().optional(),
|
||||
sessionSummaryInChat: z.boolean().optional()
|
||||
sessionSummaryInChat: z.boolean().optional(),
|
||||
teamsEnabled: z.boolean().optional()
|
||||
})
|
||||
.refine(
|
||||
(data) => data.sessionSummaryContract !== undefined || data.sessionSummaryInChat !== undefined,
|
||||
(data) => data.sessionSummaryContract !== undefined
|
||||
|| data.sessionSummaryInChat !== undefined
|
||||
|| data.teamsEnabled !== undefined,
|
||||
{ message: 'At least one hub setting field is required' }
|
||||
)
|
||||
|
||||
@@ -439,6 +446,76 @@ export const SetSessionPinnedRequestSchema = z.object({
|
||||
})
|
||||
|
||||
export type SetSessionPinnedRequest = z.infer<typeof SetSessionPinnedRequestSchema>
|
||||
|
||||
export const CreateTeamRequestSchema = z.object({
|
||||
name: z.string().min(1).max(200),
|
||||
leadSessionId: z.string().min(1).optional(),
|
||||
config: z.record(z.string(), z.unknown()).optional()
|
||||
})
|
||||
|
||||
export type CreateTeamRequest = z.infer<typeof CreateTeamRequestSchema>
|
||||
|
||||
export const TeamSendMessageRequestSchema = z.object({
|
||||
fromSessionId: z.string().min(1),
|
||||
text: z.string().min(1).max(20000),
|
||||
/** 'all' (default) | 'lead' | member session id or unique prefix. */
|
||||
to: z.string().min(1).max(200).optional(),
|
||||
kind: z.enum(['chat', 'status', 'question', 'task-update', 'decision']).optional(),
|
||||
/** Team message seq this message replies to (budget chain-depth tracking). */
|
||||
inReplyTo: z.number().int().positive().optional()
|
||||
})
|
||||
|
||||
export type TeamSendMessageRequest = z.infer<typeof TeamSendMessageRequestSchema>
|
||||
|
||||
export const TeamSpawnMemberRequestSchema = z.object({
|
||||
fromSessionId: z.string().min(1),
|
||||
role: z.string().min(1).max(80),
|
||||
task: z.string().min(1).max(20000).optional(),
|
||||
agent: AgentFlavorSchema.optional(),
|
||||
model: z.string().min(1).max(200).optional(),
|
||||
sessionType: z.enum(['simple', 'worktree']).optional(),
|
||||
worktreeName: z.string().min(1).max(80).optional(),
|
||||
/** Run the member with bypassed permission prompts (autonomous work). */
|
||||
yolo: z.boolean().optional()
|
||||
})
|
||||
|
||||
export type TeamSpawnMemberRequest = z.infer<typeof TeamSpawnMemberRequestSchema>
|
||||
|
||||
export const TeamTaskUpdateRequestSchema = z.object({
|
||||
/** Session caller (CLI/MCP). Absent = human web caller. */
|
||||
fromSessionId: z.string().min(1).optional(),
|
||||
status: z.enum(['todo', 'doing', 'done', 'blocked']).optional(),
|
||||
assigneeSessionId: z.string().min(1).nullable().optional()
|
||||
}).refine((value) => value.status !== undefined || value.assigneeSessionId !== undefined, {
|
||||
message: 'status or assigneeSessionId is required'
|
||||
})
|
||||
|
||||
export type TeamTaskUpdateRequest = z.infer<typeof TeamTaskUpdateRequestSchema>
|
||||
|
||||
export const CreateTeamTaskRequestSchema = z.object({
|
||||
title: z.string().min(1).max(200),
|
||||
assigneeSessionId: z.string().min(1).nullable().optional()
|
||||
})
|
||||
|
||||
export type CreateTeamTaskRequest = z.infer<typeof CreateTeamTaskRequestSchema>
|
||||
|
||||
export const UpdateTeamRequestSchema = z.object({
|
||||
name: z.string().min(1).max(200).optional(),
|
||||
status: z.enum(['active', 'archived']).optional()
|
||||
}).refine((value) => value.name !== undefined || value.status !== undefined, {
|
||||
message: 'name or status is required'
|
||||
})
|
||||
|
||||
export type UpdateTeamRequest = z.infer<typeof UpdateTeamRequestSchema>
|
||||
|
||||
export const TeamHumanMessageRequestSchema = z.object({
|
||||
text: z.string().min(1).max(20000),
|
||||
/** 'all' (default) | 'lead' | member session id or unique prefix. */
|
||||
to: z.string().min(1).max(200).optional(),
|
||||
kind: z.enum(['chat', 'status', 'question', 'task-update', 'decision']).optional()
|
||||
})
|
||||
|
||||
export type TeamHumanMessageRequest = z.infer<typeof TeamHumanMessageRequestSchema>
|
||||
export type SessionPinMode = SetSessionPinnedRequest['mode']
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user