@juspay/neurolink 9.82.0 → 9.84.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/CHANGELOG.md +18 -0
- package/dist/agent/agent.d.ts +104 -0
- package/dist/agent/agent.js +401 -0
- package/dist/agent/agentNetwork.d.ts +87 -0
- package/dist/agent/agentNetwork.js +458 -0
- package/dist/agent/communication/index.d.ts +9 -0
- package/dist/agent/communication/index.js +9 -0
- package/dist/agent/communication/message-bus.d.ts +113 -0
- package/dist/agent/communication/message-bus.js +406 -0
- package/dist/agent/coordination/coordinator.d.ts +83 -0
- package/dist/agent/coordination/coordinator.js +598 -0
- package/dist/agent/coordination/index.d.ts +10 -0
- package/dist/agent/coordination/index.js +10 -0
- package/dist/agent/coordination/task-distributor.d.ts +113 -0
- package/dist/agent/coordination/task-distributor.js +585 -0
- package/dist/agent/index.d.ts +38 -0
- package/dist/agent/index.js +44 -0
- package/dist/agent/orchestration/index.d.ts +10 -0
- package/dist/agent/orchestration/index.js +10 -0
- package/dist/agent/orchestration/orchestrator.d.ts +114 -0
- package/dist/agent/orchestration/orchestrator.js +476 -0
- package/dist/agent/orchestration/topology.d.ts +164 -0
- package/dist/agent/orchestration/topology.js +520 -0
- package/dist/agent/prompts/routingPrompts.d.ts +63 -0
- package/dist/agent/prompts/routingPrompts.js +201 -0
- package/dist/browser/neurolink.min.js +377 -358
- package/dist/cli/commands/agent.d.ts +37 -0
- package/dist/cli/commands/agent.js +718 -0
- package/dist/cli/factories/commandFactory.d.ts +8 -0
- package/dist/cli/factories/commandFactory.js +116 -0
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/cli/parser.js +4 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +19 -0
- package/dist/lib/agent/agent.d.ts +104 -0
- package/dist/lib/agent/agent.js +402 -0
- package/dist/lib/agent/agentNetwork.d.ts +87 -0
- package/dist/lib/agent/agentNetwork.js +459 -0
- package/dist/lib/agent/communication/index.d.ts +9 -0
- package/dist/lib/agent/communication/index.js +10 -0
- package/dist/lib/agent/communication/message-bus.d.ts +113 -0
- package/dist/lib/agent/communication/message-bus.js +407 -0
- package/dist/lib/agent/coordination/coordinator.d.ts +83 -0
- package/dist/lib/agent/coordination/coordinator.js +599 -0
- package/dist/lib/agent/coordination/index.d.ts +10 -0
- package/dist/lib/agent/coordination/index.js +11 -0
- package/dist/lib/agent/coordination/task-distributor.d.ts +113 -0
- package/dist/lib/agent/coordination/task-distributor.js +586 -0
- package/dist/lib/agent/index.d.ts +38 -0
- package/dist/lib/agent/index.js +45 -0
- package/dist/lib/agent/orchestration/index.d.ts +10 -0
- package/dist/lib/agent/orchestration/index.js +11 -0
- package/dist/lib/agent/orchestration/orchestrator.d.ts +114 -0
- package/dist/lib/agent/orchestration/orchestrator.js +477 -0
- package/dist/lib/agent/orchestration/topology.d.ts +164 -0
- package/dist/lib/agent/orchestration/topology.js +521 -0
- package/dist/lib/agent/prompts/routingPrompts.d.ts +63 -0
- package/dist/lib/agent/prompts/routingPrompts.js +202 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.js +19 -0
- package/dist/lib/neurolink.d.ts +129 -0
- package/dist/lib/neurolink.js +276 -0
- package/dist/lib/processors/config/{fileTypes.js → fileExtensions.js} +1 -1
- package/dist/lib/processors/config/index.d.ts +2 -2
- package/dist/lib/processors/config/index.js +2 -2
- package/dist/lib/processors/config/{mimeTypes.js → mimeConstants.js} +1 -1
- package/dist/lib/processors/index.js +8 -0
- package/dist/lib/providers/googleAiStudio.js +28 -7
- package/dist/lib/providers/googleNativeGemini3.d.ts +18 -0
- package/dist/lib/providers/googleNativeGemini3.js +69 -3
- package/dist/lib/providers/googleVertex.js +33 -9
- package/dist/lib/types/agentNetwork.d.ts +1184 -0
- package/dist/lib/types/agentNetwork.js +8 -0
- package/dist/lib/types/cli.d.ts +66 -0
- package/dist/lib/types/common.d.ts +3 -0
- package/dist/lib/types/generate.d.ts +53 -0
- package/dist/lib/types/index.d.ts +2 -0
- package/dist/lib/types/index.js +3 -0
- package/dist/lib/types/ioProcessor.d.ts +119 -0
- package/dist/lib/types/ioProcessor.js +10 -0
- package/dist/lib/types/providers.d.ts +8 -0
- package/dist/lib/types/stream.d.ts +36 -0
- package/dist/lib/utils/piiDetector.d.ts +24 -0
- package/dist/lib/utils/piiDetector.js +221 -0
- package/dist/lib/utils/pricing.js +144 -26
- package/dist/lib/utils/responseValidator.d.ts +21 -0
- package/dist/lib/utils/responseValidator.js +354 -0
- package/dist/lib/utils/tokenUtils.d.ts +11 -0
- package/dist/lib/utils/tokenUtils.js +33 -2
- package/dist/lib/utils/tripwireEvaluator.d.ts +73 -0
- package/dist/lib/utils/tripwireEvaluator.js +285 -0
- package/dist/neurolink.d.ts +129 -0
- package/dist/neurolink.js +276 -0
- package/dist/processors/config/index.d.ts +2 -2
- package/dist/processors/config/index.js +2 -2
- package/dist/processors/index.js +8 -0
- package/dist/providers/googleAiStudio.js +28 -7
- package/dist/providers/googleNativeGemini3.d.ts +18 -0
- package/dist/providers/googleNativeGemini3.js +69 -3
- package/dist/providers/googleVertex.js +33 -9
- package/dist/types/agentNetwork.d.ts +1184 -0
- package/dist/types/agentNetwork.js +7 -0
- package/dist/types/cli.d.ts +66 -0
- package/dist/types/common.d.ts +3 -0
- package/dist/types/generate.d.ts +53 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +3 -0
- package/dist/types/ioProcessor.d.ts +119 -0
- package/dist/types/ioProcessor.js +9 -0
- package/dist/types/providers.d.ts +8 -0
- package/dist/types/stream.d.ts +36 -0
- package/dist/utils/piiDetector.d.ts +24 -0
- package/dist/utils/piiDetector.js +220 -0
- package/dist/utils/pricing.js +144 -26
- package/dist/utils/responseValidator.d.ts +21 -0
- package/dist/utils/responseValidator.js +353 -0
- package/dist/utils/tokenUtils.d.ts +11 -0
- package/dist/utils/tokenUtils.js +33 -2
- package/dist/utils/tripwireEvaluator.d.ts +73 -0
- package/dist/utils/tripwireEvaluator.js +284 -0
- package/package.json +1 -1
- /package/dist/lib/processors/config/{fileTypes.d.ts → fileExtensions.d.ts} +0 -0
- /package/dist/lib/processors/config/{mimeTypes.d.ts → mimeConstants.d.ts} +0 -0
- /package/dist/processors/config/{fileTypes.d.ts → fileExtensions.d.ts} +0 -0
- /package/dist/processors/config/{fileTypes.js → fileExtensions.js} +0 -0
- /package/dist/processors/config/{mimeTypes.d.ts → mimeConstants.d.ts} +0 -0
- /package/dist/processors/config/{mimeTypes.js → mimeConstants.js} +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routing Prompts for Agent Network
|
|
3
|
+
*
|
|
4
|
+
* These prompts guide the routing agent in selecting the appropriate
|
|
5
|
+
* primitive (agent, workflow, or tool) for a given task.
|
|
6
|
+
*/
|
|
7
|
+
import type { Primitive, AgentRoutingDecision } from "../../types/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Prompt templates for routing decisions
|
|
10
|
+
*/
|
|
11
|
+
export declare const ROUTING_PROMPTS: {
|
|
12
|
+
/**
|
|
13
|
+
* System instructions for the routing agent
|
|
14
|
+
*/
|
|
15
|
+
SYSTEM_INSTRUCTIONS: string;
|
|
16
|
+
/**
|
|
17
|
+
* Template for task analysis and routing
|
|
18
|
+
*/
|
|
19
|
+
TASK_ROUTING: string;
|
|
20
|
+
/**
|
|
21
|
+
* Template for confidence evaluation
|
|
22
|
+
*/
|
|
23
|
+
CONFIDENCE_EVALUATION: string;
|
|
24
|
+
/**
|
|
25
|
+
* Template for multi-step planning
|
|
26
|
+
*/
|
|
27
|
+
MULTI_STEP_PLANNING: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Build a routing prompt with primitives and task
|
|
31
|
+
*
|
|
32
|
+
* @param task - The task to route
|
|
33
|
+
* @param primitives - Available primitives
|
|
34
|
+
* @param options - Additional options
|
|
35
|
+
* @returns The formatted prompt
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildRoutingPrompt(task: string, primitives: Primitive[], options?: {
|
|
38
|
+
includeAlternatives?: boolean;
|
|
39
|
+
maxPrimitivesToShow?: number;
|
|
40
|
+
}): string;
|
|
41
|
+
/**
|
|
42
|
+
* Parse routing response from LLM
|
|
43
|
+
*
|
|
44
|
+
* @param response - The raw LLM response
|
|
45
|
+
* @returns Parsed routing decision or null if parsing fails
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseRoutingResponse(response: string): Partial<AgentRoutingDecision> | null;
|
|
48
|
+
/**
|
|
49
|
+
* Build confidence evaluation prompt
|
|
50
|
+
*
|
|
51
|
+
* @param primitive - The selected primitive
|
|
52
|
+
* @param task - The task being evaluated
|
|
53
|
+
* @returns The formatted prompt
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildConfidencePrompt(primitive: Primitive, task: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Build multi-step planning prompt
|
|
58
|
+
*
|
|
59
|
+
* @param task - The task to plan
|
|
60
|
+
* @param primitives - Available primitives
|
|
61
|
+
* @returns The formatted prompt
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildMultiStepPlanningPrompt(task: string, primitives: Primitive[]): string;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routing Prompts for Agent Network
|
|
3
|
+
*
|
|
4
|
+
* These prompts guide the routing agent in selecting the appropriate
|
|
5
|
+
* primitive (agent, workflow, or tool) for a given task.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Prompt templates for routing decisions
|
|
9
|
+
*/
|
|
10
|
+
export const ROUTING_PROMPTS = {
|
|
11
|
+
/**
|
|
12
|
+
* System instructions for the routing agent
|
|
13
|
+
*/
|
|
14
|
+
SYSTEM_INSTRUCTIONS: `You are a task routing agent responsible for analyzing tasks and selecting the best primitive to handle them.
|
|
15
|
+
|
|
16
|
+
Your role is to:
|
|
17
|
+
1. Analyze the incoming task to understand what needs to be done
|
|
18
|
+
2. Review the available primitives (agents, workflows, tools)
|
|
19
|
+
3. Select the most appropriate primitive based on capabilities
|
|
20
|
+
4. Format the input appropriately for the selected primitive
|
|
21
|
+
5. Provide your reasoning and confidence level
|
|
22
|
+
|
|
23
|
+
Always respond in valid JSON format.`,
|
|
24
|
+
/**
|
|
25
|
+
* Template for task analysis and routing
|
|
26
|
+
*/
|
|
27
|
+
TASK_ROUTING: `Analyze the following task and select the most appropriate primitive to handle it.
|
|
28
|
+
|
|
29
|
+
Available Primitives:
|
|
30
|
+
{{PRIMITIVES}}
|
|
31
|
+
|
|
32
|
+
Task to route:
|
|
33
|
+
{{TASK}}
|
|
34
|
+
|
|
35
|
+
Consider:
|
|
36
|
+
1. The primitive's description and capabilities
|
|
37
|
+
2. The complexity of the task
|
|
38
|
+
3. Required tools or skills
|
|
39
|
+
4. Expected output format
|
|
40
|
+
|
|
41
|
+
Respond in JSON format:
|
|
42
|
+
{
|
|
43
|
+
"selectedPrimitive": {
|
|
44
|
+
"type": "agent" | "workflow" | "tool",
|
|
45
|
+
"id": "<primitive_id>",
|
|
46
|
+
"name": "<primitive_name>"
|
|
47
|
+
},
|
|
48
|
+
"confidence": <0.0-1.0>,
|
|
49
|
+
"reasoning": "<explanation of why this primitive was chosen>",
|
|
50
|
+
"formattedInput": "<the input formatted for the selected primitive>",
|
|
51
|
+
"alternatives": [
|
|
52
|
+
{
|
|
53
|
+
"type": "agent" | "workflow" | "tool",
|
|
54
|
+
"id": "<alternative_id>",
|
|
55
|
+
"confidence": <0.0-1.0>
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}`,
|
|
59
|
+
/**
|
|
60
|
+
* Template for confidence evaluation
|
|
61
|
+
*/
|
|
62
|
+
CONFIDENCE_EVALUATION: `Evaluate the confidence that the selected primitive can successfully complete the task.
|
|
63
|
+
|
|
64
|
+
Selected Primitive:
|
|
65
|
+
- Type: {{PRIMITIVE_TYPE}}
|
|
66
|
+
- Name: {{PRIMITIVE_NAME}}
|
|
67
|
+
- Description: {{PRIMITIVE_DESCRIPTION}}
|
|
68
|
+
|
|
69
|
+
Task: {{TASK}}
|
|
70
|
+
|
|
71
|
+
Rate the confidence from 0.0 to 1.0 based on:
|
|
72
|
+
- How well the primitive's capabilities match the task
|
|
73
|
+
- The specificity of the primitive's description
|
|
74
|
+
- The complexity of the task vs primitive's scope
|
|
75
|
+
- Potential edge cases or limitations`,
|
|
76
|
+
/**
|
|
77
|
+
* Template for multi-step planning
|
|
78
|
+
*/
|
|
79
|
+
MULTI_STEP_PLANNING: `Plan the execution of this complex task that may require multiple primitives.
|
|
80
|
+
|
|
81
|
+
Task: {{TASK}}
|
|
82
|
+
|
|
83
|
+
Available Primitives:
|
|
84
|
+
{{PRIMITIVES}}
|
|
85
|
+
|
|
86
|
+
Create an execution plan with the following structure:
|
|
87
|
+
{
|
|
88
|
+
"isMultiStep": true/false,
|
|
89
|
+
"steps": [
|
|
90
|
+
{
|
|
91
|
+
"stepNumber": 1,
|
|
92
|
+
"primitiveId": "<primitive_id>",
|
|
93
|
+
"description": "<what this step accomplishes>",
|
|
94
|
+
"dependsOn": [<step numbers this depends on>]
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"expectedOutcome": "<description of final result>"
|
|
98
|
+
}`,
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Build a routing prompt with primitives and task
|
|
102
|
+
*
|
|
103
|
+
* @param task - The task to route
|
|
104
|
+
* @param primitives - Available primitives
|
|
105
|
+
* @param options - Additional options
|
|
106
|
+
* @returns The formatted prompt
|
|
107
|
+
*/
|
|
108
|
+
export function buildRoutingPrompt(task, primitives, options) {
|
|
109
|
+
const { includeAlternatives = true, maxPrimitivesToShow = 20 } = options ?? {};
|
|
110
|
+
// Format primitives list
|
|
111
|
+
const primitivesDescription = primitives
|
|
112
|
+
.slice(0, maxPrimitivesToShow)
|
|
113
|
+
.map((p) => {
|
|
114
|
+
const tools = p.type === "agent" && "agent" in p
|
|
115
|
+
? p.agent.tools
|
|
116
|
+
: undefined;
|
|
117
|
+
const toolsInfo = tools && tools.length > 0 ? `\n Tools: ${tools.join(", ")}` : "";
|
|
118
|
+
return `- [${p.type.toUpperCase()}] ${p.id}: ${p.name}\n Description: ${p.description}${toolsInfo}`;
|
|
119
|
+
})
|
|
120
|
+
.join("\n");
|
|
121
|
+
let prompt = ROUTING_PROMPTS.TASK_ROUTING.replace("{{PRIMITIVES}}", primitivesDescription).replace("{{TASK}}", task);
|
|
122
|
+
if (!includeAlternatives) {
|
|
123
|
+
// Remove alternatives section from expected output
|
|
124
|
+
prompt = prompt.replace(`"alternatives": [
|
|
125
|
+
{
|
|
126
|
+
"type": "agent" | "workflow" | "tool",
|
|
127
|
+
"id": "<alternative_id>",
|
|
128
|
+
"confidence": <0.0-1.0>
|
|
129
|
+
}
|
|
130
|
+
]`, "");
|
|
131
|
+
}
|
|
132
|
+
return prompt;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Parse routing response from LLM
|
|
136
|
+
*
|
|
137
|
+
* @param response - The raw LLM response
|
|
138
|
+
* @returns Parsed routing decision or null if parsing fails
|
|
139
|
+
*/
|
|
140
|
+
export function parseRoutingResponse(response) {
|
|
141
|
+
try {
|
|
142
|
+
// Try to extract JSON from the response
|
|
143
|
+
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
144
|
+
if (!jsonMatch) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
148
|
+
// Validate required fields
|
|
149
|
+
if (!parsed.selectedPrimitive ||
|
|
150
|
+
!parsed.selectedPrimitive.id ||
|
|
151
|
+
!parsed.selectedPrimitive.type) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
selectedPrimitive: {
|
|
156
|
+
type: parsed.selectedPrimitive.type,
|
|
157
|
+
id: parsed.selectedPrimitive.id,
|
|
158
|
+
name: parsed.selectedPrimitive.name || parsed.selectedPrimitive.id,
|
|
159
|
+
},
|
|
160
|
+
confidence: typeof parsed.confidence === "number" ? parsed.confidence : 0.8,
|
|
161
|
+
reasoning: parsed.reasoning || "No reasoning provided",
|
|
162
|
+
formattedInput: parsed.formattedInput,
|
|
163
|
+
alternatives: Array.isArray(parsed.alternatives)
|
|
164
|
+
? parsed.alternatives.map((alt) => ({
|
|
165
|
+
type: alt.type,
|
|
166
|
+
id: alt.id,
|
|
167
|
+
confidence: typeof alt.confidence === "number" ? alt.confidence : 0.5,
|
|
168
|
+
}))
|
|
169
|
+
: undefined,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Build confidence evaluation prompt
|
|
178
|
+
*
|
|
179
|
+
* @param primitive - The selected primitive
|
|
180
|
+
* @param task - The task being evaluated
|
|
181
|
+
* @returns The formatted prompt
|
|
182
|
+
*/
|
|
183
|
+
export function buildConfidencePrompt(primitive, task) {
|
|
184
|
+
return ROUTING_PROMPTS.CONFIDENCE_EVALUATION.replace("{{PRIMITIVE_TYPE}}", primitive.type)
|
|
185
|
+
.replace("{{PRIMITIVE_NAME}}", primitive.name)
|
|
186
|
+
.replace("{{PRIMITIVE_DESCRIPTION}}", primitive.description)
|
|
187
|
+
.replace("{{TASK}}", task);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Build multi-step planning prompt
|
|
191
|
+
*
|
|
192
|
+
* @param task - The task to plan
|
|
193
|
+
* @param primitives - Available primitives
|
|
194
|
+
* @returns The formatted prompt
|
|
195
|
+
*/
|
|
196
|
+
export function buildMultiStepPlanningPrompt(task, primitives) {
|
|
197
|
+
const primitivesDescription = primitives
|
|
198
|
+
.map((p) => `- [${p.type.toUpperCase()}] ${p.id}: ${p.name} - ${p.description}`)
|
|
199
|
+
.join("\n");
|
|
200
|
+
return ROUTING_PROMPTS.MULTI_STEP_PLANNING.replace("{{TASK}}", task).replace("{{PRIMITIVES}}", primitivesDescription);
|
|
201
|
+
}
|