feat(teams,dsh): overview dashboard, lead task auth, and DSH launch tokens

- teams: cross-team overview read model + route/query/page; enforce member
  target visibility and restrict member task creation to the Lead
- dsh: accept 0.2.x launch tokens from the printed URL, HAPI_DSH_TOKEN, or
  HAPI_DSH_TOKEN_FILE; bundled wrapper captures the printed token securely;
  per-session agent availability and remote event/auth handling
- usage: support the 1d range and per-session totals in summaries
- cli/web: team prompt/client plumbing, availability gating, locale and
  route wiring for the overview page

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: HAPI <noreply@hapi.run>
This commit is contained in:
2026-11-05 02:22:50 +08:00
co-authored by Claude Code HAPI
parent bc6b1577fa
commit 362b1fe47e
28 changed files with 1666 additions and 70 deletions
+26
View File
@@ -311,6 +311,32 @@ export async function updateTeamTask(
return response.task ?? null
}
/** Create a task for an existing member. The hub allows this only for the Lead. */
export async function createTeamTask(
options: TeamClientOptions & {
teamId: string
title: string
assigneeSessionId?: string | null
dependsOn?: string[]
requirementId?: string
}
): Promise<TeamTaskView> {
const context = await openSession(options)
const response = await request<{ task: TeamTaskView }>(
context,
'post',
`/api/teams/${encodeURIComponent(options.teamId)}/tasks`,
{
fromSessionId: options.sessionId,
title: options.title,
...(options.assigneeSessionId !== undefined ? { assigneeSessionId: options.assigneeSessionId } : {}),
...(options.dependsOn && options.dependsOn.length > 0 ? { dependsOn: options.dependsOn } : {}),
...(options.requirementId ? { requirementId: options.requirementId } : {})
}
)
return response.task
}
// -------------------------------------------------------------- formatting
export function formatTeamStatus(status: TeamStatusView): string {
+1 -1
View File
@@ -24,7 +24,7 @@ export function getTeamPromptBlock(toolPrefix: string, env: NodeJS.ProcessEnv =
return trimIdent(`
You are a member of HAPI agent team "${name}" (your role: ${role}).
- Start by calling ${toolPrefix}team_status to pick up your assignment, and ${toolPrefix}team_read to pull team messages (broadcasts are not pushed to you).
- Report progress, completion, and blockers with ${toolPrefix}team_send (kind=status or task-update). Pass taskId so the update is filed under the right requirement. Batch updates; do not chat back and forth.
- Report progress, completion, and blockers with ${toolPrefix}team_send (kind=status or task-update). Always address the Lead with to="lead" — direct messages to other members are blocked. Pass taskId so the update is filed under the right requirement. Batch updates; do not chat back and forth.
- Track your work with ${toolPrefix}team_task (list/update): set a task to doing when you start, blocked when stuck, and done when finished. A done task requires a deliverable (evidence: branch/commit/files/test result), and doing/done requires its dependencies to be done first.
- Replies to a message the human just sent you are synced into the team group chat automatically. If your turn was triggered by anything else (a teammate message, a task, a timer) and it ends with something the human must see or decide, you MUST send it explicitly with ${toolPrefix}team_send: use kind="decision" (with to="human") only when the human has to decide something, and a normal broadcast (to="all") for progress or conclusions they merely need to see. Reserve to="human" for decisions - it interrupts them out-of-band.
- Spawned members inherit your tool/model/thinking level/permission by default; only pass overrides to ${toolPrefix}spawn_peer when the human explicitly asks for a different setup.