@voltagent/core 0.1.29 → 0.1.30

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.
package/dist/index.d.ts CHANGED
@@ -1457,6 +1457,17 @@ type AgentStartEventMetadata = {
1457
1457
  } & Record<string, unknown>;
1458
1458
  interface AgentSuccessEventMetadata extends BaseEventMetadata {
1459
1459
  usage?: Usage;
1460
+ modelParameters?: {
1461
+ model?: string;
1462
+ temperature?: number;
1463
+ maxTokens?: number;
1464
+ topP?: number;
1465
+ frequencyPenalty?: number;
1466
+ presencePenalty?: number;
1467
+ stop?: string[];
1468
+ system?: string;
1469
+ toolChoice?: string;
1470
+ };
1460
1471
  }
1461
1472
  interface MemoryEventMetadata extends BaseEventMetadata {
1462
1473
  type?: string;
package/dist/index.js CHANGED
@@ -6280,7 +6280,7 @@ ${context}`;
6280
6280
  */
6281
6281
  generateText(_0) {
6282
6282
  return __async(this, arguments, function* (input, options = {}) {
6283
- var _a, _b, _c, _d, _e, _f;
6283
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
6284
6284
  const internalOptions = options;
6285
6285
  const {
6286
6286
  userId,
@@ -6337,7 +6337,15 @@ ${context}`;
6337
6337
  instructions: this.instructions,
6338
6338
  userContext: Object.fromEntries(operationContext.userContext.entries()),
6339
6339
  systemPrompt: systemMessage,
6340
- messages
6340
+ messages,
6341
+ modelParameters: {
6342
+ model: this.getModelName(),
6343
+ maxTokens: (_c = internalOptions.provider) == null ? void 0 : _c.maxTokens,
6344
+ temperature: (_d = internalOptions.provider) == null ? void 0 : _d.temperature,
6345
+ topP: (_e = internalOptions.provider) == null ? void 0 : _e.topP,
6346
+ frequencyPenalty: (_f = internalOptions.provider) == null ? void 0 : _f.frequencyPenalty,
6347
+ presencePenalty: (_g = internalOptions.provider) == null ? void 0 : _g.presencePenalty
6348
+ }
6341
6349
  },
6342
6350
  traceId: operationContext.historyEntry.id
6343
6351
  };
@@ -6371,7 +6379,7 @@ ${context}`;
6371
6379
  historyEntryId: operationContext.historyEntry.id
6372
6380
  },
6373
6381
  onStepFinish: (step) => __async(this, null, function* () {
6374
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j;
6382
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
6375
6383
  this.addStepToHistory(step, operationContext);
6376
6384
  if (step.type === "tool_call") {
6377
6385
  if (step.name && step.id) {
@@ -6487,11 +6495,11 @@ ${context}`;
6487
6495
  });
6488
6496
  const tool2 = this.toolManager.getToolByName(toolName);
6489
6497
  if (tool2) {
6490
- yield (_j = (_i = this.hooks).onToolEnd) == null ? void 0 : _j.call(_i, {
6498
+ yield (_j2 = (_i2 = this.hooks).onToolEnd) == null ? void 0 : _j2.call(_i2, {
6491
6499
  agent: this,
6492
6500
  tool: tool2,
6493
- output: (_g = step.result) != null ? _g : step.content,
6494
- error: (_h = step.result) == null ? void 0 : _h.error,
6501
+ output: (_g2 = step.result) != null ? _g2 : step.content,
6502
+ error: (_h2 = step.result) == null ? void 0 : _h2.error,
6495
6503
  context: operationContext
6496
6504
  });
6497
6505
  }
@@ -6519,7 +6527,15 @@ ${context}`;
6519
6527
  displayName: this.name,
6520
6528
  id: this.id,
6521
6529
  usage: response.usage,
6522
- userContext: Object.fromEntries(operationContext.userContext.entries())
6530
+ userContext: Object.fromEntries(operationContext.userContext.entries()),
6531
+ modelParameters: {
6532
+ model: this.getModelName(),
6533
+ maxTokens: (_h = internalOptions.provider) == null ? void 0 : _h.maxTokens,
6534
+ temperature: (_i = internalOptions.provider) == null ? void 0 : _i.temperature,
6535
+ topP: (_j = internalOptions.provider) == null ? void 0 : _j.topP,
6536
+ frequencyPenalty: (_k = internalOptions.provider) == null ? void 0 : _k.frequencyPenalty,
6537
+ presencePenalty: (_l = internalOptions.provider) == null ? void 0 : _l.presencePenalty
6538
+ }
6523
6539
  },
6524
6540
  traceId: operationContext.historyEntry.id,
6525
6541
  parentEventId: agentStartInfo.eventId
@@ -6543,7 +6559,7 @@ ${context}`;
6543
6559
  finishReason: response.finishReason,
6544
6560
  providerResponse: response
6545
6561
  };
6546
- yield (_d = (_c = this.hooks).onEnd) == null ? void 0 : _d.call(_c, {
6562
+ yield (_n = (_m = this.hooks).onEnd) == null ? void 0 : _n.call(_m, {
6547
6563
  agent: this,
6548
6564
  output: standardizedOutput,
6549
6565
  error: void 0,
@@ -6607,7 +6623,7 @@ ${context}`;
6607
6623
  }, voltagentError.metadata)
6608
6624
  });
6609
6625
  operationContext.isActive = false;
6610
- yield (_f = (_e = this.hooks).onEnd) == null ? void 0 : _f.call(_e, {
6626
+ yield (_p = (_o = this.hooks).onEnd) == null ? void 0 : _p.call(_o, {
6611
6627
  agent: this,
6612
6628
  output: void 0,
6613
6629
  error: voltagentError,
@@ -6626,7 +6642,7 @@ ${context}`;
6626
6642
  */
6627
6643
  streamText(_0) {
6628
6644
  return __async(this, arguments, function* (input, options = {}) {
6629
- var _a, _b;
6645
+ var _a, _b, _c, _d, _e, _f, _g;
6630
6646
  const internalOptions = options;
6631
6647
  const {
6632
6648
  userId,
@@ -6681,7 +6697,15 @@ ${context}`;
6681
6697
  instructions: this.instructions,
6682
6698
  userContext: Object.fromEntries(operationContext.userContext.entries()),
6683
6699
  systemPrompt: systemMessage,
6684
- messages
6700
+ messages,
6701
+ modelParameters: {
6702
+ model: this.getModelName(),
6703
+ maxTokens: (_c = internalOptions.provider) == null ? void 0 : _c.maxTokens,
6704
+ temperature: (_d = internalOptions.provider) == null ? void 0 : _d.temperature,
6705
+ topP: (_e = internalOptions.provider) == null ? void 0 : _e.topP,
6706
+ frequencyPenalty: (_f = internalOptions.provider) == null ? void 0 : _f.frequencyPenalty,
6707
+ presencePenalty: (_g = internalOptions.provider) == null ? void 0 : _g.presencePenalty
6708
+ }
6685
6709
  },
6686
6710
  traceId: operationContext.historyEntry.id
6687
6711
  };
@@ -6715,7 +6739,7 @@ ${context}`;
6715
6739
  historyEntryId: operationContext.historyEntry.id
6716
6740
  },
6717
6741
  onChunk: (chunk) => __async(this, null, function* () {
6718
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
6742
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j;
6719
6743
  if (chunk.type === "tool_call") {
6720
6744
  if (chunk.name && chunk.id) {
6721
6745
  const tool2 = this.toolManager.getToolByName(chunk.name);
@@ -6764,7 +6788,7 @@ ${context}`;
6764
6788
  if (chunk.name && chunk.id) {
6765
6789
  const toolCallId = chunk.id;
6766
6790
  const toolName = chunk.name;
6767
- const isError = Boolean((_c = chunk.result) == null ? void 0 : _c.error);
6791
+ const isError = Boolean((_c2 = chunk.result) == null ? void 0 : _c2.error);
6768
6792
  const toolStartInfo = operationContext.userContext.get(`tool_${toolCallId}`) || { eventId: void 0, startTime: (/* @__PURE__ */ new Date()).toISOString() };
6769
6793
  if (isError) {
6770
6794
  const toolErrorEvent = {
@@ -6779,7 +6803,7 @@ ${context}`;
6779
6803
  level: "ERROR",
6780
6804
  input: null,
6781
6805
  output: null,
6782
- statusMessage: ((_d = chunk.result) == null ? void 0 : _d.error) || { message: "Unknown tool error" },
6806
+ statusMessage: ((_d2 = chunk.result) == null ? void 0 : _d2.error) || { message: "Unknown tool error" },
6783
6807
  metadata: {
6784
6808
  displayName: toolName,
6785
6809
  id: toolName,
@@ -6805,7 +6829,7 @@ ${context}`;
6805
6829
  // Current time as end time
6806
6830
  status: "completed",
6807
6831
  input: null,
6808
- output: (_e = chunk.result) != null ? _e : chunk.content,
6832
+ output: (_e2 = chunk.result) != null ? _e2 : chunk.content,
6809
6833
  metadata: {
6810
6834
  displayName: toolName,
6811
6835
  id: toolName,
@@ -6824,14 +6848,14 @@ ${context}`;
6824
6848
  this._endOtelToolSpan(operationContext, toolCallId, toolName, {
6825
6849
  result: chunk.result,
6826
6850
  content: chunk.content,
6827
- error: (_f = chunk.result) == null ? void 0 : _f.error
6851
+ error: (_f2 = chunk.result) == null ? void 0 : _f2.error
6828
6852
  });
6829
6853
  const tool2 = this.toolManager.getToolByName(toolName);
6830
6854
  if (tool2) {
6831
6855
  yield (_j = (_i = this.hooks).onToolEnd) == null ? void 0 : _j.call(_i, {
6832
6856
  agent: this,
6833
6857
  tool: tool2,
6834
- output: (_g = chunk.result) != null ? _g : chunk.content,
6858
+ output: (_g2 = chunk.result) != null ? _g2 : chunk.content,
6835
6859
  error: (_h = chunk.result) == null ? void 0 : _h.error,
6836
6860
  context: operationContext
6837
6861
  });
@@ -6850,7 +6874,7 @@ ${context}`;
6850
6874
  this.addStepToHistory(step, operationContext);
6851
6875
  }),
6852
6876
  onFinish: (result) => __async(this, null, function* () {
6853
- var _a2, _b2, _c;
6877
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h;
6854
6878
  if (!operationContext.isActive) {
6855
6879
  return;
6856
6880
  }
@@ -6879,7 +6903,15 @@ ${context}`;
6879
6903
  displayName: this.name,
6880
6904
  id: this.id,
6881
6905
  usage: result.usage,
6882
- userContext: Object.fromEntries(operationContext.userContext.entries())
6906
+ userContext: Object.fromEntries(operationContext.userContext.entries()),
6907
+ modelParameters: {
6908
+ model: this.getModelName(),
6909
+ maxTokens: (_a2 = internalOptions.provider) == null ? void 0 : _a2.maxTokens,
6910
+ temperature: (_b2 = internalOptions.provider) == null ? void 0 : _b2.temperature,
6911
+ topP: (_c2 = internalOptions.provider) == null ? void 0 : _c2.topP,
6912
+ frequencyPenalty: (_d2 = internalOptions.provider) == null ? void 0 : _d2.frequencyPenalty,
6913
+ presencePenalty: (_e2 = internalOptions.provider) == null ? void 0 : _e2.presencePenalty
6914
+ }
6883
6915
  },
6884
6916
  traceId: operationContext.historyEntry.id,
6885
6917
  parentEventId: agentStartInfo.eventId
@@ -6902,18 +6934,18 @@ ${context}`;
6902
6934
  }
6903
6935
  });
6904
6936
  operationContext.isActive = false;
6905
- yield (_b2 = (_a2 = this.hooks).onEnd) == null ? void 0 : _b2.call(_a2, {
6937
+ yield (_g2 = (_f2 = this.hooks).onEnd) == null ? void 0 : _g2.call(_f2, {
6906
6938
  agent: this,
6907
6939
  output: result,
6908
6940
  error: void 0,
6909
6941
  context: operationContext
6910
6942
  });
6911
- if ((_c = internalOptions.provider) == null ? void 0 : _c.onFinish) {
6943
+ if ((_h = internalOptions.provider) == null ? void 0 : _h.onFinish) {
6912
6944
  yield internalOptions.provider.onFinish(result);
6913
6945
  }
6914
6946
  }),
6915
6947
  onError: (error) => __async(this, null, function* () {
6916
- var _a2, _b2, _c, _d, _e;
6948
+ var _a2, _b2, _c2, _d2, _e2;
6917
6949
  if (error.toolError) {
6918
6950
  const { toolCallId, toolName } = error.toolError;
6919
6951
  try {
@@ -7014,10 +7046,10 @@ ${context}`;
7014
7046
  }, error.metadata)
7015
7047
  });
7016
7048
  operationContext.isActive = false;
7017
- if ((_c = internalOptions.provider) == null ? void 0 : _c.onError) {
7049
+ if ((_c2 = internalOptions.provider) == null ? void 0 : _c2.onError) {
7018
7050
  yield internalOptions.provider.onError(error);
7019
7051
  }
7020
- yield (_e = (_d = this.hooks).onEnd) == null ? void 0 : _e.call(_d, {
7052
+ yield (_e2 = (_d2 = this.hooks).onEnd) == null ? void 0 : _e2.call(_d2, {
7021
7053
  agent: this,
7022
7054
  output: void 0,
7023
7055
  error,
@@ -7034,7 +7066,7 @@ ${context}`;
7034
7066
  */
7035
7067
  generateObject(_0, _1) {
7036
7068
  return __async(this, arguments, function* (input, schema, options = {}) {
7037
- var _a, _b, _c, _d, _e, _f;
7069
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
7038
7070
  const internalOptions = options;
7039
7071
  const {
7040
7072
  userId,
@@ -7091,7 +7123,15 @@ ${context}`;
7091
7123
  instructions: this.instructions,
7092
7124
  userContext: Object.fromEntries(operationContext.userContext.entries()),
7093
7125
  systemPrompt: systemMessage,
7094
- messages
7126
+ messages,
7127
+ modelParameters: {
7128
+ model: this.getModelName(),
7129
+ maxTokens: (_c = internalOptions.provider) == null ? void 0 : _c.maxTokens,
7130
+ temperature: (_d = internalOptions.provider) == null ? void 0 : _d.temperature,
7131
+ topP: (_e = internalOptions.provider) == null ? void 0 : _e.topP,
7132
+ frequencyPenalty: (_f = internalOptions.provider) == null ? void 0 : _f.frequencyPenalty,
7133
+ presencePenalty: (_g = internalOptions.provider) == null ? void 0 : _g.presencePenalty
7134
+ }
7095
7135
  },
7096
7136
  traceId: operationContext.historyEntry.id
7097
7137
  };
@@ -7146,7 +7186,15 @@ ${context}`;
7146
7186
  displayName: this.name,
7147
7187
  id: this.id,
7148
7188
  usage: response.usage,
7149
- userContext: Object.fromEntries(operationContext.userContext.entries())
7189
+ userContext: Object.fromEntries(operationContext.userContext.entries()),
7190
+ modelParameters: {
7191
+ model: this.getModelName(),
7192
+ maxTokens: (_h = internalOptions.provider) == null ? void 0 : _h.maxTokens,
7193
+ temperature: (_i = internalOptions.provider) == null ? void 0 : _i.temperature,
7194
+ topP: (_j = internalOptions.provider) == null ? void 0 : _j.topP,
7195
+ frequencyPenalty: (_k = internalOptions.provider) == null ? void 0 : _k.frequencyPenalty,
7196
+ presencePenalty: (_l = internalOptions.provider) == null ? void 0 : _l.presencePenalty
7197
+ }
7150
7198
  },
7151
7199
  traceId: operationContext.historyEntry.id,
7152
7200
  parentEventId: agentStartInfo.eventId
@@ -7177,7 +7225,7 @@ ${context}`;
7177
7225
  finishReason: response.finishReason,
7178
7226
  providerResponse: response
7179
7227
  };
7180
- yield (_d = (_c = this.hooks).onEnd) == null ? void 0 : _d.call(_c, {
7228
+ yield (_n = (_m = this.hooks).onEnd) == null ? void 0 : _n.call(_m, {
7181
7229
  agent: this,
7182
7230
  output: standardizedOutput,
7183
7231
  error: void 0,
@@ -7239,7 +7287,7 @@ ${context}`;
7239
7287
  status: "error",
7240
7288
  endTime: /* @__PURE__ */ new Date()
7241
7289
  });
7242
- yield (_f = (_e = this.hooks).onEnd) == null ? void 0 : _f.call(_e, {
7290
+ yield (_p = (_o = this.hooks).onEnd) == null ? void 0 : _p.call(_o, {
7243
7291
  agent: this,
7244
7292
  output: void 0,
7245
7293
  error: voltagentError,
@@ -7254,7 +7302,7 @@ ${context}`;
7254
7302
  */
7255
7303
  streamObject(_0, _1) {
7256
7304
  return __async(this, arguments, function* (input, schema, options = {}) {
7257
- var _a, _b, _c, _d;
7305
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7258
7306
  const internalOptions = options;
7259
7307
  const {
7260
7308
  userId,
@@ -7310,7 +7358,15 @@ ${context}`;
7310
7358
  instructions: this.instructions,
7311
7359
  userContext: Object.fromEntries(operationContext.userContext.entries()),
7312
7360
  systemPrompt: systemMessage,
7313
- messages
7361
+ messages,
7362
+ modelParameters: {
7363
+ model: this.getModelName(),
7364
+ maxTokens: (_c = internalOptions.provider) == null ? void 0 : _c.maxTokens,
7365
+ temperature: (_d = internalOptions.provider) == null ? void 0 : _d.temperature,
7366
+ topP: (_e = internalOptions.provider) == null ? void 0 : _e.topP,
7367
+ frequencyPenalty: (_f = internalOptions.provider) == null ? void 0 : _f.frequencyPenalty,
7368
+ presencePenalty: (_g = internalOptions.provider) == null ? void 0 : _g.presencePenalty
7369
+ }
7314
7370
  },
7315
7371
  traceId: operationContext.historyEntry.id
7316
7372
  };
@@ -7346,7 +7402,7 @@ ${context}`;
7346
7402
  }
7347
7403
  }),
7348
7404
  onFinish: (result) => __async(this, null, function* () {
7349
- var _a2, _b2;
7405
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
7350
7406
  if (!operationContext.isActive) {
7351
7407
  return;
7352
7408
  }
@@ -7369,7 +7425,15 @@ ${context}`;
7369
7425
  displayName: this.name,
7370
7426
  id: this.id,
7371
7427
  usage: result.usage,
7372
- userContext: Object.fromEntries(operationContext.userContext.entries())
7428
+ userContext: Object.fromEntries(operationContext.userContext.entries()),
7429
+ modelParameters: {
7430
+ model: this.getModelName(),
7431
+ maxTokens: (_a2 = internalOptions.provider) == null ? void 0 : _a2.maxTokens,
7432
+ temperature: (_b2 = internalOptions.provider) == null ? void 0 : _b2.temperature,
7433
+ topP: (_c2 = internalOptions.provider) == null ? void 0 : _c2.topP,
7434
+ frequencyPenalty: (_d2 = internalOptions.provider) == null ? void 0 : _d2.frequencyPenalty,
7435
+ presencePenalty: (_e2 = internalOptions.provider) == null ? void 0 : _e2.presencePenalty
7436
+ }
7373
7437
  },
7374
7438
  traceId: operationContext.historyEntry.id,
7375
7439
  parentEventId: agentStartInfo.eventId
@@ -7398,7 +7462,7 @@ ${context}`;
7398
7462
  status: "completed"
7399
7463
  });
7400
7464
  operationContext.isActive = false;
7401
- yield (_b2 = (_a2 = this.hooks).onEnd) == null ? void 0 : _b2.call(_a2, {
7465
+ yield (_g2 = (_f2 = this.hooks).onEnd) == null ? void 0 : _g2.call(_f2, {
7402
7466
  agent: this,
7403
7467
  output: result,
7404
7468
  error: void 0,
@@ -7489,7 +7553,7 @@ ${context}`;
7489
7553
  return typedResponse;
7490
7554
  } catch (error) {
7491
7555
  operationContext.isActive = false;
7492
- yield (_d = (_c = this.hooks).onEnd) == null ? void 0 : _d.call(_c, {
7556
+ yield (_i = (_h = this.hooks).onEnd) == null ? void 0 : _i.call(_h, {
7493
7557
  agent: this,
7494
7558
  output: void 0,
7495
7559
  error,