fix(hub,cli,web): give web-created team sessions their team context at spawn

Root cause of 'lead never answers': sessions created through the web form
never received HAPI_TEAM_* env, so their system prompts had no team rules
(only spawn_peer-created members did). Now:
- /api/machines/:id/spawn accepts a team descriptor; the runner exports the
  env as before
- team mode creates the team first, spawns the lead with the team context,
  then attaches it as lead; member mode spawns with the team context before
  joining
- OpenCode system prompts (title + native tool instruction) carry the team
  block too
- human ping copy is action-first: reply directly (auto-synced to the
  group); do not run shell commands or explore the team
This commit is contained in:
2026-09-15 11:09:32 +08:00
parent b3f5819e45
commit 94c4a2d223
8 changed files with 57 additions and 19 deletions
+5 -3
View File
@@ -483,7 +483,7 @@ export class ApiClient {
async updateTeam(
teamId: string,
body: { name?: string; status?: 'active' | 'archived' }
body: { name?: string; status?: 'active' | 'archived'; leadSessionId?: string | null }
): Promise<{ team: TeamSummary }> {
return await this.request<{ team: TeamSummary }>(
`/api/teams/${encodeURIComponent(teamId)}`,
@@ -1117,7 +1117,8 @@ export class ApiClient {
serviceTier?: 'fast' | 'standard',
collaborationMode?: CodexCollaborationMode,
copilotAgentMode?: CopilotAgentMode,
startingMode?: 'remote' | 'pty'
startingMode?: 'remote' | 'pty',
team?: { id: string; name: string; role: string }
): Promise<SpawnResponse> {
return await this.request<SpawnResponse>(`/api/machines/${encodeURIComponent(machineId)}/spawn`, {
method: 'POST',
@@ -1134,7 +1135,8 @@ export class ApiClient {
serviceTier,
collaborationMode,
copilotAgentMode,
startingMode
startingMode,
...(team ? { team } : {})
})
})
}