-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinterfaces.ts
More file actions
313 lines (282 loc) · 8.77 KB
/
interfaces.ts
File metadata and controls
313 lines (282 loc) · 8.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
// Shared TypeScript interfaces for the Deep Research Agent system
// Based on the Deep Research Agent Design Specification
export interface ResearchQuery {
topic: string;
scope?: string;
depth?: 'basic' | 'comprehensive' | 'expert';
deadline?: Date;
constraints?: string[];
}
export interface ResearchResult {
topic: string;
findings: ResearchFinding[];
sources: SourceCitation[];
methodology: string;
confidence: number; // 0-1
generatedAt: Date;
processingTime: number; // milliseconds
}
export interface ResearchFinding {
claim: string;
evidence: string;
confidence: number; // 0-1
sources: number[]; // Indices into sources array
category: 'factual' | 'analytical' | 'speculative';
}
export interface SourceCitation {
url: string;
title: string;
author?: string;
publicationDate?: Date;
credibilityScore: number; // 0-1
type: 'academic' | 'news' | 'web' | 'government' | 'expert';
accessedAt: Date;
}
export interface ResearchPlan {
id: string;
topic: string;
objectives: string[];
methodology: ResearchMethodology;
dataSources: DataSource[];
executionSteps: ResearchStep[];
riskAssessment: RiskFactor[];
contingencyPlans: ContingencyPlan[];
qualityThresholds: QualityThreshold[];
estimatedTimeline: string;
version: string;
createdAt: Date;
updatedAt: Date;
/** Original user query that initiated this research plan (optional) */
originalQuery?: string;
}
export interface ResearchMethodology {
approach: 'systematic' | 'exploratory' | 'comparative' | 'case-study';
justification: string;
phases: string[];
qualityControls: string[];
}
export interface DataSource {
type: 'web' | 'academic' | 'news' | 'social' | 'government' | 'statistical';
priority: number; // 1-5, 1 being highest
credibilityWeight: number; // 0-1
estimatedVolume: 'high' | 'medium' | 'low';
accessRequirements?: string[];
rateLimits?: {
requestsPerMinute: number;
requestsPerHour: number;
};
}
export interface ResearchStep {
id: string;
description: string;
agentType: 'planning' | 'orchestrator' | 'web-research' | 'academic-research' | 'news-research' | 'data-analysis';
dependencies: string[]; // Step IDs
estimatedDuration: number; // minutes
successCriteria: string;
fallbackStrategies: string[];
priority: number; // 1-5, 1 being highest
}
export interface RiskFactor {
type: 'data-availability' | 'api-limits' | 'time-constraints' | 'credibility-concerns' | 'technical-failures';
probability: 'high' | 'medium' | 'low';
impact: 'high' | 'medium' | 'low';
mitigationStrategy: string;
monitoringTrigger?: string;
}
export interface ContingencyPlan {
triggerCondition: string;
fallbackStrategy: string;
resourceAdjustment: string;
estimatedImpact: string;
}
export interface QualityThreshold {
metric: 'source-credibility' | 'data-completeness' | 'cross-validation' | 'recency' | 'consistency';
minimumValue: number; // 0-1
acceptableRange: [number, number];
measurementMethod: string;
}
export interface OrchestrationState {
researchId: string;
plan: ResearchPlan;
currentPhase: 'planning' | 'execution' | 'synthesis' | 'validation' | 'reporting';
activeSteps: ResearchStepExecution[];
completedSteps: ResearchStepResult[];
issues: OrchestrationIssue[];
progress: {
completedSteps: number;
totalSteps: number;
estimatedTimeRemaining: number; // minutes
overallConfidence: number; // 0-1
};
startedAt: Date;
lastUpdated: Date;
}
export interface ResearchStepExecution {
stepId: string;
agentId: string;
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
startedAt?: Date;
completedAt?: Date;
progressUpdates: ProgressUpdate[];
assignedAgent?: string;
retryCount: number;
/** Replaced `any` with ResultPayload for type safety and clarity. */
result?: ResultPayload;
}
export interface ResearchStepResult {
stepId: string;
status: 'success' | 'partial' | 'failed';
data: unknown; // Flexible for different result types
sources: SourceCitation[];
processingTime: number; // milliseconds
qualityScore: number; // 0-1
issues: string[];
metadata: Record<string, unknown>;
}
export interface OrchestrationIssue {
id: string;
type: 'agent-failure' | 'data-quality' | 'dependency-blocked' | 'resource-exhausted' | 'timeout';
severity: 'low' | 'medium' | 'high' | 'critical';
description: string;
affectedSteps: string[];
resolution?: string;
createdAt: Date;
resolvedAt?: Date;
}
export interface ProgressUpdate {
timestamp: Date;
message: string;
percentage?: number; // 0-100
currentActivity: string;
estimatedTimeRemaining?: number; // minutes
}
// A2A Protocol interfaces
// Prefer the AgentCard type from @a2a-js/sdk to stay aligned with protocol changes.
// We expose a local alias so existing imports continue to work without churn.
export type AgentCard = import('@a2a-js/sdk').AgentCard;
export interface TaskType {
name: string;
description: string;
inputSchema: Record<string, unknown>;
outputSchema: Record<string, unknown>;
}
export interface A2AMessage {
id: string;
from: string;
to: string;
type: 'task-request' | 'task-response' | 'status-update' | 'error' | 'cancel';
payload: unknown;
timestamp: Date;
correlationId?: string;
}
export interface TaskRequest {
step: ResearchStep;
taskId: string;
type: string;
parameters: Record<string, unknown>;
priority: number;
timeout?: number; // milliseconds
metadata?: Record<string, unknown>;
}
export interface TaskResponse {
taskId: string;
status: 'success' | 'error' | 'cancelled';
result?: unknown;
error?: string;
processingTime: number;
metadata?: Record<string, unknown>;
}
export interface QueryAnalysis {
coreQuestion: string;
researchDimensions: ResearchDimension[];
complexity: 'low' | 'medium' | 'high';
estimatedScope: 'narrow' | 'broad' | 'comprehensive';
timeline: 'short' | 'medium' | 'long';
}
// New exported union type for step results to avoid `any` while remaining flexible.
// Includes concrete known result shapes plus a generic record fallback and null.
export type ResultPayload =
| TaskResponse
| ResearchStepResult
| SynthesisResult
| ResearchResult
| Record<string, unknown>
| null;
// Utility types
export type AgentType = 'planning' | 'orchestrator' | 'web-research' | 'academic-research' | 'news-research' | 'data-analysis';
export type ResearchPhase = 'planning' | 'execution' | 'synthesis' | 'validation' | 'reporting';
export type DataSourceType = 'web' | 'academic' | 'news' | 'social' | 'government' | 'statistical';
export type RiskType = 'data-availability' | 'api-limits' | 'time-constraints' | 'credibility-concerns' | 'technical-failures';
export type QualityMetric = 'source-credibility' | 'data-completeness' | 'cross-validation' | 'recency' | 'consistency';
export interface ResearchDimension {
type: 'academic' | 'web' | 'news' | 'statistical';
relevance: number; // 0-1
priority: 'high' | 'medium' | 'low';
}
export interface SynthesisResult {
id: string;
researchId: string;
synthesis: string; // The comprehensive narrative synthesis
keyFindings: Array<{
dimension: string;
finding: string;
confidence: number;
validationStatus: 'confirmed' | 'partially-confirmed' | 'unconfirmed' | 'contradicted';
supportingSources: string[];
contradictingSources?: string[];
consensusLevel: number;
}>;
confidenceMetrics: {
overallConfidence: number;
sourceDiversity: number;
validationRate: number;
contradictionRate: number;
};
gapsAndRecommendations: {
knowledgeGaps: string[];
methodologicalLimitations: string[];
recommendations: string[];
};
sourceSummary: {
totalSources: number;
sourceTypes: Record<string, number>;
topSources: Array<{source: string, contributionCount: number}>;
};
generatedAt: Date;
version: string;
}
// Orchestration-specific interfaces
export interface OrchestrationDecision {
researchId: string;
timestamp: string; // ISO-8601
currentPhase: ResearchPhase;
activeTasks: Array<{
taskId: string;
agentType: AgentType;
description: string;
priority: number; // 1-5
estimatedDuration: number; // minutes
}>;
completedTasks: string[]; // task IDs
issues: Array<{
type: string;
severity: 'low' | 'medium' | 'high' | 'critical';
description: string;
affectedTasks: string[];
resolution?: string;
}>;
progressMetrics: {
completedSteps: number;
totalSteps: number;
estimatedTimeRemaining: number; // minutes
overallConfidence: number; // 0-1
qualityScore: number; // 0-1
};
nextActions: Array<{
action: 'assign-task' | 'monitor-progress' | 'activate-contingency' | 'synthesis-data' | 'complete-research';
description: string;
priority: number; // 1-5
estimatedImpact: string;
parameters?: Record<string, unknown>;
}>;
}