@voltagent/core 0.1.45 → 0.1.46
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 +4 -4
- package/dist/index.js +21 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -790,8 +790,8 @@ type InferStreamEventBase<TStreamPart extends StreamPart> = {
|
|
|
790
790
|
type InferStreamEventData<TStreamPart extends StreamPart> = Simplify<Omit<TStreamPart, "type" | "subAgentId" | "subAgentName">>;
|
|
791
791
|
|
|
792
792
|
interface StreamEventForwarderOptions {
|
|
793
|
-
forwarder
|
|
794
|
-
|
|
793
|
+
forwarder: (event: StreamEvent) => Promise<void>;
|
|
794
|
+
types: Array<LiteralUnion<StreamEventType, string>> | ReadonlyArray<LiteralUnion<StreamEventType, string>>;
|
|
795
795
|
addSubAgentPrefix?: boolean;
|
|
796
796
|
}
|
|
797
797
|
/**
|
|
@@ -799,13 +799,13 @@ interface StreamEventForwarderOptions {
|
|
|
799
799
|
* @param event - The SubAgent event to forward
|
|
800
800
|
* @param options - Configuration options for forwarding
|
|
801
801
|
*/
|
|
802
|
-
declare function streamEventForwarder(event: StreamEvent, options
|
|
802
|
+
declare function streamEventForwarder(event: StreamEvent, options: StreamEventForwarderOptions): Promise<void>;
|
|
803
803
|
/**
|
|
804
804
|
* Creates a configured streamEventForwarder function
|
|
805
805
|
* @param options - Configuration options
|
|
806
806
|
* @returns A configured forwarder function
|
|
807
807
|
*/
|
|
808
|
-
declare function createStreamEventForwarder(options
|
|
808
|
+
declare function createStreamEventForwarder(options: StreamEventForwarderOptions): (event: StreamEvent) => Promise<void>;
|
|
809
809
|
|
|
810
810
|
/**
|
|
811
811
|
* Options object for dynamic value resolution
|
package/dist/index.js
CHANGED
|
@@ -3199,8 +3199,8 @@ __name(serializeValueForDebug, "serializeValueForDebug");
|
|
|
3199
3199
|
|
|
3200
3200
|
// src/utils/streams/stream-event-forwarder.ts
|
|
3201
3201
|
var import_dev5 = require("@voltagent/internal/dev");
|
|
3202
|
-
async function streamEventForwarder(event, options
|
|
3203
|
-
const { forwarder,
|
|
3202
|
+
async function streamEventForwarder(event, options) {
|
|
3203
|
+
const { forwarder, types } = options;
|
|
3204
3204
|
try {
|
|
3205
3205
|
if (!event || typeof event !== "object") {
|
|
3206
3206
|
import_dev5.devLogger.warn("[StreamEventForwarder] Invalid event structure:", event);
|
|
@@ -3214,7 +3214,7 @@ async function streamEventForwarder(event, options = {}) {
|
|
|
3214
3214
|
});
|
|
3215
3215
|
return;
|
|
3216
3216
|
}
|
|
3217
|
-
if (
|
|
3217
|
+
if (!types.includes(event.type)) {
|
|
3218
3218
|
import_dev5.devLogger.info(
|
|
3219
3219
|
"[StreamEventForwarder] Filtered out",
|
|
3220
3220
|
event.type,
|
|
@@ -3223,9 +3223,6 @@ async function streamEventForwarder(event, options = {}) {
|
|
|
3223
3223
|
);
|
|
3224
3224
|
return;
|
|
3225
3225
|
}
|
|
3226
|
-
if (!forwarder) {
|
|
3227
|
-
return;
|
|
3228
|
-
}
|
|
3229
3226
|
await forwarder(formatEvent(event, options));
|
|
3230
3227
|
import_dev5.devLogger.info(
|
|
3231
3228
|
"[StreamEventForwarder] Forwarded",
|
|
@@ -3238,7 +3235,7 @@ async function streamEventForwarder(event, options = {}) {
|
|
|
3238
3235
|
}
|
|
3239
3236
|
}
|
|
3240
3237
|
__name(streamEventForwarder, "streamEventForwarder");
|
|
3241
|
-
function createStreamEventForwarder(options
|
|
3238
|
+
function createStreamEventForwarder(options) {
|
|
3242
3239
|
return (event) => streamEventForwarder(event, options);
|
|
3243
3240
|
}
|
|
3244
3241
|
__name(createStreamEventForwarder, "createStreamEventForwarder");
|
|
@@ -7322,36 +7319,36 @@ var Agent = class {
|
|
|
7322
7319
|
/**
|
|
7323
7320
|
* Resolve dynamic instructions based on user context
|
|
7324
7321
|
*/
|
|
7325
|
-
|
|
7322
|
+
async resolveInstructions(options) {
|
|
7326
7323
|
if (!this.dynamicInstructions)
|
|
7327
7324
|
return this.instructions;
|
|
7328
7325
|
if (typeof this.dynamicInstructions === "function") {
|
|
7329
7326
|
return await this.dynamicInstructions(options);
|
|
7330
7327
|
}
|
|
7331
7328
|
return this.dynamicInstructions;
|
|
7332
|
-
}
|
|
7329
|
+
}
|
|
7333
7330
|
/**
|
|
7334
7331
|
* Resolve dynamic model based on user context
|
|
7335
7332
|
*/
|
|
7336
|
-
|
|
7333
|
+
async resolveModel(options) {
|
|
7337
7334
|
if (!this.dynamicModel)
|
|
7338
7335
|
return this.model;
|
|
7339
7336
|
if (typeof this.dynamicModel === "function") {
|
|
7340
7337
|
return await this.dynamicModel(options);
|
|
7341
7338
|
}
|
|
7342
7339
|
return this.dynamicModel;
|
|
7343
|
-
}
|
|
7340
|
+
}
|
|
7344
7341
|
/**
|
|
7345
7342
|
* Resolve dynamic tools based on user context
|
|
7346
7343
|
*/
|
|
7347
|
-
|
|
7344
|
+
async resolveTools(options) {
|
|
7348
7345
|
if (!this.dynamicTools)
|
|
7349
7346
|
return [];
|
|
7350
7347
|
if (typeof this.dynamicTools === "function") {
|
|
7351
7348
|
return await this.dynamicTools(options);
|
|
7352
7349
|
}
|
|
7353
7350
|
return this.dynamicTools;
|
|
7354
|
-
}
|
|
7351
|
+
}
|
|
7355
7352
|
/**
|
|
7356
7353
|
* Get the system message for the agent
|
|
7357
7354
|
*/
|
|
@@ -7602,12 +7599,13 @@ ${context}`;
|
|
|
7602
7599
|
import_dev14.devLogger.info(
|
|
7603
7600
|
`[Agent ${this.id}] Received SubAgent event: ${event.type} from ${event.subAgentName}`
|
|
7604
7601
|
);
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7602
|
+
if (internalStreamForwarder) {
|
|
7603
|
+
await streamEventForwarder(event, {
|
|
7604
|
+
forwarder: internalStreamForwarder,
|
|
7605
|
+
types: ["tool-call", "tool-result"],
|
|
7606
|
+
addSubAgentPrefix: true
|
|
7607
|
+
});
|
|
7608
|
+
}
|
|
7611
7609
|
}, "forwardEvent");
|
|
7612
7610
|
const delegateTool = this.subAgentManager.createDelegateTool({
|
|
7613
7611
|
sourceAgent: this,
|
|
@@ -7734,7 +7732,7 @@ ${context}`;
|
|
|
7734
7732
|
/**
|
|
7735
7733
|
* Fix delete operator usage for better performance
|
|
7736
7734
|
*/
|
|
7737
|
-
addToolEvent
|
|
7735
|
+
addToolEvent(context, toolName, status, data = {}) {
|
|
7738
7736
|
if (!context.toolSpans) {
|
|
7739
7737
|
context.toolSpans = /* @__PURE__ */ new Map();
|
|
7740
7738
|
}
|
|
@@ -7754,11 +7752,11 @@ ${context}`;
|
|
|
7754
7752
|
context.toolSpans.set(toolCallId, toolSpan);
|
|
7755
7753
|
}
|
|
7756
7754
|
}
|
|
7757
|
-
}
|
|
7755
|
+
}
|
|
7758
7756
|
/**
|
|
7759
7757
|
* Agent event creator (update)
|
|
7760
7758
|
*/
|
|
7761
|
-
addAgentEvent
|
|
7759
|
+
addAgentEvent(context, eventName, status, data = {}) {
|
|
7762
7760
|
const otelSpan = context.otelSpan;
|
|
7763
7761
|
if (otelSpan) {
|
|
7764
7762
|
endOperationSpan({
|
|
@@ -7771,7 +7769,7 @@ ${context}`;
|
|
|
7771
7769
|
`OpenTelemetry span not found in OperationContext for agent event ${eventName} (Operation ID: ${context.operationId})`
|
|
7772
7770
|
);
|
|
7773
7771
|
}
|
|
7774
|
-
}
|
|
7772
|
+
}
|
|
7775
7773
|
/**
|
|
7776
7774
|
* Helper method to enrich and end an OpenTelemetry span associated with a tool call.
|
|
7777
7775
|
*/
|