mirror of
https://github.com/sst/opencode.git
synced 2025-08-22 22:14:14 +00:00
sync
This commit is contained in:
parent
f22e97dd05
commit
42931d4d2a
1 changed files with 39 additions and 38 deletions
|
@ -248,6 +248,7 @@ async function assertOpencodeConnected() {
|
||||||
let retry = 0
|
let retry = 0
|
||||||
let connected = false
|
let connected = false
|
||||||
do {
|
do {
|
||||||
|
// TODO
|
||||||
console.log("!@#!@#!@# TRYING")
|
console.log("!@#!@#!@# TRYING")
|
||||||
try {
|
try {
|
||||||
await client.app.get<true>()
|
await client.app.get<true>()
|
||||||
|
@ -520,8 +521,7 @@ async function chat(text: string, files: PromptFiles = []) {
|
||||||
console.log("Sending message to opencode...")
|
console.log("Sending message to opencode...")
|
||||||
const { providerID, modelID } = useModel()
|
const { providerID, modelID } = useModel()
|
||||||
|
|
||||||
const result = await client.session
|
const chat = await client.session.chat<true>({
|
||||||
.chat<true>({
|
|
||||||
path: session,
|
path: session,
|
||||||
body: {
|
body: {
|
||||||
providerID,
|
providerID,
|
||||||
|
@ -552,18 +552,19 @@ async function chat(text: string, files: PromptFiles = []) {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((r) => r.data)
|
|
||||||
|
|
||||||
const message = await client.session
|
// TODO
|
||||||
.message<true>({
|
console.log("!@#!@#!@# CHAT", chat.data)
|
||||||
|
|
||||||
|
const message = await client.session.message<true>({
|
||||||
path: {
|
path: {
|
||||||
id: result.sessionID,
|
id: chat.data.sessionID,
|
||||||
messageID: result.id,
|
messageID: chat.data.id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((r) => r.data)
|
console.log("!@#!@#!@# MESSAGE", message.data)
|
||||||
|
|
||||||
const match = message.parts.findLast((p) => p.type === "text")
|
const match = message.data.parts.findLast((p) => p.type === "text")
|
||||||
if (!match) throw new Error("Failed to parse the text response")
|
if (!match) throw new Error("Failed to parse the text response")
|
||||||
|
|
||||||
return match.text
|
return match.text
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue