Skip to content

Commit ad60c05

Browse files
committed
toolbox returns object instead of array
1 parent 13443c7 commit ad60c05

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

client/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class NestorClient {
130130
if (response.ok) {
131131
const toolbox = await response.json()
132132
this.logger?.log(`Fetched toolbox at ${url}`)
133-
hub.tools = toolbox
133+
hub.tools = toolbox.tools
134134
}
135135
} catch (err) {
136136
this.logger?.error(`Error while fetching tools from hub ${hub.name}`, err)

client/tests/client.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import { NestorClient } from '../src/index'
44
import mdns from 'mdns'
55

66
global.fetch = vi.fn((req) => {
7-
if (req.includes('6000')) return { ok: true, json: () => [] }
8-
if (req.includes('6001')) return { ok: true, json: () => [ 1, 2, 3 ] }
7+
if (req.includes('6000')) return { ok: true, json: () => { return { tools:[] } } }
8+
if (req.includes('6001')) return { ok: true, json: () => { return { tools:[ 1, 2, 3 ] } } }
99
if (req.includes('6003')) throw new Error('not supposed to happen')
1010
if (req.includes('6002')) {
1111
if (req.includes('toolbox')) {
12-
return { ok: true, json: () => [
13-
{ function: { name: 'tool', url: 'localhost:3004'}}
14-
]}
12+
return { ok: true, json: () => { return { tools: [
13+
{ function: { name: 'tool', url: 'localhost:3004'} }
14+
]}}}
1515
} else {
1616
return { ok: true, json: () => { return { result: 'ok' }}}
1717
}
1818
}
1919
// assuming other ports are real hubs
20-
return { ok: true, json: () => [] }
20+
return { ok: true, json: () => { return { tools: [] } } }
2121
})
2222

2323
const logger = {

hub/src/routes/toolbox.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ router.get(['/', '/:format'], (req, res) => {
1010

1111
const marshaller = new Marshaller()
1212
if (req.params.format === undefined || req.params.format === 'openai') {
13-
res.json(marshaller.toOpenAI(req.serviceDirectory))
13+
res.json({ tools: marshaller.toOpenAI(req.serviceDirectory) })
1414
} else {
1515
res.status(400).send({ error: 'invalid format' })
1616
}

0 commit comments

Comments
 (0)