mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-07 18:04:54 +01:00
add synthetic user message before bash execution (when using !) (#2283)
This commit is contained in:
@@ -1035,6 +1035,25 @@ export namespace Session {
|
|||||||
export type ShellInput = z.infer<typeof ShellInput>
|
export type ShellInput = z.infer<typeof ShellInput>
|
||||||
export async function shell(input: ShellInput) {
|
export async function shell(input: ShellInput) {
|
||||||
using abort = lock(input.sessionID)
|
using abort = lock(input.sessionID)
|
||||||
|
const userMsg: MessageV2.User = {
|
||||||
|
id: Identifier.ascending("message"),
|
||||||
|
sessionID: input.sessionID,
|
||||||
|
time: {
|
||||||
|
created: Date.now(),
|
||||||
|
},
|
||||||
|
role: "user",
|
||||||
|
}
|
||||||
|
await updateMessage(userMsg)
|
||||||
|
const userPart: MessageV2.Part = {
|
||||||
|
type: "text",
|
||||||
|
id: Identifier.ascending("part"),
|
||||||
|
messageID: userMsg.id,
|
||||||
|
sessionID: input.sessionID,
|
||||||
|
text: "The following tool was executed by the user",
|
||||||
|
synthetic: true,
|
||||||
|
}
|
||||||
|
await updatePart(userPart)
|
||||||
|
|
||||||
const msg: MessageV2.Assistant = {
|
const msg: MessageV2.Assistant = {
|
||||||
id: Identifier.ascending("message"),
|
id: Identifier.ascending("message"),
|
||||||
sessionID: input.sessionID,
|
sessionID: input.sessionID,
|
||||||
|
|||||||
Reference in New Issue
Block a user