@holoscript/framework 6.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/ALL-test-results.json +1 -0
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/ROADMAP.md +175 -0
- package/dist/AgentManifest-CB4xM-Ma.d.cts +704 -0
- package/dist/AgentManifest-CB4xM-Ma.d.ts +704 -0
- package/dist/BehaviorTree-BrBFECv5.d.cts +103 -0
- package/dist/BehaviorTree-BrBFECv5.d.ts +103 -0
- package/dist/InvisibleWallet-BB6tFvRA.d.cts +1732 -0
- package/dist/InvisibleWallet-rtRrBOA8.d.ts +1732 -0
- package/dist/OrchestratorAgent-BvWgf9uw.d.cts +798 -0
- package/dist/OrchestratorAgent-Q_CbVTmO.d.ts +798 -0
- package/dist/agents/index.cjs +4790 -0
- package/dist/agents/index.d.cts +1788 -0
- package/dist/agents/index.d.ts +1788 -0
- package/dist/agents/index.js +4695 -0
- package/dist/ai/index.cjs +5347 -0
- package/dist/ai/index.d.cts +1753 -0
- package/dist/ai/index.d.ts +1753 -0
- package/dist/ai/index.js +5244 -0
- package/dist/behavior.cjs +449 -0
- package/dist/behavior.d.cts +130 -0
- package/dist/behavior.d.ts +130 -0
- package/dist/behavior.js +407 -0
- package/dist/economy/index.cjs +3659 -0
- package/dist/economy/index.d.cts +747 -0
- package/dist/economy/index.d.ts +747 -0
- package/dist/economy/index.js +3617 -0
- package/dist/implementations-D9T3un9D.d.cts +236 -0
- package/dist/implementations-D9T3un9D.d.ts +236 -0
- package/dist/index.cjs +24550 -0
- package/dist/index.d.cts +1729 -0
- package/dist/index.d.ts +1729 -0
- package/dist/index.js +24277 -0
- package/dist/learning/index.cjs +219 -0
- package/dist/learning/index.d.cts +104 -0
- package/dist/learning/index.d.ts +104 -0
- package/dist/learning/index.js +189 -0
- package/dist/negotiation/index.cjs +970 -0
- package/dist/negotiation/index.d.cts +610 -0
- package/dist/negotiation/index.d.ts +610 -0
- package/dist/negotiation/index.js +931 -0
- package/dist/skills/index.cjs +1118 -0
- package/dist/skills/index.d.cts +289 -0
- package/dist/skills/index.d.ts +289 -0
- package/dist/skills/index.js +1079 -0
- package/dist/swarm/index.cjs +5268 -0
- package/dist/swarm/index.d.cts +2433 -0
- package/dist/swarm/index.d.ts +2433 -0
- package/dist/swarm/index.js +5221 -0
- package/dist/training/index.cjs +2745 -0
- package/dist/training/index.d.cts +1734 -0
- package/dist/training/index.d.ts +1734 -0
- package/dist/training/index.js +2687 -0
- package/extract-failures.js +10 -0
- package/package.json +82 -0
- package/src/__tests__/bounty-marketplace.test.ts +374 -0
- package/src/__tests__/delegation.test.ts +144 -0
- package/src/__tests__/distributed-claimer.test.ts +147 -0
- package/src/__tests__/done-log-audit.test.ts +342 -0
- package/src/__tests__/framework.test.ts +865 -0
- package/src/__tests__/goal-synthesizer.test.ts +236 -0
- package/src/__tests__/presence.test.ts +223 -0
- package/src/__tests__/protocol-agent.test.ts +254 -0
- package/src/__tests__/revenue-splitter.test.ts +114 -0
- package/src/__tests__/scenario-driven-todo.test.ts +197 -0
- package/src/__tests__/self-improve.test.ts +349 -0
- package/src/__tests__/service-lifecycle.test.ts +237 -0
- package/src/__tests__/skill-router.test.ts +121 -0
- package/src/agents/AgentManifest.ts +493 -0
- package/src/agents/AgentRegistry.ts +475 -0
- package/src/agents/AgentTypes.ts +585 -0
- package/src/agents/AgentWalletRegistry.ts +83 -0
- package/src/agents/AuthenticatedCRDT.ts +388 -0
- package/src/agents/CapabilityMatcher.ts +453 -0
- package/src/agents/CrossRealityHandoff.ts +305 -0
- package/src/agents/CulturalMemory.ts +454 -0
- package/src/agents/FederatedRegistryAdapter.ts +429 -0
- package/src/agents/NormEngine.ts +450 -0
- package/src/agents/OrchestratorAgent.ts +414 -0
- package/src/agents/SkillWorkflowEngine.ts +472 -0
- package/src/agents/TaskDelegationService.ts +551 -0
- package/src/agents/__tests__/AgentManifest.prod.test.ts +134 -0
- package/src/agents/__tests__/AgentManifest.test.ts +182 -0
- package/src/agents/__tests__/AgentModule.test.ts +864 -0
- package/src/agents/__tests__/AgentRegistry.prod.test.ts +125 -0
- package/src/agents/__tests__/AgentRegistry.test.ts +148 -0
- package/src/agents/__tests__/AgentTypes.test.ts +534 -0
- package/src/agents/__tests__/AgentWalletRegistry.test.ts +152 -0
- package/src/agents/__tests__/AuthenticatedCRDT.test.ts +558 -0
- package/src/agents/__tests__/CapabilityMatcher.prod.test.ts +117 -0
- package/src/agents/__tests__/CapabilityMatcher.test.ts +178 -0
- package/src/agents/__tests__/CrossRealityHandoff.test.ts +402 -0
- package/src/agents/__tests__/CulturalMemory.test.ts +200 -0
- package/src/agents/__tests__/FederatedRegistryAdapter.test.ts +409 -0
- package/src/agents/__tests__/NormEngine.test.ts +276 -0
- package/src/agents/__tests__/OrchestratorAgent.test.ts +182 -0
- package/src/agents/__tests__/SkillWorkflowEngine.test.ts +357 -0
- package/src/agents/__tests__/TaskDelegationService.test.ts +446 -0
- package/src/agents/index.ts +107 -0
- package/src/agents/spatial-comms/Layer1RealTime.ts +621 -0
- package/src/agents/spatial-comms/Layer2A2A.ts +661 -0
- package/src/agents/spatial-comms/Layer3MCP.ts +651 -0
- package/src/agents/spatial-comms/ProtocolTypes.ts +543 -0
- package/src/agents/spatial-comms/SpatialCommClient.ts +483 -0
- package/src/agents/spatial-comms/__tests__/performance-benchmark.test.ts +465 -0
- package/src/agents/spatial-comms/examples/multi-agent-world-creation.ts +409 -0
- package/src/agents/spatial-comms/index.ts +66 -0
- package/src/ai/AIAdapter.ts +313 -0
- package/src/ai/AICopilot.ts +331 -0
- package/src/ai/AIOutputValidator.ts +203 -0
- package/src/ai/BTNodes.ts +239 -0
- package/src/ai/BehaviorSelector.ts +135 -0
- package/src/ai/BehaviorTree.ts +153 -0
- package/src/ai/Blackboard.ts +165 -0
- package/src/ai/GenerationAnalytics.ts +461 -0
- package/src/ai/GenerationCache.ts +265 -0
- package/src/ai/GoalPlanner.ts +165 -0
- package/src/ai/HoloScriptGenerator.ts +580 -0
- package/src/ai/InfluenceMap.ts +180 -0
- package/src/ai/NavMesh.ts +168 -0
- package/src/ai/PerceptionSystem.ts +178 -0
- package/src/ai/PromptTemplates.ts +453 -0
- package/src/ai/SemanticSearchService.ts +80 -0
- package/src/ai/StateMachine.ts +196 -0
- package/src/ai/SteeringBehavior.ts +150 -0
- package/src/ai/SteeringBehaviors.ts +244 -0
- package/src/ai/TrainingDataGenerator.ts +1082 -0
- package/src/ai/UtilityAI.ts +145 -0
- package/src/ai/__tests__/AIAdapter.prod.test.ts +259 -0
- package/src/ai/__tests__/AIAdapter.test.ts +109 -0
- package/src/ai/__tests__/AICopilot.prod.test.ts +341 -0
- package/src/ai/__tests__/AICopilot.test.ts +178 -0
- package/src/ai/__tests__/AIOutputValidator.prod.test.ts +226 -0
- package/src/ai/__tests__/AIOutputValidator.test.ts +138 -0
- package/src/ai/__tests__/BTNodes.prod.test.ts +391 -0
- package/src/ai/__tests__/BTNodes.test.ts +263 -0
- package/src/ai/__tests__/BehaviorSelector.prod.test.ts +129 -0
- package/src/ai/__tests__/BehaviorSelector.test.ts +132 -0
- package/src/ai/__tests__/BehaviorTree.prod.test.ts +266 -0
- package/src/ai/__tests__/BehaviorTree.test.ts +216 -0
- package/src/ai/__tests__/Blackboard.prod.test.ts +339 -0
- package/src/ai/__tests__/Blackboard.test.ts +183 -0
- package/src/ai/__tests__/GenerationAnalytics.prod.test.ts +141 -0
- package/src/ai/__tests__/GenerationAnalytics.test.ts +165 -0
- package/src/ai/__tests__/GenerationCache.prod.test.ts +144 -0
- package/src/ai/__tests__/GenerationCache.test.ts +171 -0
- package/src/ai/__tests__/GoalPlanner.prod.test.ts +189 -0
- package/src/ai/__tests__/GoalPlanner.test.ts +137 -0
- package/src/ai/__tests__/GoalPlannerDepth.prod.test.ts +217 -0
- package/src/ai/__tests__/HoloScriptGenerator.test.ts +125 -0
- package/src/ai/__tests__/InfluenceMap.prod.test.ts +146 -0
- package/src/ai/__tests__/InfluenceMap.test.ts +149 -0
- package/src/ai/__tests__/NavMesh.prod.test.ts +141 -0
- package/src/ai/__tests__/NavMesh.test.ts +159 -0
- package/src/ai/__tests__/PerceptionSystem.prod.test.ts +135 -0
- package/src/ai/__tests__/PerceptionSystem.test.ts +250 -0
- package/src/ai/__tests__/PromptTemplates.prod.test.ts +313 -0
- package/src/ai/__tests__/PromptTemplates.test.ts +146 -0
- package/src/ai/__tests__/SemanticSearch.test.ts +37 -0
- package/src/ai/__tests__/StateMachine.prod.test.ts +162 -0
- package/src/ai/__tests__/StateMachine.test.ts +163 -0
- package/src/ai/__tests__/SteeringBehavior.prod.test.ts +251 -0
- package/src/ai/__tests__/SteeringBehavior.test.ts +135 -0
- package/src/ai/__tests__/SteeringBehaviors.prod.test.ts +133 -0
- package/src/ai/__tests__/SteeringBehaviors.test.ts +151 -0
- package/src/ai/__tests__/TrainingDataGenerator.prod.test.ts +286 -0
- package/src/ai/__tests__/TrainingDataGenerator.test.ts +286 -0
- package/src/ai/__tests__/UtilityAI.prod.test.ts +207 -0
- package/src/ai/__tests__/UtilityAI.test.ts +155 -0
- package/src/ai/__tests__/adapters.prod.test.ts +263 -0
- package/src/ai/__tests__/adapters.test.ts +320 -0
- package/src/ai/adapters.ts +1585 -0
- package/src/ai/index.ts +130 -0
- package/src/behavior/BehaviorPresets.ts +140 -0
- package/src/behavior/BehaviorTree.ts +236 -0
- package/src/behavior/StateMachine.ts +176 -0
- package/src/behavior/StateTrait.ts +67 -0
- package/src/behavior/index.ts +8 -0
- package/src/behavior.ts +8 -0
- package/src/board/audit.ts +284 -0
- package/src/board/board-ops.ts +336 -0
- package/src/board/board-types.ts +302 -0
- package/src/board/index.ts +69 -0
- package/src/define-agent.ts +46 -0
- package/src/define-team.ts +33 -0
- package/src/delegation.ts +265 -0
- package/src/distributed-claimer.ts +228 -0
- package/src/economy/AgentBudgetEnforcer.ts +464 -0
- package/src/economy/BountyManager.ts +185 -0
- package/src/economy/CreatorRevenueAggregator.ts +460 -0
- package/src/economy/InvisibleWallet.ts +82 -0
- package/src/economy/KnowledgeMarketplace.ts +193 -0
- package/src/economy/PaymentWebhookService.ts +512 -0
- package/src/economy/RevenueSplitter.ts +156 -0
- package/src/economy/SubscriptionManager.ts +546 -0
- package/src/economy/UnifiedBudgetOptimizer.ts +635 -0
- package/src/economy/UsageMeter.ts +440 -0
- package/src/economy/_core-stubs.ts +219 -0
- package/src/economy/index.ts +100 -0
- package/src/economy/x402-facilitator.ts +1978 -0
- package/src/index.ts +348 -0
- package/src/knowledge/__tests__/knowledge-consolidator.test.ts +444 -0
- package/src/knowledge/__tests__/knowledge-store-vector.test.ts +291 -0
- package/src/knowledge/brain.ts +167 -0
- package/src/knowledge/consolidation.ts +581 -0
- package/src/knowledge/knowledge-consolidator.ts +510 -0
- package/src/knowledge/knowledge-store.ts +616 -0
- package/src/learning/MemoryConsolidator.ts +102 -0
- package/src/learning/MemoryScorer.ts +69 -0
- package/src/learning/ProceduralCompiler.ts +45 -0
- package/src/learning/SemanticClusterer.ts +66 -0
- package/src/learning/index.ts +8 -0
- package/src/llm/llm-adapter.ts +159 -0
- package/src/mesh/index.ts +309 -0
- package/src/negotiation/NegotiationProtocol.ts +694 -0
- package/src/negotiation/NegotiationTypes.ts +473 -0
- package/src/negotiation/VotingMechanisms.ts +691 -0
- package/src/negotiation/index.ts +49 -0
- package/src/protocol/goal-synthesizer.ts +317 -0
- package/src/protocol/implementations.ts +474 -0
- package/src/protocol/micro-phase-decomposer.ts +299 -0
- package/src/protocol/micro-step-decomposer.test.ts +306 -0
- package/src/protocol-agent.test.ts +353 -0
- package/src/protocol-agent.ts +670 -0
- package/src/self-improve/absorb-scanner.ts +252 -0
- package/src/self-improve/evolution-engine.ts +149 -0
- package/src/self-improve/framework-absorber.ts +214 -0
- package/src/self-improve/index.ts +50 -0
- package/src/self-improve/prompt-optimizer.ts +212 -0
- package/src/self-improve/test-generator.ts +175 -0
- package/src/skill-router.ts +186 -0
- package/src/skills/index.ts +5 -0
- package/src/skills/skill-md-bridge.ts +1699 -0
- package/src/swarm/ACOEngine.ts +261 -0
- package/src/swarm/CollectiveIntelligence.ts +383 -0
- package/src/swarm/ContributionSynthesizer.ts +481 -0
- package/src/swarm/LeaderElection.ts +393 -0
- package/src/swarm/PSOEngine.ts +206 -0
- package/src/swarm/QuorumPolicy.ts +173 -0
- package/src/swarm/SwarmCoordinator.ts +335 -0
- package/src/swarm/SwarmManager.ts +442 -0
- package/src/swarm/SwarmMembership.ts +456 -0
- package/src/swarm/VotingRound.ts +255 -0
- package/src/swarm/__tests__/ACOEngine.prod.test.ts +164 -0
- package/src/swarm/__tests__/ACOEngine.test.ts +117 -0
- package/src/swarm/__tests__/CollectiveIntelligence.prod.test.ts +296 -0
- package/src/swarm/__tests__/CollectiveIntelligence.test.ts +457 -0
- package/src/swarm/__tests__/ContributionSynthesizer.prod.test.ts +269 -0
- package/src/swarm/__tests__/ContributionSynthesizer.test.ts +254 -0
- package/src/swarm/__tests__/LeaderElection.prod.test.ts +196 -0
- package/src/swarm/__tests__/LeaderElection.test.ts +151 -0
- package/src/swarm/__tests__/PSOEngine.prod.test.ts +162 -0
- package/src/swarm/__tests__/PSOEngine.test.ts +106 -0
- package/src/swarm/__tests__/QuorumPolicy.prod.test.ts +216 -0
- package/src/swarm/__tests__/QuorumPolicy.test.ts +177 -0
- package/src/swarm/__tests__/SwarmCoordinator.prod.test.ts +186 -0
- package/src/swarm/__tests__/SwarmCoordinator.test.ts +167 -0
- package/src/swarm/__tests__/SwarmManager.prod.test.ts +308 -0
- package/src/swarm/__tests__/SwarmManager.test.ts +373 -0
- package/src/swarm/__tests__/SwarmMembership.prod.test.ts +273 -0
- package/src/swarm/__tests__/SwarmMembership.test.ts +264 -0
- package/src/swarm/__tests__/VotingRound.prod.test.ts +233 -0
- package/src/swarm/__tests__/VotingRound.test.ts +174 -0
- package/src/swarm/analytics/SwarmInspector.ts +476 -0
- package/src/swarm/analytics/SwarmMetrics.ts +449 -0
- package/src/swarm/analytics/__tests__/SwarmInspector.prod.test.ts +366 -0
- package/src/swarm/analytics/__tests__/SwarmInspector.test.ts +454 -0
- package/src/swarm/analytics/__tests__/SwarmMetrics.prod.test.ts +254 -0
- package/src/swarm/analytics/__tests__/SwarmMetrics.test.ts +370 -0
- package/src/swarm/analytics/index.ts +7 -0
- package/src/swarm/index.ts +69 -0
- package/src/swarm/messaging/BroadcastChannel.ts +509 -0
- package/src/swarm/messaging/GossipProtocol.ts +565 -0
- package/src/swarm/messaging/SwarmEventBus.ts +443 -0
- package/src/swarm/messaging/__tests__/BroadcastChannel.prod.test.ts +331 -0
- package/src/swarm/messaging/__tests__/BroadcastChannel.test.ts +333 -0
- package/src/swarm/messaging/__tests__/GossipProtocol.prod.test.ts +356 -0
- package/src/swarm/messaging/__tests__/GossipProtocol.test.ts +437 -0
- package/src/swarm/messaging/__tests__/SwarmEventBus.prod.test.ts +191 -0
- package/src/swarm/messaging/__tests__/SwarmEventBus.test.ts +247 -0
- package/src/swarm/messaging/index.ts +8 -0
- package/src/swarm/spatial/FlockingBehavior.ts +462 -0
- package/src/swarm/spatial/FormationController.ts +500 -0
- package/src/swarm/spatial/Vector3.ts +170 -0
- package/src/swarm/spatial/ZoneClaiming.ts +509 -0
- package/src/swarm/spatial/__tests__/FlockingBehavior.prod.test.ts +239 -0
- package/src/swarm/spatial/__tests__/FlockingBehavior.test.ts +298 -0
- package/src/swarm/spatial/__tests__/FormationController.prod.test.ts +240 -0
- package/src/swarm/spatial/__tests__/FormationController.test.ts +297 -0
- package/src/swarm/spatial/__tests__/Vector3.prod.test.ts +283 -0
- package/src/swarm/spatial/__tests__/Vector3.test.ts +224 -0
- package/src/swarm/spatial/__tests__/ZoneClaiming.prod.test.ts +246 -0
- package/src/swarm/spatial/__tests__/ZoneClaiming.test.ts +374 -0
- package/src/swarm/spatial/index.ts +28 -0
- package/src/team.ts +1245 -0
- package/src/training/LRScheduler.ts +377 -0
- package/src/training/QualityScoringPipeline.ts +139 -0
- package/src/training/SoftDedup.ts +461 -0
- package/src/training/SparsityMonitor.ts +685 -0
- package/src/training/SparsityMonitorTypes.ts +209 -0
- package/src/training/SpatialTrainingDataGenerator.ts +1526 -0
- package/src/training/SpatialTrainingDataTypes.ts +216 -0
- package/src/training/TrainingPipelineConfig.ts +215 -0
- package/src/training/constants.ts +94 -0
- package/src/training/index.ts +138 -0
- package/src/training/schema.ts +147 -0
- package/src/training/scripts/generate-novel-use-cases-dataset.ts +272 -0
- package/src/training/scripts/generate-spatial-dataset.ts +521 -0
- package/src/training/training/data/novel-use-cases.jsonl +153 -0
- package/src/training/training/data/spatial-reasoning-10k.jsonl +9354 -0
- package/src/training/trainingmonkey/TrainingMonkeyIntegration.ts +477 -0
- package/src/training/trainingmonkey/TrainingMonkeyTypes.ts +230 -0
- package/src/training/trainingmonkey/index.ts +26 -0
- package/src/training/trait-mappings.ts +157 -0
- package/src/types/core-stubs.d.ts +113 -0
- package/src/types.ts +304 -0
- package/test-output.txt +0 -0
- package/test-result.json +1 -0
- package/tsc-errors.txt +4 -0
- package/tsc_output.txt +0 -0
- package/tsconfig.json +14 -0
- package/tsup-learning-esm.config.ts +12 -0
- package/tsup.config.ts +21 -0
- package/typescript-errors-2.txt +0 -0
- package/typescript-errors.txt +22 -0
- package/vitest-log-utf8.txt +268 -0
- package/vitest-log.txt +0 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
import { B as BaseAgent, A as AgentIdentity, P as PhaseResult } from './implementations-D9T3un9D.cjs';
|
|
2
|
+
import { A as AgentManifest, a as AgentCapability, C as CapabilityType, b as CapabilityDomain, L as LatencyProfile, T as TrustLevel, V as Vector3 } from './AgentManifest-CB4xM-Ma.cjs';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @holoscript/core - Capability Matcher
|
|
7
|
+
*
|
|
8
|
+
* Matches capability queries against agent manifests.
|
|
9
|
+
* Part of HoloScript v3.1 Agentic Choreography.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Query for finding agents with specific capabilities
|
|
14
|
+
*/
|
|
15
|
+
interface CapabilityQuery {
|
|
16
|
+
/** Required capability type(s) */
|
|
17
|
+
type?: CapabilityType | CapabilityType[] | string | string[];
|
|
18
|
+
/** Required domain(s) */
|
|
19
|
+
domain?: CapabilityDomain | CapabilityDomain[] | string | string[];
|
|
20
|
+
/** Maximum acceptable latency */
|
|
21
|
+
maxLatency?: LatencyProfile;
|
|
22
|
+
/** Minimum required trust level */
|
|
23
|
+
minTrust?: TrustLevel;
|
|
24
|
+
/** Spatial requirements */
|
|
25
|
+
spatial?: SpatialQuery;
|
|
26
|
+
/** Required tags */
|
|
27
|
+
tags?: string[];
|
|
28
|
+
/** Custom filters */
|
|
29
|
+
filters?: Record<string, unknown>;
|
|
30
|
+
/** Maximum results to return */
|
|
31
|
+
limit?: number;
|
|
32
|
+
/** Whether to include offline agents */
|
|
33
|
+
includeOffline?: boolean;
|
|
34
|
+
/** Sort order */
|
|
35
|
+
sortBy?: 'latency' | 'trust' | 'priority' | 'name';
|
|
36
|
+
/** Sort direction */
|
|
37
|
+
sortOrder?: 'asc' | 'desc';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Spatial query for location-aware discovery
|
|
41
|
+
*/
|
|
42
|
+
interface SpatialQuery {
|
|
43
|
+
/** Point that must be within agent's scope */
|
|
44
|
+
point?: Vector3;
|
|
45
|
+
/** Scene/world filter */
|
|
46
|
+
scene?: string;
|
|
47
|
+
/** Node IDs to check */
|
|
48
|
+
nodes?: string[];
|
|
49
|
+
/** Minimum overlap with bounding box */
|
|
50
|
+
overlaps?: {
|
|
51
|
+
min: Vector3;
|
|
52
|
+
max: Vector3;
|
|
53
|
+
};
|
|
54
|
+
/** Require global scope */
|
|
55
|
+
requireGlobal?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Individual capability match result
|
|
59
|
+
*/
|
|
60
|
+
interface CapabilityMatch {
|
|
61
|
+
/** The matched capability */
|
|
62
|
+
capability: AgentCapability;
|
|
63
|
+
/** Match score (0-1) */
|
|
64
|
+
score: number;
|
|
65
|
+
/** Which query criteria matched */
|
|
66
|
+
matchedCriteria: string[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Agent match result with scoring
|
|
70
|
+
*/
|
|
71
|
+
interface AgentMatch {
|
|
72
|
+
/** The matched agent manifest */
|
|
73
|
+
manifest: AgentManifest;
|
|
74
|
+
/** Overall match score (0-1) */
|
|
75
|
+
score: number;
|
|
76
|
+
/** Individual capability matches */
|
|
77
|
+
capabilities: CapabilityMatch[];
|
|
78
|
+
/** Why this agent matched */
|
|
79
|
+
reasons: string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Matches capability queries against agent manifests
|
|
83
|
+
*/
|
|
84
|
+
declare class CapabilityMatcher {
|
|
85
|
+
/**
|
|
86
|
+
* Check if a capability matches the query
|
|
87
|
+
*/
|
|
88
|
+
matchCapability(capability: AgentCapability, query: CapabilityQuery): CapabilityMatch | null;
|
|
89
|
+
/**
|
|
90
|
+
* Check if an agent matches the query
|
|
91
|
+
*/
|
|
92
|
+
matchAgent(manifest: AgentManifest, query: CapabilityQuery): AgentMatch | null;
|
|
93
|
+
/**
|
|
94
|
+
* Find all matching agents from a list
|
|
95
|
+
*/
|
|
96
|
+
findMatches(manifests: AgentManifest[], query: CapabilityQuery): AgentMatch[];
|
|
97
|
+
/**
|
|
98
|
+
* Find the best matching agent
|
|
99
|
+
*/
|
|
100
|
+
findBest(manifests: AgentManifest[], query: CapabilityQuery): AgentMatch | null;
|
|
101
|
+
/**
|
|
102
|
+
* Sort matches by criteria
|
|
103
|
+
*/
|
|
104
|
+
sortMatches(matches: AgentMatch[], sortBy: 'latency' | 'trust' | 'priority' | 'name' | 'score', sortOrder: 'asc' | 'desc'): void;
|
|
105
|
+
private getFastestLatency;
|
|
106
|
+
private getHighestPriority;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Default matcher instance
|
|
110
|
+
*/
|
|
111
|
+
declare const defaultMatcher: CapabilityMatcher;
|
|
112
|
+
/**
|
|
113
|
+
* Convenience function to find matching agents
|
|
114
|
+
*/
|
|
115
|
+
declare function findAgents(manifests: AgentManifest[], query: CapabilityQuery): AgentMatch[];
|
|
116
|
+
/**
|
|
117
|
+
* Convenience function to find the best agent
|
|
118
|
+
*/
|
|
119
|
+
declare function findBestAgent(manifests: AgentManifest[], query: CapabilityQuery): AgentMatch | null;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @holoscript/core - Agent Registry
|
|
123
|
+
*
|
|
124
|
+
* Central registry for agent registration, discovery, and health tracking.
|
|
125
|
+
* Part of HoloScript v3.1 Agentic Choreography.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Discovery mode for the registry
|
|
130
|
+
*/
|
|
131
|
+
type DiscoveryMode = 'central' | 'broadcast' | 'hybrid';
|
|
132
|
+
/**
|
|
133
|
+
* Registry configuration
|
|
134
|
+
*/
|
|
135
|
+
interface RegistryConfig {
|
|
136
|
+
/** Discovery mode */
|
|
137
|
+
mode: DiscoveryMode;
|
|
138
|
+
/** Default TTL for agent registrations (ms) */
|
|
139
|
+
defaultTTL: number;
|
|
140
|
+
/** Health check interval (ms) */
|
|
141
|
+
healthCheckInterval: number;
|
|
142
|
+
/** Max time before agent is marked offline (ms) */
|
|
143
|
+
offlineThreshold: number;
|
|
144
|
+
/** Whether to auto-cleanup offline agents */
|
|
145
|
+
autoCleanup: boolean;
|
|
146
|
+
/** Cleanup interval (ms) */
|
|
147
|
+
cleanupInterval: number;
|
|
148
|
+
/** Maximum number of agents */
|
|
149
|
+
maxAgents: number;
|
|
150
|
+
/** Minimum trust level for registration */
|
|
151
|
+
minTrustForRegistration: TrustLevel;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Default configuration
|
|
155
|
+
*/
|
|
156
|
+
declare const DEFAULT_REGISTRY_CONFIG: RegistryConfig;
|
|
157
|
+
/**
|
|
158
|
+
* Registry event types
|
|
159
|
+
*/
|
|
160
|
+
interface RegistryEvents {
|
|
161
|
+
'agent:registered': (manifest: AgentManifest) => void;
|
|
162
|
+
'agent:deregistered': (agentId: string, reason: string) => void;
|
|
163
|
+
'agent:online': (agentId: string) => void;
|
|
164
|
+
'agent:offline': (agentId: string) => void;
|
|
165
|
+
'agent:degraded': (agentId: string) => void;
|
|
166
|
+
'agent:updated': (manifest: AgentManifest) => void;
|
|
167
|
+
'registry:cleanup': (removedCount: number) => void;
|
|
168
|
+
'registry:error': (error: Error) => void;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Central registry for agent registration and discovery
|
|
172
|
+
*/
|
|
173
|
+
declare class AgentRegistry extends EventEmitter {
|
|
174
|
+
private agents;
|
|
175
|
+
private matcher;
|
|
176
|
+
private config;
|
|
177
|
+
private healthCheckTimer?;
|
|
178
|
+
private cleanupTimer?;
|
|
179
|
+
private isShuttingDown;
|
|
180
|
+
constructor(config?: Partial<RegistryConfig>);
|
|
181
|
+
/**
|
|
182
|
+
* Start the registry (begins health checks and cleanup)
|
|
183
|
+
*/
|
|
184
|
+
start(): void;
|
|
185
|
+
/**
|
|
186
|
+
* Stop the registry
|
|
187
|
+
*/
|
|
188
|
+
stop(): void;
|
|
189
|
+
/**
|
|
190
|
+
* Clear all agents and reset
|
|
191
|
+
*/
|
|
192
|
+
clear(): void;
|
|
193
|
+
/**
|
|
194
|
+
* Register an agent
|
|
195
|
+
*/
|
|
196
|
+
register(manifest: AgentManifest): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Deregister an agent
|
|
199
|
+
*/
|
|
200
|
+
deregister(agentId: string): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Update an agent's heartbeat
|
|
203
|
+
*/
|
|
204
|
+
heartbeat(agentId: string): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Discover agents matching a capability query
|
|
207
|
+
*/
|
|
208
|
+
discover(query: CapabilityQuery): Promise<AgentManifest[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Discover agents with full match details
|
|
211
|
+
*/
|
|
212
|
+
discoverWithScores(query: CapabilityQuery): Promise<AgentMatch[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Find the best agent for a query
|
|
215
|
+
*/
|
|
216
|
+
findBest(query: CapabilityQuery): Promise<AgentManifest | null>;
|
|
217
|
+
/**
|
|
218
|
+
* Get a specific agent by ID
|
|
219
|
+
*/
|
|
220
|
+
get(agentId: string): AgentManifest | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Check if an agent is registered
|
|
223
|
+
*/
|
|
224
|
+
has(agentId: string): boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Get all registered manifests
|
|
227
|
+
*/
|
|
228
|
+
getAllManifests(): AgentManifest[];
|
|
229
|
+
/**
|
|
230
|
+
* Get count of registered agents
|
|
231
|
+
*/
|
|
232
|
+
get size(): number;
|
|
233
|
+
/**
|
|
234
|
+
* Get count by status
|
|
235
|
+
*/
|
|
236
|
+
getStatusCounts(): Record<string, number>;
|
|
237
|
+
/**
|
|
238
|
+
* Perform health check on all agents
|
|
239
|
+
*/
|
|
240
|
+
private performHealthCheck;
|
|
241
|
+
/**
|
|
242
|
+
* Cleanup expired/offline agents
|
|
243
|
+
*/
|
|
244
|
+
private cleanup;
|
|
245
|
+
/**
|
|
246
|
+
* Find agents by trust level
|
|
247
|
+
*/
|
|
248
|
+
findByTrust(trustLevel: TrustLevel): AgentManifest[];
|
|
249
|
+
/**
|
|
250
|
+
* Find agents by tag
|
|
251
|
+
*/
|
|
252
|
+
findByTag(tag: string): AgentManifest[];
|
|
253
|
+
/**
|
|
254
|
+
* Find online agents
|
|
255
|
+
*/
|
|
256
|
+
findOnline(): AgentManifest[];
|
|
257
|
+
/**
|
|
258
|
+
* Find agents in a scene
|
|
259
|
+
*/
|
|
260
|
+
findInScene(scene: string): AgentManifest[];
|
|
261
|
+
/**
|
|
262
|
+
* Export registry state
|
|
263
|
+
*/
|
|
264
|
+
export(): {
|
|
265
|
+
agents: AgentManifest[];
|
|
266
|
+
config: RegistryConfig;
|
|
267
|
+
timestamp: number;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Import registry state
|
|
271
|
+
*/
|
|
272
|
+
import(data: {
|
|
273
|
+
agents: AgentManifest[];
|
|
274
|
+
}): Promise<void>;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Get or create the default registry instance
|
|
278
|
+
*/
|
|
279
|
+
declare function getDefaultRegistry(config?: Partial<RegistryConfig>): AgentRegistry;
|
|
280
|
+
/**
|
|
281
|
+
* Reset the default registry
|
|
282
|
+
*/
|
|
283
|
+
declare function resetDefaultRegistry(): void;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @holoscript/core - Federated Registry Adapter
|
|
287
|
+
*
|
|
288
|
+
* Extends the AgentRegistry with cross-composition discovery by
|
|
289
|
+
* fetching remote A2A Agent Cards from /.well-known/agent-card.json
|
|
290
|
+
* endpoints and converting them to AgentManifest entries.
|
|
291
|
+
*
|
|
292
|
+
* Part of HoloScript v5.5 "Agents as Universal Orchestrators".
|
|
293
|
+
*/
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Minimal A2A AgentCard shape for federation.
|
|
297
|
+
* Matches the full AgentCard type in packages/mcp-server/src/a2a.ts.
|
|
298
|
+
*/
|
|
299
|
+
interface A2AAgentCard {
|
|
300
|
+
id: string;
|
|
301
|
+
name: string;
|
|
302
|
+
description?: string;
|
|
303
|
+
endpoint: string;
|
|
304
|
+
version: string;
|
|
305
|
+
provider?: {
|
|
306
|
+
organization: string;
|
|
307
|
+
url: string;
|
|
308
|
+
};
|
|
309
|
+
capabilities?: {
|
|
310
|
+
streaming?: boolean;
|
|
311
|
+
pushNotifications?: boolean;
|
|
312
|
+
stateTransitionHistory?: boolean;
|
|
313
|
+
};
|
|
314
|
+
skills?: A2ASkill[];
|
|
315
|
+
}
|
|
316
|
+
interface A2ASkill {
|
|
317
|
+
id: string;
|
|
318
|
+
name: string;
|
|
319
|
+
description?: string;
|
|
320
|
+
tags?: string[];
|
|
321
|
+
inputModes?: string[];
|
|
322
|
+
outputModes?: string[];
|
|
323
|
+
}
|
|
324
|
+
interface FederatedRegistryConfig {
|
|
325
|
+
/** Remote agent-card.json URLs to poll */
|
|
326
|
+
seedUrls: string[];
|
|
327
|
+
/** Poll interval in ms (default 60_000) */
|
|
328
|
+
pollIntervalMs: number;
|
|
329
|
+
/** Maximum remote agents to track (default 100) */
|
|
330
|
+
maxRemoteAgents: number;
|
|
331
|
+
/** Trust level assigned to remote agents (default 'external') */
|
|
332
|
+
trustRemoteAs: TrustLevel;
|
|
333
|
+
/** HTTP fetch timeout in ms (default 5_000) */
|
|
334
|
+
timeout: number;
|
|
335
|
+
/** Custom fetch function (for testing) */
|
|
336
|
+
fetchFn?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
337
|
+
}
|
|
338
|
+
declare class FederatedRegistryAdapter {
|
|
339
|
+
private registry;
|
|
340
|
+
private config;
|
|
341
|
+
private pollTimer?;
|
|
342
|
+
private remoteAgentIds;
|
|
343
|
+
private lastPollResults;
|
|
344
|
+
constructor(registry: AgentRegistry, config?: Partial<FederatedRegistryConfig>);
|
|
345
|
+
/**
|
|
346
|
+
* Fetch a remote agent card and register it into the local registry.
|
|
347
|
+
* Returns the converted manifest on success, null on failure.
|
|
348
|
+
*/
|
|
349
|
+
fetchAndRegister(url: string): Promise<AgentManifest | null>;
|
|
350
|
+
/**
|
|
351
|
+
* Poll all seed URLs once. Returns summary of results.
|
|
352
|
+
*/
|
|
353
|
+
pollAll(): Promise<{
|
|
354
|
+
added: number;
|
|
355
|
+
updated: number;
|
|
356
|
+
failed: string[];
|
|
357
|
+
}>;
|
|
358
|
+
/**
|
|
359
|
+
* Start periodic polling of seed URLs.
|
|
360
|
+
*/
|
|
361
|
+
startPolling(): void;
|
|
362
|
+
/**
|
|
363
|
+
* Stop periodic polling.
|
|
364
|
+
*/
|
|
365
|
+
stopPolling(): void;
|
|
366
|
+
/**
|
|
367
|
+
* Whether polling is currently active.
|
|
368
|
+
*/
|
|
369
|
+
get isPolling(): boolean;
|
|
370
|
+
/**
|
|
371
|
+
* Convert an A2A AgentCard to an AgentManifest.
|
|
372
|
+
*/
|
|
373
|
+
a2aCardToManifest(card: A2AAgentCard, sourceUrl: string): AgentManifest;
|
|
374
|
+
/**
|
|
375
|
+
* Discover agents across local registry + remote seeds.
|
|
376
|
+
* Ensures all seed URLs are polled before querying.
|
|
377
|
+
*/
|
|
378
|
+
discoverFederated(query: CapabilityQuery): Promise<AgentMatch[]>;
|
|
379
|
+
/**
|
|
380
|
+
* Get all remote agent IDs tracked by this adapter.
|
|
381
|
+
*/
|
|
382
|
+
getRemoteAgentIds(): string[];
|
|
383
|
+
/**
|
|
384
|
+
* Get the number of remote agents currently tracked.
|
|
385
|
+
*/
|
|
386
|
+
get remoteAgentCount(): number;
|
|
387
|
+
/**
|
|
388
|
+
* Get poll results for a specific URL.
|
|
389
|
+
*/
|
|
390
|
+
getPollResult(url: string): {
|
|
391
|
+
timestamp: number;
|
|
392
|
+
success: boolean;
|
|
393
|
+
} | undefined;
|
|
394
|
+
/**
|
|
395
|
+
* Add a seed URL dynamically (does not trigger immediate poll).
|
|
396
|
+
*/
|
|
397
|
+
addSeedUrl(url: string): void;
|
|
398
|
+
/**
|
|
399
|
+
* Remove a seed URL and optionally deregister its agent.
|
|
400
|
+
*/
|
|
401
|
+
removeSeedUrl(url: string, deregister?: boolean): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Fetch an agent card from a URL.
|
|
404
|
+
*/
|
|
405
|
+
private fetchAgentCard;
|
|
406
|
+
/**
|
|
407
|
+
* Extract capabilities from an A2A AgentCard's skills.
|
|
408
|
+
*/
|
|
409
|
+
private extractCapabilities;
|
|
410
|
+
/**
|
|
411
|
+
* Extract endpoint from an A2A AgentCard.
|
|
412
|
+
*/
|
|
413
|
+
private extractEndpoint;
|
|
414
|
+
/**
|
|
415
|
+
* Derive capability type from A2A skill tags.
|
|
416
|
+
*/
|
|
417
|
+
private deriveType;
|
|
418
|
+
/**
|
|
419
|
+
* Derive capability domain from A2A skill tags.
|
|
420
|
+
*/
|
|
421
|
+
private deriveDomain;
|
|
422
|
+
/**
|
|
423
|
+
* Check if a URL has been successfully polled before.
|
|
424
|
+
*/
|
|
425
|
+
private isKnownUrl;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* @holoscript/core - Task Delegation Service
|
|
430
|
+
*
|
|
431
|
+
* Cross-agent task forwarding with support for local (in-process) and remote
|
|
432
|
+
* (A2A JSON-RPC) delegation. Includes auto-delegation via capability matching,
|
|
433
|
+
* retry with exponential backoff, and delegation history tracking.
|
|
434
|
+
*
|
|
435
|
+
* Part of HoloScript v5.5 "Agents as Universal Orchestrators".
|
|
436
|
+
*/
|
|
437
|
+
|
|
438
|
+
interface DelegationRequest {
|
|
439
|
+
/** Target agent ID (from AgentManifest.id) */
|
|
440
|
+
targetAgentId: string;
|
|
441
|
+
/** Skill/tool name to invoke on the target agent */
|
|
442
|
+
skillId: string;
|
|
443
|
+
/** Arguments to pass to the skill */
|
|
444
|
+
arguments: Record<string, unknown>;
|
|
445
|
+
/** Timeout in ms (default 30_000) */
|
|
446
|
+
timeout?: number;
|
|
447
|
+
/** Number of retries on failure (default 0) */
|
|
448
|
+
retries?: number;
|
|
449
|
+
/** Callback URL for async results (reserved for future use) */
|
|
450
|
+
callbackUrl?: string;
|
|
451
|
+
}
|
|
452
|
+
interface DelegationResult {
|
|
453
|
+
/** Unique task ID for tracking */
|
|
454
|
+
taskId: string;
|
|
455
|
+
/** Final delegation status */
|
|
456
|
+
status: 'completed' | 'failed' | 'timeout' | 'rejected';
|
|
457
|
+
/** Result data on success */
|
|
458
|
+
result?: unknown;
|
|
459
|
+
/** Error message on failure */
|
|
460
|
+
error?: string;
|
|
461
|
+
/** Total execution time in ms */
|
|
462
|
+
durationMs: number;
|
|
463
|
+
/** Info about the delegated agent */
|
|
464
|
+
delegatedTo: {
|
|
465
|
+
agentId: string;
|
|
466
|
+
endpoint: string;
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
interface TaskDelegationConfig {
|
|
470
|
+
/** Default timeout for delegations in ms (default 30_000) */
|
|
471
|
+
defaultTimeout: number;
|
|
472
|
+
/** Maximum delegation history entries (default 1000, LRU eviction) */
|
|
473
|
+
maxHistory: number;
|
|
474
|
+
/** Custom fetch function (for testing) */
|
|
475
|
+
fetchFn?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
476
|
+
/** Local tool executor for in-process agents */
|
|
477
|
+
localExecutor?: (skillId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
478
|
+
/** Optional observability hook for per-task delegation trace events */
|
|
479
|
+
traceHook?: (event: DelegationTraceEvent) => void;
|
|
480
|
+
/** Optional transport adapter for remote A2A calls */
|
|
481
|
+
transportAdapter?: A2ATransportAdapter;
|
|
482
|
+
/** Optional idempotency key factory for remote A2A calls */
|
|
483
|
+
idempotencyKeyFactory?: (ctx: {
|
|
484
|
+
taskId: string;
|
|
485
|
+
attempt: number;
|
|
486
|
+
endpointUrl: string;
|
|
487
|
+
skillId: string;
|
|
488
|
+
}) => string;
|
|
489
|
+
}
|
|
490
|
+
interface A2ATransportAdapter {
|
|
491
|
+
send(input: {
|
|
492
|
+
endpointUrl: string;
|
|
493
|
+
requestBody: Record<string, unknown>;
|
|
494
|
+
idempotencyKey: string;
|
|
495
|
+
fetchFn: (url: string, init?: RequestInit) => Promise<Response>;
|
|
496
|
+
}): Promise<unknown>;
|
|
497
|
+
}
|
|
498
|
+
type DelegationTracePhase = 'start' | 'attempt' | 'retry' | 'success' | 'failure' | 'timeout' | 'rejected' | 'replay_requested' | 'replay_completed' | 'replay_failed';
|
|
499
|
+
interface DelegationTraceEvent {
|
|
500
|
+
taskId: string;
|
|
501
|
+
phase: DelegationTracePhase;
|
|
502
|
+
timestamp: string;
|
|
503
|
+
metadata?: Record<string, unknown>;
|
|
504
|
+
}
|
|
505
|
+
declare class TaskDelegationService {
|
|
506
|
+
private registry;
|
|
507
|
+
private adapter?;
|
|
508
|
+
private config;
|
|
509
|
+
private history;
|
|
510
|
+
private traceHistory;
|
|
511
|
+
private requestHistory;
|
|
512
|
+
constructor(registry: AgentRegistry, adapter?: FederatedRegistryAdapter, config?: Partial<TaskDelegationConfig>);
|
|
513
|
+
/**
|
|
514
|
+
* Delegate a task to a specific agent by ID.
|
|
515
|
+
*/
|
|
516
|
+
delegateTo(request: DelegationRequest): Promise<DelegationResult>;
|
|
517
|
+
/**
|
|
518
|
+
* Auto-delegate: find the best agent for a capability then delegate.
|
|
519
|
+
*/
|
|
520
|
+
autoDelegate(query: CapabilityQuery, skillId: string, args: Record<string, unknown>, options?: {
|
|
521
|
+
timeout?: number;
|
|
522
|
+
retries?: number;
|
|
523
|
+
}): Promise<DelegationResult>;
|
|
524
|
+
/**
|
|
525
|
+
* Get the status of a previously delegated task from history.
|
|
526
|
+
*/
|
|
527
|
+
getStatus(taskId: string): DelegationResult | undefined;
|
|
528
|
+
/**
|
|
529
|
+
* Get the full delegation history.
|
|
530
|
+
*/
|
|
531
|
+
getDelegationHistory(): DelegationResult[];
|
|
532
|
+
/**
|
|
533
|
+
* Get observability trace events for delegations (optionally filtered by taskId).
|
|
534
|
+
*/
|
|
535
|
+
getTraceHistory(taskId?: string): DelegationTraceEvent[];
|
|
536
|
+
/**
|
|
537
|
+
* Replay a previously delegated task using its original request payload.
|
|
538
|
+
*/
|
|
539
|
+
replay(taskId: string, overrides?: Partial<DelegationRequest>): Promise<DelegationResult>;
|
|
540
|
+
/**
|
|
541
|
+
* Get delegation stats.
|
|
542
|
+
*/
|
|
543
|
+
getStats(): {
|
|
544
|
+
total: number;
|
|
545
|
+
completed: number;
|
|
546
|
+
failed: number;
|
|
547
|
+
timeout: number;
|
|
548
|
+
rejected: number;
|
|
549
|
+
};
|
|
550
|
+
/**
|
|
551
|
+
* Execute a skill on an agent (local or remote).
|
|
552
|
+
*/
|
|
553
|
+
private executeOnAgent;
|
|
554
|
+
/**
|
|
555
|
+
* Execute via remote A2A JSON-RPC.
|
|
556
|
+
*/
|
|
557
|
+
private executeRemote;
|
|
558
|
+
/**
|
|
559
|
+
* Execute a function with a timeout.
|
|
560
|
+
*/
|
|
561
|
+
private executeWithTimeout;
|
|
562
|
+
/**
|
|
563
|
+
* Get the primary endpoint from a manifest.
|
|
564
|
+
*/
|
|
565
|
+
private getPrimaryEndpoint;
|
|
566
|
+
/**
|
|
567
|
+
* Add a result to history with LRU eviction.
|
|
568
|
+
*/
|
|
569
|
+
private addToHistory;
|
|
570
|
+
/**
|
|
571
|
+
* Emit and store delegation observability traces.
|
|
572
|
+
*/
|
|
573
|
+
private emitTrace;
|
|
574
|
+
/**
|
|
575
|
+
* Sleep utility.
|
|
576
|
+
*/
|
|
577
|
+
private sleep;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @holoscript/core - Skill Workflow Engine
|
|
582
|
+
*
|
|
583
|
+
* DAG-based skill composition and chaining. Validates workflow definitions,
|
|
584
|
+
* resolves inter-step data dependencies, and executes steps in parallel groups.
|
|
585
|
+
* Uses topological sort pattern from MicroPhaseDecomposer.
|
|
586
|
+
*
|
|
587
|
+
* Part of HoloScript v5.5 "Agents as Universal Orchestrators".
|
|
588
|
+
*/
|
|
589
|
+
/**
|
|
590
|
+
* Input can be a literal value, a reference to another step's output, or context.
|
|
591
|
+
*/
|
|
592
|
+
type WorkflowInput = {
|
|
593
|
+
type: 'literal';
|
|
594
|
+
value: unknown;
|
|
595
|
+
} | {
|
|
596
|
+
type: 'ref';
|
|
597
|
+
stepId: string;
|
|
598
|
+
outputKey: string;
|
|
599
|
+
} | {
|
|
600
|
+
type: 'context';
|
|
601
|
+
key: string;
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* A single step in a workflow.
|
|
605
|
+
*/
|
|
606
|
+
interface WorkflowStep {
|
|
607
|
+
/** Unique step identifier */
|
|
608
|
+
id: string;
|
|
609
|
+
/** Skill/tool to invoke */
|
|
610
|
+
skillId: string;
|
|
611
|
+
/** Input mapping: param name → source */
|
|
612
|
+
inputs: Record<string, WorkflowInput>;
|
|
613
|
+
/** Step IDs that must complete first */
|
|
614
|
+
dependsOn?: string[];
|
|
615
|
+
/** Per-step timeout in ms */
|
|
616
|
+
timeout?: number;
|
|
617
|
+
/** Error handling strategy */
|
|
618
|
+
onError?: 'fail' | 'skip' | 'fallback';
|
|
619
|
+
/** Fallback skill if primary fails and onError='fallback' */
|
|
620
|
+
fallbackSkillId?: string;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Complete workflow definition.
|
|
624
|
+
*/
|
|
625
|
+
interface WorkflowDefinition {
|
|
626
|
+
/** Workflow identifier */
|
|
627
|
+
id: string;
|
|
628
|
+
/** Human-readable name */
|
|
629
|
+
name: string;
|
|
630
|
+
/** Optional description */
|
|
631
|
+
description?: string;
|
|
632
|
+
/** Ordered steps (topologically sorted at validation) */
|
|
633
|
+
steps: WorkflowStep[];
|
|
634
|
+
/** Initial context data */
|
|
635
|
+
context?: Record<string, unknown>;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Validation result for a workflow definition.
|
|
639
|
+
*/
|
|
640
|
+
interface WorkflowValidation {
|
|
641
|
+
/** Whether the workflow is valid */
|
|
642
|
+
valid: boolean;
|
|
643
|
+
/** Validation errors */
|
|
644
|
+
errors: string[];
|
|
645
|
+
/** Validation warnings */
|
|
646
|
+
warnings: string[];
|
|
647
|
+
/** Execution plan: groups of step IDs that can run in parallel */
|
|
648
|
+
executionPlan: {
|
|
649
|
+
groups: string[][];
|
|
650
|
+
estimatedSteps: number;
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Result of a single step execution.
|
|
655
|
+
*/
|
|
656
|
+
interface WorkflowStepResult {
|
|
657
|
+
stepId: string;
|
|
658
|
+
status: 'completed' | 'failed' | 'skipped';
|
|
659
|
+
output: Record<string, unknown>;
|
|
660
|
+
durationMs: number;
|
|
661
|
+
error?: string;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Result of a full workflow execution.
|
|
665
|
+
*/
|
|
666
|
+
interface WorkflowResult {
|
|
667
|
+
workflowId: string;
|
|
668
|
+
status: 'completed' | 'partial' | 'failed';
|
|
669
|
+
stepResults: WorkflowStepResult[];
|
|
670
|
+
totalDurationMs: number;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Executor function type: takes a skill ID and inputs, returns outputs.
|
|
674
|
+
*/
|
|
675
|
+
type SkillExecutor = (skillId: string, inputs: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
676
|
+
/**
|
|
677
|
+
* Progress callback type.
|
|
678
|
+
*/
|
|
679
|
+
type ProgressCallback = (stepId: string, status: string) => void;
|
|
680
|
+
declare class SkillWorkflowEngine {
|
|
681
|
+
/**
|
|
682
|
+
* Validate a workflow definition.
|
|
683
|
+
*/
|
|
684
|
+
validate(definition: WorkflowDefinition, availableSkills?: string[]): WorkflowValidation;
|
|
685
|
+
/**
|
|
686
|
+
* Execute a workflow using the provided executor function.
|
|
687
|
+
*/
|
|
688
|
+
execute(definition: WorkflowDefinition, executor: SkillExecutor, onProgress?: ProgressCallback): Promise<WorkflowResult>;
|
|
689
|
+
/**
|
|
690
|
+
* Execute a single step with optional fallback.
|
|
691
|
+
*/
|
|
692
|
+
private executeStep;
|
|
693
|
+
/**
|
|
694
|
+
* Resolve step inputs from literal values, step outputs, or context.
|
|
695
|
+
*/
|
|
696
|
+
private resolveInputs;
|
|
697
|
+
/**
|
|
698
|
+
* Detect cycles in the step dependency graph.
|
|
699
|
+
* Returns a cycle description string, or null if no cycles.
|
|
700
|
+
*/
|
|
701
|
+
private detectCycles;
|
|
702
|
+
/**
|
|
703
|
+
* Build parallel execution groups via topological sort.
|
|
704
|
+
* Each group contains steps that can run concurrently.
|
|
705
|
+
*/
|
|
706
|
+
private buildExecutionGroups;
|
|
707
|
+
/**
|
|
708
|
+
* Get all dependencies for a step (explicit + implicit from ref inputs).
|
|
709
|
+
*/
|
|
710
|
+
private getAllDependencies;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* @holoscript/framework - Orchestrator Agent
|
|
715
|
+
*
|
|
716
|
+
* First concrete implementation of BaseAgent from the uAA2++ protocol.
|
|
717
|
+
* Maps the 7-phase protocol to agent orchestration concerns:
|
|
718
|
+
* INTAKE → discover available agents
|
|
719
|
+
* REFLECT → match capabilities to task requirements
|
|
720
|
+
* EXECUTE → delegate tasks or run workflows
|
|
721
|
+
* COMPRESS → summarize execution results
|
|
722
|
+
* REINTAKE → check delegation results, update agent status
|
|
723
|
+
* GROW → record delegation patterns (what worked/failed)
|
|
724
|
+
* EVOLVE → optimize routing preferences
|
|
725
|
+
*
|
|
726
|
+
* Part of HoloScript v5.5 "Agents as Universal Orchestrators".
|
|
727
|
+
*/
|
|
728
|
+
|
|
729
|
+
interface OrchestratorConfig {
|
|
730
|
+
/** Agent name */
|
|
731
|
+
name: string;
|
|
732
|
+
/** Primary domain */
|
|
733
|
+
domain: string;
|
|
734
|
+
/** Seed URLs for federated discovery */
|
|
735
|
+
seedUrls?: string[];
|
|
736
|
+
/** Whether to auto-discover on intake (default true) */
|
|
737
|
+
autoDiscovery?: boolean;
|
|
738
|
+
/** Discovery poll interval in ms */
|
|
739
|
+
discoveryIntervalMs?: number;
|
|
740
|
+
/** Custom fetch function (for testing) */
|
|
741
|
+
fetchFn?: FederatedRegistryConfig['fetchFn'];
|
|
742
|
+
/** Local tool executor (for testing/integration) */
|
|
743
|
+
localExecutor?: (skillId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
744
|
+
}
|
|
745
|
+
interface DelegationPattern {
|
|
746
|
+
agentId: string;
|
|
747
|
+
skillId: string;
|
|
748
|
+
successCount: number;
|
|
749
|
+
failureCount: number;
|
|
750
|
+
avgDurationMs: number;
|
|
751
|
+
lastUsed: number;
|
|
752
|
+
}
|
|
753
|
+
declare class OrchestratorAgent extends BaseAgent {
|
|
754
|
+
readonly identity: AgentIdentity;
|
|
755
|
+
private registry;
|
|
756
|
+
private adapter;
|
|
757
|
+
private delegator;
|
|
758
|
+
private workflowEngine;
|
|
759
|
+
private config;
|
|
760
|
+
/** Learned delegation patterns (GROW phase) */
|
|
761
|
+
private patterns;
|
|
762
|
+
/** Routing preferences (EVOLVE phase) */
|
|
763
|
+
private preferences;
|
|
764
|
+
/** Last discovered agents */
|
|
765
|
+
private lastDiscovery;
|
|
766
|
+
constructor(config: OrchestratorConfig);
|
|
767
|
+
intake(input: unknown): Promise<PhaseResult>;
|
|
768
|
+
reflect(data: unknown): Promise<PhaseResult>;
|
|
769
|
+
execute(plan: unknown): Promise<PhaseResult>;
|
|
770
|
+
compress(results: unknown): Promise<PhaseResult>;
|
|
771
|
+
reintake(compressed: unknown): Promise<PhaseResult>;
|
|
772
|
+
grow(learnings: unknown): Promise<PhaseResult>;
|
|
773
|
+
evolve(adaptations: unknown): Promise<PhaseResult>;
|
|
774
|
+
/**
|
|
775
|
+
* Delegate a task without running a full cycle.
|
|
776
|
+
*/
|
|
777
|
+
delegateTask(skillId: string, args: Record<string, unknown>): Promise<DelegationResult>;
|
|
778
|
+
/**
|
|
779
|
+
* Run a workflow without running a full cycle.
|
|
780
|
+
*/
|
|
781
|
+
runWorkflow(definition: WorkflowDefinition): Promise<WorkflowResult>;
|
|
782
|
+
/**
|
|
783
|
+
* Get all discovered agents.
|
|
784
|
+
*/
|
|
785
|
+
getDiscoveredAgents(): AgentManifest[];
|
|
786
|
+
/**
|
|
787
|
+
* Get learned patterns.
|
|
788
|
+
*/
|
|
789
|
+
getPatterns(): DelegationPattern[];
|
|
790
|
+
/**
|
|
791
|
+
* Stop polling and cleanup.
|
|
792
|
+
*/
|
|
793
|
+
shutdown(): void;
|
|
794
|
+
private taskToQuery;
|
|
795
|
+
private getPreferredAgents;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
export { type A2AAgentCard as A, resetDefaultRegistry as B, type CapabilityMatch as C, DEFAULT_REGISTRY_CONFIG as D, FederatedRegistryAdapter as F, OrchestratorAgent as O, type ProgressCallback as P, type RegistryConfig as R, type SkillExecutor as S, type TaskDelegationConfig as T, type WorkflowDefinition as W, type A2ASkill as a, type A2ATransportAdapter as b, type AgentMatch as c, AgentRegistry as d, CapabilityMatcher as e, type CapabilityQuery as f, type DelegationRequest as g, type DelegationResult as h, type DelegationTraceEvent as i, type DelegationTracePhase as j, type DiscoveryMode as k, type FederatedRegistryConfig as l, type OrchestratorConfig as m, type RegistryEvents as n, SkillWorkflowEngine as o, type SpatialQuery as p, TaskDelegationService as q, type WorkflowInput as r, type WorkflowResult as s, type WorkflowStep as t, type WorkflowStepResult as u, type WorkflowValidation as v, defaultMatcher as w, findAgents as x, findBestAgent as y, getDefaultRegistry as z };
|