(input: {
parentID: string
messages: MessageV2.WithParts[]
sessionID: string
model: {
providerID: string
modelID: string
}
agent: string
abort: AbortSignal
auto: boolean
})
| 87 | } |
| 88 | |
| 89 | export async function process(input: { |
| 90 | parentID: string |
| 91 | messages: MessageV2.WithParts[] |
| 92 | sessionID: string |
| 93 | model: { |
| 94 | providerID: string |
| 95 | modelID: string |
| 96 | } |
| 97 | agent: string |
| 98 | abort: AbortSignal |
| 99 | auto: boolean |
| 100 | }) { |
| 101 | const cfg = await Config.get() |
| 102 | const model = await Provider.getModel(input.model.providerID, input.model.modelID) |
| 103 | const language = await Provider.getLanguage(model) |
| 104 | const system = [...SystemPrompt.compaction(model.providerID)] |
| 105 | const msg = (await Session.updateMessage({ |
| 106 | id: Identifier.ascending("message"), |
| 107 | role: "assistant", |
| 108 | parentID: input.parentID, |
| 109 | sessionID: input.sessionID, |
| 110 | mode: input.agent, |
| 111 | summary: true, |
| 112 | path: { |
| 113 | cwd: Instance.directory, |
| 114 | root: Instance.worktree, |
| 115 | }, |
| 116 | cost: 0, |
| 117 | tokens: { |
| 118 | output: 0, |
| 119 | input: 0, |
| 120 | reasoning: 0, |
| 121 | cache: { read: 0, write: 0 }, |
| 122 | }, |
| 123 | modelID: input.model.modelID, |
| 124 | providerID: model.providerID, |
| 125 | time: { |
| 126 | created: Date.now(), |
| 127 | }, |
| 128 | })) as MessageV2.Assistant |
| 129 | const processor = SessionProcessor.create({ |
| 130 | assistantMessage: msg, |
| 131 | sessionID: input.sessionID, |
| 132 | model: model, |
| 133 | abort: input.abort, |
| 134 | }) |
| 135 | const result = await processor.process({ |
| 136 | onError(error) { |
| 137 | log.error("stream error", { |
| 138 | error, |
| 139 | }) |
| 140 | }, |
| 141 | maxRetries: 3, |
| 142 | providerOptions: ProviderTransform.providerOptions( |
| 143 | model, |
| 144 | pipe({}, mergeDeep(ProviderTransform.options(model, input.sessionID)), mergeDeep(model.options)), |
| 145 | ), |
| 146 | headers: model.headers, |
nothing calls this directly
no test coverage detected