mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-17 21:21:18 -04:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fdd4fddb6 |
@@ -534,11 +534,14 @@ describe("prompt submit worktree selection", () => {
|
|||||||
id: expect.stringMatching(/^msg_/),
|
id: expect.stringMatching(/^msg_/),
|
||||||
command: "review",
|
command: "review",
|
||||||
arguments: "staged changes",
|
arguments: "staged changes",
|
||||||
agent: "agent",
|
|
||||||
model: { id: "model", providerID: "provider", variant: "high" },
|
|
||||||
files: [],
|
files: [],
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
expect(switchedAgents).toEqual([{ sessionID: "session-1", agent: "agent" }])
|
||||||
|
expect(switchedModels).toEqual([
|
||||||
|
{ sessionID: "session-1", model: { id: "model", providerID: "provider", variant: "high" } },
|
||||||
|
])
|
||||||
|
expect(sessionRequestOrder).toEqual(["agent", "model"])
|
||||||
expect(serverSessionSyncs).toBe(0)
|
expect(serverSessionSyncs).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -61,23 +61,39 @@ export async function sendFollowupDraft(input: FollowupSendInput) {
|
|||||||
input.serverSync.session.set("session_status", input.draft.sessionID, { type: "idle" })
|
input.serverSync.session.set("session_status", input.draft.sessionID, { type: "idle" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const select = async () => {
|
||||||
|
const session = input.session()
|
||||||
|
if (session?.agent !== input.draft.agent) {
|
||||||
|
await input.api.switchAgent({ sessionID: input.draft.sessionID, agent: input.draft.agent })
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
session?.model?.providerID === input.draft.model.providerID &&
|
||||||
|
session.model.id === input.draft.model.modelID &&
|
||||||
|
(session.model.variant ?? "default") === (input.draft.variant ?? "default")
|
||||||
|
)
|
||||||
|
return
|
||||||
|
await input.api.switchModel({
|
||||||
|
sessionID: input.draft.sessionID,
|
||||||
|
model: {
|
||||||
|
id: input.draft.model.modelID,
|
||||||
|
providerID: input.draft.model.providerID,
|
||||||
|
variant: input.draft.variant,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const [head, ...tail] = text.split(" ")
|
const [head, ...tail] = text.split(" ")
|
||||||
const cmd = head?.startsWith("/") ? head.slice(1) : undefined
|
const cmd = head?.startsWith("/") ? head.slice(1) : undefined
|
||||||
if (cmd && input.sync.data.command.find((item) => item.name === cmd)) {
|
if (cmd && input.sync.data.command.find((item) => item.name === cmd)) {
|
||||||
setBusy()
|
setBusy()
|
||||||
try {
|
try {
|
||||||
|
await select()
|
||||||
const messageID = Identifier.ascending("message")
|
const messageID = Identifier.ascending("message")
|
||||||
await input.api.command({
|
await input.api.command({
|
||||||
sessionID: input.draft.sessionID,
|
sessionID: input.draft.sessionID,
|
||||||
id: messageID,
|
id: messageID,
|
||||||
command: cmd,
|
command: cmd,
|
||||||
arguments: tail.join(" "),
|
arguments: tail.join(" "),
|
||||||
agent: input.draft.agent,
|
|
||||||
model: {
|
|
||||||
id: input.draft.model.modelID,
|
|
||||||
providerID: input.draft.model.providerID,
|
|
||||||
variant: input.draft.variant,
|
|
||||||
},
|
|
||||||
files: await Promise.all(
|
files: await Promise.all(
|
||||||
images.map(async (attachment) => ({
|
images.map(async (attachment) => ({
|
||||||
uri: await blobDataUrl(attachment.blob, attachment.mime),
|
uri: await blobDataUrl(attachment.blob, attachment.mime),
|
||||||
@@ -118,24 +134,7 @@ export async function sendFollowupDraft(input: FollowupSendInput) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const session = input.session()
|
await select()
|
||||||
if (session?.agent !== input.draft.agent) {
|
|
||||||
await input.api.switchAgent({ sessionID: input.draft.sessionID, agent: input.draft.agent })
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
session?.model?.providerID !== input.draft.model.providerID ||
|
|
||||||
session.model.id !== input.draft.model.modelID ||
|
|
||||||
(session.model.variant ?? "default") !== (input.draft.variant ?? "default")
|
|
||||||
) {
|
|
||||||
await input.api.switchModel({
|
|
||||||
sessionID: input.draft.sessionID,
|
|
||||||
model: {
|
|
||||||
id: input.draft.model.modelID,
|
|
||||||
providerID: input.draft.model.providerID,
|
|
||||||
variant: input.draft.variant,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const admitted = await input.api.prompt({
|
const admitted = await input.api.prompt({
|
||||||
sessionID: input.draft.sessionID,
|
sessionID: input.draft.sessionID,
|
||||||
@@ -469,14 +468,23 @@ export function createPromptSubmit(input: PromptSubmitInput) {
|
|||||||
clearInput()
|
clearInput()
|
||||||
const messageID = Identifier.ascending("message")
|
const messageID = Identifier.ascending("message")
|
||||||
submissionServerSync.session.set("session_status", session.id, { type: "busy" })
|
submissionServerSync.session.set("session_status", session.id, { type: "busy" })
|
||||||
void submissionSDK.api.session
|
void (async () => {
|
||||||
.command({
|
if (session.agent !== agent)
|
||||||
|
await submissionSDK.api.session.switchAgent({ sessionID: session.id, agent })
|
||||||
|
if (
|
||||||
|
session.model?.providerID !== model.providerID ||
|
||||||
|
session.model.id !== model.modelID ||
|
||||||
|
(session.model.variant ?? "default") !== (variant ?? "default")
|
||||||
|
)
|
||||||
|
await submissionSDK.api.session.switchModel({
|
||||||
|
sessionID: session.id,
|
||||||
|
model: { id: model.modelID, providerID: model.providerID, variant },
|
||||||
|
})
|
||||||
|
await submissionSDK.api.session.command({
|
||||||
sessionID: session.id,
|
sessionID: session.id,
|
||||||
id: messageID,
|
id: messageID,
|
||||||
command: commandName,
|
command: commandName,
|
||||||
arguments: args.join(" "),
|
arguments: args.join(" "),
|
||||||
agent,
|
|
||||||
model: { id: model.modelID, providerID: model.providerID, variant },
|
|
||||||
files: await Promise.all(
|
files: await Promise.all(
|
||||||
images.map(async (attachment) => ({
|
images.map(async (attachment) => ({
|
||||||
uri: await blobDataUrl(attachment.blob, attachment.mime),
|
uri: await blobDataUrl(attachment.blob, attachment.mime),
|
||||||
@@ -484,14 +492,14 @@ export function createPromptSubmit(input: PromptSubmitInput) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
})().catch((err) => {
|
||||||
submissionServerSync.session.set("session_status", session.id, { type: "idle" })
|
submissionServerSync.session.set("session_status", session.id, { type: "idle" })
|
||||||
showToast({
|
showToast({
|
||||||
title: language.t("prompt.toast.commandSendFailed.title"),
|
title: language.t("prompt.toast.commandSendFailed.title"),
|
||||||
description: formatServerError(err, language.t, language.t("common.requestFailed")),
|
description: formatServerError(err, language.t, language.t("common.requestFailed")),
|
||||||
})
|
|
||||||
restoreInput()
|
|
||||||
})
|
})
|
||||||
|
restoreInput()
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,8 +192,6 @@ export type Endpoint5_13Input = {
|
|||||||
readonly id?: SessionMessage.ID | undefined
|
readonly id?: SessionMessage.ID | undefined
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | undefined
|
readonly arguments?: string | undefined
|
||||||
readonly agent?: Agent.ID | undefined
|
|
||||||
readonly model?: Model.Ref | undefined
|
|
||||||
readonly files?: ReadonlyArray<PromptInput.FileAttachment> | undefined
|
readonly files?: ReadonlyArray<PromptInput.FileAttachment> | undefined
|
||||||
readonly agents?: ReadonlyArray<AgentAttachment> | undefined
|
readonly agents?: ReadonlyArray<AgentAttachment> | undefined
|
||||||
readonly skills?: ReadonlyArray<PromptInput.SkillAttachment> | undefined
|
readonly skills?: ReadonlyArray<PromptInput.SkillAttachment> | undefined
|
||||||
|
|||||||
@@ -423,8 +423,6 @@ const Endpoint5_13 = (raw: RawClient["server.session"]) => (input: Endpoint5_13I
|
|||||||
id: input["id"],
|
id: input["id"],
|
||||||
command: input["command"],
|
command: input["command"],
|
||||||
arguments: input["arguments"],
|
arguments: input["arguments"],
|
||||||
agent: input["agent"],
|
|
||||||
model: input["model"],
|
|
||||||
files: input["files"],
|
files: input["files"],
|
||||||
agents: input["agents"],
|
agents: input["agents"],
|
||||||
skills: input["skills"],
|
skills: input["skills"],
|
||||||
|
|||||||
@@ -627,8 +627,6 @@ export function make(options: ClientOptions) {
|
|||||||
id: input["id"],
|
id: input["id"],
|
||||||
command: input["command"],
|
command: input["command"],
|
||||||
arguments: input["arguments"],
|
arguments: input["arguments"],
|
||||||
agent: input["agent"],
|
|
||||||
model: input["model"],
|
|
||||||
files: input["files"],
|
files: input["files"],
|
||||||
agents: input["agents"],
|
agents: input["agents"],
|
||||||
skills: input["skills"],
|
skills: input["skills"],
|
||||||
|
|||||||
@@ -3511,8 +3511,6 @@ export type SessionCommandInput = {
|
|||||||
readonly id?: string | null
|
readonly id?: string | null
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | null
|
readonly arguments?: string | null
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
readonly files?: ReadonlyArray<{
|
||||||
readonly uri: string
|
readonly uri: string
|
||||||
readonly name?: string
|
readonly name?: string
|
||||||
@@ -3534,8 +3532,6 @@ export type SessionCommandInput = {
|
|||||||
readonly id?: string | null
|
readonly id?: string | null
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | null
|
readonly arguments?: string | null
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
readonly files?: ReadonlyArray<{
|
||||||
readonly uri: string
|
readonly uri: string
|
||||||
readonly name?: string
|
readonly name?: string
|
||||||
@@ -3557,8 +3553,6 @@ export type SessionCommandInput = {
|
|||||||
readonly id?: string | null
|
readonly id?: string | null
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | null
|
readonly arguments?: string | null
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
readonly files?: ReadonlyArray<{
|
||||||
readonly uri: string
|
readonly uri: string
|
||||||
readonly name?: string
|
readonly name?: string
|
||||||
@@ -3576,58 +3570,10 @@ export type SessionCommandInput = {
|
|||||||
readonly delivery?: ("steer" | "queue") | null
|
readonly delivery?: ("steer" | "queue") | null
|
||||||
readonly resume?: boolean | null
|
readonly resume?: boolean | null
|
||||||
}["arguments"]
|
}["arguments"]
|
||||||
readonly agent?: {
|
|
||||||
readonly id?: string | null
|
|
||||||
readonly command: string
|
|
||||||
readonly arguments?: string | null
|
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
|
||||||
readonly uri: string
|
|
||||||
readonly name?: string
|
|
||||||
readonly description?: string
|
|
||||||
readonly mention?: { readonly start: number; readonly end: number; readonly text: string }
|
|
||||||
}>
|
|
||||||
readonly agents?: ReadonlyArray<{
|
|
||||||
readonly name: string
|
|
||||||
readonly mention?: { readonly start: number; readonly end: number; readonly text: string }
|
|
||||||
}>
|
|
||||||
readonly skills?: ReadonlyArray<{
|
|
||||||
readonly id: string
|
|
||||||
readonly mention?: { readonly start: number; readonly end: number; readonly text: string }
|
|
||||||
}>
|
|
||||||
readonly delivery?: ("steer" | "queue") | null
|
|
||||||
readonly resume?: boolean | null
|
|
||||||
}["agent"]
|
|
||||||
readonly model?: {
|
|
||||||
readonly id?: string | null
|
|
||||||
readonly command: string
|
|
||||||
readonly arguments?: string | null
|
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
|
||||||
readonly uri: string
|
|
||||||
readonly name?: string
|
|
||||||
readonly description?: string
|
|
||||||
readonly mention?: { readonly start: number; readonly end: number; readonly text: string }
|
|
||||||
}>
|
|
||||||
readonly agents?: ReadonlyArray<{
|
|
||||||
readonly name: string
|
|
||||||
readonly mention?: { readonly start: number; readonly end: number; readonly text: string }
|
|
||||||
}>
|
|
||||||
readonly skills?: ReadonlyArray<{
|
|
||||||
readonly id: string
|
|
||||||
readonly mention?: { readonly start: number; readonly end: number; readonly text: string }
|
|
||||||
}>
|
|
||||||
readonly delivery?: ("steer" | "queue") | null
|
|
||||||
readonly resume?: boolean | null
|
|
||||||
}["model"]
|
|
||||||
readonly files?: {
|
readonly files?: {
|
||||||
readonly id?: string | null
|
readonly id?: string | null
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | null
|
readonly arguments?: string | null
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
readonly files?: ReadonlyArray<{
|
||||||
readonly uri: string
|
readonly uri: string
|
||||||
readonly name?: string
|
readonly name?: string
|
||||||
@@ -3649,8 +3595,6 @@ export type SessionCommandInput = {
|
|||||||
readonly id?: string | null
|
readonly id?: string | null
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | null
|
readonly arguments?: string | null
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
readonly files?: ReadonlyArray<{
|
||||||
readonly uri: string
|
readonly uri: string
|
||||||
readonly name?: string
|
readonly name?: string
|
||||||
@@ -3672,8 +3616,6 @@ export type SessionCommandInput = {
|
|||||||
readonly id?: string | null
|
readonly id?: string | null
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | null
|
readonly arguments?: string | null
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
readonly files?: ReadonlyArray<{
|
||||||
readonly uri: string
|
readonly uri: string
|
||||||
readonly name?: string
|
readonly name?: string
|
||||||
@@ -3695,8 +3637,6 @@ export type SessionCommandInput = {
|
|||||||
readonly id?: string | null
|
readonly id?: string | null
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | null
|
readonly arguments?: string | null
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
readonly files?: ReadonlyArray<{
|
||||||
readonly uri: string
|
readonly uri: string
|
||||||
readonly name?: string
|
readonly name?: string
|
||||||
@@ -3718,8 +3658,6 @@ export type SessionCommandInput = {
|
|||||||
readonly id?: string | null
|
readonly id?: string | null
|
||||||
readonly command: string
|
readonly command: string
|
||||||
readonly arguments?: string | null
|
readonly arguments?: string | null
|
||||||
readonly agent?: string | null
|
|
||||||
readonly model?: { readonly id: string; readonly providerID: string; readonly variant?: string } | null
|
|
||||||
readonly files?: ReadonlyArray<{
|
readonly files?: ReadonlyArray<{
|
||||||
readonly uri: string
|
readonly uri: string
|
||||||
readonly name?: string
|
readonly name?: string
|
||||||
|
|||||||
@@ -233,8 +233,6 @@ export interface Interface {
|
|||||||
sessionID: SessionSchema.ID
|
sessionID: SessionSchema.ID
|
||||||
command: string
|
command: string
|
||||||
arguments?: string
|
arguments?: string
|
||||||
agent?: Agent.ID
|
|
||||||
model?: Model.Ref
|
|
||||||
files?: PromptInput.Prompt["files"]
|
files?: PromptInput.Prompt["files"]
|
||||||
agents?: PromptInput.Prompt["agents"]
|
agents?: PromptInput.Prompt["agents"]
|
||||||
skills?: PromptInput.Prompt["skills"]
|
skills?: PromptInput.Prompt["skills"]
|
||||||
@@ -621,13 +619,13 @@ const layer = Layer.effect(
|
|||||||
const evaluated = yield* commands.evaluate({ name: input.command, arguments: input.arguments })
|
const evaluated = yield* commands.evaluate({ name: input.command, arguments: input.arguments })
|
||||||
|
|
||||||
// TODO(v2 commands): decide whether command-level subtask/background execution belongs in v2 commands.
|
// TODO(v2 commands): decide whether command-level subtask/background execution belongs in v2 commands.
|
||||||
const agent = command.agent ?? input.agent
|
const agent = command.agent
|
||||||
const commandAgent = yield* Effect.gen(function* () {
|
const commandAgent = yield* Effect.gen(function* () {
|
||||||
if (!command.agent) return undefined
|
if (!command.agent) return undefined
|
||||||
const agents = yield* Agent.Service.pipe(Effect.provide(locations.get(session.location)))
|
const agents = yield* Agent.Service.pipe(Effect.provide(locations.get(session.location)))
|
||||||
return yield* agents.get(Agent.ID.make(command.agent))
|
return yield* agents.get(Agent.ID.make(command.agent))
|
||||||
})
|
})
|
||||||
const model = command.model ?? commandAgent?.model ?? input.model
|
const model = command.model ?? commandAgent?.model
|
||||||
if (agent !== undefined && session.agent !== Agent.ID.make(agent))
|
if (agent !== undefined && session.agent !== Agent.ID.make(agent))
|
||||||
yield* result.switchAgent({ sessionID: input.sessionID, agent: Agent.ID.make(agent) })
|
yield* result.switchAgent({ sessionID: input.sessionID, agent: Agent.ID.make(agent) })
|
||||||
if (model !== undefined) yield* result.switchModel({ sessionID: input.sessionID, model })
|
if (model !== undefined) yield* result.switchModel({ sessionID: input.sessionID, model })
|
||||||
|
|||||||
@@ -341,8 +341,6 @@ export const makeSessionGroup = <I extends HttpApiMiddleware.AnyId, S>(sessionLo
|
|||||||
id: SessionMessage.ID.pipe(Schema.optional),
|
id: SessionMessage.ID.pipe(Schema.optional),
|
||||||
command: Schema.String,
|
command: Schema.String,
|
||||||
arguments: Schema.String.pipe(Schema.optional),
|
arguments: Schema.String.pipe(Schema.optional),
|
||||||
agent: Agent.ID.pipe(Schema.optional),
|
|
||||||
model: Model.Ref.pipe(Schema.optional),
|
|
||||||
files: PromptInput.Prompt.fields.files,
|
files: PromptInput.Prompt.fields.files,
|
||||||
agents: PromptInput.Prompt.fields.agents,
|
agents: PromptInput.Prompt.fields.agents,
|
||||||
skills: PromptInput.Prompt.fields.skills,
|
skills: PromptInput.Prompt.fields.skills,
|
||||||
|
|||||||
@@ -356,8 +356,6 @@ export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handl
|
|||||||
id: ctx.payload.id,
|
id: ctx.payload.id,
|
||||||
command: ctx.payload.command,
|
command: ctx.payload.command,
|
||||||
arguments: ctx.payload.arguments,
|
arguments: ctx.payload.arguments,
|
||||||
agent: ctx.payload.agent,
|
|
||||||
model: ctx.payload.model,
|
|
||||||
files: ctx.payload.files,
|
files: ctx.payload.files,
|
||||||
agents: ctx.payload.agents,
|
agents: ctx.payload.agents,
|
||||||
skills: ctx.payload.skills,
|
skills: ctx.payload.skills,
|
||||||
|
|||||||
@@ -1220,15 +1220,23 @@ export function Prompt(props: PromptProps) {
|
|||||||
} else if (slashHead && isCommand) {
|
} else if (slashHead && isCommand) {
|
||||||
move.startSubmit()
|
move.startSubmit()
|
||||||
const model = { providerID: selection.providerID, id: selection.modelID, variant }
|
const model = { providerID: selection.providerID, id: selection.modelID, variant }
|
||||||
|
if (session?.agent !== agent.id) await client.api.session.switchAgent({ sessionID, agent: agent.id })
|
||||||
const cancelCommit = local.model.trackSessionCommit(sessionID, model)
|
const cancelCommit = local.model.trackSessionCommit(sessionID, model)
|
||||||
|
if (
|
||||||
|
session?.model?.providerID !== model.providerID ||
|
||||||
|
session.model.id !== model.id ||
|
||||||
|
(session.model.variant ?? "default") !== (model.variant ?? "default")
|
||||||
|
)
|
||||||
|
await client.api.session.switchModel({ sessionID, model }).catch((error) => {
|
||||||
|
cancelCommit()
|
||||||
|
throw error
|
||||||
|
})
|
||||||
|
|
||||||
void client.api.session
|
void client.api.session
|
||||||
.command({
|
.command({
|
||||||
sessionID,
|
sessionID,
|
||||||
command: slashHead.name,
|
command: slashHead.name,
|
||||||
arguments: slashHead.arguments,
|
arguments: slashHead.arguments,
|
||||||
agent: agent.id,
|
|
||||||
model,
|
|
||||||
files: store.prompt.files,
|
files: store.prompt.files,
|
||||||
agents: store.prompt.agents,
|
agents: store.prompt.agents,
|
||||||
skills: store.prompt.skills?.length ? store.prompt.skills : undefined,
|
skills: store.prompt.skills?.length ? store.prompt.skills : undefined,
|
||||||
|
|||||||
@@ -1647,8 +1647,6 @@ export async function createSessionTransport(input: StreamInput): Promise<Sessio
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const selected = await resolveSelectedModel(input, client, next)
|
|
||||||
if (next.variant && !selected) throw new Error("Cannot select a variant before selecting a model")
|
|
||||||
input.trace?.write("send.command", { sessionID: input.sessionID, messageID, command: command.name, delivery })
|
input.trace?.write("send.command", { sessionID: input.sessionID, messageID, command: command.name, delivery })
|
||||||
return client.session.command(
|
return client.session.command(
|
||||||
{
|
{
|
||||||
@@ -1656,8 +1654,6 @@ export async function createSessionTransport(input: StreamInput): Promise<Sessio
|
|||||||
id: messageID,
|
id: messageID,
|
||||||
command: command.name,
|
command: command.name,
|
||||||
arguments: command.arguments,
|
arguments: command.arguments,
|
||||||
agent: next.agent,
|
|
||||||
model: selected,
|
|
||||||
files: attachments.files.length ? attachments.files : undefined,
|
files: attachments.files.length ? attachments.files : undefined,
|
||||||
agents: agents.length ? agents : undefined,
|
agents: agents.length ? agents : undefined,
|
||||||
skills: skills.length ? skills : undefined,
|
skills: skills.length ? skills : undefined,
|
||||||
@@ -1700,12 +1696,10 @@ export async function createSessionTransport(input: StreamInput): Promise<Sessio
|
|||||||
const client = sdk
|
const client = sdk
|
||||||
if (next.agent)
|
if (next.agent)
|
||||||
await client.session.switchAgent({ sessionID: input.sessionID, agent: next.agent }, { signal: next.signal })
|
await client.session.switchAgent({ sessionID: input.sessionID, agent: next.agent }, { signal: next.signal })
|
||||||
if (!next.prompt.command) {
|
const selected = await resolveSelectedModel(input, client, next)
|
||||||
const selected = await resolveSelectedModel(input, client, next)
|
if (next.variant && !selected) throw new Error("Cannot select a variant before selecting a model")
|
||||||
if (next.variant && !selected) throw new Error("Cannot select a variant before selecting a model")
|
if (selected)
|
||||||
if (selected)
|
await client.session.switchModel({ sessionID: input.sessionID, model: selected }, { signal: next.signal })
|
||||||
await client.session.switchModel({ sessionID: input.sessionID, model: selected }, { signal: next.signal })
|
|
||||||
}
|
|
||||||
mergePending(await admitPrompt(next, client, delivery))
|
mergePending(await admitPrompt(next, client, delivery))
|
||||||
settlementClient = client
|
settlementClient = client
|
||||||
},
|
},
|
||||||
@@ -1744,6 +1738,12 @@ export async function createSessionTransport(input: StreamInput): Promise<Sessio
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (command) {
|
if (command) {
|
||||||
|
if (next.agent)
|
||||||
|
await client.session.switchAgent({ sessionID: input.sessionID, agent: next.agent }, { signal: next.signal })
|
||||||
|
const selected = await resolveSelectedModel(input, client, next)
|
||||||
|
if (next.variant && !selected) throw new Error("Cannot select a variant before selecting a model")
|
||||||
|
if (selected)
|
||||||
|
await client.session.switchModel({ sessionID: input.sessionID, model: selected }, { signal: next.signal })
|
||||||
await runTurnWait(
|
await runTurnWait(
|
||||||
next,
|
next,
|
||||||
messageID,
|
messageID,
|
||||||
|
|||||||
@@ -2855,8 +2855,6 @@ describe("V2 mini transport", () => {
|
|||||||
id: "msg_cmd",
|
id: "msg_cmd",
|
||||||
command: "deploy",
|
command: "deploy",
|
||||||
arguments: "prod",
|
arguments: "prod",
|
||||||
agent: "build",
|
|
||||||
model: { providerID: "test", id: "model" },
|
|
||||||
files: [
|
files: [
|
||||||
{ uri: "file:///tmp/context.txt", name: "context.txt" },
|
{ uri: "file:///tmp/context.txt", name: "context.txt" },
|
||||||
{
|
{
|
||||||
@@ -2868,9 +2866,11 @@ describe("V2 mini transport", () => {
|
|||||||
skills: [{ id: "api-design", mention: { start: 13, end: 24, text: "/api-design" } }],
|
skills: [{ id: "api-design", mention: { start: 13, end: 24, text: "/api-design" } }],
|
||||||
delivery: "steer",
|
delivery: "steer",
|
||||||
})
|
})
|
||||||
// Selection rides the command payload; no separate client-side switch.
|
expect(client.session.switchAgent).toHaveBeenCalledWith({ sessionID: "ses_1", agent: "build" }, expect.anything())
|
||||||
expect(client.session.switchAgent).not.toHaveBeenCalled()
|
expect(client.session.switchModel).toHaveBeenCalledWith(
|
||||||
expect(client.session.switchModel).not.toHaveBeenCalled()
|
{ sessionID: "ses_1", model: { providerID: "test", id: "model" } },
|
||||||
|
expect.anything(),
|
||||||
|
)
|
||||||
await transport.close()
|
await transport.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user