refactor(agent-to-agent): drop named-approver list from v1

Address PR review: remove the `approvers` option entirely for v1 — the
approver is always the target group's admins/owners. Drops the `approvers`
DB column, the `--approvers` flag + its set-time validation, the now-unused
`approverUserIds` param on requestApproval, and the related tests. The
target-scoped approver pick (`approverAgentGroupId`) stays. Named approvers
can be re-added later via a migration when needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Moshe Krupper
2026-06-17 12:03:54 +03:00
parent f72658bb50
commit b2160a56aa
7 changed files with 22 additions and 75 deletions
+3 -28
View File
@@ -1,18 +1,7 @@
import { getAgentGroup } from '../../db/agent-groups.js';
import { hasAdminPrivilege } from '../../modules/permissions/db/user-roles.js';
import { removeMessagePolicy, setMessagePolicy } from '../../modules/agent-to-agent/db/agent-message-policies.js';
import { registerResource } from '../crud.js';
/** Parse `--approvers` (comma-separated user-ids) into a list, or null when omitted. */
function parseApprovers(raw: unknown): string[] | null {
if (raw === undefined || raw === null || raw === '') return null;
const ids = String(raw)
.split(',')
.map((s) => s.trim())
.filter(Boolean);
return ids.length > 0 ? ids : null;
}
registerResource({
name: 'policy',
plural: 'policies',
@@ -23,11 +12,6 @@ registerResource({
columns: [
{ name: 'from_agent_group_id', type: 'string', description: 'Source agent group. References agent_groups.id.' },
{ name: 'to_agent_group_id', type: 'string', description: 'Target agent group. References agent_groups.id.' },
{
name: 'approvers',
type: 'string',
description: 'JSON array of user-ids allowed to approve. Empty/NULL = the target groups admins/owners.',
},
{ name: 'created_at', type: 'string', description: 'Auto-set.' },
],
operations: { list: 'open' },
@@ -35,7 +19,7 @@ registerResource({
set: {
access: 'approval',
description:
'Require approval for messages from one agent to another. Use --from <agent-group-id> --to <agent-group-id> [--approvers <user-id,user-id>]. Named approvers must be admins/owners of the target.',
'Require approval (by the targets admins/owners) for messages from one agent to another. Use --from <agent-group-id> --to <agent-group-id>.',
handler: async (args) => {
const from = args.from as string;
const to = args.to as string;
@@ -45,17 +29,8 @@ registerResource({
if (!getAgentGroup(from)) throw new Error(`source agent group not found: ${from}`);
if (!getAgentGroup(to)) throw new Error(`target agent group not found: ${to}`);
const approvers = parseApprovers(args.approvers);
if (approvers) {
for (const userId of approvers) {
if (!hasAdminPrivilege(userId, to)) {
throw new Error(`approver "${userId}" is not an admin/owner of the target agent group`);
}
}
}
setMessagePolicy(from, to, approvers ? JSON.stringify(approvers) : null, new Date().toISOString());
return { from_agent_group_id: from, to_agent_group_id: to, approvers: approvers ?? null };
setMessagePolicy(from, to, new Date().toISOString());
return { from_agent_group_id: from, to_agent_group_id: to };
},
},
remove: {