Files
Netcatty/components/ai/agentSendEligibility.test.ts
T
陈大猫 3408bba303 [codex] Add Cursor SDK agent support (#1399)
* feat(ai): add Cursor SDK agent support

* fix(ai): harden Cursor SDK support

* fix(ai): address Cursor SDK review findings

* fix(ai): refresh Cursor environment handling

* fix(ai): refresh Cursor discovery scans

* fix(ai): enable Cursor recheck without path

* Use official Cursor agent icon

* Clarify Cursor SDK setup requirements

* Split Cursor SDK setup status

* Simplify Cursor settings copy

* Improve Cursor API key error

* Add safe Cursor auth diagnostics

* Disable Cursor local sandbox by default

* Show Cursor MCP tool names in tool cards

* Add spacing inside tool call groups
2026-06-11 16:43:34 +08:00

54 lines
1.7 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { canSendWithAgent, findEnabledExternalAgent } from './agentSendEligibility';
import type { ExternalAgentConfig } from '../../infrastructure/ai/types';
const agents: ExternalAgentConfig[] = [
{
id: 'enabled-agent',
name: 'Enabled Agent',
command: '/usr/local/bin/enabled-agent',
sdkBackend: 'codex',
enabled: true,
},
{
id: 'disabled-agent',
name: 'Disabled Agent',
command: '/usr/local/bin/disabled-agent',
sdkBackend: 'codex',
enabled: false,
},
{
id: 'missing-backend-agent',
name: 'Missing Backend Agent',
command: '/usr/local/bin/missing-backend-agent',
enabled: true,
},
{
id: 'unavailable-agent',
name: 'Unavailable Agent',
command: '/usr/local/bin/unavailable-agent',
sdkBackend: 'cursor',
enabled: true,
available: false,
},
];
test('canSendWithAgent allows Catty and enabled external agents', () => {
assert.equal(canSendWithAgent('catty', agents), true);
assert.equal(canSendWithAgent('enabled-agent', agents), true);
});
test('canSendWithAgent blocks missing or disabled external agents', () => {
assert.equal(canSendWithAgent('disabled-agent', agents), false);
assert.equal(canSendWithAgent('missing-backend-agent', agents), false);
assert.equal(canSendWithAgent('unavailable-agent', agents), false);
assert.equal(canSendWithAgent('missing-agent', agents), false);
});
test('findEnabledExternalAgent ignores disabled external agents', () => {
assert.equal(findEnabledExternalAgent(agents, 'enabled-agent')?.name, 'Enabled Agent');
assert.equal(findEnabledExternalAgent(agents, 'disabled-agent'), undefined);
});