@voltagent/core 1.2.18 → 1.2.20
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.mts +57 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +151 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -457,6 +457,11 @@ type ProviderTextResponse<TOriginalResponse> = {
|
|
|
457
457
|
type StreamPart = TextStreamPart<any> & {
|
|
458
458
|
subAgentId?: string;
|
|
459
459
|
subAgentName?: string;
|
|
460
|
+
executingAgentId?: string;
|
|
461
|
+
executingAgentName?: string;
|
|
462
|
+
parentAgentId?: string;
|
|
463
|
+
parentAgentName?: string;
|
|
464
|
+
agentPath?: string[];
|
|
460
465
|
};
|
|
461
466
|
/**
|
|
462
467
|
* Response type for text streaming operations
|
|
@@ -1986,6 +1991,15 @@ type VoltOpsDiscordCredential = VoltOpsStoredCredentialRef | WithCredentialMetad
|
|
|
1986
1991
|
}> | WithCredentialMetadata<{
|
|
1987
1992
|
webhookUrl: string;
|
|
1988
1993
|
}>;
|
|
1994
|
+
type VoltOpsPostgresCredential = VoltOpsStoredCredentialRef | WithCredentialMetadata<{
|
|
1995
|
+
host: string;
|
|
1996
|
+
port?: number;
|
|
1997
|
+
user: string;
|
|
1998
|
+
password: string;
|
|
1999
|
+
database: string;
|
|
2000
|
+
ssl?: boolean;
|
|
2001
|
+
rejectUnauthorized?: boolean;
|
|
2002
|
+
}>;
|
|
1989
2003
|
type VoltOpsGmailCredential = VoltOpsStoredCredentialRef | WithCredentialMetadata<{
|
|
1990
2004
|
accessToken?: string;
|
|
1991
2005
|
refreshToken?: string;
|
|
@@ -2176,6 +2190,22 @@ interface VoltOpsDiscordMemberRoleParams extends VoltOpsDiscordBaseParams {
|
|
|
2176
2190
|
userId: string;
|
|
2177
2191
|
roleId: string;
|
|
2178
2192
|
}
|
|
2193
|
+
interface VoltOpsPostgresBaseParams {
|
|
2194
|
+
credential: VoltOpsPostgresCredential;
|
|
2195
|
+
actionId?: string;
|
|
2196
|
+
catalogId?: string;
|
|
2197
|
+
projectId?: string | null;
|
|
2198
|
+
}
|
|
2199
|
+
interface VoltOpsPostgresExecuteParams extends VoltOpsPostgresBaseParams {
|
|
2200
|
+
query: string;
|
|
2201
|
+
parameters?: unknown[];
|
|
2202
|
+
applicationName?: string;
|
|
2203
|
+
statementTimeoutMs?: number;
|
|
2204
|
+
connectionTimeoutMs?: number;
|
|
2205
|
+
ssl?: {
|
|
2206
|
+
rejectUnauthorized?: boolean;
|
|
2207
|
+
};
|
|
2208
|
+
}
|
|
2179
2209
|
interface VoltOpsGmailBaseParams {
|
|
2180
2210
|
credential: VoltOpsGmailCredential;
|
|
2181
2211
|
actionId?: string;
|
|
@@ -2258,6 +2288,9 @@ type VoltOpsActionsApi = {
|
|
|
2258
2288
|
getEmail: (params: VoltOpsGmailGetEmailParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2259
2289
|
getThread: (params: VoltOpsGmailGetThreadParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2260
2290
|
};
|
|
2291
|
+
postgres: {
|
|
2292
|
+
executeQuery: (params: VoltOpsPostgresExecuteParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2293
|
+
};
|
|
2261
2294
|
};
|
|
2262
2295
|
interface VoltOpsEvalsApi {
|
|
2263
2296
|
runs: {
|
|
@@ -2702,6 +2735,9 @@ declare class VoltOpsActionsClient {
|
|
|
2702
2735
|
getEmail: (params: VoltOpsGmailGetEmailParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2703
2736
|
getThread: (params: VoltOpsGmailGetThreadParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2704
2737
|
};
|
|
2738
|
+
readonly postgres: {
|
|
2739
|
+
executeQuery: (params: VoltOpsPostgresExecuteParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2740
|
+
};
|
|
2705
2741
|
constructor(transport: VoltOpsActionsTransport, options?: {
|
|
2706
2742
|
useProjectEndpoint?: boolean;
|
|
2707
2743
|
});
|
|
@@ -2722,6 +2758,7 @@ declare class VoltOpsActionsClient {
|
|
|
2722
2758
|
private searchGmailEmails;
|
|
2723
2759
|
private getGmailEmail;
|
|
2724
2760
|
private getGmailThread;
|
|
2761
|
+
private executePostgresQuery;
|
|
2725
2762
|
private sendDiscordMessage;
|
|
2726
2763
|
private sendDiscordWebhookMessage;
|
|
2727
2764
|
private deleteDiscordMessage;
|
|
@@ -2749,6 +2786,7 @@ declare class VoltOpsActionsClient {
|
|
|
2749
2786
|
private ensureSlackCredential;
|
|
2750
2787
|
private ensureDiscordCredential;
|
|
2751
2788
|
private ensureGmailCredential;
|
|
2789
|
+
private ensurePostgresCredential;
|
|
2752
2790
|
private normalizeCredentialMetadata;
|
|
2753
2791
|
private normalizeIdentifier;
|
|
2754
2792
|
private ensureRecord;
|
|
@@ -3051,10 +3089,29 @@ type VoltAgentTextStreamPart<TOOLS extends Record<string, any> = Record<string,
|
|
|
3051
3089
|
* Optional identifier for the subagent that generated this event
|
|
3052
3090
|
*/
|
|
3053
3091
|
subAgentId?: string;
|
|
3092
|
+
/**
|
|
3093
|
+
* Optional identifier for the agent that actually executed the step
|
|
3094
|
+
* (same as subAgentId for first-level handoffs)
|
|
3095
|
+
*/
|
|
3096
|
+
executingAgentId?: string;
|
|
3054
3097
|
/**
|
|
3055
3098
|
* Optional name of the subagent that generated this event
|
|
3056
3099
|
*/
|
|
3057
3100
|
subAgentName?: string;
|
|
3101
|
+
/**
|
|
3102
|
+
* Optional name of the agent that actually executed the step
|
|
3103
|
+
* (same as subAgentName for first-level handoffs)
|
|
3104
|
+
*/
|
|
3105
|
+
executingAgentName?: string;
|
|
3106
|
+
/**
|
|
3107
|
+
* Parent agent reference when forwarded through supervisors
|
|
3108
|
+
*/
|
|
3109
|
+
parentAgentId?: string;
|
|
3110
|
+
parentAgentName?: string;
|
|
3111
|
+
/**
|
|
3112
|
+
* Ordered list of agent names from supervisor -> executing agent
|
|
3113
|
+
*/
|
|
3114
|
+
agentPath?: string[];
|
|
3058
3115
|
};
|
|
3059
3116
|
/**
|
|
3060
3117
|
* Extended StreamTextResult that uses VoltAgentTextStreamPart for fullStream.
|
package/dist/index.d.ts
CHANGED
|
@@ -457,6 +457,11 @@ type ProviderTextResponse<TOriginalResponse> = {
|
|
|
457
457
|
type StreamPart = TextStreamPart<any> & {
|
|
458
458
|
subAgentId?: string;
|
|
459
459
|
subAgentName?: string;
|
|
460
|
+
executingAgentId?: string;
|
|
461
|
+
executingAgentName?: string;
|
|
462
|
+
parentAgentId?: string;
|
|
463
|
+
parentAgentName?: string;
|
|
464
|
+
agentPath?: string[];
|
|
460
465
|
};
|
|
461
466
|
/**
|
|
462
467
|
* Response type for text streaming operations
|
|
@@ -1986,6 +1991,15 @@ type VoltOpsDiscordCredential = VoltOpsStoredCredentialRef | WithCredentialMetad
|
|
|
1986
1991
|
}> | WithCredentialMetadata<{
|
|
1987
1992
|
webhookUrl: string;
|
|
1988
1993
|
}>;
|
|
1994
|
+
type VoltOpsPostgresCredential = VoltOpsStoredCredentialRef | WithCredentialMetadata<{
|
|
1995
|
+
host: string;
|
|
1996
|
+
port?: number;
|
|
1997
|
+
user: string;
|
|
1998
|
+
password: string;
|
|
1999
|
+
database: string;
|
|
2000
|
+
ssl?: boolean;
|
|
2001
|
+
rejectUnauthorized?: boolean;
|
|
2002
|
+
}>;
|
|
1989
2003
|
type VoltOpsGmailCredential = VoltOpsStoredCredentialRef | WithCredentialMetadata<{
|
|
1990
2004
|
accessToken?: string;
|
|
1991
2005
|
refreshToken?: string;
|
|
@@ -2176,6 +2190,22 @@ interface VoltOpsDiscordMemberRoleParams extends VoltOpsDiscordBaseParams {
|
|
|
2176
2190
|
userId: string;
|
|
2177
2191
|
roleId: string;
|
|
2178
2192
|
}
|
|
2193
|
+
interface VoltOpsPostgresBaseParams {
|
|
2194
|
+
credential: VoltOpsPostgresCredential;
|
|
2195
|
+
actionId?: string;
|
|
2196
|
+
catalogId?: string;
|
|
2197
|
+
projectId?: string | null;
|
|
2198
|
+
}
|
|
2199
|
+
interface VoltOpsPostgresExecuteParams extends VoltOpsPostgresBaseParams {
|
|
2200
|
+
query: string;
|
|
2201
|
+
parameters?: unknown[];
|
|
2202
|
+
applicationName?: string;
|
|
2203
|
+
statementTimeoutMs?: number;
|
|
2204
|
+
connectionTimeoutMs?: number;
|
|
2205
|
+
ssl?: {
|
|
2206
|
+
rejectUnauthorized?: boolean;
|
|
2207
|
+
};
|
|
2208
|
+
}
|
|
2179
2209
|
interface VoltOpsGmailBaseParams {
|
|
2180
2210
|
credential: VoltOpsGmailCredential;
|
|
2181
2211
|
actionId?: string;
|
|
@@ -2258,6 +2288,9 @@ type VoltOpsActionsApi = {
|
|
|
2258
2288
|
getEmail: (params: VoltOpsGmailGetEmailParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2259
2289
|
getThread: (params: VoltOpsGmailGetThreadParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2260
2290
|
};
|
|
2291
|
+
postgres: {
|
|
2292
|
+
executeQuery: (params: VoltOpsPostgresExecuteParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2293
|
+
};
|
|
2261
2294
|
};
|
|
2262
2295
|
interface VoltOpsEvalsApi {
|
|
2263
2296
|
runs: {
|
|
@@ -2702,6 +2735,9 @@ declare class VoltOpsActionsClient {
|
|
|
2702
2735
|
getEmail: (params: VoltOpsGmailGetEmailParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2703
2736
|
getThread: (params: VoltOpsGmailGetThreadParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2704
2737
|
};
|
|
2738
|
+
readonly postgres: {
|
|
2739
|
+
executeQuery: (params: VoltOpsPostgresExecuteParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2740
|
+
};
|
|
2705
2741
|
constructor(transport: VoltOpsActionsTransport, options?: {
|
|
2706
2742
|
useProjectEndpoint?: boolean;
|
|
2707
2743
|
});
|
|
@@ -2722,6 +2758,7 @@ declare class VoltOpsActionsClient {
|
|
|
2722
2758
|
private searchGmailEmails;
|
|
2723
2759
|
private getGmailEmail;
|
|
2724
2760
|
private getGmailThread;
|
|
2761
|
+
private executePostgresQuery;
|
|
2725
2762
|
private sendDiscordMessage;
|
|
2726
2763
|
private sendDiscordWebhookMessage;
|
|
2727
2764
|
private deleteDiscordMessage;
|
|
@@ -2749,6 +2786,7 @@ declare class VoltOpsActionsClient {
|
|
|
2749
2786
|
private ensureSlackCredential;
|
|
2750
2787
|
private ensureDiscordCredential;
|
|
2751
2788
|
private ensureGmailCredential;
|
|
2789
|
+
private ensurePostgresCredential;
|
|
2752
2790
|
private normalizeCredentialMetadata;
|
|
2753
2791
|
private normalizeIdentifier;
|
|
2754
2792
|
private ensureRecord;
|
|
@@ -3051,10 +3089,29 @@ type VoltAgentTextStreamPart<TOOLS extends Record<string, any> = Record<string,
|
|
|
3051
3089
|
* Optional identifier for the subagent that generated this event
|
|
3052
3090
|
*/
|
|
3053
3091
|
subAgentId?: string;
|
|
3092
|
+
/**
|
|
3093
|
+
* Optional identifier for the agent that actually executed the step
|
|
3094
|
+
* (same as subAgentId for first-level handoffs)
|
|
3095
|
+
*/
|
|
3096
|
+
executingAgentId?: string;
|
|
3054
3097
|
/**
|
|
3055
3098
|
* Optional name of the subagent that generated this event
|
|
3056
3099
|
*/
|
|
3057
3100
|
subAgentName?: string;
|
|
3101
|
+
/**
|
|
3102
|
+
* Optional name of the agent that actually executed the step
|
|
3103
|
+
* (same as subAgentName for first-level handoffs)
|
|
3104
|
+
*/
|
|
3105
|
+
executingAgentName?: string;
|
|
3106
|
+
/**
|
|
3107
|
+
* Parent agent reference when forwarded through supervisors
|
|
3108
|
+
*/
|
|
3109
|
+
parentAgentId?: string;
|
|
3110
|
+
parentAgentName?: string;
|
|
3111
|
+
/**
|
|
3112
|
+
* Ordered list of agent names from supervisor -> executing agent
|
|
3113
|
+
*/
|
|
3114
|
+
agentPath?: string[];
|
|
3058
3115
|
};
|
|
3059
3116
|
/**
|
|
3060
3117
|
* Extended StreamTextResult that uses VoltAgentTextStreamPart for fullStream.
|
package/dist/index.js
CHANGED
|
@@ -5850,6 +5850,21 @@ var WorkflowStreamWriterImpl = class {
|
|
|
5850
5850
|
if (part.subAgentName) {
|
|
5851
5851
|
metadata.subAgentName = part.subAgentName;
|
|
5852
5852
|
}
|
|
5853
|
+
if (part.executingAgentId) {
|
|
5854
|
+
metadata.executingAgentId = part.executingAgentId;
|
|
5855
|
+
}
|
|
5856
|
+
if (part.executingAgentName) {
|
|
5857
|
+
metadata.executingAgentName = part.executingAgentName;
|
|
5858
|
+
}
|
|
5859
|
+
if (part.parentAgentId) {
|
|
5860
|
+
metadata.parentAgentId = part.parentAgentId;
|
|
5861
|
+
}
|
|
5862
|
+
if (part.parentAgentName) {
|
|
5863
|
+
metadata.parentAgentName = part.parentAgentName;
|
|
5864
|
+
}
|
|
5865
|
+
if (part.agentPath) {
|
|
5866
|
+
metadata.agentPath = part.agentPath;
|
|
5867
|
+
}
|
|
5853
5868
|
let input;
|
|
5854
5869
|
let output;
|
|
5855
5870
|
let status;
|
|
@@ -8982,6 +8997,9 @@ var VoltOpsActionsClient = class {
|
|
|
8982
8997
|
getEmail: this.getGmailEmail.bind(this),
|
|
8983
8998
|
getThread: this.getGmailThread.bind(this)
|
|
8984
8999
|
};
|
|
9000
|
+
this.postgres = {
|
|
9001
|
+
executeQuery: this.executePostgresQuery.bind(this)
|
|
9002
|
+
};
|
|
8985
9003
|
}
|
|
8986
9004
|
static {
|
|
8987
9005
|
__name(this, "VoltOpsActionsClient");
|
|
@@ -8990,6 +9008,7 @@ var VoltOpsActionsClient = class {
|
|
|
8990
9008
|
slack;
|
|
8991
9009
|
discord;
|
|
8992
9010
|
gmail;
|
|
9011
|
+
postgres;
|
|
8993
9012
|
useProjectEndpoint;
|
|
8994
9013
|
get actionExecutionPath() {
|
|
8995
9014
|
return this.useProjectEndpoint ? "/actions/project/run" : "/actions/execute";
|
|
@@ -9453,6 +9472,60 @@ var VoltOpsActionsClient = class {
|
|
|
9453
9472
|
input
|
|
9454
9473
|
});
|
|
9455
9474
|
}
|
|
9475
|
+
async executePostgresQuery(params) {
|
|
9476
|
+
if (!params || typeof params !== "object") {
|
|
9477
|
+
throw new VoltOpsActionError("params must be provided", 400);
|
|
9478
|
+
}
|
|
9479
|
+
const credential = this.ensurePostgresCredential(params.credential);
|
|
9480
|
+
const query = this.trimString(params.query);
|
|
9481
|
+
if (!query) {
|
|
9482
|
+
throw new VoltOpsActionError("query must be provided", 400);
|
|
9483
|
+
}
|
|
9484
|
+
const parameters = Array.isArray(params.parameters) ? params.parameters : [];
|
|
9485
|
+
const applicationName = this.trimString(params.applicationName);
|
|
9486
|
+
const statementTimeoutMs = this.normalizePositiveInteger(
|
|
9487
|
+
params.statementTimeoutMs,
|
|
9488
|
+
"statementTimeoutMs",
|
|
9489
|
+
{ allowZero: false }
|
|
9490
|
+
);
|
|
9491
|
+
const connectionTimeoutMs = this.normalizePositiveInteger(
|
|
9492
|
+
params.connectionTimeoutMs,
|
|
9493
|
+
"connectionTimeoutMs",
|
|
9494
|
+
{ allowZero: false }
|
|
9495
|
+
);
|
|
9496
|
+
const ssl = params.ssl && typeof params.ssl === "object" && !Array.isArray(params.ssl) ? {
|
|
9497
|
+
rejectUnauthorized: typeof params.ssl.rejectUnauthorized === "boolean" ? params.ssl.rejectUnauthorized : void 0
|
|
9498
|
+
} : void 0;
|
|
9499
|
+
const input = {
|
|
9500
|
+
query
|
|
9501
|
+
};
|
|
9502
|
+
if (parameters.length) {
|
|
9503
|
+
input.parameters = parameters;
|
|
9504
|
+
}
|
|
9505
|
+
if (applicationName) {
|
|
9506
|
+
input.applicationName = applicationName;
|
|
9507
|
+
}
|
|
9508
|
+
if (typeof statementTimeoutMs === "number") {
|
|
9509
|
+
input.statementTimeoutMs = statementTimeoutMs;
|
|
9510
|
+
}
|
|
9511
|
+
if (typeof connectionTimeoutMs === "number") {
|
|
9512
|
+
input.connectionTimeoutMs = connectionTimeoutMs;
|
|
9513
|
+
}
|
|
9514
|
+
if (ssl) {
|
|
9515
|
+
input.ssl = ssl;
|
|
9516
|
+
}
|
|
9517
|
+
const payload = {
|
|
9518
|
+
credential,
|
|
9519
|
+
catalogId: params.catalogId ?? void 0,
|
|
9520
|
+
actionId: params.actionId ?? "postgres.executeQuery",
|
|
9521
|
+
projectId: params.projectId ?? void 0,
|
|
9522
|
+
payload: {
|
|
9523
|
+
input
|
|
9524
|
+
}
|
|
9525
|
+
};
|
|
9526
|
+
const response = await this.postActionExecution(this.actionExecutionPath, payload);
|
|
9527
|
+
return this.mapActionExecution(response);
|
|
9528
|
+
}
|
|
9456
9529
|
async sendDiscordMessage(params) {
|
|
9457
9530
|
if (!params || typeof params !== "object") {
|
|
9458
9531
|
throw new VoltOpsActionError("params must be provided", 400);
|
|
@@ -10052,6 +10125,51 @@ var VoltOpsActionsClient = class {
|
|
|
10052
10125
|
}
|
|
10053
10126
|
return payload;
|
|
10054
10127
|
}
|
|
10128
|
+
ensurePostgresCredential(value) {
|
|
10129
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
10130
|
+
throw new VoltOpsActionError("credential must be an object", 400);
|
|
10131
|
+
}
|
|
10132
|
+
const record = value;
|
|
10133
|
+
const metadata = this.normalizeCredentialMetadata(record.metadata);
|
|
10134
|
+
const storedId = this.trimString(
|
|
10135
|
+
typeof record.credentialId === "string" ? record.credentialId : typeof record.id === "string" ? record.id : void 0
|
|
10136
|
+
);
|
|
10137
|
+
if (storedId) {
|
|
10138
|
+
return metadata ? { credentialId: storedId, metadata } : { credentialId: storedId };
|
|
10139
|
+
}
|
|
10140
|
+
const host = this.trimString(record.host);
|
|
10141
|
+
const user = this.trimString(record.user);
|
|
10142
|
+
const password = this.trimString(record.password);
|
|
10143
|
+
const database = this.trimString(record.database);
|
|
10144
|
+
if (!host || !user || !password || !database) {
|
|
10145
|
+
throw new VoltOpsActionError(
|
|
10146
|
+
"credential must include host, user, password, and database for Postgres actions",
|
|
10147
|
+
400
|
|
10148
|
+
);
|
|
10149
|
+
}
|
|
10150
|
+
const port = typeof record.port === "number" && Number.isFinite(record.port) ? Math.trunc(record.port) : void 0;
|
|
10151
|
+
const ssl = typeof record.ssl === "boolean" ? record.ssl : void 0;
|
|
10152
|
+
const rejectUnauthorized = typeof record.rejectUnauthorized === "boolean" ? record.rejectUnauthorized : void 0;
|
|
10153
|
+
const payload = {
|
|
10154
|
+
host,
|
|
10155
|
+
user,
|
|
10156
|
+
password,
|
|
10157
|
+
database
|
|
10158
|
+
};
|
|
10159
|
+
if (port !== void 0) {
|
|
10160
|
+
payload.port = port;
|
|
10161
|
+
}
|
|
10162
|
+
if (ssl !== void 0) {
|
|
10163
|
+
payload.ssl = ssl;
|
|
10164
|
+
}
|
|
10165
|
+
if (rejectUnauthorized !== void 0) {
|
|
10166
|
+
payload.rejectUnauthorized = rejectUnauthorized;
|
|
10167
|
+
}
|
|
10168
|
+
if (metadata) {
|
|
10169
|
+
payload.metadata = metadata;
|
|
10170
|
+
}
|
|
10171
|
+
return payload;
|
|
10172
|
+
}
|
|
10055
10173
|
normalizeCredentialMetadata(metadata) {
|
|
10056
10174
|
if (metadata === void 0 || metadata === null) {
|
|
10057
10175
|
return void 0;
|
|
@@ -10116,7 +10234,7 @@ var VoltOpsActionsClient = class {
|
|
|
10116
10234
|
}
|
|
10117
10235
|
return entries.length > 0 ? entries : void 0;
|
|
10118
10236
|
}
|
|
10119
|
-
normalizePositiveInteger(value, field) {
|
|
10237
|
+
normalizePositiveInteger(value, field, options) {
|
|
10120
10238
|
if (value === void 0 || value === null) {
|
|
10121
10239
|
return void 0;
|
|
10122
10240
|
}
|
|
@@ -10124,8 +10242,9 @@ var VoltOpsActionsClient = class {
|
|
|
10124
10242
|
throw new VoltOpsActionError(`${field} must be a finite number`, 400);
|
|
10125
10243
|
}
|
|
10126
10244
|
const normalized = Math.floor(value);
|
|
10127
|
-
|
|
10128
|
-
|
|
10245
|
+
const allowZero = options?.allowZero ?? false;
|
|
10246
|
+
if (normalized < 0 || !allowZero && normalized === 0) {
|
|
10247
|
+
throw new VoltOpsActionError(`${field} must be greater than ${allowZero ? "-1" : "0"}`, 400);
|
|
10129
10248
|
}
|
|
10130
10249
|
return normalized;
|
|
10131
10250
|
}
|
|
@@ -15994,11 +16113,11 @@ function createMetadataEnrichedStream(originalStream, metadata, allowedTypes) {
|
|
|
15994
16113
|
type: SUBAGENT_DATA_EVENT_TYPE,
|
|
15995
16114
|
// Don't include id to prevent overwriting in AI SDK - each delta should be a new part
|
|
15996
16115
|
data: {
|
|
15997
|
-
|
|
15998
|
-
|
|
15999
|
-
|
|
16000
|
-
//
|
|
16001
|
-
|
|
16116
|
+
// Include original chunk first so metadata can override it
|
|
16117
|
+
...chunkObj,
|
|
16118
|
+
...metadata,
|
|
16119
|
+
// Preserve the original event type for consumers
|
|
16120
|
+
originalType: chunkObj.type
|
|
16002
16121
|
}
|
|
16003
16122
|
};
|
|
16004
16123
|
controller.enqueue(dataEvent);
|
|
@@ -16300,6 +16419,10 @@ Context: ${(0, import_utils17.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
16300
16419
|
};
|
|
16301
16420
|
if (this.isDirectAgent(targetAgentConfig)) {
|
|
16302
16421
|
const response = await targetAgent.streamText(messages, baseOptions);
|
|
16422
|
+
const forwardingMetadata = this.buildForwardingMetadata(
|
|
16423
|
+
targetAgent,
|
|
16424
|
+
parentOperationContext
|
|
16425
|
+
);
|
|
16303
16426
|
const uiStreamWriter = parentOperationContext?.systemContext?.get(
|
|
16304
16427
|
"uiStreamWriter"
|
|
16305
16428
|
);
|
|
@@ -16310,10 +16433,7 @@ Context: ${(0, import_utils17.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
16310
16433
|
const subagentUIStream = response.toUIMessageStream();
|
|
16311
16434
|
const enrichedStream = createMetadataEnrichedStream(
|
|
16312
16435
|
subagentUIStream,
|
|
16313
|
-
|
|
16314
|
-
subAgentId: targetAgent.id,
|
|
16315
|
-
subAgentName: targetAgent.name
|
|
16316
|
-
},
|
|
16436
|
+
forwardingMetadata,
|
|
16317
16437
|
this.supervisorConfig?.fullStreamEventForwarding?.types || ["tool-call", "tool-result"]
|
|
16318
16438
|
);
|
|
16319
16439
|
uiStreamWriter.merge(enrichedStream);
|
|
@@ -16331,8 +16451,7 @@ Context: ${(0, import_utils17.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
16331
16451
|
}
|
|
16332
16452
|
const enrichedPart = {
|
|
16333
16453
|
...part,
|
|
16334
|
-
|
|
16335
|
-
subAgentName: targetAgent.name
|
|
16454
|
+
...forwardingMetadata
|
|
16336
16455
|
};
|
|
16337
16456
|
this.registerToolCallMetadata(parentOperationContext, enrichedPart, targetAgent);
|
|
16338
16457
|
await fullStreamWriter.write(enrichedPart);
|
|
@@ -16358,6 +16477,10 @@ Context: ${(0, import_utils17.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
16358
16477
|
} else if (this.isStreamTextConfig(targetAgentConfig)) {
|
|
16359
16478
|
const options2 = { ...baseOptions, ...targetAgentConfig.options };
|
|
16360
16479
|
const response = await targetAgent.streamText(messages, options2);
|
|
16480
|
+
const forwardingMetadata = this.buildForwardingMetadata(
|
|
16481
|
+
targetAgent,
|
|
16482
|
+
parentOperationContext
|
|
16483
|
+
);
|
|
16361
16484
|
const uiStreamWriter = parentOperationContext?.systemContext?.get(
|
|
16362
16485
|
"uiStreamWriter"
|
|
16363
16486
|
);
|
|
@@ -16368,10 +16491,7 @@ Context: ${(0, import_utils17.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
16368
16491
|
const subagentUIStream = response.toUIMessageStream();
|
|
16369
16492
|
const enrichedStream = createMetadataEnrichedStream(
|
|
16370
16493
|
subagentUIStream,
|
|
16371
|
-
|
|
16372
|
-
subAgentId: targetAgent.id,
|
|
16373
|
-
subAgentName: targetAgent.name
|
|
16374
|
-
},
|
|
16494
|
+
forwardingMetadata,
|
|
16375
16495
|
this.supervisorConfig?.fullStreamEventForwarding?.types || ["tool-call", "tool-result"]
|
|
16376
16496
|
);
|
|
16377
16497
|
uiStreamWriter.merge(enrichedStream);
|
|
@@ -16389,8 +16509,7 @@ Context: ${(0, import_utils17.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
16389
16509
|
}
|
|
16390
16510
|
const enrichedPart = {
|
|
16391
16511
|
...part,
|
|
16392
|
-
|
|
16393
|
-
subAgentName: targetAgent.name
|
|
16512
|
+
...forwardingMetadata
|
|
16394
16513
|
};
|
|
16395
16514
|
this.registerToolCallMetadata(parentOperationContext, enrichedPart, targetAgent);
|
|
16396
16515
|
await fullStreamWriter.write(enrichedPart);
|
|
@@ -16686,6 +16805,18 @@ Context: ${(0, import_utils17.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
16686
16805
|
return subAgentData;
|
|
16687
16806
|
});
|
|
16688
16807
|
}
|
|
16808
|
+
buildForwardingMetadata(agent, oc) {
|
|
16809
|
+
const parentMetadata = oc?.systemContext?.get(AGENT_METADATA_CONTEXT_KEY);
|
|
16810
|
+
return {
|
|
16811
|
+
subAgentId: agent.id,
|
|
16812
|
+
subAgentName: agent.name,
|
|
16813
|
+
executingAgentId: agent.id,
|
|
16814
|
+
executingAgentName: agent.name,
|
|
16815
|
+
parentAgentId: parentMetadata?.agentId,
|
|
16816
|
+
parentAgentName: parentMetadata?.agentName,
|
|
16817
|
+
agentPath: parentMetadata ? [parentMetadata.agentName, agent.name] : [agent.name]
|
|
16818
|
+
};
|
|
16819
|
+
}
|
|
16689
16820
|
registerToolCallMetadata(oc, part, agent) {
|
|
16690
16821
|
if (!oc || !part?.type || !part.type.startsWith("tool-") || !part.toolCallId) {
|
|
16691
16822
|
return;
|