@almadar/agent 1.6.1 → 1.6.3
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/agent/index.d.ts +4 -732
- package/dist/agent/index.js +297 -2187
- package/dist/agent/index.js.map +1 -1
- package/dist/{api-types-Bj2jeOU7.d.ts → api-types-CXrq-fts.d.ts} +1 -1
- package/dist/event-transformer/index.d.ts +1 -1
- package/dist/event-transformer/index.js +1 -1
- package/dist/event-transformer/index.js.map +1 -1
- package/dist/{firestore-checkpointer-BkFR-sZM.d.ts → firestore-checkpointer-CkNKXoun.d.ts} +1 -1
- package/dist/{index-DGdLGf-L.d.ts → index-DW3F-Ihx.d.ts} +26 -22
- package/dist/{workflow-tool-wrapper-CXD0A7l3.d.ts → index-DZn69no8.d.ts} +4 -3
- package/dist/index.d.ts +10 -537
- package/dist/index.js +3195 -3564
- package/dist/index.js.map +1 -1
- package/dist/{orbital-subagent-CHEeQQr_.d.ts → orbital-subagent-BdFuf77p.d.ts} +29 -27
- package/dist/persistence/index.d.ts +2 -2
- package/dist/tools/index.d.ts +3 -3
- package/dist/tools/index.js +283 -131
- package/dist/tools/index.js.map +1 -1
- package/dist/workspace/index.d.ts +355 -0
- package/dist/workspace/index.js +675 -0
- package/dist/workspace/index.js.map +1 -0
- package/package.json +10 -8
- package/dist/prompts/index.d.ts +0 -23
- package/dist/prompts/index.js +0 -126
- package/dist/prompts/index.js.map +0 -1
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,741 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export { E as EVENT_BUDGETS, S as SessionManager, a as SessionManagerOptions, b as Skill, c as SkillAgent, d as SkillAgentOptions, e as SkillAgentResult, f as SkillLoader, g as SkillMeta, h as SkillRefLoader, T as ToolTelemetry, W as WorkflowToolWrapper, i as WorkflowToolWrapperOptions, j as createEvalWorkflowWrapper, k as createSkillAgent, l as createWorkflowToolWrapper, m as getBudgetWarningMessage, n as getEventBudget, o as getInterruptConfig, r as resumeSkillAgent } from '../workflow-tool-wrapper-CXD0A7l3.js';
|
|
1
|
+
export { E as EVENT_BUDGETS, S as SessionManager, f as SessionManagerOptions, g as Skill, F as SkillAgent, h as SkillAgentOptions, i as SkillAgentResult, j as SkillLoader, k as SkillMeta, l as SkillRefLoader, n as ToolTelemetry, W as WorkflowToolWrapper, p as WorkflowToolWrapperOptions, r as createEvalWorkflowWrapper, s as createSkillAgent, u as createWorkflowToolWrapper, w as getBudgetWarningMessage, x as getEventBudget, y as getInterruptConfig, B as resumeSkillAgent } from '../index-DZn69no8.js';
|
|
3
2
|
export { Command } from '@langchain/langgraph';
|
|
4
|
-
export { P as PersistenceMode, S as SessionMetadata,
|
|
3
|
+
export { P as PersistenceMode, S as SessionMetadata, e as SessionRecord } from '../firestore-checkpointer-CkNKXoun.js';
|
|
5
4
|
import '@almadar/llm';
|
|
6
|
-
import '../orbital-subagent-
|
|
5
|
+
import '../orbital-subagent-BdFuf77p.js';
|
|
7
6
|
import '@langchain/core/tools';
|
|
8
7
|
import 'zod';
|
|
9
|
-
import '../api-types-
|
|
8
|
+
import '../api-types-CXrq-fts.js';
|
|
10
9
|
import '@almadar/core/types';
|
|
11
10
|
import '@langchain/langgraph-checkpoint';
|
|
12
11
|
import '@almadar/core';
|
|
13
12
|
import '@langchain/core/messages';
|
|
14
13
|
import '@langchain/core/runnables';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* ReAct + Reflection Pattern - Phase 2.2
|
|
18
|
-
*
|
|
19
|
-
* Self-correcting agent loops with explicit reasoning states.
|
|
20
|
-
* Implements: REASON → ACT → REFLECT → OBSERVE
|
|
21
|
-
*
|
|
22
|
-
* @packageDocumentation
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
type ReActState = 'REASONING' | 'ACTING' | 'REFLECTING' | 'OBSERVING' | 'CORRECTING' | 'COMPLETE';
|
|
26
|
-
interface ReActStep {
|
|
27
|
-
stepNumber: number;
|
|
28
|
-
state: ReActState;
|
|
29
|
-
thought: string;
|
|
30
|
-
action?: string;
|
|
31
|
-
actionInput?: Record<string, unknown>;
|
|
32
|
-
observation?: string;
|
|
33
|
-
reflection?: string;
|
|
34
|
-
timestamp: Date;
|
|
35
|
-
error?: string;
|
|
36
|
-
}
|
|
37
|
-
interface ReflectionResult {
|
|
38
|
-
shouldCorrect: boolean;
|
|
39
|
-
correctionStrategy?: string;
|
|
40
|
-
confidence: number;
|
|
41
|
-
notes: string;
|
|
42
|
-
}
|
|
43
|
-
interface ReActSession {
|
|
44
|
-
sessionId: string;
|
|
45
|
-
userRequest: string;
|
|
46
|
-
currentStep: number;
|
|
47
|
-
steps: ReActStep[];
|
|
48
|
-
maxIterations: number;
|
|
49
|
-
state: ReActState;
|
|
50
|
-
}
|
|
51
|
-
interface ReActOptions {
|
|
52
|
-
maxIterations?: number;
|
|
53
|
-
enableReflection?: boolean;
|
|
54
|
-
enableAutoCorrect?: boolean;
|
|
55
|
-
memoryManager?: MemoryManager;
|
|
56
|
-
onStep?: (step: ReActStep) => void;
|
|
57
|
-
onError?: (error: Error, step: ReActStep) => void;
|
|
58
|
-
}
|
|
59
|
-
declare class ReActEngine {
|
|
60
|
-
private options;
|
|
61
|
-
private sessions;
|
|
62
|
-
constructor(options?: ReActOptions);
|
|
63
|
-
/**
|
|
64
|
-
* Start a new ReAct session
|
|
65
|
-
*/
|
|
66
|
-
startSession(userRequest: string): ReActSession;
|
|
67
|
-
/**
|
|
68
|
-
* Execute REASON step
|
|
69
|
-
*/
|
|
70
|
-
reason(sessionId: string, context: {
|
|
71
|
-
request: string;
|
|
72
|
-
previousSteps?: ReActStep[];
|
|
73
|
-
}): Promise<ReActStep>;
|
|
74
|
-
/**
|
|
75
|
-
* Execute ACT step
|
|
76
|
-
*/
|
|
77
|
-
act(sessionId: string, action: string, actionInput: Record<string, unknown>): Promise<ReActStep>;
|
|
78
|
-
/**
|
|
79
|
-
* Execute OBSERVE step
|
|
80
|
-
*/
|
|
81
|
-
observe(sessionId: string, observation: string): Promise<ReActStep>;
|
|
82
|
-
/**
|
|
83
|
-
* Execute REFLECT step
|
|
84
|
-
*/
|
|
85
|
-
reflect(sessionId: string, result: unknown): Promise<{
|
|
86
|
-
step: ReActStep;
|
|
87
|
-
reflection: ReflectionResult;
|
|
88
|
-
}>;
|
|
89
|
-
/**
|
|
90
|
-
* Execute CORRECT step (auto-correction)
|
|
91
|
-
*/
|
|
92
|
-
correct(sessionId: string, correctionAction: string, correctionInput: Record<string, unknown>): Promise<ReActStep>;
|
|
93
|
-
/**
|
|
94
|
-
* Handle errors with context preservation
|
|
95
|
-
*/
|
|
96
|
-
handleError(sessionId: string, error: Error, context: Record<string, unknown>): Promise<ReActStep>;
|
|
97
|
-
/**
|
|
98
|
-
* Get session by ID
|
|
99
|
-
*/
|
|
100
|
-
getSession(sessionId: string): ReActSession;
|
|
101
|
-
/**
|
|
102
|
-
* Get reflection metrics
|
|
103
|
-
*/
|
|
104
|
-
getReflectionMetrics(sessionId: string): {
|
|
105
|
-
totalSteps: number;
|
|
106
|
-
corrections: number;
|
|
107
|
-
errors: number;
|
|
108
|
-
averageConfidence: number;
|
|
109
|
-
};
|
|
110
|
-
private generateThought;
|
|
111
|
-
private performReflection;
|
|
112
|
-
private storeCorrection;
|
|
113
|
-
private storeError;
|
|
114
|
-
}
|
|
115
|
-
declare function createReActEngine(options?: ReActOptions): ReActEngine;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Human-in-the-Loop v2 - Phase 2.3
|
|
119
|
-
*
|
|
120
|
-
* Structured interrupts with memory and time-travel debugging.
|
|
121
|
-
* Interrupt types: confirm, edit, select, text
|
|
122
|
-
*
|
|
123
|
-
* @packageDocumentation
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
type InterruptType = 'confirm' | 'edit' | 'select' | 'text';
|
|
127
|
-
interface InterruptRequest<T = unknown> {
|
|
128
|
-
interruptId: string;
|
|
129
|
-
sessionId: string;
|
|
130
|
-
type: InterruptType;
|
|
131
|
-
title: string;
|
|
132
|
-
description: string;
|
|
133
|
-
context: InterruptContext;
|
|
134
|
-
payload: T;
|
|
135
|
-
timeoutMs?: number;
|
|
136
|
-
createdAt: Date;
|
|
137
|
-
}
|
|
138
|
-
interface InterruptContext {
|
|
139
|
-
checkpointId: string;
|
|
140
|
-
currentState: string;
|
|
141
|
-
previousActions: string[];
|
|
142
|
-
relevantMemory?: string[];
|
|
143
|
-
}
|
|
144
|
-
interface InterruptResponse<T = unknown> {
|
|
145
|
-
interruptId: string;
|
|
146
|
-
response: T;
|
|
147
|
-
respondedAt: Date;
|
|
148
|
-
userId?: string;
|
|
149
|
-
}
|
|
150
|
-
interface ConfirmPayload {
|
|
151
|
-
question: string;
|
|
152
|
-
defaultValue?: boolean;
|
|
153
|
-
severity: 'info' | 'warning' | 'critical';
|
|
154
|
-
}
|
|
155
|
-
interface EditPayload {
|
|
156
|
-
content: string;
|
|
157
|
-
format: 'json' | 'text' | 'code';
|
|
158
|
-
schema?: Record<string, unknown>;
|
|
159
|
-
validationRules?: string[];
|
|
160
|
-
}
|
|
161
|
-
interface SelectPayload {
|
|
162
|
-
options: Array<{
|
|
163
|
-
id: string;
|
|
164
|
-
label: string;
|
|
165
|
-
description?: string;
|
|
166
|
-
disabled?: boolean;
|
|
167
|
-
}>;
|
|
168
|
-
multiple?: boolean;
|
|
169
|
-
maxSelections?: number;
|
|
170
|
-
}
|
|
171
|
-
interface TextPayload {
|
|
172
|
-
placeholder?: string;
|
|
173
|
-
multiline?: boolean;
|
|
174
|
-
maxLength?: number;
|
|
175
|
-
validation?: 'email' | 'url' | 'regex';
|
|
176
|
-
validationRegex?: string;
|
|
177
|
-
}
|
|
178
|
-
interface HITLv2Options {
|
|
179
|
-
memoryManager?: MemoryManager;
|
|
180
|
-
defaultTimeoutMs?: number;
|
|
181
|
-
onInterrupt?: (request: InterruptRequest) => void;
|
|
182
|
-
onResponse?: (request: InterruptRequest, response: InterruptResponse) => void;
|
|
183
|
-
}
|
|
184
|
-
declare class HITLv2Manager {
|
|
185
|
-
private options;
|
|
186
|
-
private pendingInterrupts;
|
|
187
|
-
private responses;
|
|
188
|
-
private checkpoints;
|
|
189
|
-
constructor(options?: HITLv2Options);
|
|
190
|
-
/**
|
|
191
|
-
* Create a confirmation interrupt
|
|
192
|
-
*/
|
|
193
|
-
confirm(sessionId: string, question: string, options?: {
|
|
194
|
-
severity?: 'info' | 'warning' | 'critical';
|
|
195
|
-
defaultValue?: boolean;
|
|
196
|
-
timeoutMs?: number;
|
|
197
|
-
context?: Partial<InterruptContext>;
|
|
198
|
-
}): Promise<boolean>;
|
|
199
|
-
/**
|
|
200
|
-
* Create an edit interrupt
|
|
201
|
-
*/
|
|
202
|
-
edit(sessionId: string, content: string, options?: {
|
|
203
|
-
format?: 'json' | 'text' | 'code';
|
|
204
|
-
title?: string;
|
|
205
|
-
description?: string;
|
|
206
|
-
schema?: Record<string, unknown>;
|
|
207
|
-
timeoutMs?: number;
|
|
208
|
-
context?: Partial<InterruptContext>;
|
|
209
|
-
}): Promise<string>;
|
|
210
|
-
/**
|
|
211
|
-
* Create a selection interrupt
|
|
212
|
-
*/
|
|
213
|
-
select<T extends string>(sessionId: string, options: Array<{
|
|
214
|
-
id: T;
|
|
215
|
-
label: string;
|
|
216
|
-
description?: string;
|
|
217
|
-
}>, config?: {
|
|
218
|
-
title?: string;
|
|
219
|
-
description?: string;
|
|
220
|
-
multiple?: boolean;
|
|
221
|
-
timeoutMs?: number;
|
|
222
|
-
context?: Partial<InterruptContext>;
|
|
223
|
-
}): Promise<T | T[]>;
|
|
224
|
-
/**
|
|
225
|
-
* Create a text input interrupt
|
|
226
|
-
*/
|
|
227
|
-
text(sessionId: string, options?: {
|
|
228
|
-
title?: string;
|
|
229
|
-
description?: string;
|
|
230
|
-
placeholder?: string;
|
|
231
|
-
multiline?: boolean;
|
|
232
|
-
maxLength?: number;
|
|
233
|
-
timeoutMs?: number;
|
|
234
|
-
context?: Partial<InterruptContext>;
|
|
235
|
-
}): Promise<string>;
|
|
236
|
-
/**
|
|
237
|
-
* Submit a response to an interrupt
|
|
238
|
-
*/
|
|
239
|
-
submitResponse<T>(interruptId: string, response: T, userId?: string): Promise<void>;
|
|
240
|
-
/**
|
|
241
|
-
* Cancel an interrupt
|
|
242
|
-
*/
|
|
243
|
-
cancelInterrupt(interruptId: string, reason?: string): void;
|
|
244
|
-
/**
|
|
245
|
-
* Save a checkpoint for time-travel
|
|
246
|
-
*/
|
|
247
|
-
saveCheckpoint(checkpointId: string, state: unknown): void;
|
|
248
|
-
/**
|
|
249
|
-
* Restore a checkpoint
|
|
250
|
-
*/
|
|
251
|
-
restoreCheckpoint<T>(checkpointId: string): T | null;
|
|
252
|
-
/**
|
|
253
|
-
* List available checkpoints
|
|
254
|
-
*/
|
|
255
|
-
listCheckpoints(): string[];
|
|
256
|
-
/**
|
|
257
|
-
* Rewind to checkpoint and continue
|
|
258
|
-
*/
|
|
259
|
-
rewindToCheckpoint<T>(checkpointId: string, sessionId: string, modifyFn?: (state: T) => T): Promise<T | null>;
|
|
260
|
-
/**
|
|
261
|
-
* Get interrupt statistics
|
|
262
|
-
*/
|
|
263
|
-
getStats(): {
|
|
264
|
-
pendingCount: number;
|
|
265
|
-
totalHandled: number;
|
|
266
|
-
checkpointsCount: number;
|
|
267
|
-
averageResponseTimeMs: number;
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* Get pending interrupts for a session
|
|
271
|
-
*/
|
|
272
|
-
getPendingForSession(sessionId: string): InterruptRequest[];
|
|
273
|
-
private createInterrupt;
|
|
274
|
-
private waitForResponse;
|
|
275
|
-
private storeInteraction;
|
|
276
|
-
}
|
|
277
|
-
declare function createHITLv2Manager(options?: HITLv2Options): HITLv2Manager;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Memory System Integration - Phase 2.1
|
|
281
|
-
*
|
|
282
|
-
* Integrates episodic, semantic, and procedural memory with agent operations.
|
|
283
|
-
* Provides memory-aware agent capabilities.
|
|
284
|
-
*
|
|
285
|
-
* @packageDocumentation
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
interface MemoryIntegrationOptions {
|
|
289
|
-
memoryManager: MemoryManager;
|
|
290
|
-
userId: string;
|
|
291
|
-
projectId?: string;
|
|
292
|
-
enableEpisodic?: boolean;
|
|
293
|
-
enableSemantic?: boolean;
|
|
294
|
-
enableProcedural?: boolean;
|
|
295
|
-
}
|
|
296
|
-
interface SimilarSession {
|
|
297
|
-
sessionId: string;
|
|
298
|
-
request: string;
|
|
299
|
-
schema: unknown;
|
|
300
|
-
success: boolean;
|
|
301
|
-
similarity: number;
|
|
302
|
-
}
|
|
303
|
-
interface MemoryContext {
|
|
304
|
-
userPreferences: {
|
|
305
|
-
namingConvention: string;
|
|
306
|
-
preferredPatterns: string[];
|
|
307
|
-
commonEntities: string[];
|
|
308
|
-
};
|
|
309
|
-
similarSessions: SimilarSession[];
|
|
310
|
-
projectContext?: {
|
|
311
|
-
domain: 'business' | 'ecommerce' | 'cms' | 'dashboard' | 'workflow';
|
|
312
|
-
existingEntities: string[];
|
|
313
|
-
conventions: string[];
|
|
314
|
-
};
|
|
315
|
-
learnedPatterns: Array<{
|
|
316
|
-
pattern: string;
|
|
317
|
-
confidence: number;
|
|
318
|
-
useCount: number;
|
|
319
|
-
}>;
|
|
320
|
-
}
|
|
321
|
-
interface MemoryQualityMetrics {
|
|
322
|
-
recallAccuracy: number;
|
|
323
|
-
precision: number;
|
|
324
|
-
latencyMs: number;
|
|
325
|
-
cacheHitRate: number;
|
|
326
|
-
}
|
|
327
|
-
declare class MemoryIntegrationEngine {
|
|
328
|
-
private options;
|
|
329
|
-
private searchEngine;
|
|
330
|
-
private preferenceLearner;
|
|
331
|
-
private metrics;
|
|
332
|
-
constructor(options: MemoryIntegrationOptions);
|
|
333
|
-
/**
|
|
334
|
-
* Retrieve similar past generation sessions
|
|
335
|
-
*/
|
|
336
|
-
retrieveSimilarSessions(request: string, limit?: number): Promise<SimilarSession[]>;
|
|
337
|
-
/**
|
|
338
|
-
* Record a new generation session to episodic memory
|
|
339
|
-
*/
|
|
340
|
-
recordSession(request: string, result: {
|
|
341
|
-
schema: unknown;
|
|
342
|
-
success: boolean;
|
|
343
|
-
validationResult?: {
|
|
344
|
-
valid: boolean;
|
|
345
|
-
errors: string[];
|
|
346
|
-
};
|
|
347
|
-
}): Promise<void>;
|
|
348
|
-
/**
|
|
349
|
-
* Get learned user preferences
|
|
350
|
-
*/
|
|
351
|
-
getUserPreferences(): Promise<MemoryContext['userPreferences']>;
|
|
352
|
-
/**
|
|
353
|
-
* Learn from user feedback
|
|
354
|
-
*/
|
|
355
|
-
learnFromFeedback(feedback: {
|
|
356
|
-
pattern: string;
|
|
357
|
-
outcome: 'success' | 'failure';
|
|
358
|
-
entityType?: string;
|
|
359
|
-
}): Promise<void>;
|
|
360
|
-
/**
|
|
361
|
-
* Infer preferences from usage patterns
|
|
362
|
-
*/
|
|
363
|
-
inferPreferences(): Promise<{
|
|
364
|
-
namingConvention?: string;
|
|
365
|
-
validationStyle?: string;
|
|
366
|
-
confidence: number;
|
|
367
|
-
}>;
|
|
368
|
-
/**
|
|
369
|
-
* Get project context (domain-specific knowledge)
|
|
370
|
-
*/
|
|
371
|
-
getProjectContext(): Promise<MemoryContext['projectContext'] | undefined>;
|
|
372
|
-
/**
|
|
373
|
-
* Update project context with new conventions
|
|
374
|
-
*/
|
|
375
|
-
updateProjectContext(update: {
|
|
376
|
-
domain?: 'business' | 'ecommerce' | 'cms' | 'dashboard' | 'workflow';
|
|
377
|
-
conventions?: string[];
|
|
378
|
-
existingEntities?: string[];
|
|
379
|
-
}): Promise<void>;
|
|
380
|
-
/**
|
|
381
|
-
* Build complete memory context for a generation request
|
|
382
|
-
*/
|
|
383
|
-
buildContext(request: string): Promise<MemoryContext>;
|
|
384
|
-
/**
|
|
385
|
-
* Get memory quality metrics
|
|
386
|
-
*/
|
|
387
|
-
getMetrics(): MemoryQualityMetrics;
|
|
388
|
-
private recordMetrics;
|
|
389
|
-
}
|
|
390
|
-
declare function createMemoryIntegration(options: MemoryIntegrationOptions): MemoryIntegrationEngine;
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Workflow action definition for ReAct
|
|
394
|
-
*/
|
|
395
|
-
interface WorkflowAction {
|
|
396
|
-
/** Action name */
|
|
397
|
-
name: string;
|
|
398
|
-
/** Workflow definition */
|
|
399
|
-
workflow: {
|
|
400
|
-
steps: Array<{
|
|
401
|
-
id: string;
|
|
402
|
-
tool: string;
|
|
403
|
-
input: Record<string, unknown>;
|
|
404
|
-
dependsOn?: string[];
|
|
405
|
-
}>;
|
|
406
|
-
parallel?: string[][];
|
|
407
|
-
condition?: {
|
|
408
|
-
stepId: string;
|
|
409
|
-
predicate: (context: unknown) => boolean;
|
|
410
|
-
then: string;
|
|
411
|
-
else: string;
|
|
412
|
-
};
|
|
413
|
-
retry?: {
|
|
414
|
-
stepId: string;
|
|
415
|
-
maxAttempts: number;
|
|
416
|
-
backoffMs: number;
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
/** Expected output schema */
|
|
420
|
-
outputSchema?: Record<string, unknown>;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Workflow action result
|
|
424
|
-
*/
|
|
425
|
-
interface WorkflowActionResult {
|
|
426
|
-
success: boolean;
|
|
427
|
-
output: unknown;
|
|
428
|
-
stepsExecuted: number;
|
|
429
|
-
durationMs: number;
|
|
430
|
-
retries: number;
|
|
431
|
-
errors: string[];
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* ReAct workflow executor options
|
|
435
|
-
*/
|
|
436
|
-
interface ReActWorkflowOptions {
|
|
437
|
-
/** Tool executor */
|
|
438
|
-
toolExecutor: {
|
|
439
|
-
execute(tool: string, input: Record<string, unknown>): Promise<unknown>;
|
|
440
|
-
};
|
|
441
|
-
/** Memory manager for storing workflow results */
|
|
442
|
-
memoryManager?: MemoryManager;
|
|
443
|
-
/** Enable workflow telemetry */
|
|
444
|
-
enableTelemetry?: boolean;
|
|
445
|
-
/** Max workflow execution time */
|
|
446
|
-
maxExecutionMs?: number;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Workflow telemetry event
|
|
450
|
-
*/
|
|
451
|
-
interface WorkflowTelemetryEvent {
|
|
452
|
-
sessionId: string;
|
|
453
|
-
actionName: string;
|
|
454
|
-
stepId: string;
|
|
455
|
-
tool: string;
|
|
456
|
-
durationMs: number;
|
|
457
|
-
success: boolean;
|
|
458
|
-
retryCount: number;
|
|
459
|
-
timestamp: number;
|
|
460
|
-
}
|
|
461
|
-
declare class ReActWorkflowExecutor {
|
|
462
|
-
private workflowEngine;
|
|
463
|
-
private options;
|
|
464
|
-
private telemetry;
|
|
465
|
-
constructor(options: ReActWorkflowOptions);
|
|
466
|
-
/**
|
|
467
|
-
* Execute a workflow action within a ReAct session
|
|
468
|
-
* This replaces simple tool calls with full workflows
|
|
469
|
-
*/
|
|
470
|
-
executeWorkflowAction(session: ReActSession, action: WorkflowAction, context: Record<string, unknown>): Promise<WorkflowActionResult>;
|
|
471
|
-
/**
|
|
472
|
-
* Execute workflow with timeout
|
|
473
|
-
*/
|
|
474
|
-
private executeWithTimeout;
|
|
475
|
-
/**
|
|
476
|
-
* Store workflow result in memory for learning
|
|
477
|
-
*/
|
|
478
|
-
private storeWorkflowResult;
|
|
479
|
-
/**
|
|
480
|
-
* Record telemetry for a workflow step
|
|
481
|
-
*/
|
|
482
|
-
recordTelemetry(event: WorkflowTelemetryEvent): void;
|
|
483
|
-
/**
|
|
484
|
-
* Get telemetry for analysis
|
|
485
|
-
*/
|
|
486
|
-
getTelemetry(sessionId?: string): WorkflowTelemetryEvent[];
|
|
487
|
-
/**
|
|
488
|
-
* Get workflow performance metrics
|
|
489
|
-
*/
|
|
490
|
-
getMetrics(): {
|
|
491
|
-
totalWorkflows: number;
|
|
492
|
-
successRate: number;
|
|
493
|
-
avgDurationMs: number;
|
|
494
|
-
avgRetries: number;
|
|
495
|
-
toolUsage: Record<string, number>;
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
interface ExtendedReActOptions {
|
|
499
|
-
/** Base ReAct options */
|
|
500
|
-
reactOptions: ConstructorParameters<typeof ReActEngine>[0];
|
|
501
|
-
/** Workflow executor options */
|
|
502
|
-
workflowOptions: ReActWorkflowOptions;
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Extended ReAct engine with workflow integration
|
|
506
|
-
*/
|
|
507
|
-
declare class ReActWorkflowEngine {
|
|
508
|
-
private reactEngine;
|
|
509
|
-
private workflowExecutor;
|
|
510
|
-
constructor(options: ExtendedReActOptions);
|
|
511
|
-
/**
|
|
512
|
-
* Start a new session
|
|
513
|
-
*/
|
|
514
|
-
startSession(userRequest: string): ReActSession;
|
|
515
|
-
/**
|
|
516
|
-
* Execute REASON step
|
|
517
|
-
*/
|
|
518
|
-
reason(sessionId: string, context: {
|
|
519
|
-
request: string;
|
|
520
|
-
previousSteps?: ReActStep[];
|
|
521
|
-
}): Promise<ReActStep>;
|
|
522
|
-
/**
|
|
523
|
-
* Execute ACT step with workflow support
|
|
524
|
-
*
|
|
525
|
-
* This is the key integration point - replaces simple tool calls
|
|
526
|
-
* with full workflows that have retry, parallel execution, etc.
|
|
527
|
-
*/
|
|
528
|
-
act(sessionId: string, action: string, actionInput: Record<string, unknown>, workflowAction?: WorkflowAction): Promise<{
|
|
529
|
-
step: ReActStep;
|
|
530
|
-
workflowResult?: WorkflowActionResult;
|
|
531
|
-
}>;
|
|
532
|
-
/**
|
|
533
|
-
* Execute OBSERVE step
|
|
534
|
-
*/
|
|
535
|
-
observe(sessionId: string, observation: string): Promise<ReActStep>;
|
|
536
|
-
/**
|
|
537
|
-
* Execute REFLECT step
|
|
538
|
-
*/
|
|
539
|
-
reflect(sessionId: string, result: unknown): Promise<{
|
|
540
|
-
step: ReActStep;
|
|
541
|
-
reflection: ReflectionResult;
|
|
542
|
-
}>;
|
|
543
|
-
/**
|
|
544
|
-
* Execute CORRECT step
|
|
545
|
-
*/
|
|
546
|
-
correct(sessionId: string, correctionAction: string, correctionInput: Record<string, unknown>): Promise<ReActStep>;
|
|
547
|
-
/**
|
|
548
|
-
* Get session
|
|
549
|
-
*/
|
|
550
|
-
getSession(sessionId: string): ReActSession;
|
|
551
|
-
/**
|
|
552
|
-
* Get workflow metrics
|
|
553
|
-
*/
|
|
554
|
-
getWorkflowMetrics(): ReturnType<ReActWorkflowExecutor['getMetrics']>;
|
|
555
|
-
}
|
|
556
|
-
declare function createReActWorkflowExecutor(options: ReActWorkflowOptions): ReActWorkflowExecutor;
|
|
557
|
-
declare function createReActWorkflowEngine(options: ExtendedReActOptions): ReActWorkflowEngine;
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* HITL Workflow Integration - Phase 3.4
|
|
561
|
-
*
|
|
562
|
-
* Human-in-the-Loop with workflow-based conditional branching.
|
|
563
|
-
* Enables complex approval flows with human gates.
|
|
564
|
-
*
|
|
565
|
-
* @packageDocumentation
|
|
566
|
-
*/
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* Human gate types
|
|
570
|
-
*/
|
|
571
|
-
type HumanGateType = 'approval' | 'edit' | 'select' | 'custom';
|
|
572
|
-
/**
|
|
573
|
-
* Human gate configuration
|
|
574
|
-
*/
|
|
575
|
-
interface HumanGate {
|
|
576
|
-
/** Gate ID */
|
|
577
|
-
id: string;
|
|
578
|
-
/** Gate type */
|
|
579
|
-
type: HumanGateType;
|
|
580
|
-
/** Display title */
|
|
581
|
-
title: string;
|
|
582
|
-
/** Description */
|
|
583
|
-
description: string;
|
|
584
|
-
/** Gate condition - when to show */
|
|
585
|
-
condition?: (context: unknown) => boolean;
|
|
586
|
-
/** Timeout in ms */
|
|
587
|
-
timeoutMs?: number;
|
|
588
|
-
/** Auto-approve if condition met */
|
|
589
|
-
autoApprove?: {
|
|
590
|
-
condition: (context: unknown) => boolean;
|
|
591
|
-
reason: string;
|
|
592
|
-
};
|
|
593
|
-
/** Gate-specific payload */
|
|
594
|
-
payload?: Record<string, unknown>;
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Human gate result
|
|
598
|
-
*/
|
|
599
|
-
interface HumanGateResult {
|
|
600
|
-
gateId: string;
|
|
601
|
-
approved: boolean;
|
|
602
|
-
response: unknown;
|
|
603
|
-
respondedAt: number;
|
|
604
|
-
userId?: string;
|
|
605
|
-
autoApproved: boolean;
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Workflow branch definition
|
|
609
|
-
*/
|
|
610
|
-
interface WorkflowBranch {
|
|
611
|
-
/** Branch ID */
|
|
612
|
-
id: string;
|
|
613
|
-
/** Branch condition */
|
|
614
|
-
condition: (context: unknown) => boolean;
|
|
615
|
-
/** Steps to execute */
|
|
616
|
-
steps: Array<{
|
|
617
|
-
tool: string;
|
|
618
|
-
input: Record<string, unknown>;
|
|
619
|
-
}>;
|
|
620
|
-
/** Human gate before branch */
|
|
621
|
-
gate?: HumanGate;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* HITL workflow definition
|
|
625
|
-
*/
|
|
626
|
-
interface HITLWorkflowDefinition {
|
|
627
|
-
/** Workflow name */
|
|
628
|
-
name: string;
|
|
629
|
-
/** Initial steps (before any gates) */
|
|
630
|
-
initialSteps: Array<{
|
|
631
|
-
tool: string;
|
|
632
|
-
input: Record<string, unknown>;
|
|
633
|
-
}>;
|
|
634
|
-
/** Human gates with conditional branches */
|
|
635
|
-
gates: HumanGate[];
|
|
636
|
-
/** Branches based on gate outcomes */
|
|
637
|
-
branches: WorkflowBranch[];
|
|
638
|
-
/** Fallback if no branches match */
|
|
639
|
-
fallbackBranch?: WorkflowBranch;
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* HITL workflow result
|
|
643
|
-
*/
|
|
644
|
-
interface HITLWorkflowResult {
|
|
645
|
-
success: boolean;
|
|
646
|
-
output: unknown;
|
|
647
|
-
gatesPassed: HumanGateResult[];
|
|
648
|
-
branchesTaken: string[];
|
|
649
|
-
durationMs: number;
|
|
650
|
-
wasInterrupted: boolean;
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* HITL workflow options
|
|
654
|
-
*/
|
|
655
|
-
interface HITLWorkflowOptions {
|
|
656
|
-
/** HITL manager */
|
|
657
|
-
hitlManager: HITLv2Manager;
|
|
658
|
-
/** Tool executor */
|
|
659
|
-
toolExecutor: {
|
|
660
|
-
execute(tool: string, input: Record<string, unknown>): Promise<unknown>;
|
|
661
|
-
};
|
|
662
|
-
/** Memory manager */
|
|
663
|
-
memoryManager?: MemoryManager;
|
|
664
|
-
/** Default gate timeout */
|
|
665
|
-
defaultTimeoutMs?: number;
|
|
666
|
-
/** Enable auto-approval learning */
|
|
667
|
-
enableAutoApprove?: boolean;
|
|
668
|
-
}
|
|
669
|
-
declare class HITLWorkflowEngine {
|
|
670
|
-
private workflowEngine;
|
|
671
|
-
private hitlManager;
|
|
672
|
-
private options;
|
|
673
|
-
private gateHistory;
|
|
674
|
-
constructor(options: HITLWorkflowOptions);
|
|
675
|
-
/**
|
|
676
|
-
* Execute a workflow with human gates
|
|
677
|
-
*/
|
|
678
|
-
executeWorkflow(sessionId: string, workflow: HITLWorkflowDefinition, initialContext: Record<string, unknown>): Promise<HITLWorkflowResult>;
|
|
679
|
-
/**
|
|
680
|
-
* Execute initial workflow steps
|
|
681
|
-
*/
|
|
682
|
-
private executeInitialSteps;
|
|
683
|
-
/**
|
|
684
|
-
* Execute a human gate
|
|
685
|
-
*/
|
|
686
|
-
private executeHumanGate;
|
|
687
|
-
/**
|
|
688
|
-
* Execute approval gate
|
|
689
|
-
*/
|
|
690
|
-
private executeApprovalGate;
|
|
691
|
-
/**
|
|
692
|
-
* Execute edit gate
|
|
693
|
-
*/
|
|
694
|
-
private executeEditGate;
|
|
695
|
-
/**
|
|
696
|
-
* Execute select gate
|
|
697
|
-
*/
|
|
698
|
-
private executeSelectGate;
|
|
699
|
-
/**
|
|
700
|
-
* Execute custom gate
|
|
701
|
-
*/
|
|
702
|
-
private executeCustomGate;
|
|
703
|
-
/**
|
|
704
|
-
* Execute branch steps
|
|
705
|
-
*/
|
|
706
|
-
private executeBranchSteps;
|
|
707
|
-
/**
|
|
708
|
-
* Wait for interrupt response
|
|
709
|
-
*/
|
|
710
|
-
private waitForResponse;
|
|
711
|
-
/**
|
|
712
|
-
* Interpolate input with context
|
|
713
|
-
*/
|
|
714
|
-
private interpolateInput;
|
|
715
|
-
/**
|
|
716
|
-
* Get value from path
|
|
717
|
-
*/
|
|
718
|
-
private getValueFromPath;
|
|
719
|
-
/**
|
|
720
|
-
* Get gate history for a session
|
|
721
|
-
*/
|
|
722
|
-
getGateHistory(sessionId: string): HumanGateResult[];
|
|
723
|
-
/**
|
|
724
|
-
* Clear gate history
|
|
725
|
-
*/
|
|
726
|
-
clearGateHistory(sessionId?: string): void;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Schema generation with human review
|
|
730
|
-
*/
|
|
731
|
-
declare function createSchemaGenerationHITLWorkflow(complexity: 'simple' | 'medium' | 'complex'): HITLWorkflowDefinition;
|
|
732
|
-
/**
|
|
733
|
-
* Multi-stage approval workflow
|
|
734
|
-
*/
|
|
735
|
-
declare function createMultiStageApprovalWorkflow(stages: Array<{
|
|
736
|
-
name: string;
|
|
737
|
-
approver: string;
|
|
738
|
-
}>): HITLWorkflowDefinition;
|
|
739
|
-
declare function createHITLWorkflowEngine(options: HITLWorkflowOptions): HITLWorkflowEngine;
|
|
740
|
-
|
|
741
|
-
export { type ConfirmPayload, type EditPayload, type ExtendedReActOptions, type HITLWorkflowDefinition, HITLWorkflowEngine, type HITLWorkflowOptions, type HITLWorkflowResult, HITLv2Manager, type HITLv2Options, type HumanGate, type HumanGateResult, type InterruptContext, type InterruptRequest, type InterruptResponse, type InterruptType, type MemoryContext, MemoryIntegrationEngine, type MemoryIntegrationOptions, type MemoryQualityMetrics, ReActEngine, type ReActOptions, type ReActSession, type ReActState, type ReActStep, ReActWorkflowEngine, ReActWorkflowExecutor, type ReActWorkflowOptions, type ReflectionResult, type SelectPayload, type SimilarSession, type TextPayload, type WorkflowAction, type WorkflowActionResult, type WorkflowBranch, type WorkflowTelemetryEvent, createHITLWorkflowEngine, createHITLv2Manager, createMemoryIntegration, createMultiStageApprovalWorkflow, createReActEngine, createReActWorkflowEngine, createReActWorkflowExecutor, createSchemaGenerationHITLWorkflow };
|