feat: unwrap Provider namespace + improved automation script (#22690)
This commit is contained in:
@@ -10,11 +10,11 @@
|
|||||||
* 1. Reads the file and finds the `export namespace Foo { ... }` block
|
* 1. Reads the file and finds the `export namespace Foo { ... }` block
|
||||||
* (uses ast-grep for accurate AST-based boundary detection)
|
* (uses ast-grep for accurate AST-based boundary detection)
|
||||||
* 2. Removes the namespace wrapper and dedents the body
|
* 2. Removes the namespace wrapper and dedents the body
|
||||||
* 3. If the file is index.ts, renames it to <lowercase-name>.ts
|
* 3. Fixes self-references (e.g. Config.PermissionAction → PermissionAction)
|
||||||
* 4. Creates/updates index.ts with `export * as Foo from "./<file>"`
|
* 4. If the file is index.ts, renames it to <lowercase-name>.ts
|
||||||
* 5. Prints the import rewrite commands to run across the codebase
|
* 5. Creates/updates index.ts with `export * as Foo from "./<file>"`
|
||||||
*
|
* 6. Rewrites import paths across src/, test/, and script/
|
||||||
* Does NOT auto-rewrite imports — prints the commands so you can review them.
|
* 7. Fixes sibling imports within the same directory
|
||||||
*
|
*
|
||||||
* Requires: ast-grep (`brew install ast-grep` or `cargo install ast-grep`)
|
* Requires: ast-grep (`brew install ast-grep` or `cargo install ast-grep`)
|
||||||
*/
|
*/
|
||||||
@@ -90,22 +90,107 @@ const after = lines.slice(closeLine + 1)
|
|||||||
const dedented = body.map((line) => {
|
const dedented = body.map((line) => {
|
||||||
if (line === "") return ""
|
if (line === "") return ""
|
||||||
if (line.startsWith(" ")) return line.slice(2)
|
if (line.startsWith(" ")) return line.slice(2)
|
||||||
return line // don't touch lines that aren't indented (shouldn't happen)
|
return line
|
||||||
})
|
})
|
||||||
|
|
||||||
const newContent = [...before, ...dedented, ...after].join("\n")
|
let newContent = [...before, ...dedented, ...after].join("\n")
|
||||||
|
|
||||||
|
// --- Fix self-references ---
|
||||||
|
// After unwrapping, references like `Config.PermissionAction` inside the same file
|
||||||
|
// need to become just `PermissionAction`. Only fix code positions, not strings.
|
||||||
|
const exportedNames = new Set<string>()
|
||||||
|
const exportRegex = /export\s+(?:const|function|class|interface|type|enum|abstract\s+class)\s+(\w+)/g
|
||||||
|
for (const line of dedented) {
|
||||||
|
for (const m of line.matchAll(exportRegex)) exportedNames.add(m[1])
|
||||||
|
}
|
||||||
|
const reExportRegex = /export\s*\{\s*([^}]+)\}/g
|
||||||
|
for (const line of dedented) {
|
||||||
|
for (const m of line.matchAll(reExportRegex)) {
|
||||||
|
for (const name of m[1].split(",")) {
|
||||||
|
const trimmed = name
|
||||||
|
.trim()
|
||||||
|
.split(/\s+as\s+/)
|
||||||
|
.pop()!
|
||||||
|
.trim()
|
||||||
|
if (trimmed) exportedNames.add(trimmed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let selfRefCount = 0
|
||||||
|
if (exportedNames.size > 0) {
|
||||||
|
const fixedLines = newContent.split("\n").map((line) => {
|
||||||
|
// Split line into string-literal and code segments to avoid replacing inside strings
|
||||||
|
const segments: Array<{ text: string; isString: boolean }> = []
|
||||||
|
let i = 0
|
||||||
|
let current = ""
|
||||||
|
let inString: string | null = null
|
||||||
|
|
||||||
|
while (i < line.length) {
|
||||||
|
const ch = line[i]
|
||||||
|
if (inString) {
|
||||||
|
current += ch
|
||||||
|
if (ch === "\\" && i + 1 < line.length) {
|
||||||
|
current += line[i + 1]
|
||||||
|
i += 2
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (ch === inString) {
|
||||||
|
segments.push({ text: current, isString: true })
|
||||||
|
current = ""
|
||||||
|
inString = null
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (ch === '"' || ch === "'" || ch === "`") {
|
||||||
|
if (current) segments.push({ text: current, isString: false })
|
||||||
|
current = ch
|
||||||
|
inString = ch
|
||||||
|
i++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (ch === "/" && i + 1 < line.length && line[i + 1] === "/") {
|
||||||
|
current += line.slice(i)
|
||||||
|
segments.push({ text: current, isString: true })
|
||||||
|
current = ""
|
||||||
|
i = line.length
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
current += ch
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
if (current) segments.push({ text: current, isString: !!inString })
|
||||||
|
|
||||||
|
return segments
|
||||||
|
.map((seg) => {
|
||||||
|
if (seg.isString) return seg.text
|
||||||
|
let result = seg.text
|
||||||
|
for (const name of exportedNames) {
|
||||||
|
const pattern = `${nsName}.${name}`
|
||||||
|
while (result.includes(pattern)) {
|
||||||
|
const idx = result.indexOf(pattern)
|
||||||
|
const charBefore = idx > 0 ? result[idx - 1] : " "
|
||||||
|
const charAfter = idx + pattern.length < result.length ? result[idx + pattern.length] : " "
|
||||||
|
if (/\w/.test(charBefore) || /\w/.test(charAfter)) break
|
||||||
|
result = result.slice(0, idx) + name + result.slice(idx + pattern.length)
|
||||||
|
selfRefCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
.join("")
|
||||||
|
})
|
||||||
|
newContent = fixedLines.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
// Figure out file naming
|
// Figure out file naming
|
||||||
const dir = path.dirname(absPath)
|
const dir = path.dirname(absPath)
|
||||||
const basename = path.basename(absPath, ".ts")
|
const basename = path.basename(absPath, ".ts")
|
||||||
const isIndex = basename === "index"
|
const isIndex = basename === "index"
|
||||||
|
|
||||||
// The implementation file name (lowercase namespace name if currently index.ts)
|
|
||||||
const implName = isIndex ? nsName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase() : basename
|
const implName = isIndex ? nsName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase() : basename
|
||||||
const implFile = path.join(dir, `${implName}.ts`)
|
const implFile = path.join(dir, `${implName}.ts`)
|
||||||
const indexFile = path.join(dir, "index.ts")
|
const indexFile = path.join(dir, "index.ts")
|
||||||
|
|
||||||
// The barrel line
|
|
||||||
const barrelLine = `export * as ${nsName} from "./${implName}"\n`
|
const barrelLine = `export * as ${nsName} from "./${implName}"\n`
|
||||||
|
|
||||||
console.log("")
|
console.log("")
|
||||||
@@ -114,6 +199,7 @@ if (isIndex) {
|
|||||||
} else {
|
} else {
|
||||||
console.log(`Plan: rewrite ${basename}.ts in place, create index.ts barrel`)
|
console.log(`Plan: rewrite ${basename}.ts in place, create index.ts barrel`)
|
||||||
}
|
}
|
||||||
|
if (selfRefCount > 0) console.log(`Fixed ${selfRefCount} self-reference(s) (${nsName}.X → X)`)
|
||||||
console.log("")
|
console.log("")
|
||||||
|
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
@@ -128,19 +214,23 @@ if (dryRun) {
|
|||||||
console.log("")
|
console.log("")
|
||||||
console.log(`=== index.ts ===`)
|
console.log(`=== index.ts ===`)
|
||||||
console.log(` ${barrelLine.trim()}`)
|
console.log(` ${barrelLine.trim()}`)
|
||||||
|
console.log("")
|
||||||
|
if (!isIndex) {
|
||||||
|
const relDir = path.relative(path.resolve("src"), dir)
|
||||||
|
console.log(`=== Import rewrites (would apply) ===`)
|
||||||
|
console.log(` ${relDir}/${basename}" → ${relDir}" across src/, test/, script/`)
|
||||||
|
} else {
|
||||||
|
console.log("No import rewrites needed (was index.ts)")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Write the implementation file
|
|
||||||
if (isIndex) {
|
if (isIndex) {
|
||||||
// Rename: write new content to implFile, then overwrite index.ts with barrel
|
|
||||||
fs.writeFileSync(implFile, newContent)
|
fs.writeFileSync(implFile, newContent)
|
||||||
fs.writeFileSync(indexFile, barrelLine)
|
fs.writeFileSync(indexFile, barrelLine)
|
||||||
console.log(`Wrote ${implName}.ts (${newContent.split("\n").length} lines)`)
|
console.log(`Wrote ${implName}.ts (${newContent.split("\n").length} lines)`)
|
||||||
console.log(`Wrote index.ts (barrel)`)
|
console.log(`Wrote index.ts (barrel)`)
|
||||||
} else {
|
} else {
|
||||||
// Rewrite in place, create index.ts
|
|
||||||
fs.writeFileSync(absPath, newContent)
|
fs.writeFileSync(absPath, newContent)
|
||||||
if (fs.existsSync(indexFile)) {
|
if (fs.existsSync(indexFile)) {
|
||||||
// Append to existing barrel
|
|
||||||
const existing = fs.readFileSync(indexFile, "utf-8")
|
const existing = fs.readFileSync(indexFile, "utf-8")
|
||||||
if (!existing.includes(`export * as ${nsName}`)) {
|
if (!existing.includes(`export * as ${nsName}`)) {
|
||||||
fs.appendFileSync(indexFile, barrelLine)
|
fs.appendFileSync(indexFile, barrelLine)
|
||||||
@@ -154,37 +244,60 @@ if (dryRun) {
|
|||||||
}
|
}
|
||||||
console.log(`Rewrote ${basename}.ts (${newContent.split("\n").length} lines)`)
|
console.log(`Rewrote ${basename}.ts (${newContent.split("\n").length} lines)`)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Print the import rewrite guidance
|
// --- Rewrite import paths across src/, test/, script/ ---
|
||||||
const relDir = path.relative(path.resolve("src"), dir)
|
const relDir = path.relative(path.resolve("src"), dir)
|
||||||
|
if (!isIndex) {
|
||||||
console.log("")
|
|
||||||
console.log("=== Import rewrites ===")
|
|
||||||
console.log("")
|
|
||||||
|
|
||||||
if (!isIndex) {
|
|
||||||
// Non-index files: imports like "../provider/provider" need to become "../provider"
|
|
||||||
const oldTail = `${relDir}/${basename}`
|
const oldTail = `${relDir}/${basename}`
|
||||||
|
const searchDirs = ["src", "test", "script"].filter((d) => fs.existsSync(d))
|
||||||
|
const rgResult = Bun.spawnSync(["rg", "-l", `from.*${oldTail}"`, ...searchDirs], {
|
||||||
|
stdout: "pipe",
|
||||||
|
stderr: "pipe",
|
||||||
|
})
|
||||||
|
const filesToRewrite = rgResult.stdout
|
||||||
|
.toString()
|
||||||
|
.trim()
|
||||||
|
.split("\n")
|
||||||
|
.filter((f) => f.length > 0)
|
||||||
|
|
||||||
console.log(`# Find all imports to rewrite:`)
|
if (filesToRewrite.length > 0) {
|
||||||
console.log(`rg 'from.*${oldTail}' src/ --files-with-matches`)
|
console.log(`\nRewriting imports in ${filesToRewrite.length} file(s)...`)
|
||||||
console.log("")
|
for (const file of filesToRewrite) {
|
||||||
|
const content = fs.readFileSync(file, "utf-8")
|
||||||
|
fs.writeFileSync(file, content.replaceAll(`${oldTail}"`, `${relDir}"`))
|
||||||
|
}
|
||||||
|
console.log(` Done: ${oldTail}" → ${relDir}"`)
|
||||||
|
} else {
|
||||||
|
console.log("\nNo import rewrites needed")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("\nNo import rewrites needed (was index.ts)")
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-rewrite with sed (safe: only rewrites the import path, not other occurrences)
|
// --- Fix sibling imports within the same directory ---
|
||||||
console.log("# Auto-rewrite (review diff afterward):")
|
const siblingFiles = fs.readdirSync(dir).filter((f) => {
|
||||||
console.log(`rg -l 'from.*${oldTail}' src/ | xargs sed -i '' 's|${oldTail}"|${relDir}"|g'`)
|
if (!f.endsWith(".ts")) return false
|
||||||
console.log("")
|
if (f === "index.ts" || f === `${implName}.ts`) return false
|
||||||
console.log("# What changes:")
|
return true
|
||||||
console.log(`# import { ${nsName} } from ".../${oldTail}"`)
|
})
|
||||||
console.log(`# import { ${nsName} } from ".../${relDir}"`)
|
|
||||||
} else {
|
let siblingFixCount = 0
|
||||||
console.log("# File was index.ts — import paths already resolve correctly.")
|
for (const sibFile of siblingFiles) {
|
||||||
console.log("# No import rewrites needed!")
|
const sibPath = path.join(dir, sibFile)
|
||||||
|
const content = fs.readFileSync(sibPath, "utf-8")
|
||||||
|
const pattern = new RegExp(`from\\s+["']\\./${basename}["']`, "g")
|
||||||
|
if (pattern.test(content)) {
|
||||||
|
fs.writeFileSync(sibPath, content.replace(pattern, `from "."`))
|
||||||
|
siblingFixCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (siblingFixCount > 0) {
|
||||||
|
console.log(`Fixed ${siblingFixCount} sibling import(s) in ${path.basename(dir)}/ (./${basename} → .)`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("")
|
console.log("")
|
||||||
console.log("=== Verify ===")
|
console.log("=== Verify ===")
|
||||||
console.log("")
|
console.log("")
|
||||||
console.log("bun typecheck # from packages/opencode")
|
console.log("bunx --bun tsgo --noEmit # typecheck")
|
||||||
console.log("bun run test # run tests")
|
console.log("bun run test # run tests")
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import { Filesystem } from "../util/filesystem"
|
|||||||
import { Hash } from "@opencode-ai/shared/util/hash"
|
import { Hash } from "@opencode-ai/shared/util/hash"
|
||||||
import { ACPSessionManager } from "./session"
|
import { ACPSessionManager } from "./session"
|
||||||
import type { ACPConfig } from "./types"
|
import type { ACPConfig } from "./types"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider"
|
||||||
import { ModelID, ProviderID } from "../provider/schema"
|
import { ModelID, ProviderID } from "../provider/schema"
|
||||||
import { Agent as AgentModule } from "../agent/agent"
|
import { Agent as AgentModule } from "../agent/agent"
|
||||||
import { AppRuntime } from "@/effect/app-runtime"
|
import { AppRuntime } from "@/effect/app-runtime"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Config } from "../config"
|
import { Config } from "../config"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider"
|
||||||
import { ModelID, ProviderID } from "../provider/schema"
|
import { ModelID, ProviderID } from "../provider/schema"
|
||||||
import { generateObject, streamObject, type ModelMessage } from "ai"
|
import { generateObject, streamObject, type ModelMessage } from "ai"
|
||||||
import { Instance } from "../project/instance"
|
import { Instance } from "../project/instance"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { AppRuntime } from "@/effect/app-runtime"
|
|||||||
import { UI } from "../ui"
|
import { UI } from "../ui"
|
||||||
import { Global } from "../../global"
|
import { Global } from "../../global"
|
||||||
import { Agent } from "../../agent/agent"
|
import { Agent } from "../../agent/agent"
|
||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import fs from "fs/promises"
|
import fs from "fs/promises"
|
||||||
import { Filesystem } from "../../util/filesystem"
|
import { Filesystem } from "../../util/filesystem"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { EOL } from "os"
|
|||||||
import { basename } from "path"
|
import { basename } from "path"
|
||||||
import { Effect } from "effect"
|
import { Effect } from "effect"
|
||||||
import { Agent } from "../../../agent/agent"
|
import { Agent } from "../../../agent/agent"
|
||||||
import { Provider } from "../../../provider/provider"
|
import { Provider } from "../../../provider"
|
||||||
import { Session } from "../../../session"
|
import { Session } from "../../../session"
|
||||||
import type { MessageV2 } from "../../../session/message-v2"
|
import type { MessageV2 } from "../../../session/message-v2"
|
||||||
import { MessageID, PartID } from "../../../session/schema"
|
import { MessageID, PartID } from "../../../session/schema"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import { SessionShare } from "@/share/session"
|
|||||||
import { Session } from "../../session"
|
import { Session } from "../../session"
|
||||||
import type { SessionID } from "../../session/schema"
|
import type { SessionID } from "../../session/schema"
|
||||||
import { MessageID, PartID } from "../../session/schema"
|
import { MessageID, PartID } from "../../session/schema"
|
||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider"
|
||||||
import { Bus } from "../../bus"
|
import { Bus } from "../../bus"
|
||||||
import { MessageV2 } from "../../session/message-v2"
|
import { MessageV2 } from "../../session/message-v2"
|
||||||
import { SessionPrompt } from "@/session/prompt"
|
import { SessionPrompt } from "@/session/prompt"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { Argv } from "yargs"
|
import type { Argv } from "yargs"
|
||||||
import { Instance } from "../../project/instance"
|
import { Instance } from "../../project/instance"
|
||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider"
|
||||||
import { ProviderID } from "../../provider/schema"
|
import { ProviderID } from "../../provider/schema"
|
||||||
import { ModelsDev } from "../../provider/models"
|
import { ModelsDev } from "../../provider/models"
|
||||||
import { cmd } from "./cmd"
|
import { cmd } from "./cmd"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { EOL } from "os"
|
|||||||
import { Filesystem } from "../../util/filesystem"
|
import { Filesystem } from "../../util/filesystem"
|
||||||
import { createOpencodeClient, type OpencodeClient, type ToolPart } from "@opencode-ai/sdk/v2"
|
import { createOpencodeClient, type OpencodeClient, type ToolPart } from "@opencode-ai/sdk/v2"
|
||||||
import { Server } from "../../server/server"
|
import { Server } from "../../server/server"
|
||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider"
|
||||||
import { Agent } from "../../agent/agent"
|
import { Agent } from "../../agent/agent"
|
||||||
import { Permission } from "../../permission"
|
import { Permission } from "../../permission"
|
||||||
import { Tool } from "../../tool/tool"
|
import { Tool } from "../../tool/tool"
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import { ExitProvider, useExit } from "./context/exit"
|
|||||||
import { Session as SessionApi } from "@/session"
|
import { Session as SessionApi } from "@/session"
|
||||||
import { TuiEvent } from "./event"
|
import { TuiEvent } from "./event"
|
||||||
import { KVProvider, useKV } from "./context/kv"
|
import { KVProvider, useKV } from "./context/kv"
|
||||||
import { Provider } from "@/provider/provider"
|
import { Provider } from "@/provider"
|
||||||
import { ArgsProvider, useArgs, type Args } from "./context/args"
|
import { ArgsProvider, useArgs, type Args } from "./context/args"
|
||||||
import open from "open"
|
import open from "open"
|
||||||
import { PromptRefProvider, usePromptRef } from "./context/prompt"
|
import { PromptRefProvider, usePromptRef } from "./context/prompt"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { Global } from "@/global"
|
|||||||
import { iife } from "@/util/iife"
|
import { iife } from "@/util/iife"
|
||||||
import { createSimpleContext } from "./helper"
|
import { createSimpleContext } from "./helper"
|
||||||
import { useToast } from "../ui/toast"
|
import { useToast } from "../ui/toast"
|
||||||
import { Provider } from "@/provider/provider"
|
import { Provider } from "@/provider"
|
||||||
import { useArgs } from "./args"
|
import { useArgs } from "./args"
|
||||||
import { useSDK } from "./sdk"
|
import { useSDK } from "./sdk"
|
||||||
import { RGBA } from "@opentui/core"
|
import { RGBA } from "@opentui/core"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { ConfigMarkdown } from "@/config/markdown"
|
|||||||
import { errorFormat } from "@/util/error"
|
import { errorFormat } from "@/util/error"
|
||||||
import { Config } from "../config"
|
import { Config } from "../config"
|
||||||
import { MCP } from "../mcp"
|
import { MCP } from "../mcp"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider"
|
||||||
import { UI } from "./ui"
|
import { UI } from "./ui"
|
||||||
|
|
||||||
export function FormatError(input: unknown) {
|
export function FormatError(input: unknown) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { FileWatcher } from "@/file/watcher"
|
|||||||
import { Storage } from "@/storage/storage"
|
import { Storage } from "@/storage/storage"
|
||||||
import { Snapshot } from "@/snapshot"
|
import { Snapshot } from "@/snapshot"
|
||||||
import { Plugin } from "@/plugin"
|
import { Plugin } from "@/plugin"
|
||||||
import { Provider } from "@/provider/provider"
|
import { Provider } from "@/provider"
|
||||||
import { ProviderAuth } from "@/provider/auth"
|
import { ProviderAuth } from "@/provider/auth"
|
||||||
import { Agent } from "@/agent/agent"
|
import { Agent } from "@/agent/agent"
|
||||||
import { Skill } from "@/skill"
|
import { Skill } from "@/skill"
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export * as Provider from "./provider"
|
||||||
@@ -59,16 +59,15 @@ import { ProviderTransform } from "./transform"
|
|||||||
import { Installation } from "../installation"
|
import { Installation } from "../installation"
|
||||||
import { ModelID, ProviderID } from "./schema"
|
import { ModelID, ProviderID } from "./schema"
|
||||||
|
|
||||||
export namespace Provider {
|
const log = Log.create({ service: "provider" })
|
||||||
const log = Log.create({ service: "provider" })
|
|
||||||
|
|
||||||
function shouldUseCopilotResponsesApi(modelID: string): boolean {
|
function shouldUseCopilotResponsesApi(modelID: string): boolean {
|
||||||
const match = /^gpt-(\d+)/.exec(modelID)
|
const match = /^gpt-(\d+)/.exec(modelID)
|
||||||
if (!match) return false
|
if (!match) return false
|
||||||
return Number(match[1]) >= 5 && !modelID.startsWith("gpt-5-mini")
|
return Number(match[1]) >= 5 && !modelID.startsWith("gpt-5-mini")
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapSSE(res: Response, ms: number, ctl: AbortController) {
|
function wrapSSE(res: Response, ms: number, ctl: AbortController) {
|
||||||
if (typeof ms !== "number" || ms <= 0) return res
|
if (typeof ms !== "number" || ms <= 0) return res
|
||||||
if (!res.body) return res
|
if (!res.body) return res
|
||||||
if (!res.headers.get("content-type")?.includes("text/event-stream")) return res
|
if (!res.headers.get("content-type")?.includes("text/event-stream")) return res
|
||||||
@@ -114,13 +113,13 @@ export namespace Provider {
|
|||||||
status: res.status,
|
status: res.status,
|
||||||
statusText: res.statusText,
|
statusText: res.statusText,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type BundledSDK = {
|
type BundledSDK = {
|
||||||
languageModel(modelId: string): LanguageModelV3
|
languageModel(modelId: string): LanguageModelV3
|
||||||
}
|
}
|
||||||
|
|
||||||
const BUNDLED_PROVIDERS: Record<string, (options: any) => BundledSDK> = {
|
const BUNDLED_PROVIDERS: Record<string, (options: any) => BundledSDK> = {
|
||||||
"@ai-sdk/amazon-bedrock": createAmazonBedrock,
|
"@ai-sdk/amazon-bedrock": createAmazonBedrock,
|
||||||
"@ai-sdk/anthropic": createAnthropic,
|
"@ai-sdk/anthropic": createAnthropic,
|
||||||
"@ai-sdk/azure": createAzure,
|
"@ai-sdk/azure": createAzure,
|
||||||
@@ -144,31 +143,31 @@ export namespace Provider {
|
|||||||
"gitlab-ai-provider": createGitLab,
|
"gitlab-ai-provider": createGitLab,
|
||||||
"@ai-sdk/github-copilot": createGitHubCopilotOpenAICompatible,
|
"@ai-sdk/github-copilot": createGitHubCopilotOpenAICompatible,
|
||||||
"venice-ai-sdk-provider": createVenice,
|
"venice-ai-sdk-provider": createVenice,
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomModelLoader = (sdk: any, modelID: string, options?: Record<string, any>) => Promise<any>
|
type CustomModelLoader = (sdk: any, modelID: string, options?: Record<string, any>) => Promise<any>
|
||||||
type CustomVarsLoader = (options: Record<string, any>) => Record<string, string>
|
type CustomVarsLoader = (options: Record<string, any>) => Record<string, string>
|
||||||
type CustomDiscoverModels = () => Promise<Record<string, Model>>
|
type CustomDiscoverModels = () => Promise<Record<string, Model>>
|
||||||
type CustomLoader = (provider: Info) => Effect.Effect<{
|
type CustomLoader = (provider: Info) => Effect.Effect<{
|
||||||
autoload: boolean
|
autoload: boolean
|
||||||
getModel?: CustomModelLoader
|
getModel?: CustomModelLoader
|
||||||
vars?: CustomVarsLoader
|
vars?: CustomVarsLoader
|
||||||
options?: Record<string, any>
|
options?: Record<string, any>
|
||||||
discoverModels?: CustomDiscoverModels
|
discoverModels?: CustomDiscoverModels
|
||||||
}>
|
}>
|
||||||
|
|
||||||
type CustomDep = {
|
type CustomDep = {
|
||||||
auth: (id: string) => Effect.Effect<Auth.Info | undefined>
|
auth: (id: string) => Effect.Effect<Auth.Info | undefined>
|
||||||
config: () => Effect.Effect<Config.Info>
|
config: () => Effect.Effect<Config.Info>
|
||||||
env: () => Effect.Effect<Record<string, string | undefined>>
|
env: () => Effect.Effect<Record<string, string | undefined>>
|
||||||
get: (key: string) => Effect.Effect<string | undefined>
|
get: (key: string) => Effect.Effect<string | undefined>
|
||||||
}
|
}
|
||||||
|
|
||||||
function useLanguageModel(sdk: any) {
|
function useLanguageModel(sdk: any) {
|
||||||
return sdk.responses === undefined && sdk.chat === undefined
|
return sdk.responses === undefined && sdk.chat === undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function custom(dep: CustomDep): Record<string, CustomLoader> {
|
function custom(dep: CustomDep): Record<string, CustomLoader> {
|
||||||
return {
|
return {
|
||||||
anthropic: () =>
|
anthropic: () =>
|
||||||
Effect.succeed({
|
Effect.succeed({
|
||||||
@@ -815,9 +814,9 @@ export namespace Provider {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Model = z
|
export const Model = z
|
||||||
.object({
|
.object({
|
||||||
id: ModelID.zod,
|
id: ModelID.zod,
|
||||||
providerID: ProviderID.zod,
|
providerID: ProviderID.zod,
|
||||||
@@ -886,9 +885,9 @@ export namespace Provider {
|
|||||||
.meta({
|
.meta({
|
||||||
ref: "Model",
|
ref: "Model",
|
||||||
})
|
})
|
||||||
export type Model = z.infer<typeof Model>
|
export type Model = z.infer<typeof Model>
|
||||||
|
|
||||||
export const Info = z
|
export const Info = z
|
||||||
.object({
|
.object({
|
||||||
id: ProviderID.zod,
|
id: ProviderID.zod,
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
@@ -901,9 +900,9 @@ export namespace Provider {
|
|||||||
.meta({
|
.meta({
|
||||||
ref: "Provider",
|
ref: "Provider",
|
||||||
})
|
})
|
||||||
export type Info = z.infer<typeof Info>
|
export type Info = z.infer<typeof Info>
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly list: () => Effect.Effect<Record<ProviderID, Info>>
|
readonly list: () => Effect.Effect<Record<ProviderID, Info>>
|
||||||
readonly getProvider: (providerID: ProviderID) => Effect.Effect<Info>
|
readonly getProvider: (providerID: ProviderID) => Effect.Effect<Info>
|
||||||
readonly getModel: (providerID: ProviderID, modelID: ModelID) => Effect.Effect<Model>
|
readonly getModel: (providerID: ProviderID, modelID: ModelID) => Effect.Effect<Model>
|
||||||
@@ -914,19 +913,19 @@ export namespace Provider {
|
|||||||
) => Effect.Effect<{ providerID: ProviderID; modelID: string } | undefined>
|
) => Effect.Effect<{ providerID: ProviderID; modelID: string } | undefined>
|
||||||
readonly getSmallModel: (providerID: ProviderID) => Effect.Effect<Model | undefined>
|
readonly getSmallModel: (providerID: ProviderID) => Effect.Effect<Model | undefined>
|
||||||
readonly defaultModel: () => Effect.Effect<{ providerID: ProviderID; modelID: ModelID }>
|
readonly defaultModel: () => Effect.Effect<{ providerID: ProviderID; modelID: ModelID }>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
models: Map<string, LanguageModelV3>
|
models: Map<string, LanguageModelV3>
|
||||||
providers: Record<ProviderID, Info>
|
providers: Record<ProviderID, Info>
|
||||||
sdk: Map<string, BundledSDK>
|
sdk: Map<string, BundledSDK>
|
||||||
modelLoaders: Record<string, CustomModelLoader>
|
modelLoaders: Record<string, CustomModelLoader>
|
||||||
varsLoaders: Record<string, CustomVarsLoader>
|
varsLoaders: Record<string, CustomVarsLoader>
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Service extends Context.Service<Service, Interface>()("@opencode/Provider") {}
|
export class Service extends Context.Service<Service, Interface>()("@opencode/Provider") {}
|
||||||
|
|
||||||
function cost(c: ModelsDev.Model["cost"]): Model["cost"] {
|
function cost(c: ModelsDev.Model["cost"]): Model["cost"] {
|
||||||
const result: Model["cost"] = {
|
const result: Model["cost"] = {
|
||||||
input: c?.input ?? 0,
|
input: c?.input ?? 0,
|
||||||
output: c?.output ?? 0,
|
output: c?.output ?? 0,
|
||||||
@@ -946,9 +945,9 @@ export namespace Provider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
function fromModelsDevModel(provider: ModelsDev.Provider, model: ModelsDev.Model): Model {
|
function fromModelsDevModel(provider: ModelsDev.Provider, model: ModelsDev.Model): Model {
|
||||||
const m: Model = {
|
const m: Model = {
|
||||||
id: ModelID.make(model.id),
|
id: ModelID.make(model.id),
|
||||||
providerID: ProviderID.make(provider.id),
|
providerID: ProviderID.make(provider.id),
|
||||||
@@ -996,9 +995,9 @@ export namespace Provider {
|
|||||||
m.variants = mapValues(ProviderTransform.variants(m), (v) => v)
|
m.variants = mapValues(ProviderTransform.variants(m), (v) => v)
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fromModelsDevProvider(provider: ModelsDev.Provider): Info {
|
export function fromModelsDevProvider(provider: ModelsDev.Provider): Info {
|
||||||
const models: Record<string, Model> = {}
|
const models: Record<string, Model> = {}
|
||||||
for (const [key, model] of Object.entries(provider.models)) {
|
for (const [key, model] of Object.entries(provider.models)) {
|
||||||
models[key] = fromModelsDevModel(provider, model)
|
models[key] = fromModelsDevModel(provider, model)
|
||||||
@@ -1025,13 +1024,13 @@ export namespace Provider {
|
|||||||
options: {},
|
options: {},
|
||||||
models,
|
models,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const layer: Layer.Layer<
|
const layer: Layer.Layer<
|
||||||
Service,
|
Service,
|
||||||
never,
|
never,
|
||||||
Config.Service | Auth.Service | Plugin.Service | AppFileSystem.Service | Env.Service
|
Config.Service | Auth.Service | Plugin.Service | AppFileSystem.Service | Env.Service
|
||||||
> = Layer.effect(
|
> = Layer.effect(
|
||||||
Service,
|
Service,
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const fs = yield* AppFileSystem.Service
|
const fs = yield* AppFileSystem.Service
|
||||||
@@ -1661,9 +1660,9 @@ export namespace Provider {
|
|||||||
|
|
||||||
return Service.of({ list, getProvider, getModel, getLanguage, closest, getSmallModel, defaultModel })
|
return Service.of({ list, getProvider, getModel, getLanguage, closest, getSmallModel, defaultModel })
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
export const defaultLayer = Layer.suspend(() =>
|
export const defaultLayer = Layer.suspend(() =>
|
||||||
layer.pipe(
|
layer.pipe(
|
||||||
Layer.provide(AppFileSystem.defaultLayer),
|
Layer.provide(AppFileSystem.defaultLayer),
|
||||||
Layer.provide(Env.defaultLayer),
|
Layer.provide(Env.defaultLayer),
|
||||||
@@ -1671,39 +1670,38 @@ export namespace Provider {
|
|||||||
Layer.provide(Auth.defaultLayer),
|
Layer.provide(Auth.defaultLayer),
|
||||||
Layer.provide(Plugin.defaultLayer),
|
Layer.provide(Plugin.defaultLayer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
const priority = ["gpt-5", "claude-sonnet-4", "big-pickle", "gemini-3-pro"]
|
const priority = ["gpt-5", "claude-sonnet-4", "big-pickle", "gemini-3-pro"]
|
||||||
export function sort<T extends { id: string }>(models: T[]) {
|
export function sort<T extends { id: string }>(models: T[]) {
|
||||||
return sortBy(
|
return sortBy(
|
||||||
models,
|
models,
|
||||||
[(model) => priority.findIndex((filter) => model.id.includes(filter)), "desc"],
|
[(model) => priority.findIndex((filter) => model.id.includes(filter)), "desc"],
|
||||||
[(model) => (model.id.includes("latest") ? 0 : 1), "asc"],
|
[(model) => (model.id.includes("latest") ? 0 : 1), "asc"],
|
||||||
[(model) => model.id, "desc"],
|
[(model) => model.id, "desc"],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseModel(model: string) {
|
export function parseModel(model: string) {
|
||||||
const [providerID, ...rest] = model.split("/")
|
const [providerID, ...rest] = model.split("/")
|
||||||
return {
|
return {
|
||||||
providerID: ProviderID.make(providerID),
|
providerID: ProviderID.make(providerID),
|
||||||
modelID: ModelID.make(rest.join("/")),
|
modelID: ModelID.make(rest.join("/")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ModelNotFoundError = NamedError.create(
|
export const ModelNotFoundError = NamedError.create(
|
||||||
"ProviderModelNotFoundError",
|
"ProviderModelNotFoundError",
|
||||||
z.object({
|
z.object({
|
||||||
providerID: ProviderID.zod,
|
providerID: ProviderID.zod,
|
||||||
modelID: ModelID.zod,
|
modelID: ModelID.zod,
|
||||||
suggestions: z.array(z.string()).optional(),
|
suggestions: z.array(z.string()).optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
export const InitError = NamedError.create(
|
export const InitError = NamedError.create(
|
||||||
"ProviderInitError",
|
"ProviderInitError",
|
||||||
z.object({
|
z.object({
|
||||||
providerID: ProviderID.zod,
|
providerID: ProviderID.zod,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { ModelMessage } from "ai"
|
|||||||
import { mergeDeep, unique } from "remeda"
|
import { mergeDeep, unique } from "remeda"
|
||||||
import type { JSONSchema7 } from "@ai-sdk/provider"
|
import type { JSONSchema7 } from "@ai-sdk/provider"
|
||||||
import type { JSONSchema } from "zod/v4/core"
|
import type { JSONSchema } from "zod/v4/core"
|
||||||
import type { Provider } from "./provider"
|
import type { Provider } from "."
|
||||||
import type { ModelsDev } from "./models"
|
import type { ModelsDev } from "./models"
|
||||||
import { iife } from "@/util/iife"
|
import { iife } from "@/util/iife"
|
||||||
import { Flag } from "@/flag/flag"
|
import { Flag } from "@/flag/flag"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Hono } from "hono"
|
|||||||
import { describeRoute, validator, resolver } from "hono-openapi"
|
import { describeRoute, validator, resolver } from "hono-openapi"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { Config } from "../../config"
|
import { Config } from "../../config"
|
||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider"
|
||||||
import { mapValues } from "remeda"
|
import { mapValues } from "remeda"
|
||||||
import { errors } from "../error"
|
import { errors } from "../error"
|
||||||
import { lazy } from "../../util/lazy"
|
import { lazy } from "../../util/lazy"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Hono } from "hono"
|
|||||||
import { describeRoute, validator, resolver } from "hono-openapi"
|
import { describeRoute, validator, resolver } from "hono-openapi"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { Config } from "../../config"
|
import { Config } from "../../config"
|
||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider"
|
||||||
import { ModelsDev } from "../../provider/models"
|
import { ModelsDev } from "../../provider/models"
|
||||||
import { ProviderAuth } from "../../provider/auth"
|
import { ProviderAuth } from "../../provider/auth"
|
||||||
import { ProviderID } from "../../provider/schema"
|
import { ProviderID } from "../../provider/schema"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider"
|
||||||
import { NamedError } from "@opencode-ai/shared/util/error"
|
import { NamedError } from "@opencode-ai/shared/util/error"
|
||||||
import { NotFoundError } from "../storage/db"
|
import { NotFoundError } from "../storage/db"
|
||||||
import { Session } from "../session"
|
import { Session } from "../session"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { BusEvent } from "@/bus/bus-event"
|
|||||||
import { Bus } from "@/bus"
|
import { Bus } from "@/bus"
|
||||||
import { Session } from "."
|
import { Session } from "."
|
||||||
import { SessionID, MessageID, PartID } from "./schema"
|
import { SessionID, MessageID, PartID } from "./schema"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider"
|
||||||
import { MessageV2 } from "./message-v2"
|
import { MessageV2 } from "./message-v2"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { Token } from "../util/token"
|
import { Token } from "../util/token"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import { ProjectID } from "../project/schema"
|
|||||||
import { WorkspaceID } from "../control-plane/schema"
|
import { WorkspaceID } from "../control-plane/schema"
|
||||||
import { SessionID, MessageID, PartID } from "./schema"
|
import { SessionID, MessageID, PartID } from "./schema"
|
||||||
|
|
||||||
import type { Provider } from "@/provider/provider"
|
import type { Provider } from "@/provider"
|
||||||
import { Permission } from "@/permission"
|
import { Permission } from "@/permission"
|
||||||
import { Global } from "@/global"
|
import { Global } from "@/global"
|
||||||
import { Effect, Layer, Option, Context } from "effect"
|
import { Effect, Layer, Option, Context } from "effect"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Provider } from "@/provider/provider"
|
import { Provider } from "@/provider"
|
||||||
import { Log } from "@/util/log"
|
import { Log } from "@/util/log"
|
||||||
import { Context, Effect, Layer, Record } from "effect"
|
import { Context, Effect, Layer, Record } from "effect"
|
||||||
import * as Stream from "effect/Stream"
|
import * as Stream from "effect/Stream"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { ProviderError } from "@/provider/error"
|
|||||||
import { iife } from "@/util/iife"
|
import { iife } from "@/util/iife"
|
||||||
import { errorMessage } from "@/util/error"
|
import { errorMessage } from "@/util/error"
|
||||||
import type { SystemError } from "bun"
|
import type { SystemError } from "bun"
|
||||||
import type { Provider } from "@/provider/provider"
|
import type { Provider } from "@/provider"
|
||||||
import { ModelID, ProviderID } from "@/provider/schema"
|
import { ModelID, ProviderID } from "@/provider/schema"
|
||||||
import { Effect } from "effect"
|
import { Effect } from "effect"
|
||||||
import { EffectLogger } from "@/effect/logger"
|
import { EffectLogger } from "@/effect/logger"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { Config } from "@/config"
|
import type { Config } from "@/config"
|
||||||
import type { Provider } from "@/provider/provider"
|
import type { Provider } from "@/provider"
|
||||||
import { ProviderTransform } from "@/provider/transform"
|
import { ProviderTransform } from "@/provider/transform"
|
||||||
import type { MessageV2 } from "./message-v2"
|
import type { MessageV2 } from "./message-v2"
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import type { SessionID } from "./schema"
|
|||||||
import { SessionRetry } from "./retry"
|
import { SessionRetry } from "./retry"
|
||||||
import { SessionStatus } from "./status"
|
import { SessionStatus } from "./status"
|
||||||
import { SessionSummary } from "./summary"
|
import { SessionSummary } from "./summary"
|
||||||
import type { Provider } from "@/provider/provider"
|
import type { Provider } from "@/provider"
|
||||||
import { Question } from "@/question"
|
import { Question } from "@/question"
|
||||||
import { errorMessage } from "@/util/error"
|
import { errorMessage } from "@/util/error"
|
||||||
import { Log } from "@/util/log"
|
import { Log } from "@/util/log"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Log } from "../util/log"
|
|||||||
import { SessionRevert } from "./revert"
|
import { SessionRevert } from "./revert"
|
||||||
import { Session } from "."
|
import { Session } from "."
|
||||||
import { Agent } from "../agent/agent"
|
import { Agent } from "../agent/agent"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider"
|
||||||
import { ModelID, ProviderID } from "../provider/schema"
|
import { ModelID, ProviderID } from "../provider/schema"
|
||||||
import { type Tool as AITool, tool, jsonSchema, type ToolExecutionOptions, asSchema } from "ai"
|
import { type Tool as AITool, tool, jsonSchema, type ToolExecutionOptions, asSchema } from "ai"
|
||||||
import { SessionCompaction } from "./compaction"
|
import { SessionCompaction } from "./compaction"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import PROMPT_KIMI from "./prompt/kimi.txt"
|
|||||||
|
|
||||||
import PROMPT_CODEX from "./prompt/codex.txt"
|
import PROMPT_CODEX from "./prompt/codex.txt"
|
||||||
import PROMPT_TRINITY from "./prompt/trinity.txt"
|
import PROMPT_TRINITY from "./prompt/trinity.txt"
|
||||||
import type { Provider } from "@/provider/provider"
|
import type { Provider } from "@/provider"
|
||||||
import type { Agent } from "@/agent/agent"
|
import type { Agent } from "@/agent/agent"
|
||||||
import { Permission } from "@/permission"
|
import { Permission } from "@/permission"
|
||||||
import { Skill } from "@/skill"
|
import { Skill } from "@/skill"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } fr
|
|||||||
import { Account } from "@/account"
|
import { Account } from "@/account"
|
||||||
import { Bus } from "@/bus"
|
import { Bus } from "@/bus"
|
||||||
import { InstanceState } from "@/effect/instance-state"
|
import { InstanceState } from "@/effect/instance-state"
|
||||||
import { Provider } from "@/provider/provider"
|
import { Provider } from "@/provider"
|
||||||
import { ModelID, ProviderID } from "@/provider/schema"
|
import { ModelID, ProviderID } from "@/provider/schema"
|
||||||
import { Session } from "@/session"
|
import { Session } from "@/session"
|
||||||
import { MessageV2 } from "@/session/message-v2"
|
import { MessageV2 } from "@/session/message-v2"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Tool } from "./tool"
|
|||||||
import { Question } from "../question"
|
import { Question } from "../question"
|
||||||
import { Session } from "../session"
|
import { Session } from "../session"
|
||||||
import { MessageV2 } from "../session/message-v2"
|
import { MessageV2 } from "../session/message-v2"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider"
|
||||||
import { Instance } from "../project/instance"
|
import { Instance } from "../project/instance"
|
||||||
import { type SessionID, MessageID, PartID } from "../session/schema"
|
import { type SessionID, MessageID, PartID } from "../session/schema"
|
||||||
import EXIT_DESCRIPTION from "./plan-exit.txt"
|
import EXIT_DESCRIPTION from "./plan-exit.txt"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { Config } from "../config"
|
|||||||
import { type ToolContext as PluginToolContext, type ToolDefinition } from "@opencode-ai/plugin"
|
import { type ToolContext as PluginToolContext, type ToolDefinition } from "@opencode-ai/plugin"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { Plugin } from "../plugin"
|
import { Plugin } from "../plugin"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider"
|
||||||
import { ProviderID, type ModelID } from "../provider/schema"
|
import { ProviderID, type ModelID } from "../provider/schema"
|
||||||
import { WebSearchTool } from "./websearch"
|
import { WebSearchTool } from "./websearch"
|
||||||
import { CodeSearchTool } from "./codesearch"
|
import { CodeSearchTool } from "./codesearch"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Effect, Layer } from "effect"
|
import { Effect, Layer } from "effect"
|
||||||
import { Provider } from "../../src/provider/provider"
|
import { Provider } from "../../src/provider"
|
||||||
import { ModelID, ProviderID } from "../../src/provider/schema"
|
import { ModelID, ProviderID } from "../../src/provider/schema"
|
||||||
|
|
||||||
export namespace ProviderTest {
|
export namespace ProviderTest {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { unlink } from "fs/promises"
|
|||||||
import { ProviderID } from "../../src/provider/schema"
|
import { ProviderID } from "../../src/provider/schema"
|
||||||
import { tmpdir } from "../fixture/fixture"
|
import { tmpdir } from "../fixture/fixture"
|
||||||
import { Instance } from "../../src/project/instance"
|
import { Instance } from "../../src/project/instance"
|
||||||
import { Provider } from "../../src/provider/provider"
|
import { Provider } from "../../src/provider"
|
||||||
import { Env } from "../../src/env"
|
import { Env } from "../../src/env"
|
||||||
import { Global } from "../../src/global"
|
import { Global } from "../../src/global"
|
||||||
import { Filesystem } from "../../src/util/filesystem"
|
import { Filesystem } from "../../src/util/filesystem"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export {}
|
|||||||
// import { ProviderID, ModelID } from "../../src/provider/schema"
|
// import { ProviderID, ModelID } from "../../src/provider/schema"
|
||||||
// import { tmpdir } from "../fixture/fixture"
|
// import { tmpdir } from "../fixture/fixture"
|
||||||
// import { Instance } from "../../src/project/instance"
|
// import { Instance } from "../../src/project/instance"
|
||||||
// import { Provider } from "../../src/provider/provider"
|
// import { Provider } from "../../src/provider"
|
||||||
// import { Env } from "../../src/env"
|
// import { Env } from "../../src/env"
|
||||||
// import { Global } from "../../src/global"
|
// import { Global } from "../../src/global"
|
||||||
// import { GitLabWorkflowLanguageModel } from "gitlab-ai-provider"
|
// import { GitLabWorkflowLanguageModel } from "gitlab-ai-provider"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Global } from "../../src/global"
|
|||||||
import { Instance } from "../../src/project/instance"
|
import { Instance } from "../../src/project/instance"
|
||||||
import { Plugin } from "../../src/plugin/index"
|
import { Plugin } from "../../src/plugin/index"
|
||||||
import { ModelsDev } from "../../src/provider/models"
|
import { ModelsDev } from "../../src/provider/models"
|
||||||
import { Provider } from "../../src/provider/provider"
|
import { Provider } from "../../src/provider"
|
||||||
import { ProviderID, ModelID } from "../../src/provider/schema"
|
import { ProviderID, ModelID } from "../../src/provider/schema"
|
||||||
import { Filesystem } from "../../src/util/filesystem"
|
import { Filesystem } from "../../src/util/filesystem"
|
||||||
import { Env } from "../../src/env"
|
import { Env } from "../../src/env"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { MessageID, PartID, SessionID } from "../../src/session/schema"
|
|||||||
import { SessionStatus } from "../../src/session/status"
|
import { SessionStatus } from "../../src/session/status"
|
||||||
import { SessionSummary } from "../../src/session/summary"
|
import { SessionSummary } from "../../src/session/summary"
|
||||||
import { ModelID, ProviderID } from "../../src/provider/schema"
|
import { ModelID, ProviderID } from "../../src/provider/schema"
|
||||||
import type { Provider } from "../../src/provider/provider"
|
import type { Provider } from "../../src/provider"
|
||||||
import * as SessionProcessorModule from "../../src/session/processor"
|
import * as SessionProcessorModule from "../../src/session/processor"
|
||||||
import { Snapshot } from "../../src/snapshot"
|
import { Snapshot } from "../../src/snapshot"
|
||||||
import { ProviderTest } from "../fake/provider"
|
import { ProviderTest } from "../fake/provider"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import z from "zod"
|
|||||||
import { makeRuntime } from "../../src/effect/run-service"
|
import { makeRuntime } from "../../src/effect/run-service"
|
||||||
import { LLM } from "../../src/session/llm"
|
import { LLM } from "../../src/session/llm"
|
||||||
import { Instance } from "../../src/project/instance"
|
import { Instance } from "../../src/project/instance"
|
||||||
import { Provider } from "../../src/provider/provider"
|
import { Provider } from "../../src/provider"
|
||||||
import { ProviderTransform } from "../../src/provider/transform"
|
import { ProviderTransform } from "../../src/provider/transform"
|
||||||
import { ModelsDev } from "../../src/provider/models"
|
import { ModelsDev } from "../../src/provider/models"
|
||||||
import { ProviderID, ModelID } from "../../src/provider/schema"
|
import { ProviderID, ModelID } from "../../src/provider/schema"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, test } from "bun:test"
|
import { describe, expect, test } from "bun:test"
|
||||||
import { APICallError } from "ai"
|
import { APICallError } from "ai"
|
||||||
import { MessageV2 } from "../../src/session/message-v2"
|
import { MessageV2 } from "../../src/session/message-v2"
|
||||||
import type { Provider } from "../../src/provider/provider"
|
import type { Provider } from "../../src/provider"
|
||||||
import { ModelID, ProviderID } from "../../src/provider/schema"
|
import { ModelID, ProviderID } from "../../src/provider/schema"
|
||||||
import { SessionID, MessageID, PartID } from "../../src/session/schema"
|
import { SessionID, MessageID, PartID } from "../../src/session/schema"
|
||||||
import { Question } from "../../src/question"
|
import { Question } from "../../src/question"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { Bus } from "../../src/bus"
|
|||||||
import { Config } from "../../src/config"
|
import { Config } from "../../src/config"
|
||||||
import { Permission } from "../../src/permission"
|
import { Permission } from "../../src/permission"
|
||||||
import { Plugin } from "../../src/plugin"
|
import { Plugin } from "../../src/plugin"
|
||||||
import { Provider } from "../../src/provider/provider"
|
import { Provider } from "../../src/provider"
|
||||||
import { ModelID, ProviderID } from "../../src/provider/schema"
|
import { ModelID, ProviderID } from "../../src/provider/schema"
|
||||||
import { Session } from "../../src/session"
|
import { Session } from "../../src/session"
|
||||||
import { LLM } from "../../src/session/llm"
|
import { LLM } from "../../src/session/llm"
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import { LSP } from "../../src/lsp"
|
|||||||
import { MCP } from "../../src/mcp"
|
import { MCP } from "../../src/mcp"
|
||||||
import { Permission } from "../../src/permission"
|
import { Permission } from "../../src/permission"
|
||||||
import { Plugin } from "../../src/plugin"
|
import { Plugin } from "../../src/plugin"
|
||||||
import { Provider as ProviderSvc } from "../../src/provider/provider"
|
import { Provider as ProviderSvc } from "../../src/provider"
|
||||||
import { Env } from "../../src/env"
|
import { Env } from "../../src/env"
|
||||||
import type { Provider } from "../../src/provider/provider"
|
import type { Provider } from "../../src/provider"
|
||||||
import { ModelID, ProviderID } from "../../src/provider/schema"
|
import { ModelID, ProviderID } from "../../src/provider/schema"
|
||||||
import { Question } from "../../src/question"
|
import { Question } from "../../src/question"
|
||||||
import { Todo } from "../../src/session/todo"
|
import { Todo } from "../../src/session/todo"
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import { LSP } from "../../src/lsp"
|
|||||||
import { MCP } from "../../src/mcp"
|
import { MCP } from "../../src/mcp"
|
||||||
import { Permission } from "../../src/permission"
|
import { Permission } from "../../src/permission"
|
||||||
import { Plugin } from "../../src/plugin"
|
import { Plugin } from "../../src/plugin"
|
||||||
import { Provider as ProviderSvc } from "../../src/provider/provider"
|
import { Provider as ProviderSvc } from "../../src/provider"
|
||||||
import { Env } from "../../src/env"
|
import { Env } from "../../src/env"
|
||||||
import { Question } from "../../src/question"
|
import { Question } from "../../src/question"
|
||||||
import { Skill } from "../../src/skill"
|
import { Skill } from "../../src/skill"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { AccountRepo } from "../../src/account/repo"
|
|||||||
import * as CrossSpawnSpawner from "../../src/effect/cross-spawn-spawner"
|
import * as CrossSpawnSpawner from "../../src/effect/cross-spawn-spawner"
|
||||||
import { Bus } from "../../src/bus"
|
import { Bus } from "../../src/bus"
|
||||||
import { Config } from "../../src/config"
|
import { Config } from "../../src/config"
|
||||||
import { Provider } from "../../src/provider/provider"
|
import { Provider } from "../../src/provider"
|
||||||
import { Session } from "../../src/session"
|
import { Session } from "../../src/session"
|
||||||
import type { SessionID } from "../../src/session/schema"
|
import type { SessionID } from "../../src/session/schema"
|
||||||
import { ShareNext } from "../../src/share/share-next"
|
import { ShareNext } from "../../src/share/share-next"
|
||||||
|
|||||||
Reference in New Issue
Block a user