@nuvin/nuvin-core 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VERSION +2 -2
- package/dist/index.d.ts +155 -121
- package/dist/index.js +67 -29
- package/package.json +1 -1
package/dist/VERSION
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ type AgentTemplate = {
|
|
|
12
12
|
tools?: string[];
|
|
13
13
|
provider?: string;
|
|
14
14
|
model?: string;
|
|
15
|
-
apiKey?: string;
|
|
16
15
|
temperature?: number;
|
|
17
16
|
maxTokens?: number;
|
|
18
17
|
topP?: number;
|
|
@@ -331,6 +330,13 @@ interface LLMPort {
|
|
|
331
330
|
onStreamFinish?: (finishReason?: string, usage?: UsageData) => void;
|
|
332
331
|
}, signal?: AbortSignal): Promise<CompletionResult>;
|
|
333
332
|
}
|
|
333
|
+
type LLMConfig = {
|
|
334
|
+
provider?: string;
|
|
335
|
+
model?: string;
|
|
336
|
+
};
|
|
337
|
+
interface LLMFactory {
|
|
338
|
+
createLLM(config: LLMConfig): LLMPort;
|
|
339
|
+
}
|
|
334
340
|
type ToolDefinition = {
|
|
335
341
|
type: 'function';
|
|
336
342
|
function: {
|
|
@@ -356,9 +362,13 @@ type ToolExecutionResult = {
|
|
|
356
362
|
interface ToolPort {
|
|
357
363
|
getToolDefinitions(enabledTools: string[]): ToolDefinition[];
|
|
358
364
|
executeToolCalls(calls: ToolInvocation[], context?: Record<string, unknown>, maxConcurrent?: number, signal?: AbortSignal): Promise<ToolExecutionResult[]>;
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
365
|
+
}
|
|
366
|
+
interface AgentAwareToolPort {
|
|
367
|
+
setEnabledAgents(enabledAgents: Record<string, boolean>): void;
|
|
368
|
+
getAgentRegistry(): AgentRegistry | undefined;
|
|
369
|
+
}
|
|
370
|
+
interface OrchestratorAwareToolPort {
|
|
371
|
+
setOrchestrator(config: AgentConfig, tools: ToolPort, llmFactory?: LLMFactory, configResolver?: () => Partial<AgentConfig>): void;
|
|
362
372
|
}
|
|
363
373
|
type MemorySnapshot<T = unknown> = Record<string, T[]>;
|
|
364
374
|
interface MemoryPersistence<T = unknown> {
|
|
@@ -810,45 +820,6 @@ type TodoItem = {
|
|
|
810
820
|
updatedAt?: string;
|
|
811
821
|
};
|
|
812
822
|
|
|
813
|
-
declare class ToolRegistry implements ToolPort {
|
|
814
|
-
private tools;
|
|
815
|
-
private toolsMemory?;
|
|
816
|
-
private agentRegistry;
|
|
817
|
-
private assignTool?;
|
|
818
|
-
private enabledAgentsConfig;
|
|
819
|
-
constructor(opts?: {
|
|
820
|
-
todoMemory?: MemoryPort<TodoItem>;
|
|
821
|
-
toolsMemory?: MemoryPort<string>;
|
|
822
|
-
agentRegistry?: AgentRegistry;
|
|
823
|
-
});
|
|
824
|
-
private persistToolNames;
|
|
825
|
-
listRegisteredTools(): Promise<string[]>;
|
|
826
|
-
getToolDefinitions(enabledTools: string[]): ToolDefinition[];
|
|
827
|
-
/**
|
|
828
|
-
* Initialize AssignTool with orchestrator dependencies (lazy initialization)
|
|
829
|
-
*/
|
|
830
|
-
setOrchestrator(config: AgentConfig, llm: LLMPort, tools: ToolPort): void;
|
|
831
|
-
/**
|
|
832
|
-
* Get the agent registry
|
|
833
|
-
*/
|
|
834
|
-
getAgentRegistry(): AgentRegistry;
|
|
835
|
-
/**
|
|
836
|
-
* Update the enabled agents configuration for AssignTool
|
|
837
|
-
*/
|
|
838
|
-
setEnabledAgents(enabledAgents: Record<string, boolean>): void;
|
|
839
|
-
executeToolCalls(calls: ToolInvocation[], context?: Record<string, unknown>, maxConcurrent?: number, signal?: AbortSignal): Promise<ToolExecutionResult[]>;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
declare class CompositeToolPort implements ToolPort {
|
|
843
|
-
private ports;
|
|
844
|
-
constructor(ports: ToolPort[]);
|
|
845
|
-
getToolDefinitions(enabledTools: string[]): ToolDefinition[];
|
|
846
|
-
executeToolCalls(calls: ToolInvocation[], context?: Record<string, unknown>, maxConcurrent?: number, signal?: AbortSignal): Promise<ToolExecutionResult[]>;
|
|
847
|
-
setEnabledAgents(enabledAgents: Record<string, boolean>): void;
|
|
848
|
-
getAgentRegistry(): AgentRegistry | undefined;
|
|
849
|
-
listRegisteredTools(): Promise<string[]>;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
823
|
type ExecResult = Omit<ToolExecutionResult, 'id' | 'name'>;
|
|
853
824
|
type ToolExecutionContext = {
|
|
854
825
|
conversationId?: string;
|
|
@@ -867,81 +838,6 @@ interface FunctionTool<P = Record<string, unknown>, C = ToolExecutionContext> {
|
|
|
867
838
|
execute(params: P, context?: C): Promise<ExecResult> | ExecResult;
|
|
868
839
|
}
|
|
869
840
|
|
|
870
|
-
type BashParams = {
|
|
871
|
-
cmd: string;
|
|
872
|
-
cwd?: string;
|
|
873
|
-
timeoutMs?: number;
|
|
874
|
-
};
|
|
875
|
-
declare class BashTool implements FunctionTool<BashParams, ToolExecutionContext> {
|
|
876
|
-
name: "bash_tool";
|
|
877
|
-
parameters: {
|
|
878
|
-
readonly type: "object";
|
|
879
|
-
readonly properties: {
|
|
880
|
-
readonly description: {
|
|
881
|
-
readonly type: "string";
|
|
882
|
-
readonly description: "Explanation of what this command will do (e.g., \"Get git commit log\")";
|
|
883
|
-
};
|
|
884
|
-
readonly cmd: {
|
|
885
|
-
readonly type: "string";
|
|
886
|
-
readonly description: "Shell command to run.";
|
|
887
|
-
};
|
|
888
|
-
readonly cwd: {
|
|
889
|
-
readonly type: "string";
|
|
890
|
-
readonly description: "Working directory.";
|
|
891
|
-
};
|
|
892
|
-
readonly timeoutMs: {
|
|
893
|
-
readonly type: "integer";
|
|
894
|
-
readonly minimum: 1;
|
|
895
|
-
readonly description: "Timeout in ms. Default: 30000.";
|
|
896
|
-
};
|
|
897
|
-
};
|
|
898
|
-
readonly required: readonly ["cmd"];
|
|
899
|
-
};
|
|
900
|
-
definition(): ToolDefinition['function'];
|
|
901
|
-
execute(p: BashParams, ctx?: ToolExecutionContext): Promise<ExecResult>;
|
|
902
|
-
private execOnce;
|
|
903
|
-
private defaultShell;
|
|
904
|
-
private shellExists;
|
|
905
|
-
private shellArgs;
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
/**
|
|
909
|
-
* AgentManager - coordinates specialist agent execution for task delegation
|
|
910
|
-
*/
|
|
911
|
-
declare class AgentManager {
|
|
912
|
-
private delegatingConfig;
|
|
913
|
-
private delegatingLLM;
|
|
914
|
-
private delegatingTools;
|
|
915
|
-
private eventCallback?;
|
|
916
|
-
private activeAgents;
|
|
917
|
-
private eventCollectors;
|
|
918
|
-
constructor(delegatingConfig: AgentConfig, delegatingLLM: LLMPort, delegatingTools: ToolPort, eventCallback?: (event: AgentEvent) => void);
|
|
919
|
-
/**
|
|
920
|
-
* Create and execute a specialist agent for a specific task
|
|
921
|
-
*/
|
|
922
|
-
executeTask(config: SpecialistAgentConfig, signal?: AbortSignal): Promise<SpecialistAgentResult>;
|
|
923
|
-
/**
|
|
924
|
-
* Resolve which LLM to use (reuse delegating LLM or create new one)
|
|
925
|
-
*/
|
|
926
|
-
private resolveLLM;
|
|
927
|
-
/**
|
|
928
|
-
* Execute agent task with timeout
|
|
929
|
-
*/
|
|
930
|
-
private executeWithTimeout;
|
|
931
|
-
/**
|
|
932
|
-
* Get active specialist agent count
|
|
933
|
-
*/
|
|
934
|
-
getActiveAgentCount(): number;
|
|
935
|
-
/**
|
|
936
|
-
* Get events for a specific specialist agent
|
|
937
|
-
*/
|
|
938
|
-
getAgentEvents(agentId: string): AgentEvent[] | undefined;
|
|
939
|
-
/**
|
|
940
|
-
* Cleanup all active agents (emergency stop)
|
|
941
|
-
*/
|
|
942
|
-
cleanup(): void;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
841
|
interface AgentCatalog {
|
|
946
842
|
list(): AgentTemplate[];
|
|
947
843
|
get(agentId: string): AgentTemplate | undefined;
|
|
@@ -1019,11 +915,51 @@ declare class DefaultSpecialistAgentFactory implements SpecialistAgentFactory {
|
|
|
1019
915
|
create(input: SpecialistAgentFactoryInput): SpecialistAgentConfig;
|
|
1020
916
|
}
|
|
1021
917
|
|
|
918
|
+
/**
|
|
919
|
+
* AgentManager - coordinates specialist agent execution for task delegation
|
|
920
|
+
*/
|
|
921
|
+
declare class AgentManager {
|
|
922
|
+
private delegatingConfig;
|
|
923
|
+
private delegatingTools;
|
|
924
|
+
private llmFactory?;
|
|
925
|
+
private eventCallback?;
|
|
926
|
+
private configResolver?;
|
|
927
|
+
private llmResolver;
|
|
928
|
+
private activeAgents;
|
|
929
|
+
private eventCollectors;
|
|
930
|
+
constructor(delegatingConfig: AgentConfig, delegatingTools: ToolPort, llmFactory?: LLMFactory, eventCallback?: (event: AgentEvent) => void, configResolver?: () => Partial<AgentConfig>);
|
|
931
|
+
/**
|
|
932
|
+
* Create and execute a specialist agent for a specific task
|
|
933
|
+
*/
|
|
934
|
+
executeTask(config: SpecialistAgentConfig, signal?: AbortSignal): Promise<SpecialistAgentResult>;
|
|
935
|
+
/**
|
|
936
|
+
* Resolve which LLM to use - creates fresh LLM instance via factory
|
|
937
|
+
*/
|
|
938
|
+
private resolveLLM;
|
|
939
|
+
/**
|
|
940
|
+
* Execute agent task with timeout
|
|
941
|
+
*/
|
|
942
|
+
private executeWithTimeout;
|
|
943
|
+
/**
|
|
944
|
+
* Get active specialist agent count
|
|
945
|
+
*/
|
|
946
|
+
getActiveAgentCount(): number;
|
|
947
|
+
/**
|
|
948
|
+
* Get events for a specific specialist agent
|
|
949
|
+
*/
|
|
950
|
+
getAgentEvents(agentId: string): AgentEvent[] | undefined;
|
|
951
|
+
/**
|
|
952
|
+
* Cleanup all active agents (emergency stop)
|
|
953
|
+
*/
|
|
954
|
+
cleanup(): void;
|
|
955
|
+
}
|
|
956
|
+
|
|
1022
957
|
declare class AgentManagerCommandRunner implements AgentCommandRunner {
|
|
1023
958
|
private readonly delegatingConfig;
|
|
1024
|
-
private readonly delegatingLLM;
|
|
1025
959
|
private readonly delegatingTools;
|
|
1026
|
-
|
|
960
|
+
private readonly llmFactory?;
|
|
961
|
+
private readonly configResolver?;
|
|
962
|
+
constructor(delegatingConfig: AgentConfig, delegatingTools: ToolPort, llmFactory?: LLMFactory, configResolver?: () => Partial<AgentConfig>);
|
|
1027
963
|
run(config: Parameters<AgentManager['executeTask']>[0], context?: ToolExecutionContext): Promise<SpecialistAgentResult>;
|
|
1028
964
|
}
|
|
1029
965
|
|
|
@@ -1054,6 +990,104 @@ declare class DefaultDelegationResultFormatter implements DelegationResultFormat
|
|
|
1054
990
|
formatError(error: unknown): string;
|
|
1055
991
|
}
|
|
1056
992
|
|
|
993
|
+
interface DelegationServiceConfig {
|
|
994
|
+
agentRegistry: AgentCatalog;
|
|
995
|
+
commandRunner: AgentCommandRunner;
|
|
996
|
+
agentListProvider?: () => Array<{
|
|
997
|
+
id: string;
|
|
998
|
+
name: string;
|
|
999
|
+
description: string;
|
|
1000
|
+
}>;
|
|
1001
|
+
}
|
|
1002
|
+
declare class DelegationServiceFactory {
|
|
1003
|
+
create(config: DelegationServiceConfig): DelegationService;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
declare class LLMResolver {
|
|
1007
|
+
private factory;
|
|
1008
|
+
constructor(factory: LLMFactory);
|
|
1009
|
+
resolve(config: SpecialistAgentConfig): LLMPort;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
declare class ToolRegistry implements ToolPort, AgentAwareToolPort, OrchestratorAwareToolPort {
|
|
1013
|
+
private tools;
|
|
1014
|
+
private toolsMemory?;
|
|
1015
|
+
private agentRegistry;
|
|
1016
|
+
private delegationServiceFactory?;
|
|
1017
|
+
private assignTool?;
|
|
1018
|
+
private enabledAgentsConfig;
|
|
1019
|
+
constructor(opts?: {
|
|
1020
|
+
todoMemory?: MemoryPort<TodoItem>;
|
|
1021
|
+
toolsMemory?: MemoryPort<string>;
|
|
1022
|
+
agentRegistry?: AgentRegistry;
|
|
1023
|
+
delegationServiceFactory?: DelegationServiceFactory;
|
|
1024
|
+
});
|
|
1025
|
+
private persistToolNames;
|
|
1026
|
+
listRegisteredTools(): Promise<string[]>;
|
|
1027
|
+
getToolDefinitions(enabledTools: string[]): ToolDefinition[];
|
|
1028
|
+
/**
|
|
1029
|
+
* Initialize AssignTool with orchestrator dependencies (lazy initialization)
|
|
1030
|
+
*/
|
|
1031
|
+
setOrchestrator(config: AgentConfig, tools: ToolPort, llmFactory?: LLMFactory, configResolver?: () => Partial<AgentConfig>): void;
|
|
1032
|
+
/**
|
|
1033
|
+
* Get the agent registry
|
|
1034
|
+
*/
|
|
1035
|
+
getAgentRegistry(): AgentRegistry;
|
|
1036
|
+
/**
|
|
1037
|
+
* Update the enabled agents configuration for AssignTool
|
|
1038
|
+
*/
|
|
1039
|
+
setEnabledAgents(enabledAgents: Record<string, boolean>): void;
|
|
1040
|
+
executeToolCalls(calls: ToolInvocation[], context?: Record<string, unknown>, maxConcurrent?: number, signal?: AbortSignal): Promise<ToolExecutionResult[]>;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
declare class CompositeToolPort implements ToolPort {
|
|
1044
|
+
private ports;
|
|
1045
|
+
constructor(ports: ToolPort[]);
|
|
1046
|
+
getToolDefinitions(enabledTools: string[]): ToolDefinition[];
|
|
1047
|
+
executeToolCalls(calls: ToolInvocation[], context?: Record<string, unknown>, maxConcurrent?: number, signal?: AbortSignal): Promise<ToolExecutionResult[]>;
|
|
1048
|
+
setEnabledAgents(enabledAgents: Record<string, boolean>): void;
|
|
1049
|
+
getAgentRegistry(): AgentRegistry | undefined;
|
|
1050
|
+
listRegisteredTools(): Promise<string[]>;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
type BashParams = {
|
|
1054
|
+
cmd: string;
|
|
1055
|
+
cwd?: string;
|
|
1056
|
+
timeoutMs?: number;
|
|
1057
|
+
};
|
|
1058
|
+
declare class BashTool implements FunctionTool<BashParams, ToolExecutionContext> {
|
|
1059
|
+
name: "bash_tool";
|
|
1060
|
+
parameters: {
|
|
1061
|
+
readonly type: "object";
|
|
1062
|
+
readonly properties: {
|
|
1063
|
+
readonly description: {
|
|
1064
|
+
readonly type: "string";
|
|
1065
|
+
readonly description: "Explanation of what this command will do (e.g., \"Get git commit log\")";
|
|
1066
|
+
};
|
|
1067
|
+
readonly cmd: {
|
|
1068
|
+
readonly type: "string";
|
|
1069
|
+
readonly description: "Shell command to run.";
|
|
1070
|
+
};
|
|
1071
|
+
readonly cwd: {
|
|
1072
|
+
readonly type: "string";
|
|
1073
|
+
readonly description: "Working directory.";
|
|
1074
|
+
};
|
|
1075
|
+
readonly timeoutMs: {
|
|
1076
|
+
readonly type: "integer";
|
|
1077
|
+
readonly minimum: 1;
|
|
1078
|
+
readonly description: "Timeout in ms. Default: 30000.";
|
|
1079
|
+
};
|
|
1080
|
+
};
|
|
1081
|
+
readonly required: readonly ["cmd"];
|
|
1082
|
+
};
|
|
1083
|
+
definition(): ToolDefinition['function'];
|
|
1084
|
+
execute(p: BashParams, ctx?: ToolExecutionContext): Promise<ExecResult>;
|
|
1085
|
+
private execOnce;
|
|
1086
|
+
private defaultShell;
|
|
1087
|
+
private shellExists;
|
|
1088
|
+
private shellArgs;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1057
1091
|
declare class EchoLLM implements LLMPort {
|
|
1058
1092
|
generateCompletion(params: CompletionParams): Promise<CompletionResult>;
|
|
1059
1093
|
private hasTool;
|
|
@@ -1449,4 +1483,4 @@ declare function resolveBackspaces(s: string): string;
|
|
|
1449
1483
|
declare function stripAnsiAndControls(s: string): string;
|
|
1450
1484
|
declare function canonicalizeTerminalPaste(raw: string): string;
|
|
1451
1485
|
|
|
1452
|
-
export { AGENT_CREATOR_SYSTEM_PROMPT, type AgentCatalog, type AgentConfig, type AgentEvent, AgentEventTypes, AgentFilePersistence, AgentManager, AgentManagerCommandRunner, AgentOrchestrator, AgentRegistry, type AgentTemplate, AnthropicAISDKLLM, AnthropicLLM, type AssignParams, BashTool, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DeepInfraLLM, type DeepInfraModel, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationService, EchoLLM, type FolderTreeOptions, GithubLLM, InMemoryMemory, InMemoryMetadata, JsonFileMemoryPersistence, LLMError, type LLMPort, type MCPConfig, type MCPServerConfig, MCPToolPort, type MemoryPort, MemoryPortMetadataAdapter, type Message, type MessageContent, type MessageContentPart, type MetadataPort, NoopReminders, OpenRouterLLM, type OpenRouterModel, PersistedMemory, PersistingConsoleEventPort, RuntimeEnv, type SendMessageOptions, SimpleContextBuilder, SimpleCost, SimpleId, type SpecialistAgentConfig, type SpecialistAgentResult, SystemClock, type ToolApprovalDecision, type ToolCall, type ToolExecutionResult, type ToolPort, ToolRegistry, type UserAttachment, type UserMessagePayload, ZaiLLM, buildAgentCreationPrompt, buildInjectedSystem, canonicalizeTerminalPaste, generateFolderTree, loadMCPConfig, normalizeNewlines, renderTemplate, resolveBackspaces, resolveCarriageReturns, stripAnsiAndControls };
|
|
1486
|
+
export { AGENT_CREATOR_SYSTEM_PROMPT, type AgentAwareToolPort, type AgentCatalog, type AgentConfig, type AgentEvent, AgentEventTypes, AgentFilePersistence, AgentManager, AgentManagerCommandRunner, AgentOrchestrator, AgentRegistry, type AgentTemplate, AnthropicAISDKLLM, AnthropicLLM, type AssignParams, BashTool, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DeepInfraLLM, type DeepInfraModel, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationService, type DelegationServiceConfig, DelegationServiceFactory, EchoLLM, type FolderTreeOptions, GithubLLM, InMemoryMemory, InMemoryMetadata, JsonFileMemoryPersistence, type LLMConfig, LLMError, type LLMFactory, type LLMPort, LLMResolver, type MCPConfig, type MCPServerConfig, MCPToolPort, type MemoryPort, MemoryPortMetadataAdapter, type Message, type MessageContent, type MessageContentPart, type MetadataPort, NoopReminders, OpenRouterLLM, type OpenRouterModel, type OrchestratorAwareToolPort, PersistedMemory, PersistingConsoleEventPort, RuntimeEnv, type SendMessageOptions, SimpleContextBuilder, SimpleCost, SimpleId, type SpecialistAgentConfig, type SpecialistAgentResult, SystemClock, type ToolApprovalDecision, type ToolCall, type ToolExecutionResult, type ToolPort, ToolRegistry, type UserAttachment, type UserMessagePayload, ZaiLLM, buildAgentCreationPrompt, buildInjectedSystem, canonicalizeTerminalPaste, generateFolderTree, loadMCPConfig, normalizeNewlines, renderTemplate, resolveBackspaces, resolveCarriageReturns, stripAnsiAndControls };
|
package/dist/index.js
CHANGED
|
@@ -2620,7 +2620,6 @@ var AgentRegistry = class {
|
|
|
2620
2620
|
maxTokens: partial.maxTokens ?? 4e3,
|
|
2621
2621
|
provider: partial.provider,
|
|
2622
2622
|
model: partial.model,
|
|
2623
|
-
apiKey: partial.apiKey,
|
|
2624
2623
|
topP: partial.topP,
|
|
2625
2624
|
timeoutMs: partial.timeoutMs,
|
|
2626
2625
|
shareContext: partial.shareContext,
|
|
@@ -2911,16 +2910,34 @@ var DefaultSpecialistAgentFactory = class {
|
|
|
2911
2910
|
}
|
|
2912
2911
|
};
|
|
2913
2912
|
|
|
2913
|
+
// delegation/LLMResolver.ts
|
|
2914
|
+
var LLMResolver = class {
|
|
2915
|
+
constructor(factory) {
|
|
2916
|
+
this.factory = factory;
|
|
2917
|
+
}
|
|
2918
|
+
resolve(config) {
|
|
2919
|
+
return this.factory.createLLM({
|
|
2920
|
+
provider: config.provider,
|
|
2921
|
+
model: config.model
|
|
2922
|
+
});
|
|
2923
|
+
}
|
|
2924
|
+
};
|
|
2925
|
+
|
|
2914
2926
|
// agent-manager.ts
|
|
2915
2927
|
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
2916
2928
|
var MAX_DELEGATION_DEPTH = 3;
|
|
2917
2929
|
var AgentManager = class {
|
|
2918
|
-
constructor(delegatingConfig,
|
|
2930
|
+
constructor(delegatingConfig, delegatingTools, llmFactory, eventCallback, configResolver) {
|
|
2919
2931
|
this.delegatingConfig = delegatingConfig;
|
|
2920
|
-
this.delegatingLLM = delegatingLLM;
|
|
2921
2932
|
this.delegatingTools = delegatingTools;
|
|
2933
|
+
this.llmFactory = llmFactory;
|
|
2922
2934
|
this.eventCallback = eventCallback;
|
|
2935
|
+
this.configResolver = configResolver;
|
|
2936
|
+
if (llmFactory) {
|
|
2937
|
+
this.llmResolver = new LLMResolver(llmFactory);
|
|
2938
|
+
}
|
|
2923
2939
|
}
|
|
2940
|
+
llmResolver = null;
|
|
2924
2941
|
activeAgents = /* @__PURE__ */ new Map();
|
|
2925
2942
|
eventCollectors = /* @__PURE__ */ new Map();
|
|
2926
2943
|
/**
|
|
@@ -2997,18 +3014,19 @@ var AgentManager = class {
|
|
|
2997
3014
|
}
|
|
2998
3015
|
}
|
|
2999
3016
|
};
|
|
3017
|
+
const freshConfig = this.configResolver?.() ?? {};
|
|
3000
3018
|
const specialistConfig = {
|
|
3001
3019
|
id: agentId,
|
|
3002
3020
|
systemPrompt: config.systemPrompt,
|
|
3003
3021
|
temperature: config.temperature ?? this.delegatingConfig.temperature,
|
|
3004
3022
|
topP: config.topP ?? this.delegatingConfig.topP,
|
|
3005
|
-
model: config.model ?? this.delegatingConfig.model,
|
|
3023
|
+
model: config.model ?? freshConfig.model ?? this.delegatingConfig.model,
|
|
3006
3024
|
maxTokens: config.maxTokens ?? this.delegatingConfig.maxTokens,
|
|
3007
3025
|
enabledTools: config.tools,
|
|
3008
3026
|
maxToolConcurrency: this.delegatingConfig.maxToolConcurrency,
|
|
3009
3027
|
requireToolApproval: false,
|
|
3010
3028
|
// Specialists run autonomously
|
|
3011
|
-
reasoningEffort: this.delegatingConfig.reasoningEffort
|
|
3029
|
+
reasoningEffort: freshConfig.reasoningEffort ?? this.delegatingConfig.reasoningEffort
|
|
3012
3030
|
};
|
|
3013
3031
|
const llm = this.resolveLLM(config);
|
|
3014
3032
|
const specialistOrchestrator = new AgentOrchestrator(specialistConfig, {
|
|
@@ -3090,13 +3108,13 @@ var AgentManager = class {
|
|
|
3090
3108
|
}
|
|
3091
3109
|
}
|
|
3092
3110
|
/**
|
|
3093
|
-
* Resolve which LLM to use
|
|
3111
|
+
* Resolve which LLM to use - creates fresh LLM instance via factory
|
|
3094
3112
|
*/
|
|
3095
3113
|
resolveLLM(config) {
|
|
3096
|
-
if (!
|
|
3097
|
-
|
|
3114
|
+
if (!this.llmResolver) {
|
|
3115
|
+
throw new Error("AgentManager requires LLMFactory to create sub-agents. Please provide llmFactory in constructor.");
|
|
3098
3116
|
}
|
|
3099
|
-
return this.
|
|
3117
|
+
return this.llmResolver.resolve(config);
|
|
3100
3118
|
}
|
|
3101
3119
|
/**
|
|
3102
3120
|
* Execute agent task with timeout
|
|
@@ -3145,19 +3163,21 @@ var AgentManager = class {
|
|
|
3145
3163
|
|
|
3146
3164
|
// delegation/AgentManagerCommandRunner.ts
|
|
3147
3165
|
var AgentManagerCommandRunner = class {
|
|
3148
|
-
constructor(delegatingConfig,
|
|
3166
|
+
constructor(delegatingConfig, delegatingTools, llmFactory, configResolver) {
|
|
3149
3167
|
this.delegatingConfig = delegatingConfig;
|
|
3150
|
-
this.delegatingLLM = delegatingLLM;
|
|
3151
3168
|
this.delegatingTools = delegatingTools;
|
|
3169
|
+
this.llmFactory = llmFactory;
|
|
3170
|
+
this.configResolver = configResolver;
|
|
3152
3171
|
}
|
|
3153
3172
|
async run(config, context) {
|
|
3154
3173
|
const eventPort = context?.eventPort;
|
|
3155
3174
|
const signal = context?.signal;
|
|
3156
3175
|
const agentManager = new AgentManager(
|
|
3157
3176
|
this.delegatingConfig,
|
|
3158
|
-
this.delegatingLLM,
|
|
3159
3177
|
this.delegatingTools,
|
|
3160
|
-
|
|
3178
|
+
this.llmFactory,
|
|
3179
|
+
eventPort ? (event) => eventPort.emit(event) : void 0,
|
|
3180
|
+
this.configResolver
|
|
3161
3181
|
);
|
|
3162
3182
|
return agentManager.executeTask(config, signal);
|
|
3163
3183
|
}
|
|
@@ -3253,16 +3273,34 @@ var DefaultDelegationResultFormatter = class {
|
|
|
3253
3273
|
}
|
|
3254
3274
|
};
|
|
3255
3275
|
|
|
3276
|
+
// delegation/DelegationServiceFactory.ts
|
|
3277
|
+
var DelegationServiceFactory = class {
|
|
3278
|
+
create(config) {
|
|
3279
|
+
const specialistFactory = new DefaultSpecialistAgentFactory({
|
|
3280
|
+
agentListProvider: config.agentListProvider
|
|
3281
|
+
});
|
|
3282
|
+
return new DefaultDelegationService(
|
|
3283
|
+
config.agentRegistry,
|
|
3284
|
+
new DefaultDelegationPolicy(),
|
|
3285
|
+
specialistFactory,
|
|
3286
|
+
config.commandRunner,
|
|
3287
|
+
new DefaultDelegationResultFormatter()
|
|
3288
|
+
);
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3256
3292
|
// tools.ts
|
|
3257
3293
|
var ToolRegistry = class {
|
|
3258
3294
|
tools = /* @__PURE__ */ new Map();
|
|
3259
3295
|
toolsMemory;
|
|
3260
3296
|
agentRegistry;
|
|
3297
|
+
delegationServiceFactory;
|
|
3261
3298
|
assignTool;
|
|
3262
3299
|
enabledAgentsConfig = {};
|
|
3263
3300
|
constructor(opts) {
|
|
3264
3301
|
this.toolsMemory = opts?.toolsMemory || new InMemoryMemory();
|
|
3265
3302
|
this.agentRegistry = opts?.agentRegistry || new AgentRegistry();
|
|
3303
|
+
this.delegationServiceFactory = opts?.delegationServiceFactory;
|
|
3266
3304
|
const todoStore = new TodoStore(opts?.todoMemory || new InMemoryMemory());
|
|
3267
3305
|
const toolInstances = [
|
|
3268
3306
|
new TodoWriteTool(todoStore),
|
|
@@ -3301,22 +3339,20 @@ var ToolRegistry = class {
|
|
|
3301
3339
|
/**
|
|
3302
3340
|
* Initialize AssignTool with orchestrator dependencies (lazy initialization)
|
|
3303
3341
|
*/
|
|
3304
|
-
setOrchestrator(config,
|
|
3305
|
-
const
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
})
|
|
3317
|
-
|
|
3318
|
-
new DefaultDelegationResultFormatter()
|
|
3319
|
-
);
|
|
3342
|
+
setOrchestrator(config, tools, llmFactory, configResolver) {
|
|
3343
|
+
const commandRunner = new AgentManagerCommandRunner(config, tools, llmFactory, configResolver);
|
|
3344
|
+
const factory = this.delegationServiceFactory ?? new DelegationServiceFactory();
|
|
3345
|
+
const delegationService = factory.create({
|
|
3346
|
+
agentRegistry: this.agentRegistry,
|
|
3347
|
+
commandRunner,
|
|
3348
|
+
agentListProvider: () => this.agentRegistry.list().filter(
|
|
3349
|
+
(agent) => typeof agent.id === "string" && typeof agent.name === "string" && typeof agent.description === "string"
|
|
3350
|
+
).map((agent) => ({
|
|
3351
|
+
id: agent.id,
|
|
3352
|
+
name: agent.name,
|
|
3353
|
+
description: agent.description
|
|
3354
|
+
}))
|
|
3355
|
+
});
|
|
3320
3356
|
delegationService.setEnabledAgents(this.enabledAgentsConfig);
|
|
3321
3357
|
this.assignTool = new AssignTool(delegationService);
|
|
3322
3358
|
this.tools.set("assign_task", this.assignTool);
|
|
@@ -5790,12 +5826,14 @@ export {
|
|
|
5790
5826
|
DefaultDelegationResultFormatter,
|
|
5791
5827
|
DefaultDelegationService,
|
|
5792
5828
|
DefaultSpecialistAgentFactory,
|
|
5829
|
+
DelegationServiceFactory,
|
|
5793
5830
|
EchoLLM,
|
|
5794
5831
|
GithubLLM,
|
|
5795
5832
|
InMemoryMemory,
|
|
5796
5833
|
InMemoryMetadata,
|
|
5797
5834
|
JsonFileMemoryPersistence,
|
|
5798
5835
|
LLMError,
|
|
5836
|
+
LLMResolver,
|
|
5799
5837
|
MCPToolPort,
|
|
5800
5838
|
MemoryPortMetadataAdapter,
|
|
5801
5839
|
NoopReminders,
|