Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions dev/src/utils/agent_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,34 +440,12 @@ export class AgentLoader {
return Object.keys(this.preloadedAgents).sort();
}

async listApps(): Promise<string[]> {
await this.preloadAgents();

const appNames: string[] = [];
for (const [name, agentFile] of Object.entries(this.preloadedAgents)) {
try {
const loaded = await agentFile.load();
if (isApp(loaded)) {
appNames.push(name);
}
} catch {
// Ignore loading errors when listing apps
}
}

return appNames.sort();
}

async getAgentFile(agentName: string): Promise<AgentFile> {
await this.preloadAgents();

return this.preloadedAgents[agentName];
}

async getAppFile(appName: string): Promise<AgentFile> {
return this.getAgentFile(appName);
}

async disposeAll(): Promise<void> {
this.watcher?.close();
this.watcher = undefined;
Expand Down
8 changes: 4 additions & 4 deletions dev/test/utils/agent_loader_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,17 +769,17 @@ describe('AgentLoader', () => {
await loader.disposeAll();
});

it('discovers app entrypoint files (e.g. app.js) in directories and lists them via listApps() / getAppFile()', async () => {
it('discovers app entrypoint files (e.g. app.js) in directories', async () => {
const appDir = path.join(tempAgentsDir, 'my_service');
await fs.mkdir(appDir, {recursive: true});
await fs.writeFile(path.join(appDir, 'app.js'), appJsContent);

const loader = new AgentLoader(tempAgentsDir);
const apps = await loader.listApps();
const agents = await loader.listAgents();

expect(apps).toContain('my_service');
expect(agents).toContain('my_service');

const appFile = await loader.getAppFile('my_service');
const appFile = await loader.getAgentFile('my_service');
const loaded = await appFile.load();

expect(isApp(loaded)).toBe(true);
Expand Down
18 changes: 11 additions & 7 deletions tests/integration/app_loader/app_loader_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,29 @@ describe('AgentLoader discovery and loading integration', () => {
it(
'should discover apps vs agents across directories and standalone files',
async () => {
const apps = await loader.listApps();
expect(apps).toHaveLength(2);
expect(apps).toContain('service_alpha');
expect(apps).toContain('standalone_app');

const agentsAndApps = await loader.listAgents();
expect(agentsAndApps).toHaveLength(4);
expect(agentsAndApps).toContain('service_alpha');
expect(agentsAndApps).toContain('service_beta');
expect(agentsAndApps).toContain('standalone_agent');
expect(agentsAndApps).toContain('standalone_app');

const appNames: string[] = [];
for (const name of agentsAndApps) {
const file = await loader.getAgentFile(name);
if (isApp(await file.load())) {
appNames.push(name);
}
}
expect(appNames.sort()).toEqual(['service_alpha', 'standalone_app']);
},
TEST_EXECUTION_TIMEOUT,
);

it(
'should load App from directory entrypoint and expose App and rootAgent',
async () => {
const appFile = await loader.getAppFile('service_alpha');
const appFile = await loader.getAgentFile('service_alpha');
const loaded = await appFile.load();
expect(isApp(loaded)).toBe(true);
expect((loaded as App).name).toBe('alpha_app');
Expand All @@ -115,7 +119,7 @@ describe('AgentLoader discovery and loading integration', () => {
it(
'should synthesize App when loadApp() is called on BaseAgent file',
async () => {
const agentFile = await loader.getAppFile('service_beta');
const agentFile = await loader.getAgentFile('service_beta');
const loaded = await agentFile.load();
expect(isBaseAgent(loaded)).toBe(true);
expect(isApp(loaded)).toBe(false);
Expand Down
Loading