@rallycry/conveyor-agent 5.10.0 → 5.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4166,6 +4166,41 @@ function buildChatQueryOptions(agentCtx, projectDir) {
4166
4166
  thinking: settings.thinking
4167
4167
  };
4168
4168
  }
4169
+ function emitResultCostAndContext(event, connection) {
4170
+ const resultEvent = event;
4171
+ if (resultEvent.total_cost_usd !== void 0 && resultEvent.total_cost_usd > 0) {
4172
+ connection.emitEvent({
4173
+ type: "cost_update",
4174
+ costUsd: resultEvent.total_cost_usd
4175
+ });
4176
+ }
4177
+ if (resultEvent.modelUsage && typeof resultEvent.modelUsage === "object") {
4178
+ const modelUsage = resultEvent.modelUsage;
4179
+ let contextWindow = 0;
4180
+ let totalInputTokens = 0;
4181
+ let totalCacheRead = 0;
4182
+ let totalCacheCreation = 0;
4183
+ for (const data of Object.values(modelUsage)) {
4184
+ const d = data;
4185
+ totalInputTokens += d.inputTokens ?? 0;
4186
+ totalCacheRead += d.cacheReadInputTokens ?? 0;
4187
+ totalCacheCreation += d.cacheCreationInputTokens ?? 0;
4188
+ const cw = d.contextWindow ?? 0;
4189
+ if (cw > contextWindow) contextWindow = cw;
4190
+ }
4191
+ if (contextWindow > 0) {
4192
+ const queryInputTokens = totalInputTokens + totalCacheRead + totalCacheCreation;
4193
+ connection.emitEvent({
4194
+ type: "context_update",
4195
+ contextTokens: queryInputTokens,
4196
+ contextWindow,
4197
+ inputTokens: totalInputTokens,
4198
+ cacheReadInputTokens: totalCacheRead,
4199
+ cacheCreationInputTokens: totalCacheCreation
4200
+ });
4201
+ }
4202
+ }
4203
+ }
4169
4204
  function processEventStream(event, connection, responseParts, turnToolCalls, isTyping) {
4170
4205
  if (event.type === "assistant") {
4171
4206
  if (!isTyping.value) {
@@ -4187,6 +4222,7 @@ function processEventStream(event, connection, responseParts, turnToolCalls, isT
4187
4222
  connection.emitEvent({ type: "agent_typing_stop" });
4188
4223
  isTyping.value = false;
4189
4224
  }
4225
+ emitResultCostAndContext(event, connection);
4190
4226
  return true;
4191
4227
  }
4192
4228
  return false;
@@ -5238,4 +5274,4 @@ export {
5238
5274
  ProjectRunner,
5239
5275
  FileCache
5240
5276
  };
5241
- //# sourceMappingURL=chunk-MRTSBPY7.js.map
5277
+ //# sourceMappingURL=chunk-WPQXAPVA.js.map