mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
chore(sdk): update consumers to use renamed Kilo SDK exports
This commit is contained in:
@@ -41,7 +41,7 @@ import { Config } from "@/config/config"
|
||||
import { Todo } from "@/session/todo"
|
||||
import { z } from "zod"
|
||||
import { LoadAPIKeyError } from "ai"
|
||||
import type { AssistantMessage, Event, OpencodeClient, SessionMessageResponse, ToolPart } from "@kilocode/sdk/v2"
|
||||
import type { AssistantMessage, Event, KiloClient, SessionMessageResponse, ToolPart } from "@kilocode/sdk/v2"
|
||||
import { applyPatch } from "diff"
|
||||
|
||||
import { fetchDefaultModel } from "@kilocode/kilo-gateway" // kilocode_change
|
||||
@@ -55,7 +55,7 @@ export namespace ACP {
|
||||
const log = Log.create({ service: "acp-agent" })
|
||||
|
||||
async function getContextLimit(
|
||||
sdk: OpencodeClient,
|
||||
sdk: KiloClient,
|
||||
providerID: string,
|
||||
modelID: string,
|
||||
directory: string,
|
||||
@@ -75,7 +75,7 @@ export namespace ACP {
|
||||
|
||||
async function sendUsageUpdate(
|
||||
connection: AgentSideConnection,
|
||||
sdk: OpencodeClient,
|
||||
sdk: KiloClient,
|
||||
sessionID: string,
|
||||
directory: string,
|
||||
): Promise<void> {
|
||||
@@ -122,7 +122,7 @@ export namespace ACP {
|
||||
})
|
||||
}
|
||||
|
||||
export async function init({ sdk: _sdk }: { sdk: OpencodeClient }) {
|
||||
export async function init({ sdk: _sdk }: { sdk: KiloClient }) {
|
||||
return {
|
||||
create: (connection: AgentSideConnection, fullConfig: ACPConfig) => {
|
||||
return new Agent(connection, fullConfig)
|
||||
@@ -133,7 +133,7 @@ export namespace ACP {
|
||||
export class Agent implements ACPAgent {
|
||||
private connection: AgentSideConnection
|
||||
private config: ACPConfig
|
||||
private sdk: OpencodeClient
|
||||
private sdk: KiloClient
|
||||
private sessionManager: ACPSessionManager
|
||||
private eventAbort = new AbortController()
|
||||
private eventStarted = false
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { RequestError, type McpServer } from "@agentclientprotocol/sdk"
|
||||
import type { ACPSessionState } from "./types"
|
||||
import { Log } from "@/util/log"
|
||||
import type { OpencodeClient } from "@kilocode/sdk/v2"
|
||||
import type { KiloClient } from "@kilocode/sdk/v2"
|
||||
|
||||
const log = Log.create({ service: "acp-session-manager" })
|
||||
|
||||
export class ACPSessionManager {
|
||||
private sessions = new Map<string, ACPSessionState>()
|
||||
private sdk: OpencodeClient
|
||||
private sdk: KiloClient
|
||||
|
||||
constructor(sdk: OpencodeClient) {
|
||||
constructor(sdk: KiloClient) {
|
||||
this.sdk = sdk
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { McpServer } from "@agentclientprotocol/sdk"
|
||||
import type { OpencodeClient } from "@kilocode/sdk/v2"
|
||||
import type { KiloClient } from "@kilocode/sdk/v2"
|
||||
|
||||
export interface ACPSessionState {
|
||||
id: string
|
||||
@@ -15,7 +15,7 @@ export interface ACPSessionState {
|
||||
}
|
||||
|
||||
export interface ACPConfig {
|
||||
sdk: OpencodeClient
|
||||
sdk: KiloClient
|
||||
defaultModel?: {
|
||||
providerID: string
|
||||
modelID: string
|
||||
|
||||
@@ -4,7 +4,7 @@ import { cmd } from "./cmd"
|
||||
import { AgentSideConnection, ndJsonStream } from "@agentclientprotocol/sdk"
|
||||
import { ACP } from "@/acp/agent"
|
||||
import { Server } from "@/server/server"
|
||||
import { createOpencodeClient } from "@kilocode/sdk/v2"
|
||||
import { createKiloClient } from "@kilocode/sdk/v2"
|
||||
import { withNetworkOptions, resolveNetworkOptions } from "../network"
|
||||
|
||||
const log = Log.create({ service: "acp-command" })
|
||||
@@ -25,7 +25,7 @@ export const AcpCommand = cmd({
|
||||
const opts = await resolveNetworkOptions(args)
|
||||
const server = Server.listen(opts)
|
||||
|
||||
const sdk = createOpencodeClient({
|
||||
const sdk = createKiloClient({
|
||||
baseUrl: `http://${server.hostname}:${server.port}`,
|
||||
})
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ export const GenerateCommand = {
|
||||
{
|
||||
lang: "js",
|
||||
source: [
|
||||
`import { createOpencodeClient } from "@kilocode/sdk`,
|
||||
`import { createKiloClient } from "@kilocode/sdk`,
|
||||
``,
|
||||
`const client = createOpencodeClient()`,
|
||||
`const client = createKiloClient()`,
|
||||
`await client.${operation.operationId}({`,
|
||||
` ...`,
|
||||
`})`,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Flag } from "../../flag/flag"
|
||||
import { bootstrap } from "../bootstrap"
|
||||
import { EOL } from "os"
|
||||
import { Filesystem } from "../../util/filesystem"
|
||||
import { createOpencodeClient, type Message, type OpencodeClient, type ToolPart } from "@kilocode/sdk/v2"
|
||||
import { createKiloClient, type Message, type KiloClient, type ToolPart } from "@kilocode/sdk/v2"
|
||||
import { Server } from "../../server/server"
|
||||
import { Provider } from "../../provider/provider"
|
||||
import { Agent } from "../../agent/agent"
|
||||
@@ -382,7 +382,7 @@ export const RunCommand = cmd({
|
||||
return message.slice(0, 50) + (message.length > 50 ? "..." : "")
|
||||
}
|
||||
|
||||
async function session(sdk: OpencodeClient) {
|
||||
async function session(sdk: KiloClient) {
|
||||
const baseID = args.continue ? (await sdk.session.list()).data?.find((s) => !s.parentID)?.id : args.session
|
||||
|
||||
if (baseID && args.fork) {
|
||||
@@ -397,7 +397,7 @@ export const RunCommand = cmd({
|
||||
return result.data?.id
|
||||
}
|
||||
|
||||
async function share(sdk: OpencodeClient, sessionID: string) {
|
||||
async function share(sdk: KiloClient, sessionID: string) {
|
||||
const cfg = await sdk.config.get()
|
||||
if (!cfg.data) return
|
||||
if (cfg.data.share !== "auto" && !Flag.KILO_AUTO_SHARE && !args.share) return
|
||||
@@ -412,7 +412,7 @@ export const RunCommand = cmd({
|
||||
}
|
||||
}
|
||||
|
||||
async function execute(sdk: OpencodeClient) {
|
||||
async function execute(sdk: KiloClient) {
|
||||
function tool(part: ToolPart) {
|
||||
try {
|
||||
if (part.tool === "bash") return bash(props<typeof BashTool>(part))
|
||||
@@ -630,7 +630,7 @@ export const RunCommand = cmd({
|
||||
}
|
||||
|
||||
if (args.attach) {
|
||||
const sdk = createOpencodeClient({ baseUrl: args.attach, directory })
|
||||
const sdk = createKiloClient({ baseUrl: args.attach, directory })
|
||||
return await execute(sdk)
|
||||
}
|
||||
|
||||
@@ -639,7 +639,7 @@ export const RunCommand = cmd({
|
||||
const request = new Request(input, init)
|
||||
return Server.App().fetch(request)
|
||||
}) as typeof globalThis.fetch
|
||||
const sdk = createOpencodeClient({ baseUrl: "http://opencode.internal", fetch: fetchFn })
|
||||
const sdk = createKiloClient({ baseUrl: "http://opencode.internal", fetch: fetchFn })
|
||||
await execute(sdk)
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createOpencodeClient, type Event } from "@kilocode/sdk/v2"
|
||||
import { createKiloClient, type Event } from "@kilocode/sdk/v2"
|
||||
import { createSimpleContext } from "./helper"
|
||||
import { createGlobalEmitter } from "@solid-primitives/event-bus"
|
||||
import { batch, onCleanup, onMount } from "solid-js"
|
||||
@@ -17,7 +17,7 @@ export const { use: useSDK, provider: SDKProvider } = createSimpleContext({
|
||||
events?: EventSource
|
||||
}) => {
|
||||
const abort = new AbortController()
|
||||
const sdk = createOpencodeClient({
|
||||
const sdk = createKiloClient({
|
||||
baseUrl: props.url,
|
||||
signal: abort.signal,
|
||||
directory: props.directory,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Rpc } from "@/util/rpc"
|
||||
import { upgrade } from "@/cli/upgrade"
|
||||
import { Config } from "@/config/config"
|
||||
import { GlobalBus } from "@/bus/global"
|
||||
import { createOpencodeClient, type Event } from "@kilocode/sdk/v2"
|
||||
import { createKiloClient, type Event } from "@kilocode/sdk/v2"
|
||||
import type { BunWebSocketData } from "hono/bun"
|
||||
import { Flag } from "@/flag/flag"
|
||||
|
||||
@@ -56,7 +56,7 @@ const startEventStream = (directory: string) => {
|
||||
return Server.App().fetch(request)
|
||||
}) as typeof globalThis.fetch
|
||||
|
||||
const sdk = createOpencodeClient({
|
||||
const sdk = createKiloClient({
|
||||
baseUrl: "http://opencode.internal",
|
||||
directory,
|
||||
fetch: fetchFn,
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Hooks, PluginInput, Plugin as PluginInstance } from "@kilocode/plu
|
||||
import { Config } from "../config/config"
|
||||
import { Bus } from "../bus"
|
||||
import { Log } from "../util/log"
|
||||
import { createOpencodeClient } from "@kilocode/sdk"
|
||||
import { createKiloClient } from "@kilocode/sdk"
|
||||
import { Server } from "../server/server"
|
||||
import { BunProc } from "../bun"
|
||||
import { Instance } from "../project/instance"
|
||||
@@ -30,7 +30,7 @@ export namespace Plugin {
|
||||
] // kilocode_change end
|
||||
|
||||
const state = Instance.state(async () => {
|
||||
const client = createOpencodeClient({
|
||||
const client = createKiloClient({
|
||||
baseUrl: "http://localhost:4096",
|
||||
directory: Instance.directory,
|
||||
// @ts-ignore - fetch type incompatibility
|
||||
|
||||
Reference in New Issue
Block a user