Skip to content

Commit 2dd6afd

Browse files
Claudehotlong
andauthored
Add missing metadata API routes to test mock
The test mock in simulateBrowser.ts was missing critical HTTP handlers for metadata API endpoints that the ObjectStackClient uses to query agents and tools: 1. Added GET /api/v1/meta handler (base route that returns all metadata types) 2. Added generic GET /api/v1/meta/:type handler (for querying any metadata type like 'agent', 'tool', etc.) Without these handlers, the client's meta.getTypes() and meta.getItems('agent'/'tool') calls would fail in tests, making it appear that agents and tools were not registered even though the broker shim was correctly querying MetadataService. This was the final missing piece - the broker shim fix in commit 322a2a6 made agents/tools queryable from the kernel, but the test infrastructure couldn't actually test it because the HTTP routes weren't mocked. Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/b6593eda-d805-4d4d-8a8d-10f5438b7a25 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 322a2a6 commit 2dd6afd

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

apps/studio/src/mocks/simulateBrowser.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ export async function simulateBrowser() {
142142
}
143143
}),
144144

145+
// Metadata - Get all types (base route returns types)
146+
http.get('http://localhost:3000/api/v1/meta', async () => {
147+
console.log('[VirtualNetwork] GET /meta (types)');
148+
try {
149+
const result = await (kernel as any).broker.call('metadata.types', {});
150+
return HttpResponse.json({ success: true, data: result });
151+
} catch (err: any) {
152+
return HttpResponse.json({ error: err.message }, { status: 500 });
153+
}
154+
}),
155+
145156
// Metadata - Objects List (Singular & Plural support)
146157
http.get('http://localhost:3000/api/v1/meta/object', async () => {
147158
console.log('[VirtualNetwork] GET /meta/object');
@@ -194,6 +205,22 @@ export async function simulateBrowser() {
194205
} catch (err: any) {
195206
return HttpResponse.json({ error: err.message }, { status: 500 });
196207
}
208+
}),
209+
210+
// Metadata - Generic type list (for agents, tools, etc.)
211+
// This must come AFTER specific routes like /meta/object to avoid conflicts
212+
http.get('http://localhost:3000/api/v1/meta/:type', async ({ params }) => {
213+
// Skip if it's a specific route we already handled
214+
if (params.type === 'object' || params.type === 'objects') {
215+
return;
216+
}
217+
console.log(`[VirtualNetwork] GET /meta/${params.type}`);
218+
try {
219+
const result = await (kernel as any).broker.call(`metadata.${params.type}`, {});
220+
return HttpResponse.json({ success: true, data: result });
221+
} catch (err: any) {
222+
return HttpResponse.json({ error: err.message }, { status: 500 });
223+
}
197224
})
198225
];
199226

0 commit comments

Comments
 (0)