@robosystems/client 0.3.27 → 0.3.28
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/artifacts/{AgentClient.d.ts → OperatorClient.d.ts} +18 -18
- package/artifacts/{AgentClient.js → OperatorClient.js} +45 -45
- package/artifacts/{AgentClient.ts → OperatorClient.ts} +74 -70
- package/artifacts/graphql/generated/graphql.d.ts +3 -0
- package/artifacts/graphql/generated/graphql.ts +4 -0
- package/artifacts/index.d.ts +7 -7
- package/artifacts/index.js +11 -11
- package/artifacts/index.ts +11 -11
- package/index.ts +2 -2
- package/package.json +1 -1
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +8 -8
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +13 -13
- package/sdk/sdk.gen.js +24 -24
- package/sdk/sdk.gen.ts +19 -19
- package/sdk/types.gen.d.ts +885 -885
- package/sdk/types.gen.ts +1027 -1027
- package/sdk.gen.d.ts +13 -13
- package/sdk.gen.js +24 -24
- package/sdk.gen.ts +19 -19
- package/types.gen.d.ts +885 -885
- package/types.gen.ts +1027 -1027
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface OperatorQueryRequest {
|
|
2
2
|
message: string;
|
|
3
3
|
history?: Array<{
|
|
4
4
|
role: string;
|
|
@@ -9,14 +9,14 @@ export interface AgentQueryRequest {
|
|
|
9
9
|
enableRag?: boolean;
|
|
10
10
|
forceExtendedAnalysis?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
12
|
+
export interface OperatorOptions {
|
|
13
13
|
mode?: 'auto' | 'sync' | 'async';
|
|
14
14
|
maxWait?: number;
|
|
15
15
|
onProgress?: (message: string, percentage?: number) => void;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
17
|
+
export interface OperatorResult {
|
|
18
18
|
content: string;
|
|
19
|
-
|
|
19
|
+
operator_used: string;
|
|
20
20
|
mode_used: 'quick' | 'standard' | 'extended' | 'streaming';
|
|
21
21
|
metadata?: Record<string, any>;
|
|
22
22
|
tokens_used?: {
|
|
@@ -28,13 +28,13 @@ export interface AgentResult {
|
|
|
28
28
|
execution_time?: number;
|
|
29
29
|
timestamp?: string;
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
31
|
+
export interface QueuedOperatorResponse {
|
|
32
32
|
status: 'queued';
|
|
33
33
|
operation_id: string;
|
|
34
34
|
message: string;
|
|
35
35
|
sse_endpoint?: string;
|
|
36
36
|
}
|
|
37
|
-
export declare class
|
|
37
|
+
export declare class OperatorClient {
|
|
38
38
|
private sseClient?;
|
|
39
39
|
private config;
|
|
40
40
|
constructor(config: {
|
|
@@ -44,30 +44,30 @@ export declare class AgentClient {
|
|
|
44
44
|
token?: string;
|
|
45
45
|
});
|
|
46
46
|
/**
|
|
47
|
-
* Execute
|
|
47
|
+
* Execute operator query with automatic operator selection
|
|
48
48
|
*/
|
|
49
|
-
executeQuery(graphId: string, request:
|
|
49
|
+
executeQuery(graphId: string, request: OperatorQueryRequest, options?: OperatorOptions): Promise<OperatorResult>;
|
|
50
50
|
/**
|
|
51
|
-
* Execute specific
|
|
51
|
+
* Execute specific operator type
|
|
52
52
|
*/
|
|
53
|
-
|
|
54
|
-
private
|
|
53
|
+
executeOperator(graphId: string, operatorType: string, request: OperatorQueryRequest, options?: OperatorOptions): Promise<OperatorResult>;
|
|
54
|
+
private waitForOperatorCompletion;
|
|
55
55
|
/**
|
|
56
56
|
* Convenience method for simple agent queries with auto-selection
|
|
57
57
|
*/
|
|
58
|
-
query(graphId: string, message: string, context?: Record<string, any>): Promise<
|
|
58
|
+
query(graphId: string, message: string, context?: Record<string, any>): Promise<OperatorResult>;
|
|
59
59
|
/**
|
|
60
60
|
* Execute financial agent for financial analysis
|
|
61
61
|
*/
|
|
62
|
-
analyzeFinancials(graphId: string, message: string, options?:
|
|
62
|
+
analyzeFinancials(graphId: string, message: string, options?: OperatorOptions): Promise<OperatorResult>;
|
|
63
63
|
/**
|
|
64
64
|
* Execute research agent for deep research
|
|
65
65
|
*/
|
|
66
|
-
research(graphId: string, message: string, options?:
|
|
66
|
+
research(graphId: string, message: string, options?: OperatorOptions): Promise<OperatorResult>;
|
|
67
67
|
/**
|
|
68
68
|
* Execute RAG agent for fast retrieval
|
|
69
69
|
*/
|
|
70
|
-
rag(graphId: string, message: string, options?:
|
|
70
|
+
rag(graphId: string, message: string, options?: OperatorOptions): Promise<OperatorResult>;
|
|
71
71
|
/**
|
|
72
72
|
* Cancel any active SSE connections
|
|
73
73
|
*/
|
|
@@ -76,7 +76,7 @@ export declare class AgentClient {
|
|
|
76
76
|
/**
|
|
77
77
|
* Error thrown when agent execution is queued and maxWait is 0
|
|
78
78
|
*/
|
|
79
|
-
export declare class
|
|
80
|
-
queueInfo:
|
|
81
|
-
constructor(queueInfo:
|
|
79
|
+
export declare class QueuedOperatorError extends Error {
|
|
80
|
+
queueInfo: QueuedOperatorResponse;
|
|
81
|
+
constructor(queueInfo: QueuedOperatorResponse);
|
|
82
82
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.QueuedOperatorError = exports.OperatorClient = void 0;
|
|
5
5
|
/**
|
|
6
|
-
* Enhanced
|
|
7
|
-
* Provides intelligent
|
|
6
|
+
* Enhanced AI Operator Client with SSE support
|
|
7
|
+
* Provides intelligent operator execution with automatic strategy selection
|
|
8
8
|
*/
|
|
9
9
|
const sdk_gen_1 = require("../sdk.gen");
|
|
10
10
|
const SSEClient_1 = require("./SSEClient");
|
|
11
|
-
class
|
|
11
|
+
class OperatorClient {
|
|
12
12
|
constructor(config) {
|
|
13
13
|
this.config = config;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Execute
|
|
16
|
+
* Execute operator query with automatic operator selection
|
|
17
17
|
*/
|
|
18
18
|
async executeQuery(graphId, request, options = {}) {
|
|
19
19
|
const data = {
|
|
20
|
-
url: '/v1/graphs/{graph_id}/
|
|
20
|
+
url: '/v1/graphs/{graph_id}/operator',
|
|
21
21
|
path: { graph_id: graphId },
|
|
22
22
|
body: {
|
|
23
23
|
message: request.message,
|
|
@@ -28,13 +28,13 @@ class AgentClient {
|
|
|
28
28
|
force_extended_analysis: request.forceExtendedAnalysis,
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
|
-
const response = await (0, sdk_gen_1.
|
|
31
|
+
const response = await (0, sdk_gen_1.autoSelectOperator)(data);
|
|
32
32
|
const responseData = response.data;
|
|
33
33
|
// Check if this is an immediate response (sync execution)
|
|
34
|
-
if (responseData?.content !== undefined && responseData?.
|
|
34
|
+
if (responseData?.content !== undefined && responseData?.operator_used) {
|
|
35
35
|
return {
|
|
36
36
|
content: responseData.content,
|
|
37
|
-
|
|
37
|
+
operator_used: responseData.operator_used,
|
|
38
38
|
mode_used: responseData.mode_used,
|
|
39
39
|
metadata: responseData.metadata,
|
|
40
40
|
tokens_used: responseData.tokens_used,
|
|
@@ -48,21 +48,21 @@ class AgentClient {
|
|
|
48
48
|
const queuedResponse = responseData;
|
|
49
49
|
// If user doesn't want to wait, throw with queue info
|
|
50
50
|
if (options.maxWait === 0) {
|
|
51
|
-
throw new
|
|
51
|
+
throw new QueuedOperatorError(queuedResponse);
|
|
52
52
|
}
|
|
53
53
|
// Use SSE to monitor the operation
|
|
54
|
-
return this.
|
|
54
|
+
return this.waitForOperatorCompletion(queuedResponse.operation_id, options);
|
|
55
55
|
}
|
|
56
56
|
// Unexpected response format
|
|
57
|
-
throw new Error('Unexpected response format from
|
|
57
|
+
throw new Error('Unexpected response format from operator endpoint');
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* Execute specific
|
|
60
|
+
* Execute specific operator type
|
|
61
61
|
*/
|
|
62
|
-
async
|
|
62
|
+
async executeOperator(graphId, operatorType, request, options = {}) {
|
|
63
63
|
const data = {
|
|
64
|
-
url: '/v1/graphs/{graph_id}/
|
|
65
|
-
path: { graph_id: graphId,
|
|
64
|
+
url: '/v1/graphs/{graph_id}/operator/{operator_type}',
|
|
65
|
+
path: { graph_id: graphId, operator_type: operatorType },
|
|
66
66
|
body: {
|
|
67
67
|
message: request.message,
|
|
68
68
|
history: request.history,
|
|
@@ -72,13 +72,13 @@ class AgentClient {
|
|
|
72
72
|
force_extended_analysis: request.forceExtendedAnalysis,
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
|
-
const response = await (0, sdk_gen_1.
|
|
75
|
+
const response = await (0, sdk_gen_1.executeSpecificOperator)(data);
|
|
76
76
|
const responseData = response.data;
|
|
77
77
|
// Check if this is an immediate response (sync execution)
|
|
78
|
-
if (responseData?.content !== undefined && responseData?.
|
|
78
|
+
if (responseData?.content !== undefined && responseData?.operator_used) {
|
|
79
79
|
return {
|
|
80
80
|
content: responseData.content,
|
|
81
|
-
|
|
81
|
+
operator_used: responseData.operator_used,
|
|
82
82
|
mode_used: responseData.mode_used,
|
|
83
83
|
metadata: responseData.metadata,
|
|
84
84
|
tokens_used: responseData.tokens_used,
|
|
@@ -92,15 +92,15 @@ class AgentClient {
|
|
|
92
92
|
const queuedResponse = responseData;
|
|
93
93
|
// If user doesn't want to wait, throw with queue info
|
|
94
94
|
if (options.maxWait === 0) {
|
|
95
|
-
throw new
|
|
95
|
+
throw new QueuedOperatorError(queuedResponse);
|
|
96
96
|
}
|
|
97
97
|
// Use SSE to monitor the operation
|
|
98
|
-
return this.
|
|
98
|
+
return this.waitForOperatorCompletion(queuedResponse.operation_id, options);
|
|
99
99
|
}
|
|
100
100
|
// Unexpected response format
|
|
101
|
-
throw new Error('Unexpected response format from
|
|
101
|
+
throw new Error('Unexpected response format from operator endpoint');
|
|
102
102
|
}
|
|
103
|
-
async
|
|
103
|
+
async waitForOperatorCompletion(operationId, options) {
|
|
104
104
|
return new Promise((resolve, reject) => {
|
|
105
105
|
const sseClient = new SSEClient_1.SSEClient(this.config);
|
|
106
106
|
sseClient
|
|
@@ -112,19 +112,19 @@ class AgentClient {
|
|
|
112
112
|
options.onProgress?.(data.message, data.progress_percentage);
|
|
113
113
|
});
|
|
114
114
|
// Listen for agent-specific events
|
|
115
|
-
sseClient.on('
|
|
116
|
-
options.onProgress?.(`
|
|
115
|
+
sseClient.on('operator_started', (data) => {
|
|
116
|
+
options.onProgress?.(`Operator ${data.operator_type} started`, 0);
|
|
117
117
|
});
|
|
118
|
-
sseClient.on('
|
|
118
|
+
sseClient.on('operator_initialized', (data) => {
|
|
119
119
|
options.onProgress?.(`${data.agent_name} initialized`, 10);
|
|
120
120
|
});
|
|
121
121
|
sseClient.on('progress', (data) => {
|
|
122
122
|
options.onProgress?.(data.message, data.percentage);
|
|
123
123
|
});
|
|
124
|
-
sseClient.on('
|
|
124
|
+
sseClient.on('operator_completed', (data) => {
|
|
125
125
|
result = {
|
|
126
126
|
content: data.content,
|
|
127
|
-
|
|
127
|
+
operator_used: data.operator_used,
|
|
128
128
|
mode_used: data.mode_used,
|
|
129
129
|
metadata: data.metadata,
|
|
130
130
|
tokens_used: data.tokens_used,
|
|
@@ -138,16 +138,16 @@ class AgentClient {
|
|
|
138
138
|
// Fallback to generic completion event
|
|
139
139
|
sseClient.on(SSEClient_1.EventType.OPERATION_COMPLETED, (data) => {
|
|
140
140
|
if (!result) {
|
|
141
|
-
const
|
|
141
|
+
const operatorResult = data.result || data;
|
|
142
142
|
result = {
|
|
143
|
-
content:
|
|
144
|
-
|
|
145
|
-
mode_used:
|
|
146
|
-
metadata:
|
|
147
|
-
tokens_used:
|
|
148
|
-
confidence_score:
|
|
149
|
-
execution_time:
|
|
150
|
-
timestamp:
|
|
143
|
+
content: operatorResult.content || '',
|
|
144
|
+
operator_used: operatorResult.operator_used || 'unknown',
|
|
145
|
+
mode_used: operatorResult.mode_used || 'standard',
|
|
146
|
+
metadata: operatorResult.metadata,
|
|
147
|
+
tokens_used: operatorResult.tokens_used,
|
|
148
|
+
confidence_score: operatorResult.confidence_score,
|
|
149
|
+
execution_time: operatorResult.execution_time,
|
|
150
|
+
timestamp: operatorResult.timestamp || new Date().toISOString(),
|
|
151
151
|
};
|
|
152
152
|
sseClient.close();
|
|
153
153
|
resolve(result);
|
|
@@ -180,19 +180,19 @@ class AgentClient {
|
|
|
180
180
|
* Execute financial agent for financial analysis
|
|
181
181
|
*/
|
|
182
182
|
async analyzeFinancials(graphId, message, options = {}) {
|
|
183
|
-
return this.
|
|
183
|
+
return this.executeOperator(graphId, 'financial', { message }, options);
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* Execute research agent for deep research
|
|
187
187
|
*/
|
|
188
188
|
async research(graphId, message, options = {}) {
|
|
189
|
-
return this.
|
|
189
|
+
return this.executeOperator(graphId, 'research', { message }, options);
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
192
192
|
* Execute RAG agent for fast retrieval
|
|
193
193
|
*/
|
|
194
194
|
async rag(graphId, message, options = {}) {
|
|
195
|
-
return this.
|
|
195
|
+
return this.executeOperator(graphId, 'rag', { message }, options);
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* Cancel any active SSE connections
|
|
@@ -204,15 +204,15 @@ class AgentClient {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
exports.
|
|
207
|
+
exports.OperatorClient = OperatorClient;
|
|
208
208
|
/**
|
|
209
209
|
* Error thrown when agent execution is queued and maxWait is 0
|
|
210
210
|
*/
|
|
211
|
-
class
|
|
211
|
+
class QueuedOperatorError extends Error {
|
|
212
212
|
constructor(queueInfo) {
|
|
213
|
-
super('
|
|
213
|
+
super('Operator execution was queued');
|
|
214
214
|
this.queueInfo = queueInfo;
|
|
215
|
-
this.name = '
|
|
215
|
+
this.name = 'QueuedOperatorError';
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
exports.
|
|
218
|
+
exports.QueuedOperatorError = QueuedOperatorError;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Enhanced
|
|
5
|
-
* Provides intelligent
|
|
4
|
+
* Enhanced AI Operator Client with SSE support
|
|
5
|
+
* Provides intelligent operator execution with automatic strategy selection
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import type {
|
|
8
|
+
import { autoSelectOperator, executeSpecificOperator } from '../sdk.gen'
|
|
9
|
+
import type { AutoSelectOperatorData, ExecuteSpecificOperatorData } from '../types.gen'
|
|
10
10
|
import { EventType, SSEClient } from './SSEClient'
|
|
11
11
|
|
|
12
|
-
export interface
|
|
12
|
+
export interface OperatorQueryRequest {
|
|
13
13
|
message: string
|
|
14
14
|
history?: Array<{ role: string; content: string }>
|
|
15
15
|
context?: Record<string, any>
|
|
@@ -18,15 +18,15 @@ export interface AgentQueryRequest {
|
|
|
18
18
|
forceExtendedAnalysis?: boolean
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export interface
|
|
21
|
+
export interface OperatorOptions {
|
|
22
22
|
mode?: 'auto' | 'sync' | 'async'
|
|
23
23
|
maxWait?: number
|
|
24
24
|
onProgress?: (message: string, percentage?: number) => void
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export interface
|
|
27
|
+
export interface OperatorResult {
|
|
28
28
|
content: string
|
|
29
|
-
|
|
29
|
+
operator_used: string
|
|
30
30
|
mode_used: 'quick' | 'standard' | 'extended' | 'streaming'
|
|
31
31
|
metadata?: Record<string, any>
|
|
32
32
|
tokens_used?: {
|
|
@@ -39,14 +39,14 @@ export interface AgentResult {
|
|
|
39
39
|
timestamp?: string
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export interface
|
|
42
|
+
export interface QueuedOperatorResponse {
|
|
43
43
|
status: 'queued'
|
|
44
44
|
operation_id: string
|
|
45
45
|
message: string
|
|
46
46
|
sse_endpoint?: string
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export class
|
|
49
|
+
export class OperatorClient {
|
|
50
50
|
private sseClient?: SSEClient
|
|
51
51
|
private config: {
|
|
52
52
|
baseUrl: string
|
|
@@ -65,15 +65,15 @@ export class AgentClient {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* Execute
|
|
68
|
+
* Execute operator query with automatic operator selection
|
|
69
69
|
*/
|
|
70
70
|
async executeQuery(
|
|
71
71
|
graphId: string,
|
|
72
|
-
request:
|
|
73
|
-
options:
|
|
74
|
-
): Promise<
|
|
75
|
-
const data:
|
|
76
|
-
url: '/v1/graphs/{graph_id}/
|
|
72
|
+
request: OperatorQueryRequest,
|
|
73
|
+
options: OperatorOptions = {}
|
|
74
|
+
): Promise<OperatorResult> {
|
|
75
|
+
const data: AutoSelectOperatorData = {
|
|
76
|
+
url: '/v1/graphs/{graph_id}/operator' as const,
|
|
77
77
|
path: { graph_id: graphId },
|
|
78
78
|
body: {
|
|
79
79
|
message: request.message,
|
|
@@ -85,14 +85,14 @@ export class AgentClient {
|
|
|
85
85
|
},
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const response = await
|
|
88
|
+
const response = await autoSelectOperator(data)
|
|
89
89
|
const responseData = response.data as any
|
|
90
90
|
|
|
91
91
|
// Check if this is an immediate response (sync execution)
|
|
92
|
-
if (responseData?.content !== undefined && responseData?.
|
|
92
|
+
if (responseData?.content !== undefined && responseData?.operator_used) {
|
|
93
93
|
return {
|
|
94
94
|
content: responseData.content,
|
|
95
|
-
|
|
95
|
+
operator_used: responseData.operator_used,
|
|
96
96
|
mode_used: responseData.mode_used,
|
|
97
97
|
metadata: responseData.metadata,
|
|
98
98
|
tokens_used: responseData.tokens_used,
|
|
@@ -104,33 +104,33 @@ export class AgentClient {
|
|
|
104
104
|
|
|
105
105
|
// Check if this is a queued response (async background task execution)
|
|
106
106
|
if (responseData?.operation_id) {
|
|
107
|
-
const queuedResponse = responseData as
|
|
107
|
+
const queuedResponse = responseData as QueuedOperatorResponse
|
|
108
108
|
|
|
109
109
|
// If user doesn't want to wait, throw with queue info
|
|
110
110
|
if (options.maxWait === 0) {
|
|
111
|
-
throw new
|
|
111
|
+
throw new QueuedOperatorError(queuedResponse)
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// Use SSE to monitor the operation
|
|
115
|
-
return this.
|
|
115
|
+
return this.waitForOperatorCompletion(queuedResponse.operation_id, options)
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
// Unexpected response format
|
|
119
|
-
throw new Error('Unexpected response format from
|
|
119
|
+
throw new Error('Unexpected response format from operator endpoint')
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* Execute specific
|
|
123
|
+
* Execute specific operator type
|
|
124
124
|
*/
|
|
125
|
-
async
|
|
125
|
+
async executeOperator(
|
|
126
126
|
graphId: string,
|
|
127
|
-
|
|
128
|
-
request:
|
|
129
|
-
options:
|
|
130
|
-
): Promise<
|
|
131
|
-
const data:
|
|
132
|
-
url: '/v1/graphs/{graph_id}/
|
|
133
|
-
path: { graph_id: graphId,
|
|
127
|
+
operatorType: string,
|
|
128
|
+
request: OperatorQueryRequest,
|
|
129
|
+
options: OperatorOptions = {}
|
|
130
|
+
): Promise<OperatorResult> {
|
|
131
|
+
const data: ExecuteSpecificOperatorData = {
|
|
132
|
+
url: '/v1/graphs/{graph_id}/operator/{operator_type}' as const,
|
|
133
|
+
path: { graph_id: graphId, operator_type: operatorType },
|
|
134
134
|
body: {
|
|
135
135
|
message: request.message,
|
|
136
136
|
history: request.history,
|
|
@@ -141,14 +141,14 @@ export class AgentClient {
|
|
|
141
141
|
},
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
const response = await
|
|
144
|
+
const response = await executeSpecificOperator(data)
|
|
145
145
|
const responseData = response.data as any
|
|
146
146
|
|
|
147
147
|
// Check if this is an immediate response (sync execution)
|
|
148
|
-
if (responseData?.content !== undefined && responseData?.
|
|
148
|
+
if (responseData?.content !== undefined && responseData?.operator_used) {
|
|
149
149
|
return {
|
|
150
150
|
content: responseData.content,
|
|
151
|
-
|
|
151
|
+
operator_used: responseData.operator_used,
|
|
152
152
|
mode_used: responseData.mode_used,
|
|
153
153
|
metadata: responseData.metadata,
|
|
154
154
|
tokens_used: responseData.tokens_used,
|
|
@@ -160,32 +160,32 @@ export class AgentClient {
|
|
|
160
160
|
|
|
161
161
|
// Check if this is a queued response (async background task execution)
|
|
162
162
|
if (responseData?.operation_id) {
|
|
163
|
-
const queuedResponse = responseData as
|
|
163
|
+
const queuedResponse = responseData as QueuedOperatorResponse
|
|
164
164
|
|
|
165
165
|
// If user doesn't want to wait, throw with queue info
|
|
166
166
|
if (options.maxWait === 0) {
|
|
167
|
-
throw new
|
|
167
|
+
throw new QueuedOperatorError(queuedResponse)
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
// Use SSE to monitor the operation
|
|
171
|
-
return this.
|
|
171
|
+
return this.waitForOperatorCompletion(queuedResponse.operation_id, options)
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// Unexpected response format
|
|
175
|
-
throw new Error('Unexpected response format from
|
|
175
|
+
throw new Error('Unexpected response format from operator endpoint')
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
private async
|
|
178
|
+
private async waitForOperatorCompletion(
|
|
179
179
|
operationId: string,
|
|
180
|
-
options:
|
|
181
|
-
): Promise<
|
|
180
|
+
options: OperatorOptions
|
|
181
|
+
): Promise<OperatorResult> {
|
|
182
182
|
return new Promise((resolve, reject) => {
|
|
183
183
|
const sseClient = new SSEClient(this.config)
|
|
184
184
|
|
|
185
185
|
sseClient
|
|
186
186
|
.connect(operationId)
|
|
187
187
|
.then(() => {
|
|
188
|
-
let result:
|
|
188
|
+
let result: OperatorResult | null = null
|
|
189
189
|
|
|
190
190
|
// Listen for progress events
|
|
191
191
|
sseClient.on(EventType.OPERATION_PROGRESS, (data) => {
|
|
@@ -193,11 +193,11 @@ export class AgentClient {
|
|
|
193
193
|
})
|
|
194
194
|
|
|
195
195
|
// Listen for agent-specific events
|
|
196
|
-
sseClient.on('
|
|
197
|
-
options.onProgress?.(`
|
|
196
|
+
sseClient.on('operator_started' as EventType, (data) => {
|
|
197
|
+
options.onProgress?.(`Operator ${data.operator_type} started`, 0)
|
|
198
198
|
})
|
|
199
199
|
|
|
200
|
-
sseClient.on('
|
|
200
|
+
sseClient.on('operator_initialized' as EventType, (data) => {
|
|
201
201
|
options.onProgress?.(`${data.agent_name} initialized`, 10)
|
|
202
202
|
})
|
|
203
203
|
|
|
@@ -205,10 +205,10 @@ export class AgentClient {
|
|
|
205
205
|
options.onProgress?.(data.message, data.percentage)
|
|
206
206
|
})
|
|
207
207
|
|
|
208
|
-
sseClient.on('
|
|
208
|
+
sseClient.on('operator_completed' as EventType, (data) => {
|
|
209
209
|
result = {
|
|
210
210
|
content: data.content,
|
|
211
|
-
|
|
211
|
+
operator_used: data.operator_used,
|
|
212
212
|
mode_used: data.mode_used,
|
|
213
213
|
metadata: data.metadata,
|
|
214
214
|
tokens_used: data.tokens_used,
|
|
@@ -223,16 +223,16 @@ export class AgentClient {
|
|
|
223
223
|
// Fallback to generic completion event
|
|
224
224
|
sseClient.on(EventType.OPERATION_COMPLETED, (data) => {
|
|
225
225
|
if (!result) {
|
|
226
|
-
const
|
|
226
|
+
const operatorResult = data.result || data
|
|
227
227
|
result = {
|
|
228
|
-
content:
|
|
229
|
-
|
|
230
|
-
mode_used:
|
|
231
|
-
metadata:
|
|
232
|
-
tokens_used:
|
|
233
|
-
confidence_score:
|
|
234
|
-
execution_time:
|
|
235
|
-
timestamp:
|
|
228
|
+
content: operatorResult.content || '',
|
|
229
|
+
operator_used: operatorResult.operator_used || 'unknown',
|
|
230
|
+
mode_used: operatorResult.mode_used || 'standard',
|
|
231
|
+
metadata: operatorResult.metadata,
|
|
232
|
+
tokens_used: operatorResult.tokens_used,
|
|
233
|
+
confidence_score: operatorResult.confidence_score,
|
|
234
|
+
execution_time: operatorResult.execution_time,
|
|
235
|
+
timestamp: operatorResult.timestamp || new Date().toISOString(),
|
|
236
236
|
}
|
|
237
237
|
sseClient.close()
|
|
238
238
|
resolve(result)
|
|
@@ -266,7 +266,7 @@ export class AgentClient {
|
|
|
266
266
|
graphId: string,
|
|
267
267
|
message: string,
|
|
268
268
|
context?: Record<string, any>
|
|
269
|
-
): Promise<
|
|
269
|
+
): Promise<OperatorResult> {
|
|
270
270
|
return this.executeQuery(graphId, { message, context }, { mode: 'auto' })
|
|
271
271
|
}
|
|
272
272
|
|
|
@@ -276,9 +276,9 @@ export class AgentClient {
|
|
|
276
276
|
async analyzeFinancials(
|
|
277
277
|
graphId: string,
|
|
278
278
|
message: string,
|
|
279
|
-
options:
|
|
280
|
-
): Promise<
|
|
281
|
-
return this.
|
|
279
|
+
options: OperatorOptions = {}
|
|
280
|
+
): Promise<OperatorResult> {
|
|
281
|
+
return this.executeOperator(graphId, 'financial', { message }, options)
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
@@ -287,16 +287,20 @@ export class AgentClient {
|
|
|
287
287
|
async research(
|
|
288
288
|
graphId: string,
|
|
289
289
|
message: string,
|
|
290
|
-
options:
|
|
291
|
-
): Promise<
|
|
292
|
-
return this.
|
|
290
|
+
options: OperatorOptions = {}
|
|
291
|
+
): Promise<OperatorResult> {
|
|
292
|
+
return this.executeOperator(graphId, 'research', { message }, options)
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
296
|
* Execute RAG agent for fast retrieval
|
|
297
297
|
*/
|
|
298
|
-
async rag(
|
|
299
|
-
|
|
298
|
+
async rag(
|
|
299
|
+
graphId: string,
|
|
300
|
+
message: string,
|
|
301
|
+
options: OperatorOptions = {}
|
|
302
|
+
): Promise<OperatorResult> {
|
|
303
|
+
return this.executeOperator(graphId, 'rag', { message }, options)
|
|
300
304
|
}
|
|
301
305
|
|
|
302
306
|
/**
|
|
@@ -313,9 +317,9 @@ export class AgentClient {
|
|
|
313
317
|
/**
|
|
314
318
|
* Error thrown when agent execution is queued and maxWait is 0
|
|
315
319
|
*/
|
|
316
|
-
export class
|
|
317
|
-
constructor(public queueInfo:
|
|
318
|
-
super('
|
|
319
|
-
this.name = '
|
|
320
|
+
export class QueuedOperatorError extends Error {
|
|
321
|
+
constructor(public queueInfo: QueuedOperatorResponse) {
|
|
322
|
+
super('Operator execution was queued')
|
|
323
|
+
this.name = 'QueuedOperatorError'
|
|
320
324
|
}
|
|
321
325
|
}
|
|
@@ -1453,6 +1453,9 @@ export type QueryAccountRollupsArgs = {
|
|
|
1453
1453
|
mappingId?: InputMaybe<Scalars['String']['input']>;
|
|
1454
1454
|
startDate?: InputMaybe<Scalars['Date']['input']>;
|
|
1455
1455
|
};
|
|
1456
|
+
export type QueryAccountTreeArgs = {
|
|
1457
|
+
includeInactive?: Scalars['Boolean']['input'];
|
|
1458
|
+
};
|
|
1456
1459
|
export type QueryAccountsArgs = {
|
|
1457
1460
|
classification?: InputMaybe<Scalars['String']['input']>;
|
|
1458
1461
|
isActive?: InputMaybe<Scalars['Boolean']['input']>;
|
|
@@ -1502,6 +1502,10 @@ export type QueryAccountRollupsArgs = {
|
|
|
1502
1502
|
startDate?: InputMaybe<Scalars['Date']['input']>
|
|
1503
1503
|
}
|
|
1504
1504
|
|
|
1505
|
+
export type QueryAccountTreeArgs = {
|
|
1506
|
+
includeInactive?: Scalars['Boolean']['input']
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1505
1509
|
export type QueryAccountsArgs = {
|
|
1506
1510
|
classification?: InputMaybe<Scalars['String']['input']>
|
|
1507
1511
|
isActive?: InputMaybe<Scalars['Boolean']['input']>
|