(params: {
toolName: string
toolUseId: string
input: Record<string, unknown>
description: string
permissionSuggestions?: unknown[]
teamName?: string
workerId?: string
workerName?: string
workerColor?: string
})
| 165 | * Create a new SwarmPermissionRequest object |
| 166 | */ |
| 167 | export function createPermissionRequest(params: { |
| 168 | toolName: string |
| 169 | toolUseId: string |
| 170 | input: Record<string, unknown> |
| 171 | description: string |
| 172 | permissionSuggestions?: unknown[] |
| 173 | teamName?: string |
| 174 | workerId?: string |
| 175 | workerName?: string |
| 176 | workerColor?: string |
| 177 | }): SwarmPermissionRequest { |
| 178 | const teamName = params.teamName || getTeamName() |
| 179 | const workerId = params.workerId || getAgentId() |
| 180 | const workerName = params.workerName || getAgentName() |
| 181 | const workerColor = params.workerColor || getTeammateColor() |
| 182 | |
| 183 | if (!teamName) { |
| 184 | throw new Error('Team name is required for permission requests') |
| 185 | } |
| 186 | if (!workerId) { |
| 187 | throw new Error('Worker ID is required for permission requests') |
| 188 | } |
| 189 | if (!workerName) { |
| 190 | throw new Error('Worker name is required for permission requests') |
| 191 | } |
| 192 | |
| 193 | return { |
| 194 | id: generateRequestId(), |
| 195 | workerId, |
| 196 | workerName, |
| 197 | workerColor, |
| 198 | teamName, |
| 199 | toolName: params.toolName, |
| 200 | toolUseId: params.toolUseId, |
| 201 | description: params.description, |
| 202 | input: params.input, |
| 203 | permissionSuggestions: params.permissionSuggestions || [], |
| 204 | status: 'pending', |
| 205 | createdAt: Date.now(), |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Write a permission request to the pending directory with file locking |
no test coverage detected