lynkr 7.2.5 → 8.0.1
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/README.md +3 -3
- package/config/model-tiers.json +89 -0
- package/install.sh +6 -1
- package/package.json +4 -2
- package/scripts/setup.js +0 -1
- package/src/agents/executor.js +14 -6
- package/src/api/middleware/session.js +15 -2
- package/src/api/openai-router.js +162 -37
- package/src/api/providers-handler.js +15 -1
- package/src/api/router.js +107 -2
- package/src/budget/index.js +4 -3
- package/src/clients/databricks.js +431 -234
- package/src/clients/gpt-utils.js +181 -0
- package/src/clients/ollama-utils.js +66 -140
- package/src/clients/routing.js +0 -1
- package/src/clients/standard-tools.js +99 -3
- package/src/config/index.js +133 -35
- package/src/context/toon.js +173 -0
- package/src/logger/index.js +23 -0
- package/src/orchestrator/index.js +688 -213
- package/src/routing/agentic-detector.js +320 -0
- package/src/routing/complexity-analyzer.js +202 -2
- package/src/routing/cost-optimizer.js +305 -0
- package/src/routing/index.js +168 -159
- package/src/routing/model-tiers.js +365 -0
- package/src/server.js +4 -14
- package/src/sessions/cleanup.js +3 -3
- package/src/sessions/record.js +10 -1
- package/src/sessions/store.js +7 -2
- package/src/tools/agent-task.js +48 -1
- package/src/tools/index.js +19 -2
- package/src/tools/lazy-loader.js +7 -0
- package/src/tools/tinyfish.js +358 -0
- package/src/tools/truncate.js +1 -0
- package/.github/FUNDING.yml +0 -15
- package/.github/workflows/README.md +0 -215
- package/.github/workflows/ci.yml +0 -69
- package/.github/workflows/index.yml +0 -62
- package/.github/workflows/web-tools-tests.yml +0 -56
- package/CITATIONS.bib +0 -6
- package/CLAWROUTER_ROUTING_PLAN.md +0 -910
- package/DEPLOYMENT.md +0 -1001
- package/LYNKR-TUI-PLAN.md +0 -984
- package/PERFORMANCE-REPORT.md +0 -866
- package/PLAN-per-client-model-routing.md +0 -252
- package/ROUTER_COMPARISON.md +0 -173
- package/TIER_ROUTING_PLAN.md +0 -771
- package/docs/42642f749da6234f41b6b425c3bb07c9.txt +0 -1
- package/docs/BingSiteAuth.xml +0 -4
- package/docs/docs-style.css +0 -478
- package/docs/docs.html +0 -197
- package/docs/google5be250e608e6da39.html +0 -1
- package/docs/index.html +0 -577
- package/docs/index.md +0 -577
- package/docs/robots.txt +0 -4
- package/docs/sitemap.xml +0 -44
- package/docs/style.css +0 -1223
- package/documentation/README.md +0 -100
- package/documentation/api.md +0 -806
- package/documentation/claude-code-cli.md +0 -672
- package/documentation/codex-cli.md +0 -397
- package/documentation/contributing.md +0 -571
- package/documentation/cursor-integration.md +0 -731
- package/documentation/docker.md +0 -867
- package/documentation/embeddings.md +0 -760
- package/documentation/faq.md +0 -659
- package/documentation/features.md +0 -396
- package/documentation/headroom.md +0 -519
- package/documentation/installation.md +0 -706
- package/documentation/memory-system.md +0 -476
- package/documentation/production.md +0 -601
- package/documentation/providers.md +0 -906
- package/documentation/testing.md +0 -629
- package/documentation/token-optimization.md +0 -323
- package/documentation/tools.md +0 -697
- package/documentation/troubleshooting.md +0 -893
- package/final-test.js +0 -33
- package/headroom-sidecar/config.py +0 -93
- package/headroom-sidecar/requirements.txt +0 -14
- package/headroom-sidecar/server.py +0 -451
- package/monitor-agents.sh +0 -31
- package/scripts/audit-log-reader.js +0 -399
- package/scripts/compact-dictionary.js +0 -204
- package/scripts/test-deduplication.js +0 -448
- package/src/db/database.sqlite +0 -0
- package/test/README.md +0 -212
- package/test/azure-openai-config.test.js +0 -204
- package/test/azure-openai-error-resilience.test.js +0 -238
- package/test/azure-openai-format-conversion.test.js +0 -354
- package/test/azure-openai-integration.test.js +0 -281
- package/test/azure-openai-routing.test.js +0 -177
- package/test/azure-openai-streaming.test.js +0 -171
- package/test/bedrock-integration.test.js +0 -471
- package/test/comprehensive-test-suite.js +0 -928
- package/test/config-validation.test.js +0 -207
- package/test/cursor-integration.test.js +0 -484
- package/test/format-conversion.test.js +0 -578
- package/test/hybrid-routing-integration.test.js +0 -254
- package/test/hybrid-routing-performance.test.js +0 -418
- package/test/llamacpp-integration.test.js +0 -863
- package/test/lmstudio-integration.test.js +0 -335
- package/test/memory/extractor.test.js +0 -398
- package/test/memory/retriever.test.js +0 -613
- package/test/memory/retriever.test.js.bak +0 -585
- package/test/memory/search.test.js +0 -537
- package/test/memory/search.test.js.bak +0 -389
- package/test/memory/store.test.js +0 -344
- package/test/memory/store.test.js.bak +0 -312
- package/test/memory/surprise.test.js +0 -300
- package/test/memory-performance.test.js +0 -472
- package/test/openai-integration.test.js +0 -686
- package/test/openrouter-error-resilience.test.js +0 -418
- package/test/passthrough-mode.test.js +0 -385
- package/test/performance-benchmark.js +0 -351
- package/test/performance-tests.js +0 -528
- package/test/routing.test.js +0 -219
- package/test/web-tools.test.js +0 -329
- package/test-agents-simple.js +0 -43
- package/test-cli-connection.sh +0 -33
- package/test-learning-unit.js +0 -126
- package/test-learning.js +0 -112
- package/test-parallel-agents.sh +0 -124
- package/test-parallel-direct.js +0 -155
- package/test-subagents.sh +0 -117
package/test-learning-unit.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
const Skillbook = require('./src/agents/skillbook');
|
|
2
|
-
const Reflector = require('./src/agents/reflector');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
|
|
6
|
-
console.log('========================================');
|
|
7
|
-
console.log('Learning System Unit Test');
|
|
8
|
-
console.log('========================================\n');
|
|
9
|
-
|
|
10
|
-
async function testLearningSystem() {
|
|
11
|
-
try {
|
|
12
|
-
// Test 1: Create and save skillbook
|
|
13
|
-
console.log('Test 1: Creating skillbook...');
|
|
14
|
-
const skillbook = new Skillbook('Explore');
|
|
15
|
-
|
|
16
|
-
// Add a test skill
|
|
17
|
-
skillbook.addSkill({
|
|
18
|
-
pattern: "Search task",
|
|
19
|
-
action: "Use tools: Glob, Grep, Read",
|
|
20
|
-
reasoning: "Successfully completed search task using these tools",
|
|
21
|
-
tools: ["Glob", "Grep", "Read"],
|
|
22
|
-
confidence: 0.75
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
console.log(`✓ Added 1 skill`);
|
|
26
|
-
console.log(` Total skills: ${skillbook.skills.size}\n`);
|
|
27
|
-
|
|
28
|
-
// Test 2: Save skillbook
|
|
29
|
-
console.log('Test 2: Saving skillbook...');
|
|
30
|
-
const saved = await skillbook.save();
|
|
31
|
-
console.log(`✓ Skillbook saved: ${saved}\n`);
|
|
32
|
-
|
|
33
|
-
// Test 3: Load skillbook
|
|
34
|
-
console.log('Test 3: Loading skillbook...');
|
|
35
|
-
const loaded = await Skillbook.load('Explore');
|
|
36
|
-
console.log(`✓ Loaded skillbook`);
|
|
37
|
-
console.log(` Skills: ${loaded.skills.size}\n`);
|
|
38
|
-
|
|
39
|
-
// Test 4: Get top skills
|
|
40
|
-
console.log('Test 4: Getting top skills...');
|
|
41
|
-
const topSkills = loaded.getTopSkills(3);
|
|
42
|
-
console.log(`✓ Top skills: ${topSkills.length}`);
|
|
43
|
-
topSkills.forEach((skill, i) => {
|
|
44
|
-
console.log(` ${i + 1}. ${skill.pattern} (confidence: ${Math.round(skill.confidence * 100)}%)`);
|
|
45
|
-
});
|
|
46
|
-
console.log('');
|
|
47
|
-
|
|
48
|
-
// Test 5: Format for prompt
|
|
49
|
-
console.log('Test 5: Formatting for prompt...');
|
|
50
|
-
const promptSection = loaded.formatForPrompt();
|
|
51
|
-
console.log(`✓ Generated prompt section (${promptSection.length} chars):`);
|
|
52
|
-
console.log(promptSection.substring(0, 200) + '...\n');
|
|
53
|
-
|
|
54
|
-
// Test 6: Test Reflector
|
|
55
|
-
console.log('Test 6: Testing Reflector...');
|
|
56
|
-
const mockContext = {
|
|
57
|
-
agentName: 'Test',
|
|
58
|
-
taskPrompt: 'Find all JavaScript files in src directory',
|
|
59
|
-
steps: 3,
|
|
60
|
-
maxSteps: 10,
|
|
61
|
-
inputTokens: 500,
|
|
62
|
-
outputTokens: 300,
|
|
63
|
-
transcript: [
|
|
64
|
-
{
|
|
65
|
-
type: 'tool_call',
|
|
66
|
-
toolName: 'Glob',
|
|
67
|
-
timestamp: Date.now() - 2000
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
type: 'tool_call',
|
|
71
|
-
toolName: 'Grep',
|
|
72
|
-
timestamp: Date.now() - 1000
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
type: 'tool_call',
|
|
76
|
-
toolName: 'Read',
|
|
77
|
-
timestamp: Date.now()
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const patterns = Reflector.reflect(mockContext, true);
|
|
83
|
-
console.log(`✓ Reflector extracted ${patterns.length} patterns:`);
|
|
84
|
-
patterns.forEach((p, i) => {
|
|
85
|
-
console.log(` ${i + 1}. ${p.pattern}`);
|
|
86
|
-
console.log(` Action: ${p.action}`);
|
|
87
|
-
console.log(` Confidence: ${Math.round(p.confidence * 100)}%`);
|
|
88
|
-
});
|
|
89
|
-
console.log('');
|
|
90
|
-
|
|
91
|
-
// Test 7: Add reflected patterns to skillbook
|
|
92
|
-
console.log('Test 7: Adding reflected patterns...');
|
|
93
|
-
const testSkillbook = new Skillbook('Test');
|
|
94
|
-
for (const pattern of patterns) {
|
|
95
|
-
testSkillbook.addSkill(pattern);
|
|
96
|
-
}
|
|
97
|
-
console.log(`✓ Added ${patterns.length} patterns`);
|
|
98
|
-
console.log(` Total skills: ${testSkillbook.skills.size}\n`);
|
|
99
|
-
|
|
100
|
-
// Test 8: Save test skillbook
|
|
101
|
-
console.log('Test 8: Saving test skillbook...');
|
|
102
|
-
await testSkillbook.save();
|
|
103
|
-
console.log(`✓ Test skillbook saved\n`);
|
|
104
|
-
|
|
105
|
-
// Test 9: List all skillbooks
|
|
106
|
-
console.log('Test 9: Listing all skillbooks...');
|
|
107
|
-
const skillbooksDir = path.join(process.cwd(), 'data', 'skillbooks');
|
|
108
|
-
const files = fs.readdirSync(skillbooksDir);
|
|
109
|
-
console.log(`✓ Found ${files.length} skillbook(s):`);
|
|
110
|
-
files.forEach(file => {
|
|
111
|
-
console.log(` - ${file}`);
|
|
112
|
-
});
|
|
113
|
-
console.log('');
|
|
114
|
-
|
|
115
|
-
console.log('========================================');
|
|
116
|
-
console.log('✅ All Tests Passed!');
|
|
117
|
-
console.log('========================================\n');
|
|
118
|
-
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error('❌ Test failed:', error.message);
|
|
121
|
-
console.error(error.stack);
|
|
122
|
-
process.exit(1);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
testLearningSystem();
|
package/test-learning.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
const http = require('http');
|
|
2
|
-
|
|
3
|
-
console.log('========================================');
|
|
4
|
-
console.log('Testing Learning System');
|
|
5
|
-
console.log('========================================\n');
|
|
6
|
-
|
|
7
|
-
// Simple request to trigger a subagent
|
|
8
|
-
const testPayload = {
|
|
9
|
-
model: "claude-3-5-sonnet-20241022",
|
|
10
|
-
max_tokens: 4096,
|
|
11
|
-
messages: [
|
|
12
|
-
{
|
|
13
|
-
role: "user",
|
|
14
|
-
content: "Use the Explore agent to find all JavaScript files in the src directory."
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const options = {
|
|
20
|
-
hostname: 'localhost',
|
|
21
|
-
port: 8080,
|
|
22
|
-
path: '/v1/messages',
|
|
23
|
-
method: 'POST',
|
|
24
|
-
headers: {
|
|
25
|
-
'Content-Type': 'application/json'
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
console.log('Sending request to trigger Explore agent...\n');
|
|
30
|
-
const startTime = Date.now();
|
|
31
|
-
|
|
32
|
-
const req = http.request(options, (res) => {
|
|
33
|
-
let data = '';
|
|
34
|
-
|
|
35
|
-
res.on('data', (chunk) => {
|
|
36
|
-
data += chunk;
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
res.on('end', () => {
|
|
40
|
-
const duration = Date.now() - startTime;
|
|
41
|
-
console.log(`\nRequest completed in ${(duration / 1000).toFixed(1)} seconds\n`);
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const response = JSON.parse(data);
|
|
45
|
-
|
|
46
|
-
if (response.error) {
|
|
47
|
-
console.log('❌ Error:', response.error);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log('✓ Response received');
|
|
52
|
-
console.log(`Content blocks: ${response.content?.length || 0}\n`);
|
|
53
|
-
|
|
54
|
-
// Wait a moment for learning to complete (async)
|
|
55
|
-
console.log('Waiting for learning to complete (3s)...');
|
|
56
|
-
setTimeout(() => {
|
|
57
|
-
console.log('\n========================================');
|
|
58
|
-
console.log('Checking Skillbooks');
|
|
59
|
-
console.log('========================================\n');
|
|
60
|
-
|
|
61
|
-
const fs = require('fs');
|
|
62
|
-
const path = require('path');
|
|
63
|
-
const skillbooksDir = path.join(process.cwd(), 'data', 'skillbooks');
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
const files = fs.readdirSync(skillbooksDir);
|
|
67
|
-
console.log(`Found ${files.length} skillbook(s):\n`);
|
|
68
|
-
|
|
69
|
-
files.forEach(file => {
|
|
70
|
-
const filepath = path.join(skillbooksDir, file);
|
|
71
|
-
const content = fs.readFileSync(filepath, 'utf8');
|
|
72
|
-
const skillbook = JSON.parse(content);
|
|
73
|
-
|
|
74
|
-
console.log(`📚 ${skillbook.agentType}`);
|
|
75
|
-
console.log(` Skills: ${skillbook.skills.length}`);
|
|
76
|
-
console.log(` Last saved: ${new Date(skillbook.savedAt).toLocaleString()}\n`);
|
|
77
|
-
|
|
78
|
-
if (skillbook.skills.length > 0) {
|
|
79
|
-
console.log(' Learned patterns:');
|
|
80
|
-
skillbook.skills.slice(0, 3).forEach(([pattern, skill]) => {
|
|
81
|
-
console.log(` - ${skill.pattern} (confidence: ${Math.round(skill.confidence * 100)}%)`);
|
|
82
|
-
});
|
|
83
|
-
console.log('');
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
console.log('========================================');
|
|
88
|
-
console.log('Test Complete!');
|
|
89
|
-
console.log('========================================\n');
|
|
90
|
-
process.exit(0);
|
|
91
|
-
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.log('⚠️ Error reading skillbooks:', error.message);
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
96
|
-
}, 3000);
|
|
97
|
-
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error('❌ Error parsing response:', error.message);
|
|
100
|
-
console.log('Raw response (first 500 chars):', data.substring(0, 500));
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
req.on('error', (error) => {
|
|
107
|
-
console.error('❌ Request error:', error);
|
|
108
|
-
process.exit(1);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
req.write(JSON.stringify(testPayload));
|
|
112
|
-
req.end();
|
package/test-parallel-agents.sh
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Test parallel subagent execution
|
|
4
|
-
# This simulates a main agent spawning multiple Task tools in one response
|
|
5
|
-
|
|
6
|
-
echo "========================================="
|
|
7
|
-
echo "Testing Parallel Subagent Execution"
|
|
8
|
-
echo "========================================="
|
|
9
|
-
echo ""
|
|
10
|
-
|
|
11
|
-
# Create a test request with multiple Task tool calls
|
|
12
|
-
# Simulates the model returning 3 Task tool uses in a single response
|
|
13
|
-
cat > /tmp/parallel-test-request.json <<'EOF'
|
|
14
|
-
{
|
|
15
|
-
"model": "claude-3-5-sonnet-20241022",
|
|
16
|
-
"max_tokens": 4096,
|
|
17
|
-
"messages": [
|
|
18
|
-
{
|
|
19
|
-
"role": "user",
|
|
20
|
-
"content": "I need you to perform three tasks in parallel: 1) Explore the src/config directory to understand configuration structure, 2) Find all test files in the project, and 3) Check what agents are available. Use the Task tool three times."
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"role": "assistant",
|
|
24
|
-
"content": [
|
|
25
|
-
{
|
|
26
|
-
"type": "text",
|
|
27
|
-
"text": "I'll execute these three tasks in parallel using subagents."
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"type": "tool_use",
|
|
31
|
-
"id": "task1",
|
|
32
|
-
"name": "Task",
|
|
33
|
-
"input": {
|
|
34
|
-
"subagent_type": "Explore",
|
|
35
|
-
"description": "Explore config directory",
|
|
36
|
-
"prompt": "Explore the src/config directory and explain what configuration files exist and what they do."
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"type": "tool_use",
|
|
41
|
-
"id": "task2",
|
|
42
|
-
"name": "Task",
|
|
43
|
-
"input": {
|
|
44
|
-
"subagent_type": "Explore",
|
|
45
|
-
"description": "Find test files",
|
|
46
|
-
"prompt": "Find all test files in the project (files ending in .test.js or .test.ts). List their locations."
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"type": "tool_use",
|
|
51
|
-
"id": "task3",
|
|
52
|
-
"name": "Task",
|
|
53
|
-
"input": {
|
|
54
|
-
"subagent_type": "Explore",
|
|
55
|
-
"description": "List available agents",
|
|
56
|
-
"prompt": "Search the codebase to find what agent types are available. Look for agent definitions."
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
EOF
|
|
64
|
-
|
|
65
|
-
echo "Sending request with 3 parallel Task tool calls..."
|
|
66
|
-
echo ""
|
|
67
|
-
|
|
68
|
-
# Set tool execution mode to server so tools execute server-side
|
|
69
|
-
export TOOL_EXECUTION_MODE=server
|
|
70
|
-
|
|
71
|
-
# Make the request
|
|
72
|
-
start_time=$(date +%s)
|
|
73
|
-
curl -s -X POST http://localhost:8080/v1/messages \
|
|
74
|
-
-H "Content-Type: application/json" \
|
|
75
|
-
-d @/tmp/parallel-test-request.json \
|
|
76
|
-
> /tmp/parallel-test-response.json
|
|
77
|
-
|
|
78
|
-
end_time=$(date +%s)
|
|
79
|
-
duration=$((end_time - start_time))
|
|
80
|
-
|
|
81
|
-
echo "Request completed in ${duration} seconds"
|
|
82
|
-
echo ""
|
|
83
|
-
|
|
84
|
-
# Check the logs for parallel execution evidence
|
|
85
|
-
echo "========================================="
|
|
86
|
-
echo "Checking logs for parallel execution..."
|
|
87
|
-
echo "========================================="
|
|
88
|
-
echo ""
|
|
89
|
-
|
|
90
|
-
echo "Looking for 'Executing multiple Task tools in parallel':"
|
|
91
|
-
grep "Executing multiple Task tools in parallel" /tmp/lynkr.log | tail -1 | jq .
|
|
92
|
-
|
|
93
|
-
echo ""
|
|
94
|
-
echo "Looking for 'Completed parallel Task execution':"
|
|
95
|
-
grep "Completed parallel Task execution" /tmp/lynkr.log | tail -1 | jq .
|
|
96
|
-
|
|
97
|
-
echo ""
|
|
98
|
-
echo "========================================="
|
|
99
|
-
echo "Response Summary:"
|
|
100
|
-
echo "========================================="
|
|
101
|
-
|
|
102
|
-
# Show response structure
|
|
103
|
-
if [ -f /tmp/parallel-test-response.json ]; then
|
|
104
|
-
echo ""
|
|
105
|
-
echo "Response content blocks:"
|
|
106
|
-
cat /tmp/parallel-test-response.json | jq '.content | length'
|
|
107
|
-
echo " content blocks returned"
|
|
108
|
-
|
|
109
|
-
echo ""
|
|
110
|
-
echo "Tool result IDs:"
|
|
111
|
-
cat /tmp/parallel-test-response.json | jq -r '.content[] | select(.type=="tool_result") | .tool_use_id'
|
|
112
|
-
|
|
113
|
-
echo ""
|
|
114
|
-
echo "First 100 chars of each tool result:"
|
|
115
|
-
cat /tmp/parallel-test-response.json | jq -r '.content[] | select(.type=="tool_result") | .content' | head -c 300
|
|
116
|
-
echo ""
|
|
117
|
-
else
|
|
118
|
-
echo "ERROR: No response file found!"
|
|
119
|
-
fi
|
|
120
|
-
|
|
121
|
-
echo ""
|
|
122
|
-
echo "========================================="
|
|
123
|
-
echo "Test Complete!"
|
|
124
|
-
echo "========================================="
|
package/test-parallel-direct.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
const http = require('http');
|
|
2
|
-
|
|
3
|
-
console.log('========================================');
|
|
4
|
-
console.log('Direct Parallel Subagent Test');
|
|
5
|
-
console.log('========================================\n');
|
|
6
|
-
|
|
7
|
-
// Directly call the /v1/messages endpoint with tool_use blocks in assistant message
|
|
8
|
-
// This simulates what happens when the model returns multiple Task tool calls
|
|
9
|
-
|
|
10
|
-
const testPayload = {
|
|
11
|
-
model: "claude-3-5-sonnet-20241022",
|
|
12
|
-
max_tokens: 8000,
|
|
13
|
-
messages: [
|
|
14
|
-
{
|
|
15
|
-
role: "user",
|
|
16
|
-
content: "Please use three Explore agents in parallel to: 1) list files in src/config, 2) find test files, and 3) check what agents are defined."
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
role: "assistant",
|
|
20
|
-
content: [
|
|
21
|
-
{
|
|
22
|
-
type: "text",
|
|
23
|
-
text: "I'll execute these three exploration tasks in parallel."
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
type: "tool_use",
|
|
27
|
-
id: "task_001",
|
|
28
|
-
name: "Task",
|
|
29
|
-
input: {
|
|
30
|
-
subagent_type: "Explore",
|
|
31
|
-
description: "List config files",
|
|
32
|
-
prompt: "List all files in the src/config directory. Just show the file names."
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
type: "tool_use",
|
|
37
|
-
id: "task_002",
|
|
38
|
-
name: "Task",
|
|
39
|
-
input: {
|
|
40
|
-
subagent_type: "Explore",
|
|
41
|
-
description: "Find test files",
|
|
42
|
-
prompt: "Find all test files in the project (*.test.js, *.spec.js). List the file paths."
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: "tool_use",
|
|
47
|
-
id: "task_003",
|
|
48
|
-
name: "Task",
|
|
49
|
-
input: {
|
|
50
|
-
subagent_type: "Explore",
|
|
51
|
-
description: "Check agent definitions",
|
|
52
|
-
prompt: "Find where agent types are defined in the codebase. Look for agent definitions like Explore, Plan, Test, etc."
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const options = {
|
|
61
|
-
hostname: 'localhost',
|
|
62
|
-
port: 8080,
|
|
63
|
-
path: '/v1/messages',
|
|
64
|
-
method: 'POST',
|
|
65
|
-
headers: {
|
|
66
|
-
'Content-Type': 'application/json'
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
console.log('Sending request with 3 Task tool calls...\n');
|
|
71
|
-
const startTime = Date.now();
|
|
72
|
-
|
|
73
|
-
const req = http.request(options, (res) => {
|
|
74
|
-
let data = '';
|
|
75
|
-
|
|
76
|
-
res.on('data', (chunk) => {
|
|
77
|
-
data += chunk;
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
res.on('end', () => {
|
|
81
|
-
const duration = Date.now() - startTime;
|
|
82
|
-
console.log(`Request completed in ${(duration / 1000).toFixed(1)} seconds\n`);
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
const response = JSON.parse(data);
|
|
86
|
-
|
|
87
|
-
console.log('========================================');
|
|
88
|
-
console.log('Response Analysis:');
|
|
89
|
-
console.log('========================================\n');
|
|
90
|
-
|
|
91
|
-
console.log(`Content blocks: ${response.content?.length || 0}`);
|
|
92
|
-
|
|
93
|
-
if (response.content) {
|
|
94
|
-
response.content.forEach((block, i) => {
|
|
95
|
-
console.log(`\nBlock ${i + 1}:`);
|
|
96
|
-
console.log(` Type: ${block.type}`);
|
|
97
|
-
|
|
98
|
-
if (block.type === 'tool_result') {
|
|
99
|
-
console.log(` Tool Use ID: ${block.tool_use_id}`);
|
|
100
|
-
console.log(` Is Error: ${block.is_error || false}`);
|
|
101
|
-
console.log(` Content (first 200 chars): ${block.content?.substring(0, 200)}...`);
|
|
102
|
-
} else if (block.type === 'text') {
|
|
103
|
-
console.log(` Text (first 100 chars): ${block.text?.substring(0, 100)}...`);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
console.log('\n========================================');
|
|
109
|
-
console.log('Log Analysis:');
|
|
110
|
-
console.log('========================================\n');
|
|
111
|
-
|
|
112
|
-
// Check logs for parallel execution
|
|
113
|
-
const { execSync } = require('child_process');
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const parallelStart = execSync('grep "Executing multiple Task tools in parallel" /tmp/lynkr.log | tail -1').toString().trim();
|
|
117
|
-
if (parallelStart) {
|
|
118
|
-
console.log('✅ Found parallel execution log entry');
|
|
119
|
-
const match = parallelStart.match(/"taskCount":\s*(\d+)/);
|
|
120
|
-
if (match) {
|
|
121
|
-
console.log(` Task count: ${match[1]}`);
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
console.log('❌ No parallel execution log found');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const parallelComplete = execSync('grep "Completed parallel Task execution" /tmp/lynkr.log | tail -1').toString().trim();
|
|
128
|
-
if (parallelComplete) {
|
|
129
|
-
console.log('✅ Found parallel completion log entry');
|
|
130
|
-
const match = parallelComplete.match(/"completedTasks":\s*(\d+)/);
|
|
131
|
-
if (match) {
|
|
132
|
-
console.log(` Completed tasks: ${match[1]}`);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
} catch (e) {
|
|
136
|
-
console.log('⚠️ Could not read logs');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
console.log('\n========================================');
|
|
140
|
-
console.log('Test Complete!');
|
|
141
|
-
console.log('========================================\n');
|
|
142
|
-
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error('Error parsing response:', error.message);
|
|
145
|
-
console.log('Raw response:', data.substring(0, 500));
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
req.on('error', (error) => {
|
|
151
|
-
console.error('Request error:', error);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
req.write(JSON.stringify(testPayload));
|
|
155
|
-
req.end();
|
package/test-subagents.sh
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Test Subagent System
|
|
4
|
-
# This script tests the live subagent functionality
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
echo "🚀 Testing Subagent System"
|
|
9
|
-
echo "================================"
|
|
10
|
-
echo ""
|
|
11
|
-
|
|
12
|
-
# Load test environment (filter out comments)
|
|
13
|
-
export $(grep -v '^#' .env.test | grep -v '^$' | xargs)
|
|
14
|
-
|
|
15
|
-
# Start server in background
|
|
16
|
-
echo "1. Starting server..."
|
|
17
|
-
node index.js > /tmp/subagent-test.log 2>&1 &
|
|
18
|
-
SERVER_PID=$!
|
|
19
|
-
echo " Server PID: $SERVER_PID"
|
|
20
|
-
|
|
21
|
-
# Wait for server to start
|
|
22
|
-
echo "2. Waiting for server to be ready..."
|
|
23
|
-
for i in {1..30}; do
|
|
24
|
-
if curl -s http://localhost:8080/health > /dev/null 2>&1; then
|
|
25
|
-
echo " ✅ Server is ready!"
|
|
26
|
-
break
|
|
27
|
-
fi
|
|
28
|
-
sleep 1
|
|
29
|
-
if [ $i -eq 30 ]; then
|
|
30
|
-
echo " ❌ Server failed to start"
|
|
31
|
-
kill $SERVER_PID 2>/dev/null || true
|
|
32
|
-
exit 1
|
|
33
|
-
fi
|
|
34
|
-
done
|
|
35
|
-
|
|
36
|
-
echo ""
|
|
37
|
-
echo "3. Testing agent endpoints..."
|
|
38
|
-
|
|
39
|
-
# Test 1: List available agents
|
|
40
|
-
echo " 📋 GET /v1/agents - List available agents"
|
|
41
|
-
curl -s http://localhost:8080/v1/agents | jq -r '.agents[] | " - \(.name): \(.description[:60])..."' 2>/dev/null || echo " (Install jq for pretty output)"
|
|
42
|
-
|
|
43
|
-
echo ""
|
|
44
|
-
echo " 📊 GET /v1/agents/stats - Agent statistics"
|
|
45
|
-
curl -s http://localhost:8080/v1/agents/stats | jq . 2>/dev/null || curl -s http://localhost:8080/v1/agents/stats
|
|
46
|
-
|
|
47
|
-
echo ""
|
|
48
|
-
echo "4. Testing Task tool with real request..."
|
|
49
|
-
|
|
50
|
-
# Create test request that uses Task tool (NO tools array - server provides tools)
|
|
51
|
-
cat > /tmp/test-task-request.json << 'EOFR'
|
|
52
|
-
{
|
|
53
|
-
"model": "claude-3-5-sonnet-20241022",
|
|
54
|
-
"max_tokens": 4096,
|
|
55
|
-
"messages": [
|
|
56
|
-
{
|
|
57
|
-
"role": "user",
|
|
58
|
-
"content": "Use the Task tool to search for all files in the src/agents directory."
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
EOFR
|
|
63
|
-
|
|
64
|
-
echo " 📤 Sending request to /v1/messages..."
|
|
65
|
-
RESPONSE=$(curl -s -X POST http://localhost:8080/v1/messages \
|
|
66
|
-
-H "Content-Type: application/json" \
|
|
67
|
-
-H "x-session-id: test-session-$(date +%s)" \
|
|
68
|
-
-d @/tmp/test-task-request.json)
|
|
69
|
-
|
|
70
|
-
echo ""
|
|
71
|
-
echo " 📥 Response received!"
|
|
72
|
-
|
|
73
|
-
# Check response type
|
|
74
|
-
if echo "$RESPONSE" | grep -q "tool_use"; then
|
|
75
|
-
echo " ⚠️ WARNING: Server returned tool_use (passthrough mode)"
|
|
76
|
-
echo " 🔧 Tool calls in response:"
|
|
77
|
-
echo "$RESPONSE" | jq -r '.content[] | select(.type=="tool_use") | " - \(.name): \(.input.prompt[:80])..."' 2>/dev/null || echo " (Install jq to see tool calls)"
|
|
78
|
-
elif echo "$RESPONSE" | grep -q "content"; then
|
|
79
|
-
echo " ✅ Server executed tools and returned final response!"
|
|
80
|
-
echo ""
|
|
81
|
-
echo " 📄 Response content (first 200 chars):"
|
|
82
|
-
echo "$RESPONSE" | jq -r '.content[0].text[:200]' 2>/dev/null || echo " (Install jq to see content)"
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
# Check agent stats again
|
|
86
|
-
echo ""
|
|
87
|
-
echo "5. Checking agent execution stats..."
|
|
88
|
-
sleep 2
|
|
89
|
-
curl -s http://localhost:8080/v1/agents/stats | jq . 2>/dev/null || curl -s http://localhost:8080/v1/agents/stats
|
|
90
|
-
|
|
91
|
-
# Check for transcripts
|
|
92
|
-
echo ""
|
|
93
|
-
echo "6. Checking for agent transcripts..."
|
|
94
|
-
TRANSCRIPT_COUNT=$(ls -1 data/agent-transcripts/*.jsonl 2>/dev/null | wc -l || echo "0")
|
|
95
|
-
echo " Found $TRANSCRIPT_COUNT transcript file(s)"
|
|
96
|
-
|
|
97
|
-
if [ "$TRANSCRIPT_COUNT" -gt 0 ]; then
|
|
98
|
-
echo " Latest transcript:"
|
|
99
|
-
LATEST=$(ls -t data/agent-transcripts/*.jsonl 2>/dev/null | head -1)
|
|
100
|
-
echo " File: $LATEST"
|
|
101
|
-
echo " First few lines:"
|
|
102
|
-
head -3 "$LATEST" | jq -r '"\(.type): \(.timestamp)"' 2>/dev/null || head -3 "$LATEST"
|
|
103
|
-
fi
|
|
104
|
-
|
|
105
|
-
echo ""
|
|
106
|
-
echo "7. Checking server logs for agent activity..."
|
|
107
|
-
echo " Last 20 lines from server log:"
|
|
108
|
-
tail -20 /tmp/subagent-test.log | grep -E "agent|Task tool|subagent" --color=always || echo " (No agent activity in logs)"
|
|
109
|
-
|
|
110
|
-
echo ""
|
|
111
|
-
echo "================================"
|
|
112
|
-
echo "✅ Test complete!"
|
|
113
|
-
echo ""
|
|
114
|
-
echo "Server is still running (PID: $SERVER_PID)"
|
|
115
|
-
echo "To view full logs: tail -f /tmp/subagent-test.log"
|
|
116
|
-
echo "To stop server: kill $SERVER_PID"
|
|
117
|
-
echo ""
|