feat: Support ACP audience by mapping to ignore and synthetic (#9593)
Co-authored-by: noam-v <noam@bespo.ai>
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
type PermissionOption,
|
type PermissionOption,
|
||||||
type PlanEntry,
|
type PlanEntry,
|
||||||
type PromptRequest,
|
type PromptRequest,
|
||||||
|
type Role,
|
||||||
type SetSessionModelRequest,
|
type SetSessionModelRequest,
|
||||||
type SetSessionModeRequest,
|
type SetSessionModeRequest,
|
||||||
type SetSessionModeResponse,
|
type SetSessionModeResponse,
|
||||||
@@ -687,7 +688,12 @@ export namespace ACP {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if (part.type === "text") {
|
} else if (part.type === "text") {
|
||||||
if (part.text && !part.ignored) {
|
if (part.text) {
|
||||||
|
const audience: Role[] | undefined = part.synthetic
|
||||||
|
? ["assistant"]
|
||||||
|
: part.ignored
|
||||||
|
? ["user"]
|
||||||
|
: undefined
|
||||||
await this.connection
|
await this.connection
|
||||||
.sessionUpdate({
|
.sessionUpdate({
|
||||||
sessionId,
|
sessionId,
|
||||||
@@ -696,6 +702,7 @@ export namespace ACP {
|
|||||||
content: {
|
content: {
|
||||||
type: "text",
|
type: "text",
|
||||||
text: part.text,
|
text: part.text,
|
||||||
|
...(audience && { annotations: { audience } }),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -968,14 +975,19 @@ export namespace ACP {
|
|||||||
const agent = session.modeId ?? (await AgentModule.defaultAgent())
|
const agent = session.modeId ?? (await AgentModule.defaultAgent())
|
||||||
|
|
||||||
const parts: Array<
|
const parts: Array<
|
||||||
{ type: "text"; text: string } | { type: "file"; url: string; filename: string; mime: string }
|
{ type: "text"; text: string; synthetic?: boolean; ignored?: boolean } | { type: "file"; url: string; filename: string; mime: string }
|
||||||
> = []
|
> = []
|
||||||
for (const part of params.prompt) {
|
for (const part of params.prompt) {
|
||||||
switch (part.type) {
|
switch (part.type) {
|
||||||
case "text":
|
case "text":
|
||||||
|
const audience = part.annotations?.audience
|
||||||
|
const forAssistant = audience?.length === 1 && audience[0] === "assistant"
|
||||||
|
const forUser = audience?.length === 1 && audience[0] === "user"
|
||||||
parts.push({
|
parts.push({
|
||||||
type: "text" as const,
|
type: "text" as const,
|
||||||
text: part.text,
|
text: part.text,
|
||||||
|
...(forAssistant && { synthetic: true }),
|
||||||
|
...(forUser && { ignored: true }),
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case "image": {
|
case "image": {
|
||||||
|
|||||||
Reference in New Issue
Block a user