@lucashca/claudecontrol 0.3.28 → 0.3.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -43,8 +43,13 @@ export function createBypassCanUseTool(agentId: string, workspaceId: string) {
|
|
|
43
43
|
* Creates canUseTool for default (secure) mode.
|
|
44
44
|
* Shows permission prompt in the frontend and waits for user response.
|
|
45
45
|
*/
|
|
46
|
-
export function createCanUseTool(agentId: string, workspaceId: string) {
|
|
46
|
+
export function createCanUseTool(agentId: string, workspaceId: string, isOrchestrator = false) {
|
|
47
47
|
return (toolName: string, input: Record<string, unknown>, options: CanUseToolOptions) => {
|
|
48
|
+
if (toolName === 'Task' && !isOrchestrator) {
|
|
49
|
+
const session = agents.get(agentId);
|
|
50
|
+
if (session) pushLog(session, { type: 'system', text: 'Subagente bloqueado: apenas orquestradores podem iniciar subagentes', timestamp: new Date().toISOString() });
|
|
51
|
+
return Promise.resolve({ behavior: 'deny' as const, message: 'Apenas orquestradores podem iniciar subagentes' });
|
|
52
|
+
}
|
|
48
53
|
const requestId = genId();
|
|
49
54
|
const session = agents.get(agentId);
|
|
50
55
|
|
|
@@ -43,7 +43,7 @@ function loadCustomContext(cwd: string): string {
|
|
|
43
43
|
} catch { return ''; }
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function getOrchestratorRole(workspaceId: string): string {
|
|
46
|
+
export function getOrchestratorRole(workspaceId: string): string {
|
|
47
47
|
const workspace = getWorkspaceById(workspaceId);
|
|
48
48
|
if (workspace?.orchestratorRole) return workspace.orchestratorRole;
|
|
49
49
|
const cwd = workspace?.cwd;
|
|
@@ -252,12 +252,12 @@ export async function sendToAgent(id: string, message: string, attachments?: Att
|
|
|
252
252
|
}
|
|
253
253
|
broadcast({ type: 'agent_working', agentId: id, workspaceId: session.workspaceId, task: displayText });
|
|
254
254
|
|
|
255
|
+
// Only the orchestrator role gets native subagent tools; specialists just execute tasks
|
|
256
|
+
const isOrchestrator = session.isOrchestrator === true || session.role === getOrchestratorRole(session.workspaceId);
|
|
257
|
+
|
|
255
258
|
const permissionOpts = session.bypass
|
|
256
259
|
? { permissionMode: 'bypassPermissions' as const, allowDangerouslySkipPermissions: true, canUseTool: createBypassCanUseTool(id, session.workspaceId) }
|
|
257
|
-
: { permissionMode: 'default' as const, canUseTool: createCanUseTool(id, session.workspaceId) };
|
|
258
|
-
|
|
259
|
-
// Only the orchestrator role gets native subagent tools; specialists just execute tasks
|
|
260
|
-
const isOrchestrator = session.role === getOrchestratorRole(session.workspaceId);
|
|
260
|
+
: { permissionMode: 'default' as const, canUseTool: createCanUseTool(id, session.workspaceId, isOrchestrator) };
|
|
261
261
|
const subagents = (isOrchestrator && runtime.enableSubagents) ? buildSubagents(cwd, session.role) : {};
|
|
262
262
|
const hasAttachments = attachments && attachments.length > 0;
|
|
263
263
|
|
|
@@ -389,7 +389,7 @@ export async function runAgentQuery(session: AgentSession, task: string, bypass
|
|
|
389
389
|
stderr: (text: string) => console.error(`[agent:${session.id}]`, text),
|
|
390
390
|
...(bypass
|
|
391
391
|
? { permissionMode: 'bypassPermissions' as const, allowDangerouslySkipPermissions: true, canUseTool: createBypassCanUseTool(session.id, session.workspaceId) }
|
|
392
|
-
: { permissionMode: 'default' as const, canUseTool: createCanUseTool(session.id, session.workspaceId) }),
|
|
392
|
+
: { permissionMode: 'default' as const, canUseTool: createCanUseTool(session.id, session.workspaceId, isOrchestrator) }),
|
|
393
393
|
};
|
|
394
394
|
|
|
395
395
|
try {
|
package/backend/routes/agents.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
persistAgents, persistLogEntry, addAgentToIndex, pushLog, hideLogEntry,
|
|
9
9
|
delegations, agentQueues,
|
|
10
10
|
} from '../agents/store.js';
|
|
11
|
-
import { sendToAgent, runAgentQuery, delegateTask, compactAgentContext } from '../agents/lifecycle.js';
|
|
11
|
+
import { sendToAgent, runAgentQuery, delegateTask, compactAgentContext, getOrchestratorRole } from '../agents/lifecycle.js';
|
|
12
12
|
import { spawnRequests, createSpawnRequest, resolveSpawnRequest } from '../agents/spawn-requests.js';
|
|
13
13
|
|
|
14
14
|
export async function handleAgentRoutes(
|
|
@@ -206,7 +206,8 @@ export async function handleAgentRoutes(
|
|
|
206
206
|
const fromAgent = from ? agents.get(from) : null;
|
|
207
207
|
const workspaceId = fromAgent?.workspaceId;
|
|
208
208
|
if (!workspaceId) { jsonError(res, 'from agent not found or has no workspace'); return true; }
|
|
209
|
-
|
|
209
|
+
const isOrch = fromAgent.isOrchestrator === true || fromAgent.role === getOrchestratorRole(workspaceId);
|
|
210
|
+
if (!isOrch) { jsonError(res, 'Apenas orquestradores podem delegar tarefas', 403); return true; }
|
|
210
211
|
|
|
211
212
|
try {
|
|
212
213
|
const result = await delegateTask(from, to, task, workspaceId, model, toId);
|
package/package.json
CHANGED
package/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.3.
|
|
1
|
+
{"version":"0.3.30","build":"2026-04-03T23:54:10.502Z"}
|