mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +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:
@@ -29,6 +29,11 @@ export interface SpawnSessionOptions {
|
||||
forkSession?: boolean
|
||||
/** Runner-internal post-create containment revalidation. Never serialized. */
|
||||
validateDirectory?: (path: string) => Promise<boolean>
|
||||
/**
|
||||
* Agent Team context (hub-set). The runner exports HAPI_TEAM_* env vars so
|
||||
* the child CLI can register team MCP tools and identify its role.
|
||||
*/
|
||||
team?: { id: string; name: string; role: string }
|
||||
}
|
||||
|
||||
export type SpawnSessionResult =
|
||||
|
||||
@@ -90,7 +90,7 @@ const AUTH_RECOVERY_HINT =
|
||||
'or run `hapi auth login` to save the token. Inside a HAPI session prefer MCP ' +
|
||||
'`list_peers` / `ping_peer` / `inspect_peer`, which use the session CLI credentials.'
|
||||
|
||||
function resolveApiUrl(apiUrl?: string): string {
|
||||
export function resolveApiUrl(apiUrl?: string): string {
|
||||
const raw = (apiUrl ?? configuration.apiUrl).trim().replace(/\/+$/, '')
|
||||
if (!raw) {
|
||||
throw new PingPeerError(
|
||||
@@ -103,7 +103,7 @@ function resolveApiUrl(apiUrl?: string): string {
|
||||
return raw
|
||||
}
|
||||
|
||||
function resolveAccessToken(accessToken?: string): string {
|
||||
export function resolveAccessToken(accessToken?: string): string {
|
||||
let token = ''
|
||||
try {
|
||||
token = (accessToken ?? getAuthToken()).trim()
|
||||
@@ -123,7 +123,7 @@ function authFailedMessage(apiUrl: string, detail: string): string {
|
||||
return `failed to exchange access token for JWT (${detail}). Hub URL: ${apiUrl}. ${AUTH_RECOVERY_HINT}`
|
||||
}
|
||||
|
||||
async function exchangeJwt(
|
||||
export async function exchangeJwt(
|
||||
apiUrl: string,
|
||||
accessToken: string,
|
||||
http: AxiosInstance
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { AxiosInstance } from 'axios'
|
||||
|
||||
import {
|
||||
fetchTeamStatus,
|
||||
formatTeamMessages,
|
||||
formatTeamStatus,
|
||||
sendTeamMessage,
|
||||
type TeamStatusView
|
||||
} from './teamClient'
|
||||
|
||||
type MockResponse = { status: number; data: unknown }
|
||||
|
||||
function createHttpMock(responses: MockResponse[]) {
|
||||
const calls: Array<{ method: string; url: string; data?: unknown; headers?: Record<string, string> }> = []
|
||||
const queue = [...responses]
|
||||
const http = {
|
||||
post: vi.fn(async (url: string) => {
|
||||
calls.push({ method: 'post', url })
|
||||
return { status: 200, data: { token: 'jwt-1' } }
|
||||
}),
|
||||
request: vi.fn(async (config: { method: string; url: string; data?: unknown; headers?: Record<string, string> }) => {
|
||||
calls.push({ method: config.method, url: config.url, data: config.data, headers: config.headers })
|
||||
const next = queue.shift()
|
||||
if (!next) throw new Error('no mocked response left')
|
||||
return next
|
||||
})
|
||||
} as unknown as AxiosInstance
|
||||
return { http, calls }
|
||||
}
|
||||
|
||||
const statusBody: TeamStatusView = {
|
||||
team: { id: 'team-1', name: 'Refactor auth', status: 'active', leadSessionId: 'sess-lead' },
|
||||
me: { sessionId: 'sess-lead', role: 'lead', status: 'idle' },
|
||||
members: [{ sessionId: 'sess-lead', role: 'lead', status: 'idle' }],
|
||||
tasks: [],
|
||||
pendingTasks: [],
|
||||
budget: { maxMembers: 5, maxMessagesPerMinute: 30, maxChainDepth: 8 }
|
||||
}
|
||||
|
||||
describe('teamClient', () => {
|
||||
const originalTeamId = process.env.HAPI_TEAM_ID
|
||||
|
||||
afterEach(() => {
|
||||
if (originalTeamId === undefined) {
|
||||
delete process.env.HAPI_TEAM_ID
|
||||
} else {
|
||||
process.env.HAPI_TEAM_ID = originalTeamId
|
||||
}
|
||||
})
|
||||
|
||||
it('fetches status with bearer auth and returns null on 404', async () => {
|
||||
const { http, calls } = createHttpMock([
|
||||
{ status: 200, data: statusBody },
|
||||
{ status: 404, data: { error: 'Session is not a member of any team' } }
|
||||
])
|
||||
const options = { sessionId: 'sess-lead', apiUrl: 'http://hub.test', accessToken: 'token', http }
|
||||
|
||||
const status = await fetchTeamStatus(options)
|
||||
expect(status?.team.id).toBe('team-1')
|
||||
expect(calls[1]?.url).toBe('http://hub.test/api/teams/by-session/sess-lead')
|
||||
expect(calls[1]?.headers?.Authorization).toBe('Bearer jwt-1')
|
||||
|
||||
const missing = await fetchTeamStatus({ ...options, sessionId: 'sess-out' })
|
||||
expect(missing).toBeNull()
|
||||
})
|
||||
|
||||
it('sends team messages with the caller session id', async () => {
|
||||
const { http, calls } = createHttpMock([
|
||||
{ status: 201, data: { message: { seq: 7, fromSessionId: 'sess-lead', fromKind: 'session', toSessionId: null, kind: 'chat', text: 'hi', createdAt: 1, meta: null } } }
|
||||
])
|
||||
|
||||
const message = await sendTeamMessage({
|
||||
sessionId: 'sess-lead',
|
||||
teamId: 'team-1',
|
||||
text: 'hi',
|
||||
to: 'lead',
|
||||
kind: 'status',
|
||||
inReplyTo: 3,
|
||||
apiUrl: 'http://hub.test',
|
||||
accessToken: 'token',
|
||||
http
|
||||
})
|
||||
|
||||
expect(message.seq).toBe(7)
|
||||
expect(calls[1]?.url).toBe('http://hub.test/api/teams/team-1/messages')
|
||||
expect(calls[1]?.data).toEqual({
|
||||
fromSessionId: 'sess-lead',
|
||||
text: 'hi',
|
||||
to: 'lead',
|
||||
kind: 'status',
|
||||
inReplyTo: 3
|
||||
})
|
||||
})
|
||||
|
||||
it('formats status and message logs for the agent', () => {
|
||||
const text = formatTeamStatus(statusBody)
|
||||
expect(text).toContain('团队:Refactor auth')
|
||||
expect(text).toContain('你的角色:lead')
|
||||
expect(text).toContain('你的待办任务:无')
|
||||
|
||||
const log = formatTeamMessages([
|
||||
{
|
||||
seq: 2,
|
||||
fromSessionId: 'sess-builder1234',
|
||||
fromKind: 'session',
|
||||
toSessionId: null,
|
||||
kind: 'task-update',
|
||||
text: 'T1 done',
|
||||
createdAt: Date.UTC(2026, 0, 1, 10, 0, 0),
|
||||
meta: null
|
||||
}
|
||||
], 'sess-lead')
|
||||
expect(log).toContain('#2')
|
||||
expect(log).toContain('sess-bui')
|
||||
expect(log).toContain('T1 done')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,303 @@
|
||||
/**
|
||||
* Agent Team client used by the CLI / MCP tools.
|
||||
*
|
||||
* Talks to the hub's /api/teams endpoints with the same JWT flow as the web
|
||||
* app (`POST /api/auth` with the CLI_API_TOKEN), scoped to the token's
|
||||
* namespace. Never accepts an arbitrary host: always the configured hub.
|
||||
*/
|
||||
|
||||
import axios, { type AxiosInstance } from 'axios'
|
||||
|
||||
import { configuration } from '@/configuration'
|
||||
import { getAuthToken } from '@/api/auth'
|
||||
import { buildHubRequestHeaders } from '@/api/hubExtraHeaders'
|
||||
import { exchangeJwt, resolveAccessToken, resolveApiUrl } from '@/modules/pingPeer/pingPeer'
|
||||
|
||||
export class TeamClientError extends Error {
|
||||
readonly code: 'not_in_team' | 'auth_failed' | 'request_failed'
|
||||
|
||||
constructor(code: TeamClientError['code'], message: string) {
|
||||
super(message)
|
||||
this.name = 'TeamClientError'
|
||||
this.code = code
|
||||
}
|
||||
}
|
||||
|
||||
export interface TeamClientOptions {
|
||||
sessionId: string
|
||||
apiUrl?: string
|
||||
accessToken?: string
|
||||
http?: AxiosInstance
|
||||
/** Per-request timeout; defaults to 15s. Startup probes use a shorter one. */
|
||||
timeoutMs?: number
|
||||
}
|
||||
|
||||
export interface TeamMemberView {
|
||||
sessionId: string
|
||||
role: string
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface TeamTaskView {
|
||||
id: string
|
||||
title: string
|
||||
status: string
|
||||
assigneeSessionId: string | null
|
||||
}
|
||||
|
||||
export interface TeamStatusView {
|
||||
team: { id: string; name: string; status: string; leadSessionId: string | null }
|
||||
me: { sessionId: string; role: string; status: string }
|
||||
members: TeamMemberView[]
|
||||
tasks: TeamTaskView[]
|
||||
pendingTasks: TeamTaskView[]
|
||||
budget: { maxMembers: number; maxMessagesPerMinute: number; maxChainDepth: number }
|
||||
}
|
||||
|
||||
export interface TeamMessageView {
|
||||
seq: number
|
||||
fromSessionId: string | null
|
||||
fromKind: string
|
||||
toSessionId: string | null
|
||||
kind: string
|
||||
text: string
|
||||
createdAt: number
|
||||
meta: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
interface SessionContext {
|
||||
apiUrl: string
|
||||
jwt: string
|
||||
http: AxiosInstance
|
||||
timeoutMs: number
|
||||
}
|
||||
|
||||
async function openSession(options: TeamClientOptions): Promise<SessionContext> {
|
||||
const apiUrl = resolveApiUrl(options.apiUrl ?? configuration.apiUrl)
|
||||
const accessToken = resolveAccessToken(options.accessToken)
|
||||
const http = options.http ?? axios
|
||||
let jwt: string
|
||||
try {
|
||||
jwt = await exchangeJwt(apiUrl, accessToken, http)
|
||||
} catch (error) {
|
||||
throw new TeamClientError('auth_failed', error instanceof Error ? error.message : String(error))
|
||||
}
|
||||
return { apiUrl, jwt, http, timeoutMs: options.timeoutMs ?? 15_000 }
|
||||
}
|
||||
|
||||
function headers(jwt: string): Record<string, string> {
|
||||
return buildHubRequestHeaders({
|
||||
Authorization: `Bearer ${jwt}`,
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
}
|
||||
|
||||
async function request<T>(
|
||||
context: SessionContext,
|
||||
method: 'get' | 'post' | 'patch',
|
||||
path: string,
|
||||
body?: unknown
|
||||
): Promise<T> {
|
||||
let response
|
||||
try {
|
||||
response = await context.http.request({
|
||||
method,
|
||||
url: `${context.apiUrl}${path}`,
|
||||
headers: headers(context.jwt),
|
||||
data: body,
|
||||
timeout: context.timeoutMs,
|
||||
validateStatus: () => true
|
||||
})
|
||||
} catch (error) {
|
||||
throw new TeamClientError('request_failed', error instanceof Error ? error.message : String(error))
|
||||
}
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return response.data as T
|
||||
}
|
||||
const detail = typeof response.data?.error === 'string' ? response.data.error : 'request failed'
|
||||
throw new TeamClientError('request_failed', `HTTP ${response.status}: ${detail}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the team status for a session. Returns null when the session is not a
|
||||
* team member (or the hub has the feature disabled / older than teams).
|
||||
*/
|
||||
export async function fetchTeamStatus(options: TeamClientOptions): Promise<TeamStatusView | null> {
|
||||
const context = await openSession(options)
|
||||
try {
|
||||
return await request<TeamStatusView>(
|
||||
context,
|
||||
'get',
|
||||
`/api/teams/by-session/${encodeURIComponent(options.sessionId)}`
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof TeamClientError && error.code === 'request_failed' && /HTTP 404/.test(error.message)) {
|
||||
return null
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup probe: does this hub build have the team feature enabled?
|
||||
* 404 means disabled (or an older hub) -> the CLI must not register team
|
||||
* tools, keeping non-team behavior byte-identical. Never throws.
|
||||
*/
|
||||
export async function probeTeamsSupport(): Promise<boolean> {
|
||||
try {
|
||||
const context = await openSession({ sessionId: '', timeoutMs: 3000 })
|
||||
const response = await context.http.request({
|
||||
method: 'get',
|
||||
url: `${context.apiUrl}/api/teams/feature`,
|
||||
headers: headers(context.jwt),
|
||||
timeout: context.timeoutMs,
|
||||
validateStatus: () => true
|
||||
})
|
||||
return response.status >= 200 && response.status < 300
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the caller's current team membership fresh from the hub. Returns
|
||||
* null when the session is not a member (callers must handle that). This is
|
||||
* what makes team tools work for sessions that joined mid-life.
|
||||
*/
|
||||
export async function resolveCurrentTeam(
|
||||
options: TeamClientOptions
|
||||
): Promise<TeamStatusView | null> {
|
||||
try {
|
||||
return await fetchTeamStatus(options)
|
||||
} catch (error) {
|
||||
if (error instanceof TeamClientError && error.code === 'request_failed' && /HTTP 404/.test(error.message)) {
|
||||
return null
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export async function sendTeamMessage(
|
||||
options: TeamClientOptions & {
|
||||
teamId: string
|
||||
text: string
|
||||
to?: string
|
||||
kind?: string
|
||||
inReplyTo?: number
|
||||
}
|
||||
): Promise<TeamMessageView> {
|
||||
const context = await openSession(options)
|
||||
const response = await request<{ message: TeamMessageView }>(
|
||||
context,
|
||||
'post',
|
||||
`/api/teams/${encodeURIComponent(options.teamId)}/messages`,
|
||||
{
|
||||
fromSessionId: options.sessionId,
|
||||
text: options.text,
|
||||
to: options.to,
|
||||
kind: options.kind,
|
||||
inReplyTo: options.inReplyTo
|
||||
}
|
||||
)
|
||||
return response.message
|
||||
}
|
||||
|
||||
export async function readTeamMessages(
|
||||
options: TeamClientOptions & { teamId: string; afterSeq?: number; limit?: number }
|
||||
): Promise<TeamMessageView[]> {
|
||||
const context = await openSession(options)
|
||||
const params = new URLSearchParams({ sessionId: options.sessionId })
|
||||
if (options.afterSeq !== undefined) params.set('afterSeq', String(options.afterSeq))
|
||||
if (options.limit !== undefined) params.set('limit', String(options.limit))
|
||||
const response = await request<{ messages: TeamMessageView[] }>(
|
||||
context,
|
||||
'get',
|
||||
`/api/teams/${encodeURIComponent(options.teamId)}/messages?${params.toString()}`
|
||||
)
|
||||
return response.messages
|
||||
}
|
||||
|
||||
export async function spawnTeamMember(
|
||||
options: TeamClientOptions & {
|
||||
teamId: string
|
||||
role: string
|
||||
task?: string
|
||||
agent?: string
|
||||
model?: string
|
||||
sessionType?: 'simple' | 'worktree'
|
||||
worktreeName?: string
|
||||
}
|
||||
): Promise<{ teamId: string; sessionId: string; role: string; taskId: string | null }> {
|
||||
const context = await openSession(options)
|
||||
return await request(
|
||||
context,
|
||||
'post',
|
||||
`/api/teams/${encodeURIComponent(options.teamId)}/spawn`,
|
||||
{
|
||||
fromSessionId: options.sessionId,
|
||||
role: options.role,
|
||||
task: options.task,
|
||||
agent: options.agent,
|
||||
model: options.model,
|
||||
sessionType: options.sessionType,
|
||||
worktreeName: options.worktreeName
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export async function updateTeamTask(
|
||||
options: TeamClientOptions & { teamId: string; taskId: string; status: 'todo' | 'doing' | 'done' | 'blocked' }
|
||||
): Promise<void> {
|
||||
const context = await openSession(options)
|
||||
await request(
|
||||
context,
|
||||
'patch',
|
||||
`/api/teams/${encodeURIComponent(options.teamId)}/tasks/${encodeURIComponent(options.taskId)}`,
|
||||
{ fromSessionId: options.sessionId, status: options.status }
|
||||
)
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------- formatting
|
||||
|
||||
export function formatTeamStatus(status: TeamStatusView): string {
|
||||
const lines: string[] = []
|
||||
lines.push(`团队:${status.team.name}(${status.team.status}) · 你的角色:${status.me.role}`)
|
||||
lines.push('')
|
||||
lines.push(`成员(${status.members.length}/${status.budget.maxMembers}):`)
|
||||
for (const member of status.members) {
|
||||
const me = member.sessionId === status.me.sessionId ? ' ← 你' : ''
|
||||
const lead = member.sessionId === status.team.leadSessionId ? ' [lead]' : ''
|
||||
lines.push(`- ${member.role} (${member.sessionId.slice(0, 8)}) · ${member.status}${lead}${me}`)
|
||||
}
|
||||
if (status.pendingTasks.length > 0) {
|
||||
lines.push('')
|
||||
lines.push('你的待办任务:')
|
||||
for (const task of status.pendingTasks) {
|
||||
lines.push(`- ${task.title} [${task.status}] id=${task.id}`)
|
||||
}
|
||||
} else {
|
||||
lines.push('')
|
||||
lines.push('你的待办任务:无')
|
||||
}
|
||||
lines.push('')
|
||||
lines.push(`限额:消息 ${status.budget.maxMessagesPerMinute}/分钟 · 链深 ${status.budget.maxChainDepth}`)
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
export function formatTeamMessages(messages: TeamMessageView[], selfSessionId: string): string {
|
||||
if (messages.length === 0) {
|
||||
return '(没有新消息)'
|
||||
}
|
||||
return messages.map((message) => {
|
||||
const from = message.fromKind === 'hub'
|
||||
? 'hub'
|
||||
: message.fromKind === 'human'
|
||||
? '人类'
|
||||
: message.fromSessionId === selfSessionId
|
||||
? '你'
|
||||
: message.fromSessionId?.slice(0, 8) ?? '成员'
|
||||
const to = message.toSessionId ? ` → ${message.toSessionId.slice(0, 8)}` : ' → 全员'
|
||||
const time = new Date(message.createdAt).toISOString().slice(11, 19)
|
||||
return `#${message.seq} [${time}] ${from}${to} (${message.kind}): ${message.text}`
|
||||
}).join('\n')
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { getTeamPromptBlock, withTeamInstruction } from './teamPrompt'
|
||||
|
||||
describe('teamPrompt', () => {
|
||||
it('returns null for non-team sessions', () => {
|
||||
expect(getTeamPromptBlock('mcp__hapi__', {})).toBeNull()
|
||||
})
|
||||
|
||||
it('renders the team block with the flavor tool prefix', () => {
|
||||
const env = { HAPI_TEAM_ID: 'team-1', HAPI_TEAM_NAME: 'Refactor auth', HAPI_TEAM_ROLE: 'builder' }
|
||||
const block = getTeamPromptBlock('functions.hapi__', env)
|
||||
|
||||
expect(block).toContain('HAPI agent team "Refactor auth"')
|
||||
expect(block).toContain('your role: builder')
|
||||
expect(block).toContain('functions.hapi__team_status')
|
||||
expect(block).toContain('functions.hapi__team_read')
|
||||
expect(block).toContain('functions.hapi__team_send')
|
||||
expect(block).toContain('functions.hapi__spawn_peer')
|
||||
expect(block).not.toContain('mcp__hapi__')
|
||||
})
|
||||
|
||||
it('appends the block only when a team id is present', () => {
|
||||
expect(withTeamInstruction('BASE', 'mcp__hapi__', {})).toBe('BASE')
|
||||
const appended = withTeamInstruction('BASE', 'mcp__hapi__', { HAPI_TEAM_ID: 't' })
|
||||
expect(appended.startsWith('BASE\n\n')).toBe(true)
|
||||
expect(appended).toContain('mcp__hapi__team_status')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,30 @@
|
||||
import { trimIdent } from '@/utils/trimIdent'
|
||||
|
||||
/**
|
||||
* System-prompt block injected into team member sessions.
|
||||
*
|
||||
* Gated by HAPI_TEAM_ID (set by the runner when the hub spawns a member), so
|
||||
* non-team sessions are byte-identical to before. Flavors without
|
||||
* system-prompt injection (ACP) get the same rules via the hub's assignment
|
||||
* brief instead.
|
||||
*/
|
||||
export function getTeamPromptBlock(toolPrefix: string, env: NodeJS.ProcessEnv = process.env): string | null {
|
||||
const teamId = env.HAPI_TEAM_ID?.trim()
|
||||
if (!teamId) {
|
||||
return null
|
||||
}
|
||||
const name = env.HAPI_TEAM_NAME?.trim() || teamId.slice(0, 8)
|
||||
const role = env.HAPI_TEAM_ROLE?.trim() || 'member'
|
||||
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). Batch updates; do not chat back and forth.
|
||||
- Never use team_send for routine replies to the human - your normal replies are visible to them. Use ${toolPrefix}team_send with to="human" (or kind="decision") only when you genuinely need a human decision; it notifies them out-of-band.
|
||||
- Only use ${toolPrefix}spawn_peer when the human or the lead explicitly asks you to.
|
||||
`)
|
||||
}
|
||||
|
||||
export function withTeamInstruction(prompt: string, toolPrefix: string, env: NodeJS.ProcessEnv = process.env): string {
|
||||
const block = getTeamPromptBlock(toolPrefix, env)
|
||||
return block ? `${prompt}\n\n${block}` : prompt
|
||||
}
|
||||
Reference in New Issue
Block a user