@defai.digital/agent-domain 13.0.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/LICENSE +214 -0
- package/dist/enhanced-executor.d.ts +170 -0
- package/dist/enhanced-executor.d.ts.map +1 -0
- package/dist/enhanced-executor.js +1072 -0
- package/dist/enhanced-executor.js.map +1 -0
- package/dist/executor.d.ts +120 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +929 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +50 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +160 -0
- package/dist/loader.js.map +1 -0
- package/dist/persistent-registry.d.ts +105 -0
- package/dist/persistent-registry.d.ts.map +1 -0
- package/dist/persistent-registry.js +183 -0
- package/dist/persistent-registry.js.map +1 -0
- package/dist/production-factories.d.ts +70 -0
- package/dist/production-factories.d.ts.map +1 -0
- package/dist/production-factories.js +434 -0
- package/dist/production-factories.js.map +1 -0
- package/dist/prompt-executor.d.ts +119 -0
- package/dist/prompt-executor.d.ts.map +1 -0
- package/dist/prompt-executor.js +211 -0
- package/dist/prompt-executor.js.map +1 -0
- package/dist/registry.d.ts +57 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +123 -0
- package/dist/registry.js.map +1 -0
- package/dist/selection-service.d.ts +74 -0
- package/dist/selection-service.d.ts.map +1 -0
- package/dist/selection-service.js +322 -0
- package/dist/selection-service.js.map +1 -0
- package/dist/selector.d.ts +51 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +249 -0
- package/dist/selector.js.map +1 -0
- package/dist/stub-checkpoint.d.ts +23 -0
- package/dist/stub-checkpoint.d.ts.map +1 -0
- package/dist/stub-checkpoint.js +137 -0
- package/dist/stub-checkpoint.js.map +1 -0
- package/dist/stub-delegation-tracker.d.ts +25 -0
- package/dist/stub-delegation-tracker.d.ts.map +1 -0
- package/dist/stub-delegation-tracker.js +118 -0
- package/dist/stub-delegation-tracker.js.map +1 -0
- package/dist/stub-parallel-executor.d.ts +19 -0
- package/dist/stub-parallel-executor.d.ts.map +1 -0
- package/dist/stub-parallel-executor.js +176 -0
- package/dist/stub-parallel-executor.js.map +1 -0
- package/dist/types.d.ts +614 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/workflow-templates.d.ts +117 -0
- package/dist/workflow-templates.d.ts.map +1 -0
- package/dist/workflow-templates.js +342 -0
- package/dist/workflow-templates.js.map +1 -0
- package/package.json +51 -0
- package/src/enhanced-executor.ts +1395 -0
- package/src/executor.ts +1153 -0
- package/src/index.ts +172 -0
- package/src/loader.ts +191 -0
- package/src/persistent-registry.ts +235 -0
- package/src/production-factories.ts +613 -0
- package/src/prompt-executor.ts +310 -0
- package/src/registry.ts +167 -0
- package/src/selection-service.ts +411 -0
- package/src/selector.ts +299 -0
- package/src/stub-checkpoint.ts +187 -0
- package/src/stub-delegation-tracker.ts +161 -0
- package/src/stub-parallel-executor.ts +224 -0
- package/src/types.ts +784 -0
- package/src/workflow-templates.ts +393 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistent-registry.js","sourceRoot":"","sources":["../src/persistent-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,oBAAoB,EAEpB,aAAa,EACb,eAAe,EACf,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAuBtD;;GAEG;AACH,MAAM,OAAO,uBAAuB;IACjB,QAAQ,CAAwB;IAChC,MAAM,CAAqC;IACpD,WAAW,GAAG,KAAK,CAA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CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACnE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACjC,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,6BAA6B,CAC3C,MAAgC;IAEhC,OAAO,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production Factory Implementations
|
|
3
|
+
*
|
|
4
|
+
* Provides real implementations of checkpoint, delegation, and parallel execution
|
|
5
|
+
* factories for production use. These wire together the various domain packages.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createProductionFactories } from '@defai.digital/agent-domain';
|
|
10
|
+
*
|
|
11
|
+
* const factories = createProductionFactories({
|
|
12
|
+
* checkpointStorage: sqliteCheckpointStorage,
|
|
13
|
+
* // ... other config
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const executor = createEnhancedAgentExecutor(registry, {
|
|
17
|
+
* ...factories,
|
|
18
|
+
* // ... other config
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { CheckpointConfig, ParallelExecutionConfig } from '@defai.digital/contracts';
|
|
23
|
+
import type { CheckpointStoragePort, CheckpointStorageFactory, CheckpointManagerFactory, DelegationTrackerFactory, ParallelExecutorFactory } from './types.js';
|
|
24
|
+
/**
|
|
25
|
+
* Create a production checkpoint storage factory
|
|
26
|
+
*/
|
|
27
|
+
export declare function createCheckpointStorageFactory(storage: CheckpointStoragePort): CheckpointStorageFactory;
|
|
28
|
+
/**
|
|
29
|
+
* Create a production checkpoint manager factory
|
|
30
|
+
*/
|
|
31
|
+
export declare function createCheckpointManagerFactory(): CheckpointManagerFactory;
|
|
32
|
+
/**
|
|
33
|
+
* Create a production delegation tracker factory
|
|
34
|
+
*/
|
|
35
|
+
export declare function createDelegationTrackerFactory(): DelegationTrackerFactory;
|
|
36
|
+
/**
|
|
37
|
+
* Create a production parallel executor factory
|
|
38
|
+
*/
|
|
39
|
+
export declare function createParallelExecutorFactory(): ParallelExecutorFactory;
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for production factories
|
|
42
|
+
*/
|
|
43
|
+
export interface ProductionFactoriesConfig {
|
|
44
|
+
/** Checkpoint storage implementation */
|
|
45
|
+
checkpointStorage?: CheckpointStoragePort;
|
|
46
|
+
/** Checkpoint config overrides */
|
|
47
|
+
checkpointConfig?: Partial<CheckpointConfig>;
|
|
48
|
+
/** Parallel execution config overrides */
|
|
49
|
+
parallelConfig?: Partial<ParallelExecutionConfig>;
|
|
50
|
+
/** Maximum delegation depth */
|
|
51
|
+
maxDelegationDepth?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Production factories result
|
|
55
|
+
*/
|
|
56
|
+
export interface ProductionFactories {
|
|
57
|
+
checkpointStorageFactory?: CheckpointStorageFactory;
|
|
58
|
+
checkpointManagerFactory: CheckpointManagerFactory;
|
|
59
|
+
delegationTrackerFactory: DelegationTrackerFactory;
|
|
60
|
+
parallelExecutorFactory: ParallelExecutorFactory;
|
|
61
|
+
checkpointConfig?: Partial<CheckpointConfig>;
|
|
62
|
+
parallelConfig?: Partial<ParallelExecutionConfig>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create all production factories
|
|
66
|
+
*
|
|
67
|
+
* This is the main entry point for wiring real implementations.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createProductionFactories(config?: ProductionFactoriesConfig): ProductionFactories;
|
|
70
|
+
//# sourceMappingURL=production-factories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-factories.d.ts","sourceRoot":"","sources":["../src/production-factories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAE1F,OAAO,KAAK,EACV,qBAAqB,EAErB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EAGxB,uBAAuB,EAExB,MAAM,YAAY,CAAC;AA4dpB;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,qBAAqB,GAC7B,wBAAwB,CAE1B;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,wBAAwB,CAOzE;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,wBAAwB,CAMzE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,uBAAuB,CAMvE;AAMD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,wCAAwC;IACxC,iBAAiB,CAAC,EAAE,qBAAqB,CAAC;IAC1C,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7C,0CAA0C;IAC1C,cAAc,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAClD,+BAA+B;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7C,cAAc,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,GAAE,yBAA8B,GACrC,mBAAmB,CAsBrB"}
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production Factory Implementations
|
|
3
|
+
*
|
|
4
|
+
* Provides real implementations of checkpoint, delegation, and parallel execution
|
|
5
|
+
* factories for production use. These wire together the various domain packages.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createProductionFactories } from '@defai.digital/agent-domain';
|
|
10
|
+
*
|
|
11
|
+
* const factories = createProductionFactories({
|
|
12
|
+
* checkpointStorage: sqliteCheckpointStorage,
|
|
13
|
+
* // ... other config
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const executor = createEnhancedAgentExecutor(registry, {
|
|
17
|
+
* ...factories,
|
|
18
|
+
* // ... other config
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { createDefaultParallelExecutionConfig } from '@defai.digital/contracts';
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Production Checkpoint Manager
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Production checkpoint manager implementation
|
|
28
|
+
*
|
|
29
|
+
* INV-CP-001: Checkpoint contains all data needed to resume
|
|
30
|
+
* INV-CP-002: Resumed execution starts from step after checkpoint
|
|
31
|
+
*/
|
|
32
|
+
class ProductionCheckpointManager {
|
|
33
|
+
agentId;
|
|
34
|
+
sessionId;
|
|
35
|
+
storage;
|
|
36
|
+
config;
|
|
37
|
+
checkpointCount = 0;
|
|
38
|
+
constructor(agentId, sessionId, storage, config) {
|
|
39
|
+
this.agentId = agentId;
|
|
40
|
+
this.sessionId = sessionId;
|
|
41
|
+
this.storage = storage;
|
|
42
|
+
this.config = config;
|
|
43
|
+
}
|
|
44
|
+
getConfig() {
|
|
45
|
+
return { ...this.config };
|
|
46
|
+
}
|
|
47
|
+
shouldCheckpoint(stepIndex) {
|
|
48
|
+
if (!this.config.enabled)
|
|
49
|
+
return false;
|
|
50
|
+
if (this.config.intervalSteps === 0)
|
|
51
|
+
return true;
|
|
52
|
+
return stepIndex % this.config.intervalSteps === 0;
|
|
53
|
+
}
|
|
54
|
+
async createCheckpoint(stepIndex, stepId, previousOutputs, metadata) {
|
|
55
|
+
const now = new Date();
|
|
56
|
+
const expiresAt = new Date(now.getTime() + this.config.retentionHours * 60 * 60 * 1000);
|
|
57
|
+
// INV-CP-001: Checkpoint contains all data needed to resume
|
|
58
|
+
const checkpoint = {
|
|
59
|
+
checkpointId: crypto.randomUUID(),
|
|
60
|
+
agentId: this.agentId,
|
|
61
|
+
sessionId: this.sessionId,
|
|
62
|
+
stepIndex,
|
|
63
|
+
stepId,
|
|
64
|
+
previousOutputs,
|
|
65
|
+
metadata,
|
|
66
|
+
createdAt: now.toISOString(),
|
|
67
|
+
expiresAt: expiresAt.toISOString(),
|
|
68
|
+
};
|
|
69
|
+
await this.storage.save(checkpoint);
|
|
70
|
+
this.checkpointCount++;
|
|
71
|
+
// Enforce max checkpoints
|
|
72
|
+
if (this.checkpointCount > this.config.maxCheckpoints) {
|
|
73
|
+
const allCheckpoints = await this.storage.list(this.agentId, this.sessionId);
|
|
74
|
+
const toDelete = allCheckpoints.slice(this.config.maxCheckpoints);
|
|
75
|
+
for (const cp of toDelete) {
|
|
76
|
+
await this.storage.delete(cp.checkpointId);
|
|
77
|
+
}
|
|
78
|
+
this.checkpointCount = this.config.maxCheckpoints;
|
|
79
|
+
}
|
|
80
|
+
return checkpoint;
|
|
81
|
+
}
|
|
82
|
+
async getLatestCheckpoint() {
|
|
83
|
+
return this.storage.loadLatest(this.agentId, this.sessionId);
|
|
84
|
+
}
|
|
85
|
+
async getResumeContext(checkpointId) {
|
|
86
|
+
const checkpoint = await this.storage.load(checkpointId);
|
|
87
|
+
if (!checkpoint) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
// Check if expired
|
|
91
|
+
if (checkpoint.expiresAt) {
|
|
92
|
+
const expiresAt = new Date(checkpoint.expiresAt).getTime();
|
|
93
|
+
if (expiresAt < Date.now()) {
|
|
94
|
+
await this.storage.delete(checkpointId);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// INV-CP-002: Resumed execution starts from step after checkpoint
|
|
99
|
+
return {
|
|
100
|
+
startFromStep: checkpoint.stepIndex + 1,
|
|
101
|
+
previousOutputs: checkpoint.previousOutputs,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async cleanup() {
|
|
105
|
+
return this.storage.deleteExpired();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// Production Delegation Tracker
|
|
110
|
+
// ============================================================================
|
|
111
|
+
/**
|
|
112
|
+
* Production delegation tracker implementation
|
|
113
|
+
*
|
|
114
|
+
* INV-DT-001: Maximum delegation depth enforced
|
|
115
|
+
* INV-DT-002: Circular delegations prevented
|
|
116
|
+
*/
|
|
117
|
+
class ProductionDelegationTracker {
|
|
118
|
+
agentId;
|
|
119
|
+
context;
|
|
120
|
+
maxDepth;
|
|
121
|
+
history = [];
|
|
122
|
+
rootTaskId;
|
|
123
|
+
constructor(agentId, parentContext, maxDepth) {
|
|
124
|
+
this.agentId = agentId;
|
|
125
|
+
this.maxDepth = maxDepth;
|
|
126
|
+
if (parentContext) {
|
|
127
|
+
this.rootTaskId = parentContext.rootTaskId;
|
|
128
|
+
this.context = {
|
|
129
|
+
initiatorAgentId: parentContext.initiatorAgentId,
|
|
130
|
+
rootTaskId: parentContext.rootTaskId,
|
|
131
|
+
currentDepth: parentContext.currentDepth + 1,
|
|
132
|
+
delegationChain: [...parentContext.delegationChain, agentId],
|
|
133
|
+
maxDepth: parentContext.maxDepth,
|
|
134
|
+
startedAt: parentContext.startedAt,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this.rootTaskId = crypto.randomUUID();
|
|
139
|
+
this.context = {
|
|
140
|
+
initiatorAgentId: agentId,
|
|
141
|
+
rootTaskId: this.rootTaskId,
|
|
142
|
+
currentDepth: 0,
|
|
143
|
+
delegationChain: [agentId],
|
|
144
|
+
maxDepth,
|
|
145
|
+
startedAt: new Date().toISOString(),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
getContext() {
|
|
150
|
+
return { ...this.context };
|
|
151
|
+
}
|
|
152
|
+
canDelegate(toAgentId) {
|
|
153
|
+
// INV-DT-001: Check depth limit
|
|
154
|
+
if (this.context.currentDepth >= this.maxDepth) {
|
|
155
|
+
return {
|
|
156
|
+
allowed: false,
|
|
157
|
+
reason: 'MAX_DEPTH_EXCEEDED',
|
|
158
|
+
message: `Maximum delegation depth (${this.maxDepth}) exceeded`,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// INV-DT-002: Check for circular delegation
|
|
162
|
+
if (this.context.delegationChain.includes(toAgentId)) {
|
|
163
|
+
return {
|
|
164
|
+
allowed: false,
|
|
165
|
+
reason: 'CIRCULAR_DELEGATION',
|
|
166
|
+
message: `Circular delegation detected: ${this.context.delegationChain.join(' -> ')} -> ${toAgentId}`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
allowed: true,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
createDelegationRequest(toAgentId, task, input, timeout) {
|
|
174
|
+
const check = this.canDelegate(toAgentId);
|
|
175
|
+
if (!check.allowed) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
fromAgentId: this.agentId,
|
|
180
|
+
toAgentId,
|
|
181
|
+
task,
|
|
182
|
+
input,
|
|
183
|
+
timeout,
|
|
184
|
+
context: this.context,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
createChildContext(toAgentId) {
|
|
188
|
+
return {
|
|
189
|
+
initiatorAgentId: this.context.initiatorAgentId,
|
|
190
|
+
rootTaskId: this.context.rootTaskId,
|
|
191
|
+
currentDepth: this.context.currentDepth + 1,
|
|
192
|
+
delegationChain: [...this.context.delegationChain, toAgentId],
|
|
193
|
+
maxDepth: this.context.maxDepth,
|
|
194
|
+
startedAt: this.context.startedAt,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
recordResult(result) {
|
|
198
|
+
this.history.push(result);
|
|
199
|
+
}
|
|
200
|
+
getHistory() {
|
|
201
|
+
return [...this.history];
|
|
202
|
+
}
|
|
203
|
+
isRoot() {
|
|
204
|
+
return this.context.currentDepth === 0;
|
|
205
|
+
}
|
|
206
|
+
getRemainingDepth() {
|
|
207
|
+
return this.maxDepth - this.context.currentDepth;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Production parallel executor implementation
|
|
212
|
+
*
|
|
213
|
+
* INV-PE-001: Independent steps execute concurrently
|
|
214
|
+
* INV-PE-002: Dependencies honored (DAG ordering)
|
|
215
|
+
* INV-PE-003: Concurrency limit respected
|
|
216
|
+
*/
|
|
217
|
+
class ProductionParallelExecutor {
|
|
218
|
+
config;
|
|
219
|
+
cancelled = false;
|
|
220
|
+
constructor(config) {
|
|
221
|
+
this.config = config;
|
|
222
|
+
}
|
|
223
|
+
getConfig() {
|
|
224
|
+
return { ...this.config };
|
|
225
|
+
}
|
|
226
|
+
async executeGroup(steps, executor, previousOutputs = {}) {
|
|
227
|
+
this.cancelled = false;
|
|
228
|
+
const startTime = Date.now();
|
|
229
|
+
const results = [];
|
|
230
|
+
const outputs = { ...previousOutputs };
|
|
231
|
+
if (!this.config.enabled) {
|
|
232
|
+
// Sequential execution
|
|
233
|
+
for (const step of steps) {
|
|
234
|
+
if (this.cancelled) {
|
|
235
|
+
results.push(this.createCancelledResult(step.stepId));
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const stepResult = await this.executeStep(step, executor, outputs);
|
|
239
|
+
results.push(stepResult);
|
|
240
|
+
if (stepResult.success && stepResult.output !== undefined) {
|
|
241
|
+
outputs[step.stepId] = stepResult.output;
|
|
242
|
+
}
|
|
243
|
+
// Handle failure strategy
|
|
244
|
+
if (!stepResult.success && this.config.failureStrategy === 'failFast') {
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
// Parallel execution with DAG ordering
|
|
251
|
+
// INV-PE-002: Dependencies honored
|
|
252
|
+
const layers = this.buildExecutionLayers(steps);
|
|
253
|
+
for (const layer of layers) {
|
|
254
|
+
if (this.cancelled) {
|
|
255
|
+
for (const step of layer) {
|
|
256
|
+
results.push(this.createCancelledResult(step.stepId));
|
|
257
|
+
}
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
// INV-PE-001: Independent steps execute concurrently
|
|
261
|
+
// INV-PE-003: Concurrency limit respected
|
|
262
|
+
const layerResults = await this.executeLayer(layer, executor, outputs);
|
|
263
|
+
results.push(...layerResults);
|
|
264
|
+
// Collect outputs
|
|
265
|
+
for (const result of layerResults) {
|
|
266
|
+
if (result.success && result.output !== undefined) {
|
|
267
|
+
outputs[result.stepId] = result.output;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Handle failure strategy
|
|
271
|
+
if (this.config.failureStrategy === 'failFast') {
|
|
272
|
+
if (layerResults.some((r) => !r.success)) {
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const failedCount = results.filter((r) => !r.success && !r.cancelled).length;
|
|
279
|
+
const cancelledCount = results.filter((r) => r.cancelled).length;
|
|
280
|
+
return {
|
|
281
|
+
stepResults: results,
|
|
282
|
+
totalDurationMs: Date.now() - startTime,
|
|
283
|
+
allSucceeded: failedCount === 0 && cancelledCount === 0,
|
|
284
|
+
failedCount,
|
|
285
|
+
cancelledCount,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
buildExecutionLayers(steps) {
|
|
289
|
+
const layers = [];
|
|
290
|
+
const completed = new Set();
|
|
291
|
+
const remaining = [...steps];
|
|
292
|
+
// Guard against infinite loops with max iteration limit
|
|
293
|
+
const maxIterations = steps.length + 1;
|
|
294
|
+
let iterations = 0;
|
|
295
|
+
while (remaining.length > 0 && iterations < maxIterations) {
|
|
296
|
+
iterations++;
|
|
297
|
+
const layer = [];
|
|
298
|
+
const toRemove = [];
|
|
299
|
+
for (let i = 0; i < remaining.length; i++) {
|
|
300
|
+
const step = remaining[i];
|
|
301
|
+
if (!step)
|
|
302
|
+
continue;
|
|
303
|
+
const deps = step.dependencies ?? [];
|
|
304
|
+
// Check if all dependencies are completed
|
|
305
|
+
if (deps.every((d) => completed.has(d))) {
|
|
306
|
+
layer.push(step);
|
|
307
|
+
toRemove.push(i);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// Remove processed steps
|
|
311
|
+
for (let i = toRemove.length - 1; i >= 0; i--) {
|
|
312
|
+
const idx = toRemove[i];
|
|
313
|
+
if (idx !== undefined) {
|
|
314
|
+
remaining.splice(idx, 1);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (layer.length === 0 && remaining.length > 0) {
|
|
318
|
+
// Circular dependency or unresolvable - add remaining as single layer
|
|
319
|
+
const unresolvableSteps = remaining.map((s) => s.stepId).join(', ');
|
|
320
|
+
console.warn(`[buildExecutionLayers] Circular or unresolvable dependencies detected. ` +
|
|
321
|
+
`Unresolvable steps: ${unresolvableSteps}`);
|
|
322
|
+
layers.push(remaining);
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
if (layer.length > 0) {
|
|
326
|
+
layers.push(layer);
|
|
327
|
+
for (const step of layer) {
|
|
328
|
+
completed.add(step.stepId);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (iterations >= maxIterations) {
|
|
333
|
+
console.error(`[buildExecutionLayers] Max iterations (${maxIterations}) reached. ` +
|
|
334
|
+
`This indicates a bug in the algorithm or malformed input.`);
|
|
335
|
+
}
|
|
336
|
+
return layers;
|
|
337
|
+
}
|
|
338
|
+
cancel() {
|
|
339
|
+
this.cancelled = true;
|
|
340
|
+
}
|
|
341
|
+
async executeLayer(layer, executor, outputs) {
|
|
342
|
+
// INV-PE-003: Respect concurrency limit
|
|
343
|
+
const concurrency = this.config.maxConcurrency;
|
|
344
|
+
const results = [];
|
|
345
|
+
for (let i = 0; i < layer.length; i += concurrency) {
|
|
346
|
+
const batch = layer.slice(i, i + concurrency);
|
|
347
|
+
const batchPromises = batch.map((step) => this.executeStep(step, executor, outputs));
|
|
348
|
+
const batchResults = await Promise.all(batchPromises);
|
|
349
|
+
results.push(...batchResults);
|
|
350
|
+
}
|
|
351
|
+
return results;
|
|
352
|
+
}
|
|
353
|
+
async executeStep(step, executor, outputs) {
|
|
354
|
+
const startTime = Date.now();
|
|
355
|
+
try {
|
|
356
|
+
const output = await executor(step, outputs);
|
|
357
|
+
return {
|
|
358
|
+
stepId: step.stepId,
|
|
359
|
+
success: true,
|
|
360
|
+
output,
|
|
361
|
+
durationMs: Date.now() - startTime,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
return {
|
|
366
|
+
stepId: step.stepId,
|
|
367
|
+
success: false,
|
|
368
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
369
|
+
durationMs: Date.now() - startTime,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
createCancelledResult(stepId) {
|
|
374
|
+
return {
|
|
375
|
+
stepId,
|
|
376
|
+
success: false,
|
|
377
|
+
cancelled: true,
|
|
378
|
+
durationMs: 0,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
// ============================================================================
|
|
383
|
+
// Factory Functions
|
|
384
|
+
// ============================================================================
|
|
385
|
+
/**
|
|
386
|
+
* Create a production checkpoint storage factory
|
|
387
|
+
*/
|
|
388
|
+
export function createCheckpointStorageFactory(storage) {
|
|
389
|
+
return () => storage;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Create a production checkpoint manager factory
|
|
393
|
+
*/
|
|
394
|
+
export function createCheckpointManagerFactory() {
|
|
395
|
+
return (agentId, sessionId, storage, config) => new ProductionCheckpointManager(agentId, sessionId, storage, config);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Create a production delegation tracker factory
|
|
399
|
+
*/
|
|
400
|
+
export function createDelegationTrackerFactory() {
|
|
401
|
+
return (agentId, parentContext, maxDepth) => new ProductionDelegationTracker(agentId, parentContext, maxDepth);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Create a production parallel executor factory
|
|
405
|
+
*/
|
|
406
|
+
export function createParallelExecutorFactory() {
|
|
407
|
+
return (config) => new ProductionParallelExecutor({
|
|
408
|
+
...createDefaultParallelExecutionConfig(),
|
|
409
|
+
...config,
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Create all production factories
|
|
414
|
+
*
|
|
415
|
+
* This is the main entry point for wiring real implementations.
|
|
416
|
+
*/
|
|
417
|
+
export function createProductionFactories(config = {}) {
|
|
418
|
+
const factories = {
|
|
419
|
+
checkpointManagerFactory: createCheckpointManagerFactory(),
|
|
420
|
+
delegationTrackerFactory: createDelegationTrackerFactory(),
|
|
421
|
+
parallelExecutorFactory: createParallelExecutorFactory(),
|
|
422
|
+
};
|
|
423
|
+
if (config.checkpointStorage) {
|
|
424
|
+
factories.checkpointStorageFactory = createCheckpointStorageFactory(config.checkpointStorage);
|
|
425
|
+
}
|
|
426
|
+
if (config.checkpointConfig) {
|
|
427
|
+
factories.checkpointConfig = config.checkpointConfig;
|
|
428
|
+
}
|
|
429
|
+
if (config.parallelConfig) {
|
|
430
|
+
factories.parallelConfig = config.parallelConfig;
|
|
431
|
+
}
|
|
432
|
+
return factories;
|
|
433
|
+
}
|
|
434
|
+
//# sourceMappingURL=production-factories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-factories.js","sourceRoot":"","sources":["../src/production-factories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAmBhF,+EAA+E;AAC/E,gCAAgC;AAChC,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,2BAA2B;IACd,OAAO,CAAS;IAChB,SAAS,CAAqB;IAC9B,OAAO,CAAwB;IAC/B,MAAM,CAAmB;IAClC,eAAe,GAAG,CAAC,CAAC;IAE5B,YACE,OAAe,EACf,SAA6B,EAC7B,OAA8B,EAC9B,MAAwB;QAExB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED,gBAAgB,CAAC,SAAiB;QAChC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QACvC,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACjD,OAAO,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,KA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E,8BAA8B,EAAE;QAC1D,wBAAwB,EAAE,8BAA8B,EAAE;QAC1D,uBAAuB,EAAE,6BAA6B,EAAE;KACzD,CAAC;IAEF,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC7B,SAAS,CAAC,wBAAwB,GAAG,8BAA8B,CACjE,MAAM,CAAC,iBAAiB,CACzB,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC5B,SAAS,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACvD,CAAC;IAED,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,SAAS,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IACnD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Executor Implementation
|
|
3
|
+
*
|
|
4
|
+
* Bridges the agent domain with LLM providers for real prompt execution.
|
|
5
|
+
* This file provides both a stub executor for testing and a factory
|
|
6
|
+
* for creating real executors with provider integration.
|
|
7
|
+
*/
|
|
8
|
+
import type { PromptExecutor, PromptExecutionRequest, PromptExecutionResponse } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Stub prompt executor for testing and development
|
|
11
|
+
* Returns mock responses without calling real providers
|
|
12
|
+
*
|
|
13
|
+
* WARNING: This executor returns fake responses. For production use,
|
|
14
|
+
* inject a real PromptExecutor via config.promptExecutor.
|
|
15
|
+
*/
|
|
16
|
+
export declare class StubPromptExecutor implements PromptExecutor {
|
|
17
|
+
private readonly defaultProvider;
|
|
18
|
+
private hasWarnedOnce;
|
|
19
|
+
constructor(defaultProvider?: string);
|
|
20
|
+
execute(request: PromptExecutionRequest): Promise<PromptExecutionResponse>;
|
|
21
|
+
isProviderAvailable(_providerId: string): Promise<boolean>;
|
|
22
|
+
getAvailableProviders(): Promise<string[]>;
|
|
23
|
+
getDefaultProvider(): string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Provider-based prompt executor configuration
|
|
27
|
+
*/
|
|
28
|
+
export interface ProviderPromptExecutorConfig {
|
|
29
|
+
/**
|
|
30
|
+
* Default provider to use when none specified
|
|
31
|
+
*/
|
|
32
|
+
defaultProvider: string;
|
|
33
|
+
/**
|
|
34
|
+
* Default model to use when none specified (per provider)
|
|
35
|
+
*/
|
|
36
|
+
defaultModels?: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Default timeout in milliseconds
|
|
39
|
+
*/
|
|
40
|
+
defaultTimeout?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Interface that matches the provider registry from @defai.digital/providers
|
|
44
|
+
* This allows loose coupling without direct dependency
|
|
45
|
+
*/
|
|
46
|
+
export interface ProviderRegistryLike {
|
|
47
|
+
get(providerId: string): ProviderLike | undefined;
|
|
48
|
+
getProviderIds(): string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Interface that matches a provider from @defai.digital/providers
|
|
52
|
+
*/
|
|
53
|
+
export interface ProviderLike {
|
|
54
|
+
providerId: string;
|
|
55
|
+
complete(request: {
|
|
56
|
+
requestId: string;
|
|
57
|
+
model: string;
|
|
58
|
+
messages: {
|
|
59
|
+
role: 'user' | 'assistant' | 'system';
|
|
60
|
+
content: string;
|
|
61
|
+
}[];
|
|
62
|
+
systemPrompt?: string;
|
|
63
|
+
maxTokens?: number;
|
|
64
|
+
temperature?: number;
|
|
65
|
+
timeout?: number;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
success: boolean;
|
|
68
|
+
content?: string;
|
|
69
|
+
error?: {
|
|
70
|
+
message: string;
|
|
71
|
+
category: string;
|
|
72
|
+
};
|
|
73
|
+
latencyMs: number;
|
|
74
|
+
usage?: {
|
|
75
|
+
inputTokens: number;
|
|
76
|
+
outputTokens: number;
|
|
77
|
+
totalTokens: number;
|
|
78
|
+
};
|
|
79
|
+
model?: string;
|
|
80
|
+
}>;
|
|
81
|
+
isAvailable(): Promise<boolean>;
|
|
82
|
+
getModels(): readonly {
|
|
83
|
+
modelId: string;
|
|
84
|
+
isDefault?: boolean | undefined;
|
|
85
|
+
}[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Real prompt executor that uses the provider registry
|
|
89
|
+
*/
|
|
90
|
+
export declare class ProviderPromptExecutor implements PromptExecutor {
|
|
91
|
+
private readonly registry;
|
|
92
|
+
private readonly config;
|
|
93
|
+
constructor(registry: ProviderRegistryLike, config: ProviderPromptExecutorConfig);
|
|
94
|
+
execute(request: PromptExecutionRequest): Promise<PromptExecutionResponse>;
|
|
95
|
+
isProviderAvailable(providerId: string): Promise<boolean>;
|
|
96
|
+
getAvailableProviders(): Promise<string[]>;
|
|
97
|
+
getDefaultProvider(): string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Creates a stub prompt executor for testing
|
|
101
|
+
*/
|
|
102
|
+
export declare function createStubPromptExecutor(defaultProvider?: string): PromptExecutor;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a real prompt executor using a provider registry
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* import { createProviderRegistry } from '@defai.digital/providers';
|
|
109
|
+
* import { createProviderPromptExecutor } from '@defai.digital/agent-domain';
|
|
110
|
+
*
|
|
111
|
+
* const registry = createProviderRegistry();
|
|
112
|
+
* const executor = createProviderPromptExecutor(registry, {
|
|
113
|
+
* defaultProvider: 'claude',
|
|
114
|
+
* defaultTimeout: 120000,
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function createProviderPromptExecutor(registry: ProviderRegistryLike, config: ProviderPromptExecutorConfig): PromptExecutor;
|
|
119
|
+
//# sourceMappingURL=prompt-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-executor.d.ts","sourceRoot":"","sources":["../src/prompt-executor.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