fix(run): inherit main-session tool permissions for continuation prompts
This commit is contained in:
@@ -3,13 +3,14 @@ import { log } from "../../shared/logger"
|
||||
import { findNearestMessageWithFields } from "../../features/hook-message-injector"
|
||||
import { getMessageDir } from "./message-storage-directory"
|
||||
import { withTimeout } from "./with-timeout"
|
||||
import { normalizeSDKResponse } from "../../shared"
|
||||
import { normalizeSDKResponse, resolveInheritedPromptTools } from "../../shared"
|
||||
|
||||
type MessageInfo = {
|
||||
agent?: string
|
||||
model?: { providerID: string; modelID: string }
|
||||
modelID?: string
|
||||
providerID?: string
|
||||
tools?: Record<string, boolean | "allow" | "deny" | "ask">
|
||||
}
|
||||
|
||||
export async function injectContinuationPrompt(
|
||||
@@ -18,6 +19,7 @@ export async function injectContinuationPrompt(
|
||||
): Promise<void> {
|
||||
let agent: string | undefined
|
||||
let model: { providerID: string; modelID: string } | undefined
|
||||
let tools: Record<string, boolean | "allow" | "deny" | "ask"> | undefined
|
||||
|
||||
try {
|
||||
const messagesResp = await withTimeout(
|
||||
@@ -36,6 +38,7 @@ export async function injectContinuationPrompt(
|
||||
(info.providerID && info.modelID
|
||||
? { providerID: info.providerID, modelID: info.modelID }
|
||||
: undefined)
|
||||
tools = info.tools
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -50,13 +53,17 @@ export async function injectContinuationPrompt(
|
||||
modelID: currentMessage.model.modelID,
|
||||
}
|
||||
: undefined
|
||||
tools = currentMessage?.tools
|
||||
}
|
||||
|
||||
const inheritedTools = resolveInheritedPromptTools(options.sessionID, tools)
|
||||
|
||||
await ctx.client.session.promptAsync({
|
||||
path: { id: options.sessionID },
|
||||
body: {
|
||||
...(agent !== undefined ? { agent } : {}),
|
||||
...(model !== undefined ? { model } : {}),
|
||||
...(inheritedTools ? { tools: inheritedTools } : {}),
|
||||
parts: [{ type: "text", text: options.prompt }],
|
||||
},
|
||||
query: { directory: options.directory },
|
||||
|
||||
Reference in New Issue
Block a user