style: fix prettier formatting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -93,8 +93,7 @@ export function registerResourceHelpCommands(): void {
|
|||||||
lines.push('');
|
lines.push('');
|
||||||
|
|
||||||
// Verbs
|
// Verbs
|
||||||
const idAutoFilled =
|
const idAutoFilled = cliScope === 'group' && (res.plural === 'groups' || res.plural === 'destinations');
|
||||||
cliScope === 'group' && (res.plural === 'groups' || res.plural === 'destinations');
|
|
||||||
const idHint = idAutoFilled ? '' : ' <id>';
|
const idHint = idAutoFilled ? '' : ' <id>';
|
||||||
const verbs: string[] = [];
|
const verbs: string[] = [];
|
||||||
if (res.operations.list) verbs.push(`list [open]`);
|
if (res.operations.list) verbs.push(`list [open]`);
|
||||||
@@ -112,9 +111,8 @@ export function registerResourceHelpCommands(): void {
|
|||||||
lines.push('');
|
lines.push('');
|
||||||
|
|
||||||
// Columns
|
// Columns
|
||||||
const autoFilledFields = cliScope === 'group'
|
const autoFilledFields =
|
||||||
? new Set(['id', 'agent_group_id', 'group'])
|
cliScope === 'group' ? new Set(['id', 'agent_group_id', 'group']) : new Set<string>();
|
||||||
: new Set<string>();
|
|
||||||
lines.push('Fields:');
|
lines.push('Fields:');
|
||||||
for (const col of res.columns) {
|
for (const col of res.columns) {
|
||||||
const tags: string[] = [];
|
const tags: string[] = [];
|
||||||
|
|||||||
@@ -185,10 +185,7 @@ describe('CLI scope enforcement', () => {
|
|||||||
it('group: blocks cli_scope escalation', async () => {
|
it('group: blocks cli_scope escalation', async () => {
|
||||||
mockGetContainerConfig.mockReturnValue({ cli_scope: 'group' });
|
mockGetContainerConfig.mockReturnValue({ cli_scope: 'group' });
|
||||||
|
|
||||||
const resp = await dispatch(
|
const resp = await dispatch({ id: '1', command: 'groups-test', args: { cli_scope: 'global' } }, agentCtx());
|
||||||
{ id: '1', command: 'groups-test', args: { cli_scope: 'global' } },
|
|
||||||
agentCtx(),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(resp.ok).toBe(false);
|
expect(resp.ok).toBe(false);
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
@@ -200,10 +197,7 @@ describe('CLI scope enforcement', () => {
|
|||||||
it('group: blocks cli-scope escalation (hyphenated)', async () => {
|
it('group: blocks cli-scope escalation (hyphenated)', async () => {
|
||||||
mockGetContainerConfig.mockReturnValue({ cli_scope: 'group' });
|
mockGetContainerConfig.mockReturnValue({ cli_scope: 'group' });
|
||||||
|
|
||||||
const resp = await dispatch(
|
const resp = await dispatch({ id: '1', command: 'groups-test', args: { 'cli-scope': 'global' } }, agentCtx());
|
||||||
{ id: '1', command: 'groups-test', args: { 'cli-scope': 'global' } },
|
|
||||||
agentCtx(),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(resp.ok).toBe(false);
|
expect(resp.ok).toBe(false);
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ export async function dispatch(req: RequestFrame, ctx: CallerContext): Promise<R
|
|||||||
return err(req.id, 'forbidden', 'CLI access is scoped to this agent group.');
|
return err(req.id, 'forbidden', 'CLI access is scoped to this agent group.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((cmd.resource === 'groups' || cmd.resource === 'destinations') && req.args.id && req.args.id !== ctx.agentGroupId) {
|
if (
|
||||||
|
(cmd.resource === 'groups' || cmd.resource === 'destinations') &&
|
||||||
|
req.args.id &&
|
||||||
|
req.args.id !== ctx.agentGroupId
|
||||||
|
) {
|
||||||
return err(req.id, 'forbidden', 'CLI access is scoped to this agent group.');
|
return err(req.id, 'forbidden', 'CLI access is scoped to this agent group.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +134,10 @@ export async function dispatch(req: RequestFrame, ctx: CallerContext): Promise<R
|
|||||||
const groupField = cmd.resource === 'groups' ? 'id' : 'agent_group_id';
|
const groupField = cmd.resource === 'groups' ? 'id' : 'agent_group_id';
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
data = data.filter(
|
data = data.filter(
|
||||||
(row) => typeof row === 'object' && row !== null && (row as Record<string, unknown>)[groupField] === ctx.agentGroupId,
|
(row) =>
|
||||||
|
typeof row === 'object' &&
|
||||||
|
row !== null &&
|
||||||
|
(row as Record<string, unknown>)[groupField] === ctx.agentGroupId,
|
||||||
);
|
);
|
||||||
} else if (data && typeof data === 'object' && groupField in (data as Record<string, unknown>)) {
|
} else if (data && typeof data === 'object' && groupField in (data as Record<string, unknown>)) {
|
||||||
if ((data as Record<string, unknown>)[groupField] !== ctx.agentGroupId) {
|
if ((data as Record<string, unknown>)[groupField] !== ctx.agentGroupId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user