mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 17:01:37 +03:00
Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
7b3f52f810
commit
cd15a6a38b
-1
@@ -2612,7 +2612,6 @@ export type SessionEventDurable =
|
||||
export type IntegrationInfo = {
|
||||
id: IntegrationID
|
||||
name: string
|
||||
configured?: boolean
|
||||
metadata?: { [x: string]: any }
|
||||
methods: Array<IntegrationMethod>
|
||||
connections: Array<ConnectionInfo>
|
||||
|
||||
@@ -34,7 +34,6 @@ export const Plugin = define({
|
||||
}
|
||||
integrations.update(integrationID, (integration) => {
|
||||
integration.name = provider.name || integration.name
|
||||
integration.configured = true
|
||||
})
|
||||
if (provider.env !== undefined) {
|
||||
integrations.method.update({
|
||||
|
||||
@@ -426,7 +426,6 @@ const layer = Layer.effect(
|
||||
Info.make({
|
||||
id: entry.ref.id,
|
||||
name: entry.ref.name,
|
||||
...(entry.ref.configured === undefined ? {} : { configured: entry.ref.configured }),
|
||||
...(entry.ref.metadata === undefined ? {} : { metadata: entry.ref.metadata }),
|
||||
methods: entry.methods,
|
||||
connections: connections.map((connection) => {
|
||||
|
||||
@@ -365,9 +365,7 @@ describe("ConfigProviderPlugin.Plugin", () => {
|
||||
expect(yield* integrations.get(Integration.ID.make("litellm"))).toMatchObject({
|
||||
id: "litellm",
|
||||
name: "litellm",
|
||||
configured: true,
|
||||
methods: [{ type: "key", label: "Manually enter API Key" }],
|
||||
connections: [],
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ConnectionInfo, IntegrationInfo } from "@opencode/client"
|
||||
import type { ConnectionInfo } from "@opencode/client"
|
||||
import type { IntegrationApi } from "@opencode/client/effect/api"
|
||||
import { Connection } from "@opencode/schema/connection"
|
||||
import { Credential } from "@opencode/schema/credential"
|
||||
@@ -6,7 +6,7 @@ import { Form } from "@opencode/schema/form"
|
||||
import type { Effect, Scope } from "effect"
|
||||
import type { Transform } from "./registration.js"
|
||||
|
||||
type IntegrationRef = Pick<IntegrationInfo, "id" | "name" | "configured">
|
||||
type IntegrationRef = { id: string; name: string }
|
||||
|
||||
export interface IntegrationOAuthMethod {
|
||||
readonly id: string
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { ConnectionInfo, IntegrationInfo } from "@opencode/client"
|
||||
import type { ConnectionInfo } from "@opencode/client"
|
||||
import type { IntegrationApi } from "@opencode/client/promise/api"
|
||||
import { Connection } from "@opencode/schema/connection"
|
||||
import { Credential } from "@opencode/schema/credential"
|
||||
import { Form } from "@opencode/schema/form"
|
||||
import type { Transform } from "./registration.js"
|
||||
|
||||
type IntegrationRef = Pick<IntegrationInfo, "id" | "name" | "configured">
|
||||
type IntegrationRef = { id: string; name: string }
|
||||
|
||||
export interface IntegrationOAuthMethod {
|
||||
readonly id: string
|
||||
|
||||
Generated
-3
@@ -17370,9 +17370,6 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"configured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
},
|
||||
|
||||
@@ -68,15 +68,12 @@ export interface Ref extends Schema.Schema.Type<typeof Ref> {}
|
||||
export const Ref = Schema.Struct({
|
||||
id: ID,
|
||||
name: Schema.String,
|
||||
/** Declared in provider configuration, independently of credential connections. */
|
||||
configured: optional(Schema.Boolean),
|
||||
metadata: optional(Schema.Record(Schema.String, Schema.Any)),
|
||||
}).annotate({ identifier: "Integration.Ref" })
|
||||
|
||||
export const Info = Schema.Struct({
|
||||
id: ID,
|
||||
name: Schema.String,
|
||||
configured: optional(Schema.Boolean),
|
||||
metadata: optional(Schema.Record(Schema.String, Schema.Any)),
|
||||
methods: Schema.Array(Method),
|
||||
connections: Schema.Array(Connection.Info),
|
||||
|
||||
@@ -135,14 +135,12 @@ export function DialogIntegration(
|
||||
title: integration.name,
|
||||
value: integration.id,
|
||||
description: methods.length === 0 ? "Environment only" : undefined,
|
||||
footer: status
|
||||
? "Sign in required →"
|
||||
: connectionSummary(integration) || (integration.configured ? "Configured" : undefined),
|
||||
footer: status ? "Sign in required →" : connectionSummary(integration) || undefined,
|
||||
footerColor: status ? theme.text.feedback.warning.base : undefined,
|
||||
category,
|
||||
disabled: methods.length === 0 && credentials.length === 0,
|
||||
gutter:
|
||||
(integration.connections.length > 0 || integration.configured) && !status
|
||||
integration.connections.length > 0 && !status
|
||||
? () => <text fg={theme.text.feedback.success.base}>✓</text>
|
||||
: undefined,
|
||||
onSelect: () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { IntegrationInfo } from "@opencode/client"
|
||||
|
||||
export function hasConnectedProvider(integrations: readonly Pick<IntegrationInfo, "connections" | "configured">[]) {
|
||||
return integrations.some((integration) => integration.connections.length > 0 || integration.configured)
|
||||
export function hasConnectedProvider(integrations: readonly Pick<IntegrationInfo, "connections">[]) {
|
||||
return integrations.some((integration) => integration.connections.length > 0)
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { CliRenderEvents, InputRenderable } from "@opentui/core"
|
||||
import { once } from "node:events"
|
||||
import { DialogIntegration } from "../../src/component/dialog-integration"
|
||||
import { DialogModel } from "../../src/component/dialog-model"
|
||||
import { model, renderLocal } from "../fixture/local"
|
||||
import { directory, json } from "../fixture/tui-client"
|
||||
|
||||
test("identifies models with the same name from config-only integrations", async () => {
|
||||
await using setup = await renderLocal({
|
||||
models: ["one", "two"].map((providerID) => ({ ...model("chat"), providerID, name: "Same Model" })),
|
||||
fetch: (url) => {
|
||||
if (url.pathname === "/api/integration")
|
||||
return json({
|
||||
location: { directory },
|
||||
data: [
|
||||
{ id: "one", name: "Gateway One", configured: true, methods: [], connections: [] },
|
||||
{ id: "two", name: "Gateway Two", configured: true, methods: [], connections: [] },
|
||||
],
|
||||
})
|
||||
if (url.pathname === "/api/provider")
|
||||
return json({
|
||||
location: { directory },
|
||||
data: [
|
||||
{ id: "one", name: "Gateway One" },
|
||||
{ id: "two", name: "Gateway Two" },
|
||||
],
|
||||
})
|
||||
},
|
||||
})
|
||||
setup.dialog.replace(() => <DialogModel />)
|
||||
await setup.renderOnce()
|
||||
expect(setup.captureCharFrame()).toContain("Gateway One")
|
||||
expect(setup.captureCharFrame()).toContain("Gateway Two")
|
||||
|
||||
// DialogSelect defers filter focus until after its first render.
|
||||
if (!(setup.renderer.currentFocusedRenderable instanceof InputRenderable))
|
||||
await once(setup.renderer, CliRenderEvents.FOCUSED_RENDERABLE)
|
||||
await setup.mockInput.typeText("Same Model")
|
||||
await setup.renderOnce()
|
||||
const rows = setup
|
||||
.captureCharFrame()
|
||||
.split("\n")
|
||||
.filter((line) => line.includes("Same Model") && line.includes("Gateway"))
|
||||
expect(rows).toHaveLength(2)
|
||||
expect(rows.some((line) => line.includes("Gateway One"))).toBe(true)
|
||||
expect(rows.some((line) => line.includes("Gateway Two"))).toBe(true)
|
||||
})
|
||||
|
||||
test("marks config-only integrations as configured", async () => {
|
||||
await using setup = await renderLocal({
|
||||
fetch: (url) => {
|
||||
if (url.pathname === "/api/integration")
|
||||
return json({
|
||||
location: { directory },
|
||||
data: [
|
||||
{ id: "config", name: "Config only", configured: true, methods: [{ type: "key" }], connections: [] },
|
||||
{ id: "unconfigured", name: "Not configured", methods: [{ type: "key" }], connections: [] },
|
||||
],
|
||||
})
|
||||
},
|
||||
})
|
||||
setup.dialog.replace(() => <DialogIntegration />)
|
||||
await setup.renderOnce()
|
||||
const rows = setup.captureCharFrame().split("\n")
|
||||
expect(rows.find((line) => line.includes("Config only"))).toContain("Configured")
|
||||
expect(rows.find((line) => line.includes("Config only"))).toContain("✓")
|
||||
expect(rows.find((line) => line.includes("Not configured"))).not.toContain("Configured")
|
||||
expect(rows.find((line) => line.includes("Not configured"))).not.toContain("✓")
|
||||
})
|
||||
Reference in New Issue
Block a user