mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 10:11:46 +03:00
feat(tui): autocomplete skill references
This commit is contained in:
@@ -3,6 +3,7 @@ import { describe, expect, test } from "bun:test"
|
||||
import {
|
||||
NanobotClient,
|
||||
GatewayConnectionError,
|
||||
fetchAvailableSkills,
|
||||
fetchGatewayConnection,
|
||||
fetchHistory,
|
||||
fetchMentionCandidates,
|
||||
@@ -805,6 +806,53 @@ describe("gateway protocol", () => {
|
||||
}
|
||||
})
|
||||
|
||||
test("loads only enabled and available skills", async () => {
|
||||
const original = globalThis.fetch
|
||||
let authorization = ""
|
||||
globalThis.fetch = ((_: string | URL | Request, init?: RequestInit) => {
|
||||
authorization = new Headers(init?.headers).get("Authorization") || ""
|
||||
return Promise.resolve(new Response(JSON.stringify({
|
||||
skills: [
|
||||
{
|
||||
name: "verify",
|
||||
description: "Verify public behavior",
|
||||
source: "builtin",
|
||||
enabled: true,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
name: "disabled",
|
||||
description: "Disabled skill",
|
||||
source: "workspace",
|
||||
enabled: false,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
name: "unavailable",
|
||||
description: "Missing dependency",
|
||||
source: "builtin",
|
||||
enabled: true,
|
||||
available: false,
|
||||
},
|
||||
{ name: "my skill", enabled: true, available: true },
|
||||
{ name: "技能", enabled: true, available: true },
|
||||
{ enabled: true, available: true },
|
||||
],
|
||||
})))
|
||||
}) as typeof fetch
|
||||
|
||||
try {
|
||||
expect(await fetchAvailableSkills("http://nanobot.test", "secret")).toEqual([{
|
||||
name: "verify",
|
||||
description: "Verify public behavior",
|
||||
source: "builtin",
|
||||
}])
|
||||
expect(authorization).toBe("Bearer secret")
|
||||
} finally {
|
||||
globalThis.fetch = original
|
||||
}
|
||||
})
|
||||
|
||||
test("drops slash commands with unknown lifecycle metadata", async () => {
|
||||
const original = globalThis.fetch
|
||||
globalThis.fetch = (() => Promise.resolve(new Response(JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user