@sparkleideas/integration 3.0.3 → 3.0.4
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/package.json +1 -1
- package/src/__tests__/agent-adapter.test.ts +5 -5
- package/src/__tests__/token-optimizer.test.ts +3 -3
- package/src/agent-adapter.ts +33 -33
- package/src/agentic-flow-agent.ts +34 -34
- package/src/agentic-flow-bridge.ts +39 -39
- package/src/attention-coordinator.ts +14 -14
- package/src/index.ts +6 -6
- package/src/long-running-worker.ts +1 -1
- package/src/multi-model-router.ts +1 -1
- package/src/provider-adapter.ts +1 -1
- package/src/sdk-bridge.ts +7 -7
- package/src/sona-adapter.ts +21 -21
- package/src/specialized-worker.ts +1 -1
- package/src/swarm-adapter.ts +36 -36
- package/src/token-optimizer.ts +7 -7
- package/src/types.ts +5 -5
- package/src/worker-base.ts +3 -3
- package/src/worker-pool.ts +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agentic Flow Integration Bridge
|
|
3
3
|
*
|
|
4
|
-
* Core integration bridge for
|
|
5
|
-
* Implements ADR-001: Adopt
|
|
4
|
+
* Core integration bridge for agentic-flow@alpha deep integration.
|
|
5
|
+
* Implements ADR-001: Adopt agentic-flow as Core Foundation
|
|
6
6
|
*
|
|
7
|
-
* Eliminates 10,000+ lines of duplicate code by building on
|
|
7
|
+
* Eliminates 10,000+ lines of duplicate code by building on agentic-flow
|
|
8
8
|
* rather than implementing parallel systems.
|
|
9
9
|
*
|
|
10
10
|
* @module v3/integration/agentic-flow-bridge
|
|
@@ -28,8 +28,8 @@ import { AttentionCoordinator } from './attention-coordinator.js';
|
|
|
28
28
|
import { SDKBridge } from './sdk-bridge.js';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Interface for
|
|
32
|
-
* This represents the external
|
|
31
|
+
* Interface for agentic-flow core module (dynamically loaded)
|
|
32
|
+
* This represents the external agentic-flow@alpha package API
|
|
33
33
|
*/
|
|
34
34
|
interface AgenticFlowSONAInterface {
|
|
35
35
|
setMode(mode: string): Promise<void>;
|
|
@@ -51,26 +51,26 @@ interface AgenticFlowAgentDBInterface {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* Core interface for
|
|
54
|
+
* Core interface for agentic-flow@alpha package
|
|
55
55
|
* Used for deep integration and code deduplication per ADR-001
|
|
56
56
|
*/
|
|
57
57
|
export interface AgenticFlowCore {
|
|
58
58
|
sona: AgenticFlowSONAInterface;
|
|
59
59
|
attention: AgenticFlowAttentionInterface;
|
|
60
|
-
|
|
60
|
+
agentdb: AgenticFlowAgentDBInterface;
|
|
61
61
|
version: string;
|
|
62
62
|
isConnected: boolean;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* Factory function type for creating
|
|
66
|
+
* Factory function type for creating agentic-flow instance
|
|
67
67
|
*/
|
|
68
68
|
type AgenticFlowFactory = (config: unknown) => Promise<AgenticFlowCore>;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* AgenticFlowBridge - Core integration class for
|
|
71
|
+
* AgenticFlowBridge - Core integration class for agentic-flow@alpha
|
|
72
72
|
*
|
|
73
|
-
* This class serves as the main entry point for all
|
|
73
|
+
* This class serves as the main entry point for all agentic-flow integration,
|
|
74
74
|
* providing unified access to SONA learning, Flash Attention, and AgentDB.
|
|
75
75
|
*
|
|
76
76
|
* Performance Targets:
|
|
@@ -90,14 +90,14 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
90
90
|
private initializationPromise: Promise<void> | null = null;
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* Reference to the
|
|
93
|
+
* Reference to the agentic-flow@alpha core instance
|
|
94
94
|
* When available, components delegate to this instead of local implementations
|
|
95
|
-
* This follows ADR-001: Adopt
|
|
95
|
+
* This follows ADR-001: Adopt agentic-flow as Core Foundation
|
|
96
96
|
*/
|
|
97
97
|
private agenticFlowCore: AgenticFlowCore | null = null;
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
* Indicates whether
|
|
100
|
+
* Indicates whether agentic-flow is available for delegation
|
|
101
101
|
*/
|
|
102
102
|
private agenticFlowAvailable: boolean = false;
|
|
103
103
|
|
|
@@ -149,7 +149,7 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
149
149
|
this.runtimeInfo = await this.detectRuntime();
|
|
150
150
|
this.logDebug('Runtime detected', this.runtimeInfo);
|
|
151
151
|
|
|
152
|
-
// ADR-001: Attempt to load
|
|
152
|
+
// ADR-001: Attempt to load agentic-flow@alpha dynamically
|
|
153
153
|
// This enables deep integration and code deduplication
|
|
154
154
|
await this.connectToAgenticFlow();
|
|
155
155
|
|
|
@@ -165,11 +165,11 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
165
165
|
this.updateComponentHealth('sdk', 'healthy');
|
|
166
166
|
|
|
167
167
|
// Initialize SONA adapter if enabled
|
|
168
|
-
// Pass
|
|
168
|
+
// Pass agentic-flow reference for delegation when available
|
|
169
169
|
if (this.config.features.enableSONA) {
|
|
170
170
|
this.sona = new SONAAdapter(this.config.sona);
|
|
171
171
|
if (this.agenticFlowCore) {
|
|
172
|
-
// Type cast:
|
|
172
|
+
// Type cast: agentic-flow runtime API is compatible but typed as `unknown`
|
|
173
173
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
174
|
this.sona.setAgenticFlowReference(this.agenticFlowCore.sona as any);
|
|
175
175
|
}
|
|
@@ -178,11 +178,11 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// Initialize Attention coordinator if enabled
|
|
181
|
-
// Pass
|
|
181
|
+
// Pass agentic-flow reference for delegation when available
|
|
182
182
|
if (this.config.features.enableFlashAttention) {
|
|
183
183
|
this.attention = new AttentionCoordinator(this.config.attention);
|
|
184
184
|
if (this.agenticFlowCore) {
|
|
185
|
-
// Type cast:
|
|
185
|
+
// Type cast: agentic-flow runtime API is compatible but typed as `unknown`
|
|
186
186
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
187
187
|
this.attention.setAgenticFlowReference(this.agenticFlowCore.attention as any);
|
|
188
188
|
}
|
|
@@ -207,22 +207,22 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
/**
|
|
210
|
-
* Connect to
|
|
210
|
+
* Connect to agentic-flow@alpha package dynamically
|
|
211
211
|
*
|
|
212
|
-
* This implements ADR-001: Adopt
|
|
213
|
-
* When
|
|
212
|
+
* This implements ADR-001: Adopt agentic-flow as Core Foundation
|
|
213
|
+
* When agentic-flow is available, components delegate to it for:
|
|
214
214
|
* - SONA learning (eliminating duplicate pattern storage)
|
|
215
215
|
* - Flash Attention (using native optimized implementations)
|
|
216
216
|
* - AgentDB (leveraging 150x-12,500x faster HNSW search)
|
|
217
217
|
*
|
|
218
|
-
* If
|
|
218
|
+
* If agentic-flow is not installed, falls back to local implementations
|
|
219
219
|
* to maintain backward compatibility.
|
|
220
220
|
*/
|
|
221
221
|
private async connectToAgenticFlow(): Promise<void> {
|
|
222
222
|
try {
|
|
223
223
|
// Dynamic import to handle optional dependency
|
|
224
224
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
|
-
const agenticFlowModule: any = await import('
|
|
225
|
+
const agenticFlowModule: any = await import('agentic-flow').catch(() => null);
|
|
226
226
|
|
|
227
227
|
if (agenticFlowModule && typeof agenticFlowModule.createAgenticFlow === 'function') {
|
|
228
228
|
const factory: AgenticFlowFactory = agenticFlowModule.createAgenticFlow;
|
|
@@ -230,40 +230,40 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
230
230
|
this.agenticFlowCore = await factory({
|
|
231
231
|
sona: this.config.sona,
|
|
232
232
|
attention: this.config.attention,
|
|
233
|
-
|
|
233
|
+
agentdb: this.config.agentdb,
|
|
234
234
|
});
|
|
235
235
|
|
|
236
236
|
this.agenticFlowAvailable = true;
|
|
237
|
-
this.updateComponentHealth('
|
|
237
|
+
this.updateComponentHealth('agentic-flow', 'healthy');
|
|
238
238
|
|
|
239
|
-
this.emit('
|
|
239
|
+
this.emit('agentic-flow:connected', {
|
|
240
240
|
version: this.agenticFlowCore.version,
|
|
241
241
|
features: {
|
|
242
242
|
sona: true,
|
|
243
243
|
attention: true,
|
|
244
|
-
|
|
244
|
+
agentdb: true,
|
|
245
245
|
},
|
|
246
246
|
});
|
|
247
247
|
|
|
248
|
-
this.logDebug('Connected to
|
|
248
|
+
this.logDebug('Connected to agentic-flow', {
|
|
249
249
|
version: this.agenticFlowCore.version,
|
|
250
250
|
});
|
|
251
251
|
} else {
|
|
252
252
|
// Package not found or doesn't export expected factory
|
|
253
253
|
this.agenticFlowAvailable = false;
|
|
254
|
-
this.emit('
|
|
254
|
+
this.emit('agentic-flow:fallback', {
|
|
255
255
|
reason: 'package not found or incompatible',
|
|
256
256
|
});
|
|
257
|
-
this.logDebug('
|
|
257
|
+
this.logDebug('agentic-flow not available, using local implementations');
|
|
258
258
|
}
|
|
259
259
|
} catch (error) {
|
|
260
|
-
// Fallback to local implementation if
|
|
260
|
+
// Fallback to local implementation if agentic-flow fails to load
|
|
261
261
|
this.agenticFlowAvailable = false;
|
|
262
|
-
this.emit('
|
|
262
|
+
this.emit('agentic-flow:fallback', {
|
|
263
263
|
reason: 'initialization error',
|
|
264
264
|
error: (error as Error).message,
|
|
265
265
|
});
|
|
266
|
-
this.logDebug('
|
|
266
|
+
this.logDebug('agentic-flow initialization failed, using fallback', error);
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
|
|
@@ -558,9 +558,9 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
|
-
* Check if
|
|
561
|
+
* Check if agentic-flow@alpha is connected and available for delegation
|
|
562
562
|
*
|
|
563
|
-
* When true, components can delegate to
|
|
563
|
+
* When true, components can delegate to agentic-flow for optimized
|
|
564
564
|
* implementations (per ADR-001).
|
|
565
565
|
*/
|
|
566
566
|
isAgenticFlowConnected(): boolean {
|
|
@@ -568,9 +568,9 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
/**
|
|
571
|
-
* Get the
|
|
571
|
+
* Get the agentic-flow core instance for direct access
|
|
572
572
|
*
|
|
573
|
-
* Returns null if
|
|
573
|
+
* Returns null if agentic-flow is not available.
|
|
574
574
|
* Prefer using getSONAAdapter() or getAttentionCoordinator() which
|
|
575
575
|
* handle delegation automatically.
|
|
576
576
|
*/
|
|
@@ -601,7 +601,7 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
601
601
|
flashOptLevel: 2,
|
|
602
602
|
memoryOptimization: 'moderate',
|
|
603
603
|
},
|
|
604
|
-
|
|
604
|
+
agentdb: {
|
|
605
605
|
dimension: 1536,
|
|
606
606
|
indexType: 'hnsw',
|
|
607
607
|
hnswM: 16,
|
|
@@ -633,7 +633,7 @@ export class AgenticFlowBridge extends EventEmitter {
|
|
|
633
633
|
...config,
|
|
634
634
|
sona: { ...defaultConfig.sona, ...config.sona },
|
|
635
635
|
attention: { ...defaultConfig.attention, ...config.attention },
|
|
636
|
-
|
|
636
|
+
agentdb: { ...defaultConfig.agentdb, ...config.agentdb },
|
|
637
637
|
features: { ...defaultConfig.features, ...config.features },
|
|
638
638
|
};
|
|
639
639
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Attention Coordinator for Flash Attention Integration
|
|
3
3
|
*
|
|
4
|
-
* Provides integration with
|
|
4
|
+
* Provides integration with agentic-flow's attention mechanisms,
|
|
5
5
|
* including Flash Attention for 2.49x-7.47x speedup with
|
|
6
6
|
* 50-75% memory reduction.
|
|
7
7
|
*
|
|
@@ -28,8 +28,8 @@ import type {
|
|
|
28
28
|
} from './types.js';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Interface for
|
|
32
|
-
* This allows the coordinator to delegate to
|
|
31
|
+
* Interface for agentic-flow Attention reference (for delegation)
|
|
32
|
+
* This allows the coordinator to delegate to agentic-flow when available
|
|
33
33
|
*/
|
|
34
34
|
interface AgenticFlowAttentionReference {
|
|
35
35
|
compute(params: {
|
|
@@ -136,13 +136,13 @@ export class AttentionCoordinator extends EventEmitter {
|
|
|
136
136
|
private maxCacheSize: number = 1000;
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
|
-
* Reference to
|
|
139
|
+
* Reference to agentic-flow Attention for delegation (ADR-001)
|
|
140
140
|
* When set, performAttention delegates to native Flash Attention
|
|
141
141
|
*/
|
|
142
142
|
private agenticFlowAttention: AgenticFlowAttentionReference | null = null;
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Indicates if delegation to
|
|
145
|
+
* Indicates if delegation to agentic-flow is active
|
|
146
146
|
*/
|
|
147
147
|
private delegationEnabled: boolean = false;
|
|
148
148
|
|
|
@@ -153,23 +153,23 @@ export class AttentionCoordinator extends EventEmitter {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
|
-
* Set reference to
|
|
156
|
+
* Set reference to agentic-flow Attention for delegation
|
|
157
157
|
*
|
|
158
|
-
* This implements ADR-001: Adopt
|
|
158
|
+
* This implements ADR-001: Adopt agentic-flow as Core Foundation
|
|
159
159
|
* When a reference is provided, attention computation for sequences
|
|
160
|
-
* longer than 512 tokens delegates to
|
|
160
|
+
* longer than 512 tokens delegates to agentic-flow's optimized
|
|
161
161
|
* Flash Attention implementation for 2.49x-7.47x speedup.
|
|
162
162
|
*
|
|
163
|
-
* @param attentionRef - The
|
|
163
|
+
* @param attentionRef - The agentic-flow Attention interface reference
|
|
164
164
|
*/
|
|
165
165
|
setAgenticFlowReference(attentionRef: AgenticFlowAttentionReference): void {
|
|
166
166
|
this.agenticFlowAttention = attentionRef;
|
|
167
167
|
this.delegationEnabled = true;
|
|
168
|
-
this.emit('delegation-enabled', { target: '
|
|
168
|
+
this.emit('delegation-enabled', { target: 'agentic-flow' });
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
|
-
* Check if delegation to
|
|
172
|
+
* Check if delegation to agentic-flow is enabled
|
|
173
173
|
*/
|
|
174
174
|
isDelegationEnabled(): boolean {
|
|
175
175
|
return this.delegationEnabled && this.agenticFlowAttention !== null;
|
|
@@ -496,7 +496,7 @@ export class AttentionCoordinator extends EventEmitter {
|
|
|
496
496
|
* Perform attention computation
|
|
497
497
|
*
|
|
498
498
|
* ADR-001: For sequences longer than 512 tokens, delegates to
|
|
499
|
-
*
|
|
499
|
+
* agentic-flow's native Flash Attention for 2.49x-7.47x speedup
|
|
500
500
|
* and 50-75% memory reduction.
|
|
501
501
|
*/
|
|
502
502
|
private async performAttention(params: {
|
|
@@ -514,7 +514,7 @@ export class AttentionCoordinator extends EventEmitter {
|
|
|
514
514
|
// Calculate sequence length for delegation decision
|
|
515
515
|
const sequenceLength = qArray.length;
|
|
516
516
|
|
|
517
|
-
// ADR-001: Delegate to
|
|
517
|
+
// ADR-001: Delegate to agentic-flow for long sequences
|
|
518
518
|
// Flash Attention provides 2.49x-7.47x speedup for sequences > 512 tokens
|
|
519
519
|
if (
|
|
520
520
|
this.isDelegationEnabled() &&
|
|
@@ -534,7 +534,7 @@ export class AttentionCoordinator extends EventEmitter {
|
|
|
534
534
|
sequenceLength,
|
|
535
535
|
mechanism: result.mechanism,
|
|
536
536
|
latencyMs: result.latencyMs,
|
|
537
|
-
target: '
|
|
537
|
+
target: 'agentic-flow',
|
|
538
538
|
});
|
|
539
539
|
|
|
540
540
|
return result.output;
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @sparkleideas/integration - V3 Integration Module
|
|
3
3
|
*
|
|
4
|
-
* Main entry point for the
|
|
4
|
+
* Main entry point for the agentic-flow@alpha integration module.
|
|
5
5
|
* Provides deep integration with SONA learning, Flash Attention,
|
|
6
6
|
* and AgentDB for maximum performance and capability.
|
|
7
7
|
*
|
|
8
|
-
* This module implements ADR-001: Adopt
|
|
8
|
+
* This module implements ADR-001: Adopt agentic-flow as Core Foundation
|
|
9
9
|
*
|
|
10
10
|
* Key Features:
|
|
11
11
|
* - SONA Learning: Real-time adaptation with <0.05ms response
|
|
@@ -145,7 +145,7 @@ export type {
|
|
|
145
145
|
AgentConversionResult,
|
|
146
146
|
} from './agent-adapter.js';
|
|
147
147
|
|
|
148
|
-
// ===== Swarm Adapter (
|
|
148
|
+
// ===== Swarm Adapter (agentic-flow pattern alignment) =====
|
|
149
149
|
export {
|
|
150
150
|
SwarmAdapter,
|
|
151
151
|
createSwarmAdapter,
|
|
@@ -154,7 +154,7 @@ export {
|
|
|
154
154
|
} from './swarm-adapter.js';
|
|
155
155
|
|
|
156
156
|
export type {
|
|
157
|
-
//
|
|
157
|
+
// agentic-flow pattern types
|
|
158
158
|
AgenticFlowTopology,
|
|
159
159
|
AgenticFlowAttentionMechanism,
|
|
160
160
|
AgenticFlowAgentOutput,
|
|
@@ -433,7 +433,7 @@ export const VERSION = '3.0.0-alpha.1';
|
|
|
433
433
|
export const METADATA = {
|
|
434
434
|
name: '@sparkleideas/integration',
|
|
435
435
|
version: VERSION,
|
|
436
|
-
description: 'Deep
|
|
436
|
+
description: 'Deep agentic-flow@alpha integration for claude-flow v3',
|
|
437
437
|
implements: ['ADR-001'],
|
|
438
438
|
features: [
|
|
439
439
|
'SONA Learning (5 modes)',
|
|
@@ -443,7 +443,7 @@ export const METADATA = {
|
|
|
443
443
|
'Trajectory Tracking',
|
|
444
444
|
'Feature Flags',
|
|
445
445
|
'SDK Compatibility Layer',
|
|
446
|
-
'Worker Patterns (
|
|
446
|
+
'Worker Patterns (agentic-flow aligned)',
|
|
447
447
|
'Specialized Workers (16 domains)',
|
|
448
448
|
'Long-Running Workers (checkpoint support)',
|
|
449
449
|
'Worker Pool (intelligent routing)',
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - Timeout management with graceful handling
|
|
12
12
|
* - Resource cleanup on completion or failure
|
|
13
13
|
*
|
|
14
|
-
* Compatible with
|
|
14
|
+
* Compatible with agentic-flow's long-running agent patterns.
|
|
15
15
|
*
|
|
16
16
|
* @module v3/integration/long-running-worker
|
|
17
17
|
* @version 3.0.0-alpha.1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Multi-Model Router
|
|
3
3
|
*
|
|
4
|
-
* Cost-optimized routing across multiple LLM providers from
|
|
4
|
+
* Cost-optimized routing across multiple LLM providers from agentic-flow@alpha:
|
|
5
5
|
* - anthropic: Claude models
|
|
6
6
|
* - openai: GPT models
|
|
7
7
|
* - openrouter: 100+ models, 85-99% cost savings
|
package/src/provider-adapter.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - Cost tracking and optimization
|
|
14
14
|
* - Provider health monitoring
|
|
15
15
|
*
|
|
16
|
-
* Compatible with
|
|
16
|
+
* Compatible with agentic-flow's provider manager patterns.
|
|
17
17
|
*
|
|
18
18
|
* @module v3/integration/provider-adapter
|
|
19
19
|
* @version 3.0.0-alpha.1
|
package/src/sdk-bridge.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SDK Bridge for
|
|
2
|
+
* SDK Bridge for agentic-flow API Compatibility
|
|
3
3
|
*
|
|
4
|
-
* Provides API compatibility layer between
|
|
5
|
-
*
|
|
4
|
+
* Provides API compatibility layer between claude-flow v3 and
|
|
5
|
+
* agentic-flow@alpha, handling version negotiation, feature
|
|
6
6
|
* detection, and fallback behavior.
|
|
7
7
|
*
|
|
8
8
|
* Key Responsibilities:
|
|
@@ -65,7 +65,7 @@ const DEPRECATED_API_MAP: Record<string, {
|
|
|
65
65
|
* SDKBridge - API Compatibility Layer
|
|
66
66
|
*
|
|
67
67
|
* This bridge handles version compatibility, feature detection,
|
|
68
|
-
* and API translation between
|
|
68
|
+
* and API translation between claude-flow and agentic-flow.
|
|
69
69
|
*/
|
|
70
70
|
export class SDKBridge extends EventEmitter {
|
|
71
71
|
private config: SDKBridgeConfig;
|
|
@@ -334,14 +334,14 @@ export class SDKBridge extends EventEmitter {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
private async detectVersion(): Promise<SDKVersion> {
|
|
337
|
-
// Detect
|
|
337
|
+
// Detect agentic-flow version dynamically
|
|
338
338
|
try {
|
|
339
|
-
const af = await import('
|
|
339
|
+
const af = await import('agentic-flow');
|
|
340
340
|
if (af.VERSION) {
|
|
341
341
|
return this.parseVersion(af.VERSION);
|
|
342
342
|
}
|
|
343
343
|
} catch {
|
|
344
|
-
//
|
|
344
|
+
// agentic-flow not available, use fallback version
|
|
345
345
|
}
|
|
346
346
|
return this.parseVersion('2.0.1-alpha.50');
|
|
347
347
|
}
|
package/src/sona-adapter.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SONA (Self-Optimizing Neural Architecture) Adapter
|
|
3
3
|
*
|
|
4
|
-
* Provides integration with
|
|
4
|
+
* Provides integration with agentic-flow's SONA learning system,
|
|
5
5
|
* enabling real-time adaptation, pattern recognition, and
|
|
6
6
|
* continuous learning capabilities.
|
|
7
7
|
*
|
|
@@ -26,8 +26,8 @@ import type {
|
|
|
26
26
|
} from './types.js';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Interface for
|
|
30
|
-
* This allows the adapter to delegate to
|
|
29
|
+
* Interface for agentic-flow SONA reference (for delegation)
|
|
30
|
+
* This allows the adapter to delegate to agentic-flow when available
|
|
31
31
|
*/
|
|
32
32
|
interface AgenticFlowSONAReference {
|
|
33
33
|
setMode(mode: string): Promise<void>;
|
|
@@ -98,7 +98,7 @@ const MODE_CONFIGS: Record<SONALearningMode, Partial<SONAConfiguration>> = {
|
|
|
98
98
|
/**
|
|
99
99
|
* SONAAdapter - SONA Learning System Integration
|
|
100
100
|
*
|
|
101
|
-
* This adapter provides a clean interface to
|
|
101
|
+
* This adapter provides a clean interface to agentic-flow's SONA
|
|
102
102
|
* learning capabilities, including:
|
|
103
103
|
* - Learning mode selection and auto-switching
|
|
104
104
|
* - Trajectory tracking for experience replay
|
|
@@ -115,13 +115,13 @@ export class SONAAdapter extends EventEmitter {
|
|
|
115
115
|
private learningCycleCount: number = 0;
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
* Reference to
|
|
119
|
-
* When set, methods delegate to
|
|
118
|
+
* Reference to agentic-flow SONA for delegation (ADR-001)
|
|
119
|
+
* When set, methods delegate to agentic-flow instead of local implementation
|
|
120
120
|
*/
|
|
121
121
|
private agenticFlowSona: AgenticFlowSONAReference | null = null;
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
* Indicates if delegation to
|
|
124
|
+
* Indicates if delegation to agentic-flow is active
|
|
125
125
|
*/
|
|
126
126
|
private delegationEnabled: boolean = false;
|
|
127
127
|
|
|
@@ -132,22 +132,22 @@ export class SONAAdapter extends EventEmitter {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* Set reference to
|
|
135
|
+
* Set reference to agentic-flow SONA for delegation
|
|
136
136
|
*
|
|
137
|
-
* This implements ADR-001: Adopt
|
|
137
|
+
* This implements ADR-001: Adopt agentic-flow as Core Foundation
|
|
138
138
|
* When a reference is provided, pattern storage and retrieval
|
|
139
|
-
* delegate to
|
|
139
|
+
* delegate to agentic-flow's optimized implementations.
|
|
140
140
|
*
|
|
141
|
-
* @param sonaRef - The
|
|
141
|
+
* @param sonaRef - The agentic-flow SONA interface reference
|
|
142
142
|
*/
|
|
143
143
|
setAgenticFlowReference(sonaRef: AgenticFlowSONAReference): void {
|
|
144
144
|
this.agenticFlowSona = sonaRef;
|
|
145
145
|
this.delegationEnabled = true;
|
|
146
|
-
this.emit('delegation-enabled', { target: '
|
|
146
|
+
this.emit('delegation-enabled', { target: 'agentic-flow' });
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* Check if delegation to
|
|
150
|
+
* Check if delegation to agentic-flow is enabled
|
|
151
151
|
*/
|
|
152
152
|
isDelegationEnabled(): boolean {
|
|
153
153
|
return this.delegationEnabled && this.agenticFlowSona !== null;
|
|
@@ -336,7 +336,7 @@ export class SONAAdapter extends EventEmitter {
|
|
|
336
336
|
/**
|
|
337
337
|
* Store a learned pattern
|
|
338
338
|
*
|
|
339
|
-
* ADR-001: When
|
|
339
|
+
* ADR-001: When agentic-flow is available, delegates to its optimized
|
|
340
340
|
* pattern storage which uses AgentDB with HNSW indexing for
|
|
341
341
|
* 150x-12,500x faster similarity search.
|
|
342
342
|
*/
|
|
@@ -349,7 +349,7 @@ export class SONAAdapter extends EventEmitter {
|
|
|
349
349
|
}): Promise<string> {
|
|
350
350
|
this.ensureInitialized();
|
|
351
351
|
|
|
352
|
-
// ADR-001: Delegate to
|
|
352
|
+
// ADR-001: Delegate to agentic-flow when available
|
|
353
353
|
if (this.isDelegationEnabled() && this.agenticFlowSona) {
|
|
354
354
|
try {
|
|
355
355
|
const patternId = await this.agenticFlowSona.storePattern({
|
|
@@ -364,7 +364,7 @@ export class SONAAdapter extends EventEmitter {
|
|
|
364
364
|
this.emit('pattern-stored', {
|
|
365
365
|
patternId,
|
|
366
366
|
delegated: true,
|
|
367
|
-
target: '
|
|
367
|
+
target: 'agentic-flow',
|
|
368
368
|
});
|
|
369
369
|
|
|
370
370
|
return patternId;
|
|
@@ -379,7 +379,7 @@ export class SONAAdapter extends EventEmitter {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
// Local implementation (fallback or when
|
|
382
|
+
// Local implementation (fallback or when agentic-flow not available)
|
|
383
383
|
const patternId = this.generateId('pat');
|
|
384
384
|
const storedPattern: SONAPattern = {
|
|
385
385
|
id: patternId,
|
|
@@ -409,7 +409,7 @@ export class SONAAdapter extends EventEmitter {
|
|
|
409
409
|
/**
|
|
410
410
|
* Find similar patterns to a query
|
|
411
411
|
*
|
|
412
|
-
* ADR-001: When
|
|
412
|
+
* ADR-001: When agentic-flow is available, delegates to its optimized
|
|
413
413
|
* HNSW-indexed search for 150x-12,500x faster retrieval.
|
|
414
414
|
*/
|
|
415
415
|
async findSimilarPatterns(params: {
|
|
@@ -423,7 +423,7 @@ export class SONAAdapter extends EventEmitter {
|
|
|
423
423
|
const topK = params.topK || 5;
|
|
424
424
|
const threshold = params.threshold ?? this.config.similarityThreshold;
|
|
425
425
|
|
|
426
|
-
// ADR-001: Delegate to
|
|
426
|
+
// ADR-001: Delegate to agentic-flow when available for optimized search
|
|
427
427
|
if (this.isDelegationEnabled() && this.agenticFlowSona) {
|
|
428
428
|
try {
|
|
429
429
|
const results = await this.agenticFlowSona.findPatterns(params.query, {
|
|
@@ -449,7 +449,7 @@ export class SONAAdapter extends EventEmitter {
|
|
|
449
449
|
query: params.query,
|
|
450
450
|
count: patterns.length,
|
|
451
451
|
delegated: true,
|
|
452
|
-
target: '
|
|
452
|
+
target: 'agentic-flow',
|
|
453
453
|
});
|
|
454
454
|
|
|
455
455
|
return patterns;
|
|
@@ -464,7 +464,7 @@ export class SONAAdapter extends EventEmitter {
|
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
|
|
467
|
-
// Local implementation (fallback or when
|
|
467
|
+
// Local implementation (fallback or when agentic-flow not available)
|
|
468
468
|
const results: Array<{ pattern: SONAPattern; score: number }> = [];
|
|
469
469
|
|
|
470
470
|
for (const pattern of this.patterns.values()) {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - Capability verification and scoring
|
|
11
11
|
* - Domain-specific execution strategies
|
|
12
12
|
*
|
|
13
|
-
* Compatible with
|
|
13
|
+
* Compatible with agentic-flow's SpecializedAgent pattern.
|
|
14
14
|
*
|
|
15
15
|
* @module v3/integration/specialized-worker
|
|
16
16
|
* @version 3.0.0-alpha.1
|