|
|
@@ -325,42 +325,60 @@ export namespace SessionPrompt {
|
|
|
prompt: task.prompt,
|
|
|
description: task.description,
|
|
|
subagent_type: task.agent,
|
|
|
+ command: task.command,
|
|
|
},
|
|
|
time: {
|
|
|
start: Date.now(),
|
|
|
},
|
|
|
},
|
|
|
})) as MessageV2.ToolPart
|
|
|
+ const taskArgs = {
|
|
|
+ prompt: task.prompt,
|
|
|
+ description: task.description,
|
|
|
+ subagent_type: task.agent,
|
|
|
+ command: task.command,
|
|
|
+ }
|
|
|
+ await Plugin.trigger(
|
|
|
+ "tool.execute.before",
|
|
|
+ {
|
|
|
+ tool: "task",
|
|
|
+ sessionID,
|
|
|
+ callID: part.id,
|
|
|
+ },
|
|
|
+ { args: taskArgs },
|
|
|
+ )
|
|
|
let executionError: Error | undefined
|
|
|
const result = await taskTool
|
|
|
- .execute(
|
|
|
- {
|
|
|
- prompt: task.prompt,
|
|
|
- description: task.description,
|
|
|
- subagent_type: task.agent,
|
|
|
- },
|
|
|
- {
|
|
|
- agent: task.agent,
|
|
|
- messageID: assistantMessage.id,
|
|
|
- sessionID: sessionID,
|
|
|
- abort,
|
|
|
- async metadata(input) {
|
|
|
- await Session.updatePart({
|
|
|
- ...part,
|
|
|
- type: "tool",
|
|
|
- state: {
|
|
|
- ...part.state,
|
|
|
- ...input,
|
|
|
- },
|
|
|
- } satisfies MessageV2.ToolPart)
|
|
|
- },
|
|
|
+ .execute(taskArgs, {
|
|
|
+ agent: task.agent,
|
|
|
+ messageID: assistantMessage.id,
|
|
|
+ sessionID: sessionID,
|
|
|
+ abort,
|
|
|
+ async metadata(input) {
|
|
|
+ await Session.updatePart({
|
|
|
+ ...part,
|
|
|
+ type: "tool",
|
|
|
+ state: {
|
|
|
+ ...part.state,
|
|
|
+ ...input,
|
|
|
+ },
|
|
|
+ } satisfies MessageV2.ToolPart)
|
|
|
},
|
|
|
- )
|
|
|
+ })
|
|
|
.catch((error) => {
|
|
|
executionError = error
|
|
|
log.error("subtask execution failed", { error, agent: task.agent, description: task.description })
|
|
|
return undefined
|
|
|
})
|
|
|
+ await Plugin.trigger(
|
|
|
+ "tool.execute.after",
|
|
|
+ {
|
|
|
+ tool: "task",
|
|
|
+ sessionID,
|
|
|
+ callID: part.id,
|
|
|
+ },
|
|
|
+ result,
|
|
|
+ )
|
|
|
assistantMessage.finish = "tool-calls"
|
|
|
assistantMessage.time.completed = Date.now()
|
|
|
await Session.updateMessage(assistantMessage)
|
|
|
@@ -1323,6 +1341,7 @@ export namespace SessionPrompt {
|
|
|
type: "subtask" as const,
|
|
|
agent: agent.name,
|
|
|
description: command.description ?? "",
|
|
|
+ command: input.command,
|
|
|
// TODO: how can we make task tool accept a more complex input?
|
|
|
prompt: await resolvePromptParts(template).then((x) => x.find((y) => y.type === "text")?.text ?? ""),
|
|
|
},
|