@dexto/core 1.8.4 → 1.8.5

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.
@@ -382,7 +382,7 @@ class TurnExecutor {
382
382
  {
383
383
  name: "turn.prepare_model_step",
384
384
  componentName: "TurnExecutor",
385
- attributes: { "turn.step_count": stepCount }
385
+ attributes: this.createTurnStepSpanAttributes(stepCount)
386
386
  },
387
387
  () => this.prepareNextModelRequest({
388
388
  contributorContext,
@@ -420,7 +420,7 @@ class TurnExecutor {
420
420
  {
421
421
  name: "turn.prepare_model_step",
422
422
  componentName: "TurnExecutor",
423
- attributes: { "turn.step_count": stepCount }
423
+ attributes: this.createTurnStepSpanAttributes(stepCount)
424
424
  },
425
425
  () => this.prepareNextModelRequest({
426
426
  contributorContext,
@@ -435,7 +435,20 @@ class TurnExecutor {
435
435
  throw new Error("Model step request was not prepared");
436
436
  }
437
437
  this.logger.debug(`Step ${stepCount}: Starting`);
438
- const result = await this.runModelStepWithRetry(modelStepRequest);
438
+ const result = await (0, import_operation_span.recordOperationSpan)(
439
+ {
440
+ name: "turn.run_model_step",
441
+ componentName: "TurnExecutor",
442
+ attributes: this.createTurnStepSpanAttributes(stepCount),
443
+ resultAttributes: (stepResult) => ({
444
+ "llm.finish_reason": stepResult.finishReason,
445
+ "llm.output_text_length": stepResult.text.length,
446
+ "tool.count": stepResult.toolCalls.length
447
+ })
448
+ },
449
+ () => this.runModelStepWithRetry(modelStepRequest),
450
+ this.logger
451
+ );
439
452
  currentResult = result;
440
453
  currentToolCallsExecuted = result.finishReason !== "tool-calls";
441
454
  preparedModelRequest = null;
@@ -474,7 +487,18 @@ class TurnExecutor {
474
487
  toolCallsRunning = true;
475
488
  currentToolCallsExecuted = true;
476
489
  try {
477
- await this.executeModelToolCalls(result.toolCalls);
490
+ await (0, import_operation_span.recordOperationSpan)(
491
+ {
492
+ name: "turn.execute_tool_calls",
493
+ componentName: "TurnExecutor",
494
+ attributes: {
495
+ ...this.createTurnStepSpanAttributes(stepCount),
496
+ "tool.count": result.toolCalls.length
497
+ }
498
+ },
499
+ () => this.executeModelToolCalls(result.toolCalls),
500
+ this.logger
501
+ );
478
502
  } catch (error) {
479
503
  currentToolCallsExecuted = false;
480
504
  throw error;
@@ -495,7 +519,23 @@ class TurnExecutor {
495
519
  if (result.finishReason === "tool-calls" && !currentToolCallsExecuted) {
496
520
  throw new Error("Tool calls must finish before deciding the next model step");
497
521
  }
498
- const nextStep = await this.decideNextStep(result, stepCount);
522
+ const nextStep = await (0, import_operation_span.recordOperationSpan)(
523
+ {
524
+ name: "turn.decide_next_step",
525
+ componentName: "TurnExecutor",
526
+ attributes: {
527
+ ...this.createTurnStepSpanAttributes(stepCount),
528
+ "llm.finish_reason": result.finishReason,
529
+ "tool.calls_executed": currentToolCallsExecuted
530
+ },
531
+ resultAttributes: (decision) => ({
532
+ "turn.next_action": decision.kind,
533
+ "turn.next_step_count": decision.stepCount
534
+ })
535
+ },
536
+ () => this.decideNextStep(result, stepCount),
537
+ this.logger
538
+ );
499
539
  stepCount = nextStep.stepCount;
500
540
  currentResult = null;
501
541
  currentToolCallsExecuted = false;
@@ -599,6 +639,13 @@ class TurnExecutor {
599
639
  }
600
640
  };
601
641
  }
642
+ createTurnStepSpanAttributes(stepCount) {
643
+ return {
644
+ "turn.step_count": stepCount,
645
+ "llm.model": this.llmContext.model,
646
+ "llm.provider": this.llmContext.provider
647
+ };
648
+ }
602
649
  async finishTurn(input) {
603
650
  await this.contextManager.flush();
604
651
  this.setTelemetryAttributes(input.usage);
@@ -1026,29 +1073,46 @@ class TurnExecutor {
1026
1073
  request.streaming,
1027
1074
  false
1028
1075
  );
1029
- return streamProcessor.process(
1030
- () => (0, import_ai.streamText)({
1031
- model: this.model,
1032
- stopWhen: (0, import_ai.stepCountIs)(1),
1033
- maxRetries: 0,
1034
- tools: request.tools,
1035
- abortSignal: this.stepAbortController.signal,
1036
- messages: request.messages,
1037
- ...this.config.maxOutputTokens !== void 0 && {
1038
- maxOutputTokens: this.config.maxOutputTokens
1039
- },
1040
- ...this.config.temperature !== void 0 && {
1041
- temperature: this.config.temperature
1042
- },
1043
- // Provider-specific options (caching, reasoning, etc.)
1044
- ...request.providerOptions !== void 0 && {
1045
- providerOptions: request.providerOptions
1076
+ return (0, import_operation_span.recordOperationSpan)(
1077
+ {
1078
+ name: "llm.stream",
1079
+ componentName: "TurnExecutor",
1080
+ attributes: {
1081
+ "llm.model": this.llmContext.model,
1082
+ "llm.provider": this.llmContext.provider,
1083
+ "tools.count": Object.keys(request.toolDefinitions).length
1046
1084
  },
1047
- // Log stream-level errors (tool errors, API errors during streaming)
1048
- onError: (error) => {
1049
- this.logger.error("Stream error", { error });
1050
- }
1051
- })
1085
+ resultAttributes: (result) => ({
1086
+ "llm.finish_reason": result.finishReason,
1087
+ "llm.output_text_length": result.text.length,
1088
+ "tool.count": result.toolCalls.length
1089
+ })
1090
+ },
1091
+ () => streamProcessor.process(
1092
+ () => (0, import_ai.streamText)({
1093
+ model: this.model,
1094
+ stopWhen: (0, import_ai.stepCountIs)(1),
1095
+ maxRetries: 0,
1096
+ tools: request.tools,
1097
+ abortSignal: this.stepAbortController.signal,
1098
+ messages: request.messages,
1099
+ ...this.config.maxOutputTokens !== void 0 && {
1100
+ maxOutputTokens: this.config.maxOutputTokens
1101
+ },
1102
+ ...this.config.temperature !== void 0 && {
1103
+ temperature: this.config.temperature
1104
+ },
1105
+ // Provider-specific options (caching, reasoning, etc.)
1106
+ ...request.providerOptions !== void 0 && {
1107
+ providerOptions: request.providerOptions
1108
+ },
1109
+ // Log stream-level errors (tool errors, API errors during streaming)
1110
+ onError: (error) => {
1111
+ this.logger.error("Stream error", { error });
1112
+ }
1113
+ })
1114
+ ),
1115
+ this.logger
1052
1116
  );
1053
1117
  }
1054
1118
  async runModelStepWithRetry(request) {
@@ -1121,10 +1185,41 @@ class TurnExecutor {
1121
1185
  async executeModelToolCalls(toolCalls) {
1122
1186
  const preparedCalls = [];
1123
1187
  for (const toolCall of toolCalls) {
1124
- preparedCalls.push(await this.prepareModelToolCall(toolCall));
1188
+ preparedCalls.push(
1189
+ await (0, import_operation_span.recordOperationSpan)(
1190
+ {
1191
+ name: "tool.prepare",
1192
+ componentName: "TurnExecutor",
1193
+ attributes: {
1194
+ "tool.call_id": toolCall.toolCallId,
1195
+ "tool.name": toolCall.toolName
1196
+ },
1197
+ resultAttributes: (prepared) => ({ "tool.prepare_kind": prepared.kind })
1198
+ },
1199
+ () => this.prepareModelToolCall(toolCall),
1200
+ this.logger
1201
+ )
1202
+ );
1125
1203
  }
1126
1204
  const executionResults = await Promise.all(
1127
- preparedCalls.map((prepared) => this.executePreparedModelToolCall(prepared))
1205
+ preparedCalls.map(
1206
+ (prepared) => (0, import_operation_span.recordOperationSpan)(
1207
+ {
1208
+ name: "tool.execute",
1209
+ componentName: "TurnExecutor",
1210
+ attributes: {
1211
+ "tool.call_id": prepared.toolCall.toolCallId,
1212
+ "tool.name": prepared.toolCall.toolName,
1213
+ "tool.prepare_kind": prepared.kind
1214
+ },
1215
+ resultAttributes: (result) => ({
1216
+ "tool.success": this.isToolExecutionSuccessful(result)
1217
+ })
1218
+ },
1219
+ () => this.executePreparedModelToolCall(prepared),
1220
+ this.logger
1221
+ )
1222
+ )
1128
1223
  );
1129
1224
  for (let index = 0; index < toolCalls.length; index += 1) {
1130
1225
  const toolCall = toolCalls[index];
@@ -1132,7 +1227,19 @@ class TurnExecutor {
1132
1227
  if (toolCall === void 0 || executionResult === void 0) {
1133
1228
  throw new Error("Tool call result count must match emitted tool call count");
1134
1229
  }
1135
- await this.persistModelToolResult(toolCall, executionResult);
1230
+ await (0, import_operation_span.recordOperationSpan)(
1231
+ {
1232
+ name: "tool.persist_result",
1233
+ componentName: "TurnExecutor",
1234
+ attributes: {
1235
+ "tool.call_id": toolCall.toolCallId,
1236
+ "tool.name": toolCall.toolName,
1237
+ "tool.success": this.isToolExecutionSuccessful(executionResult)
1238
+ }
1239
+ },
1240
+ () => this.persistModelToolResult(toolCall, executionResult),
1241
+ this.logger
1242
+ );
1136
1243
  }
1137
1244
  }
1138
1245
  async prepareModelToolCall(toolCall) {
@@ -298,6 +298,7 @@ export declare class TurnExecutor {
298
298
  private validateInitialToolSupport;
299
299
  private startTurn;
300
300
  private startModelStepScope;
301
+ private createTurnStepSpanAttributes;
301
302
  private finishTurn;
302
303
  private failTurn;
303
304
  private advanceStep;
@@ -1 +1 @@
1
- {"version":3,"file":"turn-executor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/turn-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAMb,KAAK,YAAY,EAEpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAa,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAS1D,OAAO,EACH,WAAW,EAId,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAMpD,OAAO,KAAK,EAAE,cAAc,EAAiB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvF,OAAO,KAAK,EACR,UAAU,EACV,kBAAkB,EAClB,UAAU,EAGb,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAIxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAQ1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,M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_step",
358
358
  componentName: "TurnExecutor",
359
- attributes: { "turn.step_count": stepCount }
359
+ attributes: this.createTurnStepSpanAttributes(stepCount)
360
360
  },
361
361
  () => this.prepareNextModelRequest({
362
362
  contributorContext,
@@ -394,7 +394,7 @@ class TurnExecutor {
394
394
  {
395
395
  name: "turn.prepare_model_step",
396
396
  componentName: "TurnExecutor",
397
- attributes: { "turn.step_count": stepCount }
397
+ attributes: this.createTurnStepSpanAttributes(stepCount)
398
398
  },
399
399
  () => this.prepareNextModelRequest({
400
400
  contributorContext,
@@ -409,7 +409,20 @@ class TurnExecutor {
409
409
  throw new Error("Model step request was not prepared");
410
410
  }
411
411
  this.logger.debug(`Step ${stepCount}: Starting`);
412
- const result = await this.runModelStepWithRetry(modelStepRequest);
412
+ const result = await recordOperationSpan(
413
+ {
414
+ name: "turn.run_model_step",
415
+ componentName: "TurnExecutor",
416
+ attributes: this.createTurnStepSpanAttributes(stepCount),
417
+ resultAttributes: (stepResult) => ({
418
+ "llm.finish_reason": stepResult.finishReason,
419
+ "llm.output_text_length": stepResult.text.length,
420
+ "tool.count": stepResult.toolCalls.length
421
+ })
422
+ },
423
+ () => this.runModelStepWithRetry(modelStepRequest),
424
+ this.logger
425
+ );
413
426
  currentResult = result;
414
427
  currentToolCallsExecuted = result.finishReason !== "tool-calls";
415
428
  preparedModelRequest = null;
@@ -448,7 +461,18 @@ class TurnExecutor {
448
461
  toolCallsRunning = true;
449
462
  currentToolCallsExecuted = true;
450
463
  try {
451
- await this.executeModelToolCalls(result.toolCalls);
464
+ await recordOperationSpan(
465
+ {
466
+ name: "turn.execute_tool_calls",
467
+ componentName: "TurnExecutor",
468
+ attributes: {
469
+ ...this.createTurnStepSpanAttributes(stepCount),
470
+ "tool.count": result.toolCalls.length
471
+ }
472
+ },
473
+ () => this.executeModelToolCalls(result.toolCalls),
474
+ this.logger
475
+ );
452
476
  } catch (error) {
453
477
  currentToolCallsExecuted = false;
454
478
  throw error;
@@ -469,7 +493,23 @@ class TurnExecutor {
469
493
  if (result.finishReason === "tool-calls" && !currentToolCallsExecuted) {
470
494
  throw new Error("Tool calls must finish before deciding the next model step");
471
495
  }
472
- const nextStep = await this.decideNextStep(result, stepCount);
496
+ const nextStep = await recordOperationSpan(
497
+ {
498
+ name: "turn.decide_next_step",
499
+ componentName: "TurnExecutor",
500
+ attributes: {
501
+ ...this.createTurnStepSpanAttributes(stepCount),
502
+ "llm.finish_reason": result.finishReason,
503
+ "tool.calls_executed": currentToolCallsExecuted
504
+ },
505
+ resultAttributes: (decision) => ({
506
+ "turn.next_action": decision.kind,
507
+ "turn.next_step_count": decision.stepCount
508
+ })
509
+ },
510
+ () => this.decideNextStep(result, stepCount),
511
+ this.logger
512
+ );
473
513
  stepCount = nextStep.stepCount;
474
514
  currentResult = null;
475
515
  currentToolCallsExecuted = false;
@@ -573,6 +613,13 @@ class TurnExecutor {
573
613
  }
574
614
  };
575
615
  }
616
+ createTurnStepSpanAttributes(stepCount) {
617
+ return {
618
+ "turn.step_count": stepCount,
619
+ "llm.model": this.llmContext.model,
620
+ "llm.provider": this.llmContext.provider
621
+ };
622
+ }
576
623
  async finishTurn(input) {
577
624
  await this.contextManager.flush();
578
625
  this.setTelemetryAttributes(input.usage);
@@ -1000,29 +1047,46 @@ class TurnExecutor {
1000
1047
  request.streaming,
1001
1048
  false
1002
1049
  );
1003
- return streamProcessor.process(
1004
- () => streamText({
1005
- model: this.model,
1006
- stopWhen: stepCountIs(1),
1007
- maxRetries: 0,
1008
- tools: request.tools,
1009
- abortSignal: this.stepAbortController.signal,
1010
- messages: request.messages,
1011
- ...this.config.maxOutputTokens !== void 0 && {
1012
- maxOutputTokens: this.config.maxOutputTokens
1013
- },
1014
- ...this.config.temperature !== void 0 && {
1015
- temperature: this.config.temperature
1016
- },
1017
- // Provider-specific options (caching, reasoning, etc.)
1018
- ...request.providerOptions !== void 0 && {
1019
- providerOptions: request.providerOptions
1050
+ return recordOperationSpan(
1051
+ {
1052
+ name: "llm.stream",
1053
+ componentName: "TurnExecutor",
1054
+ attributes: {
1055
+ "llm.model": this.llmContext.model,
1056
+ "llm.provider": this.llmContext.provider,
1057
+ "tools.count": Object.keys(request.toolDefinitions).length
1020
1058
  },
1021
- // Log stream-level errors (tool errors, API errors during streaming)
1022
- onError: (error) => {
1023
- this.logger.error("Stream error", { error });
1024
- }
1025
- })
1059
+ resultAttributes: (result) => ({
1060
+ "llm.finish_reason": result.finishReason,
1061
+ "llm.output_text_length": result.text.length,
1062
+ "tool.count": result.toolCalls.length
1063
+ })
1064
+ },
1065
+ () => streamProcessor.process(
1066
+ () => streamText({
1067
+ model: this.model,
1068
+ stopWhen: stepCountIs(1),
1069
+ maxRetries: 0,
1070
+ tools: request.tools,
1071
+ abortSignal: this.stepAbortController.signal,
1072
+ messages: request.messages,
1073
+ ...this.config.maxOutputTokens !== void 0 && {
1074
+ maxOutputTokens: this.config.maxOutputTokens
1075
+ },
1076
+ ...this.config.temperature !== void 0 && {
1077
+ temperature: this.config.temperature
1078
+ },
1079
+ // Provider-specific options (caching, reasoning, etc.)
1080
+ ...request.providerOptions !== void 0 && {
1081
+ providerOptions: request.providerOptions
1082
+ },
1083
+ // Log stream-level errors (tool errors, API errors during streaming)
1084
+ onError: (error) => {
1085
+ this.logger.error("Stream error", { error });
1086
+ }
1087
+ })
1088
+ ),
1089
+ this.logger
1026
1090
  );
1027
1091
  }
1028
1092
  async runModelStepWithRetry(request) {
@@ -1095,10 +1159,41 @@ class TurnExecutor {
1095
1159
  async executeModelToolCalls(toolCalls) {
1096
1160
  const preparedCalls = [];
1097
1161
  for (const toolCall of toolCalls) {
1098
- preparedCalls.push(await this.prepareModelToolCall(toolCall));
1162
+ preparedCalls.push(
1163
+ await recordOperationSpan(
1164
+ {
1165
+ name: "tool.prepare",
1166
+ componentName: "TurnExecutor",
1167
+ attributes: {
1168
+ "tool.call_id": toolCall.toolCallId,
1169
+ "tool.name": toolCall.toolName
1170
+ },
1171
+ resultAttributes: (prepared) => ({ "tool.prepare_kind": prepared.kind })
1172
+ },
1173
+ () => this.prepareModelToolCall(toolCall),
1174
+ this.logger
1175
+ )
1176
+ );
1099
1177
  }
1100
1178
  const executionResults = await Promise.all(
1101
- preparedCalls.map((prepared) => this.executePreparedModelToolCall(prepared))
1179
+ preparedCalls.map(
1180
+ (prepared) => recordOperationSpan(
1181
+ {
1182
+ name: "tool.execute",
1183
+ componentName: "TurnExecutor",
1184
+ attributes: {
1185
+ "tool.call_id": prepared.toolCall.toolCallId,
1186
+ "tool.name": prepared.toolCall.toolName,
1187
+ "tool.prepare_kind": prepared.kind
1188
+ },
1189
+ resultAttributes: (result) => ({
1190
+ "tool.success": this.isToolExecutionSuccessful(result)
1191
+ })
1192
+ },
1193
+ () => this.executePreparedModelToolCall(prepared),
1194
+ this.logger
1195
+ )
1196
+ )
1102
1197
  );
1103
1198
  for (let index = 0; index < toolCalls.length; index += 1) {
1104
1199
  const toolCall = toolCalls[index];
@@ -1106,7 +1201,19 @@ class TurnExecutor {
1106
1201
  if (toolCall === void 0 || executionResult === void 0) {
1107
1202
  throw new Error("Tool call result count must match emitted tool call count");
1108
1203
  }
1109
- await this.persistModelToolResult(toolCall, executionResult);
1204
+ await recordOperationSpan(
1205
+ {
1206
+ name: "tool.persist_result",
1207
+ componentName: "TurnExecutor",
1208
+ attributes: {
1209
+ "tool.call_id": toolCall.toolCallId,
1210
+ "tool.name": toolCall.toolName,
1211
+ "tool.success": this.isToolExecutionSuccessful(executionResult)
1212
+ }
1213
+ },
1214
+ () => this.persistModelToolResult(toolCall, executionResult),
1215
+ this.logger
1216
+ );
1110
1217
  }
1111
1218
  }
1112
1219
  async prepareModelToolCall(toolCall) {
@@ -257,6 +257,19 @@ function buildModelsFromModelsDevProvider(params) {
257
257
  results.sort((a, b) => a.name.localeCompare(b.name));
258
258
  return results;
259
259
  }
260
+ function hasProviderMetadata(model) {
261
+ return model.providerMetadata != null && Object.keys(model.providerMetadata).length > 0;
262
+ }
263
+ function dedupeModelsByNamePreferProviderMetadata(models) {
264
+ const byName = /* @__PURE__ */ new Map();
265
+ for (const model of models) {
266
+ const existing = byName.get(model.name);
267
+ if (!existing || !hasProviderMetadata(existing) && hasProviderMetadata(model)) {
268
+ byName.set(model.name, model);
269
+ }
270
+ }
271
+ return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
272
+ }
260
273
  function buildModelsByProviderFromParsedSources(params) {
261
274
  const { modelsDevApi } = params;
262
275
  const defaults = {
@@ -368,7 +381,7 @@ function buildModelsByProviderFromParsedSources(params) {
368
381
  }),
369
382
  litellm: [],
370
383
  glama: [],
371
- vertex: [
384
+ vertex: dedupeModelsByNamePreferProviderMetadata([
372
385
  ...buildModelsFromModelsDevProvider({
373
386
  spec: {
374
387
  provider: "vertex",
@@ -386,7 +399,7 @@ function buildModelsByProviderFromParsedSources(params) {
386
399
  },
387
400
  modelsDevApi
388
401
  })
389
- ].sort((a, b) => a.name.localeCompare(b.name)),
402
+ ]),
390
403
  bedrock: buildModelsFromModelsDevProvider({
391
404
  spec: {
392
405
  provider: "bedrock",
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/llm/registry/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,eAAO,MAAM,cAAc,gCAAgC,CAAC;AAE5D,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AACtD,KAAK,iBAAiB,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc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AM,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,CAuJnC;AAED,wBAAsB,+BAA+B,CAAC,OAAO,CAAC,EAAE;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAoB5C"}
@@ -232,6 +232,19 @@ function buildModelsFromModelsDevProvider(params) {
232
232
  results.sort((a, b) => a.name.localeCompare(b.name));
233
233
  return results;
234
234
  }
235
+ function hasProviderMetadata(model) {
236
+ return model.providerMetadata != null && Object.keys(model.providerMetadata).length > 0;
237
+ }
238
+ function dedupeModelsByNamePreferProviderMetadata(models) {
239
+ const byName = /* @__PURE__ */ new Map();
240
+ for (const model of models) {
241
+ const existing = byName.get(model.name);
242
+ if (!existing || !hasProviderMetadata(existing) && hasProviderMetadata(model)) {
243
+ byName.set(model.name, model);
244
+ }
245
+ }
246
+ return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
247
+ }
235
248
  function buildModelsByProviderFromParsedSources(params) {
236
249
  const { modelsDevApi } = params;
237
250
  const defaults = {
@@ -343,7 +356,7 @@ function buildModelsByProviderFromParsedSources(params) {
343
356
  }),
344
357
  litellm: [],
345
358
  glama: [],
346
- vertex: [
359
+ vertex: dedupeModelsByNamePreferProviderMetadata([
347
360
  ...buildModelsFromModelsDevProvider({
348
361
  spec: {
349
362
  provider: "vertex",
@@ -361,7 +374,7 @@ function buildModelsByProviderFromParsedSources(params) {
361
374
  },
362
375
  modelsDevApi
363
376
  })
364
- ].sort((a, b) => a.name.localeCompare(b.name)),
377
+ ]),
365
378
  bedrock: buildModelsFromModelsDevProvider({
366
379
  spec: {
367
380
  provider: "bedrock",
@@ -77,6 +77,7 @@ var import_turn_executor = require("../executor/turn-executor.js");
77
77
  var import_DextoRuntimeError = require("../../errors/DextoRuntimeError.js");
78
78
  var import_types4 = require("../../errors/types.js");
79
79
  var import_error_codes = require("../error-codes.js");
80
+ var import_operation_span = require("../../telemetry/operation-span.js");
80
81
  var _VercelLLMService_decorators, _init;
81
82
  function ensureRunContextMatchesServiceSession(serviceSessionId, runContext) {
82
83
  if (runContext !== void 0 && runContext.sessionId !== serviceSessionId) {
@@ -157,11 +158,37 @@ class VercelLLMService {
157
158
  async createTurnDriver(options = {}) {
158
159
  const sessionId = ensureRunContextMatchesServiceSession(this.sessionId, options.runContext);
159
160
  const executor = this.createTurnExecutor(options.signal, options.runContext);
160
- const contributorContext = await this.toolManager.buildContributorContext({ sessionId });
161
- return executor.createDriver(contributorContext, {
162
- streaming: options.streaming ?? true,
163
- ...options.state !== void 0 ? { state: options.state } : {}
164
- });
161
+ const contributorContext = await (0, import_operation_span.recordOperationSpan)(
162
+ {
163
+ name: "llm.vercel.build_contributor_context",
164
+ attributes: {
165
+ "session.id": sessionId
166
+ },
167
+ resultAttributes: (context2) => ({
168
+ "tool.has_workspace_context": context2.workspace !== null,
169
+ "tool.has_environment_context": context2.environment !== void 0,
170
+ "tool.session_prompt_contributors": context2.session?.systemPromptContributors?.length ?? 0
171
+ })
172
+ },
173
+ () => this.toolManager.buildContributorContext({ sessionId }),
174
+ this.logger
175
+ );
176
+ const streaming = options.streaming ?? true;
177
+ return (0, import_operation_span.recordOperationSpan)(
178
+ {
179
+ name: "llm.vercel.create_turn_executor_driver",
180
+ attributes: {
181
+ "session.id": sessionId,
182
+ "turn.streaming": streaming,
183
+ "turn.resume": options.state !== void 0
184
+ }
185
+ },
186
+ () => executor.createDriver(contributorContext, {
187
+ streaming,
188
+ ...options.state !== void 0 ? { state: options.state } : {}
189
+ }),
190
+ this.logger
191
+ );
165
192
  }
166
193
  /**
167
194
  * Create a TurnExecutor instance for executing the agent loop.
@@ -1 +1 @@
1
- {"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/llm/services/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,EA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