| 138 | } |
| 139 | |
| 140 | async function createSyntheticUserMessage(input: RunInput) { |
| 141 | const userMsg = await Session.updateMessage({ |
| 142 | id: Identifier.ascending("message"), |
| 143 | role: "user", |
| 144 | sessionID: input.sessionID, |
| 145 | agent: input.agent, |
| 146 | model: { |
| 147 | providerID: input.model.providerID, |
| 148 | modelID: input.model.modelID, |
| 149 | }, |
| 150 | time: { |
| 151 | created: Date.now(), |
| 152 | }, |
| 153 | }) |
| 154 | await Session.updatePart({ |
| 155 | id: Identifier.ascending("part"), |
| 156 | messageID: userMsg.id, |
| 157 | sessionID: userMsg.sessionID, |
| 158 | type: "text", |
| 159 | text: "/usage", |
| 160 | synthetic: true, |
| 161 | time: { |
| 162 | start: Date.now(), |
| 163 | end: Date.now(), |
| 164 | }, |
| 165 | }) |
| 166 | return { info: userMsg, parts: [] as MessageV2.Part[] } |
| 167 | } |
| 168 | } |