chore: generate
This commit is contained in:
@@ -246,7 +246,9 @@ async function createModelAccessKey(bearer: string): Promise<ApiKeyInfo> {
|
|||||||
return data.api_key_info
|
return data.api_key_info
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listRouters(bearer: string): Promise<{ ok: true; routers: RouterEntry[] } | { ok: false; status: number }> {
|
async function listRouters(
|
||||||
|
bearer: string,
|
||||||
|
): Promise<{ ok: true; routers: RouterEntry[] } | { ok: false; status: number }> {
|
||||||
const res = await fetch(`${DO_API_BASE}/v2/gen-ai/models/routers`, {
|
const res = await fetch(`${DO_API_BASE}/v2/gen-ai/models/routers`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${bearer}`,
|
Authorization: `Bearer ${bearer}`,
|
||||||
@@ -293,7 +295,9 @@ function parseRoutersJSON(raw: string | undefined): RouterEntry[] {
|
|||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(raw)
|
const parsed = JSON.parse(raw)
|
||||||
if (!Array.isArray(parsed)) return []
|
if (!Array.isArray(parsed)) return []
|
||||||
return parsed.flatMap((r) => (r && typeof r.name === "string" ? [{ name: r.name, uuid: r.uuid, description: r.description }] : []))
|
return parsed.flatMap((r) =>
|
||||||
|
r && typeof r.name === "string" ? [{ name: r.name, uuid: r.uuid, description: r.description }] : [],
|
||||||
|
)
|
||||||
} catch {
|
} catch {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,10 +43,7 @@ function injectAuth(metadata: Record<string, string> | undefined) {
|
|||||||
test("digitalocean provider autoloads from DIGITALOCEAN_ACCESS_TOKEN", async () => {
|
test("digitalocean provider autoloads from DIGITALOCEAN_ACCESS_TOKEN", async () => {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
await Bun.write(
|
await Bun.write(path.join(dir, "opencode.json"), JSON.stringify({ $schema: "https://opencode.ai/config.json" }))
|
||||||
path.join(dir, "opencode.json"),
|
|
||||||
JSON.stringify({ $schema: "https://opencode.ai/config.json" }),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await WithInstance.provide({
|
await WithInstance.provide({
|
||||||
@@ -68,10 +65,7 @@ test("digitalocean provider autoloads from DIGITALOCEAN_ACCESS_TOKEN", async ()
|
|||||||
test("digitalocean provider.models surfaces cached routers from auth metadata", async () => {
|
test("digitalocean provider.models surfaces cached routers from auth metadata", async () => {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
await Bun.write(
|
await Bun.write(path.join(dir, "opencode.json"), JSON.stringify({ $schema: "https://opencode.ai/config.json" }))
|
||||||
path.join(dir, "opencode.json"),
|
|
||||||
JSON.stringify({ $schema: "https://opencode.ai/config.json" }),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
injectAuth({
|
injectAuth({
|
||||||
@@ -100,10 +94,7 @@ test("digitalocean provider.models surfaces cached routers from auth metadata",
|
|||||||
test("digitalocean provider.models skips refresh when oauth bearer is expired", async () => {
|
test("digitalocean provider.models skips refresh when oauth bearer is expired", async () => {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
await Bun.write(
|
await Bun.write(path.join(dir, "opencode.json"), JSON.stringify({ $schema: "https://opencode.ai/config.json" }))
|
||||||
path.join(dir, "opencode.json"),
|
|
||||||
JSON.stringify({ $schema: "https://opencode.ai/config.json" }),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
injectAuth({
|
injectAuth({
|
||||||
@@ -125,10 +116,7 @@ test("digitalocean provider.models skips refresh when oauth bearer is expired",
|
|||||||
test("digitalocean provider.models passes through base models when no auth metadata", async () => {
|
test("digitalocean provider.models passes through base models when no auth metadata", async () => {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
await Bun.write(
|
await Bun.write(path.join(dir, "opencode.json"), JSON.stringify({ $schema: "https://opencode.ai/config.json" }))
|
||||||
path.join(dir, "opencode.json"),
|
|
||||||
JSON.stringify({ $schema: "https://opencode.ai/config.json" }),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await WithInstance.provide({
|
await WithInstance.provide({
|
||||||
|
|||||||
@@ -223,18 +223,15 @@ describe("tool.registry", () => {
|
|||||||
const loaded = (yield* registry.all()).find((tool) => tool.id === "image")
|
const loaded = (yield* registry.all()).find((tool) => tool.id === "image")
|
||||||
if (!loaded) throw new Error("custom image tool was not loaded")
|
if (!loaded) throw new Error("custom image tool was not loaded")
|
||||||
const agents = yield* Agent.Service
|
const agents = yield* Agent.Service
|
||||||
const result = yield* loaded.execute(
|
const result = yield* loaded.execute({}, {
|
||||||
{},
|
sessionID: SessionID.make("ses_test"),
|
||||||
{
|
messageID: MessageID.make("msg_test"),
|
||||||
sessionID: SessionID.make("ses_test"),
|
agent: (yield* agents.defaultInfo()).name,
|
||||||
messageID: MessageID.make("msg_test"),
|
abort: new AbortController().signal,
|
||||||
agent: (yield* agents.defaultInfo()).name,
|
messages: [],
|
||||||
abort: new AbortController().signal,
|
metadata: () => Effect.void,
|
||||||
messages: [],
|
ask: () => Effect.void,
|
||||||
metadata: () => Effect.void,
|
} satisfies Tool.Context)
|
||||||
ask: () => Effect.void,
|
|
||||||
} satisfies Tool.Context,
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(result.output).toBe("here is an image")
|
expect(result.output).toBe("here is an image")
|
||||||
expect(result.attachments).toEqual([
|
expect(result.attachments).toEqual([
|
||||||
|
|||||||
Reference in New Issue
Block a user