lynkr 8.0.0 → 9.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/.lynkr/telemetry.db +0 -0
- package/.lynkr/telemetry.db-shm +0 -0
- package/.lynkr/telemetry.db-wal +0 -0
- package/README.md +196 -322
- package/lynkr-skill.tar.gz +0 -0
- package/package.json +4 -3
- package/src/api/openai-router.js +64 -13
- package/src/api/providers-handler.js +171 -3
- package/src/api/router.js +9 -2
- package/src/clients/circuit-breaker.js +10 -247
- package/src/clients/codex-process.js +342 -0
- package/src/clients/codex-utils.js +143 -0
- package/src/clients/databricks.js +210 -63
- package/src/clients/resilience.js +540 -0
- package/src/clients/retry.js +22 -167
- package/src/clients/standard-tools.js +23 -0
- package/src/config/index.js +77 -0
- package/src/context/compression.js +42 -9
- package/src/context/distill.js +492 -0
- package/src/orchestrator/index.js +48 -8
- package/src/routing/complexity-analyzer.js +258 -5
- package/src/routing/index.js +12 -2
- package/src/routing/latency-tracker.js +148 -0
- package/src/routing/model-tiers.js +2 -0
- package/src/routing/quality-scorer.js +113 -0
- package/src/routing/telemetry.js +464 -0
- package/src/server.js +13 -12
- package/src/tools/code-graph.js +538 -0
- package/src/tools/code-mode.js +304 -0
- package/src/tools/index.js +4 -0
- package/src/tools/lazy-loader.js +18 -0
- package/src/tools/mcp-remote.js +7 -0
- package/src/tools/smart-selection.js +11 -0
- package/src/tools/tinyfish.js +358 -0
- package/src/tools/truncate.js +1 -0
- package/src/utils/payload.js +206 -0
- package/src/utils/perf-timer.js +80 -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/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/docs/42642f749da6234f41b6b425c3bb07c9.txt +0 -1
- package/docs/BingSiteAuth.xml +0 -4
- package/docs/docs-style.css +0 -478
- package/docs/docs.html +0 -198
- package/docs/google5be250e608e6da39.html +0 -1
- package/docs/index.html +0 -577
- package/docs/index.md +0 -584
- package/docs/robots.txt +0 -4
- package/docs/sitemap.xml +0 -44
- package/docs/style.css +0 -1223
- package/docs/toon-integration-spec.md +0 -130
- package/documentation/README.md +0 -101
- package/documentation/api.md +0 -806
- package/documentation/claude-code-cli.md +0 -679
- package/documentation/codex-cli.md +0 -397
- package/documentation/contributing.md +0 -571
- package/documentation/cursor-integration.md +0 -734
- package/documentation/docker.md +0 -874
- package/documentation/embeddings.md +0 -762
- package/documentation/faq.md +0 -713
- package/documentation/features.md +0 -403
- package/documentation/headroom.md +0 -519
- package/documentation/installation.md +0 -758
- package/documentation/memory-system.md +0 -476
- package/documentation/production.md +0 -636
- package/documentation/providers.md +0 -1009
- package/documentation/routing.md +0 -476
- package/documentation/testing.md +0 -629
- package/documentation/token-optimization.md +0 -325
- package/documentation/tools.md +0 -697
- package/documentation/troubleshooting.md +0 -969
- 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/te +0 -11622
- package/test/README.md +0 -212
- package/test/azure-openai-config.test.js +0 -213
- 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 -287
- package/test/azure-openai-routing.test.js +0 -175
- package/test/azure-openai-streaming.test.js +0 -171
- package/test/bedrock-integration.test.js +0 -457
- 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 -269
- package/test/hybrid-routing-performance.test.js +0 -428
- package/test/llamacpp-integration.test.js +0 -882
- package/test/lmstudio-integration.test.js +0 -347
- 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 -683
- 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 -225
- package/test/toon-compression.test.js +0 -131
- 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-agents-simple.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Simple test to verify agent system is working
|
|
2
|
-
// Run: AGENTS_ENABLED=true node test-agents-simple.js
|
|
3
|
-
|
|
4
|
-
const config = require('./src/config');
|
|
5
|
-
const { listAgents, getAgentStats } = require('./src/agents');
|
|
6
|
-
|
|
7
|
-
console.log('🧪 Testing Agent System\n');
|
|
8
|
-
|
|
9
|
-
// Test 1: Check configuration
|
|
10
|
-
console.log('1. Configuration:');
|
|
11
|
-
console.log(` Agents enabled: ${config.agents?.enabled}`);
|
|
12
|
-
console.log(` Max concurrent: ${config.agents?.maxConcurrent}`);
|
|
13
|
-
console.log(` Default model: ${config.agents?.defaultModel}`);
|
|
14
|
-
console.log(` Max steps: ${config.agents?.maxSteps}`);
|
|
15
|
-
console.log(` Timeout: ${config.agents?.timeout}ms`);
|
|
16
|
-
|
|
17
|
-
// Test 2: List available agents
|
|
18
|
-
console.log('\n2. Available Agents:');
|
|
19
|
-
const agents = listAgents();
|
|
20
|
-
agents.forEach(agent => {
|
|
21
|
-
console.log(` - ${agent.name} (${agent.model})`);
|
|
22
|
-
console.log(` ${agent.description.substring(0, 80)}...`);
|
|
23
|
-
console.log(` Tools: ${agent.allowedTools.length === 0 ? 'ALL' : agent.allowedTools.join(', ')}`);
|
|
24
|
-
console.log(` Max steps: ${agent.maxSteps}`);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Test 3: Check stats
|
|
28
|
-
console.log('\n3. Execution Stats:');
|
|
29
|
-
const stats = getAgentStats();
|
|
30
|
-
if (stats.length === 0) {
|
|
31
|
-
console.log(' No executions yet');
|
|
32
|
-
} else {
|
|
33
|
-
stats.forEach(stat => {
|
|
34
|
-
console.log(` - ${stat.agent_type}:`);
|
|
35
|
-
console.log(` Total: ${stat.total_executions}, Completed: ${stat.completed}, Failed: ${stat.failed}`);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
console.log('\n✅ Agent system is operational!\n');
|
|
40
|
-
console.log('Next steps:');
|
|
41
|
-
console.log('1. Start server: AGENTS_ENABLED=true npm start');
|
|
42
|
-
console.log('2. Test with curl (see README)');
|
|
43
|
-
console.log('3. Or run: ./test-subagents.sh\n');
|
package/test-cli-connection.sh
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
echo "🔍 Claude Code CLI Connection Test"
|
|
4
|
-
echo "===================================="
|
|
5
|
-
echo ""
|
|
6
|
-
|
|
7
|
-
echo "1. Environment Variables:"
|
|
8
|
-
env | grep -i anthropic | sed 's/^/ /'
|
|
9
|
-
|
|
10
|
-
echo ""
|
|
11
|
-
echo "2. Testing ngrok endpoint:"
|
|
12
|
-
curl -s https://ae619b9fdba2.ngrok-free.app/health -H "ngrok-skip-browser-warning: true" | jq .
|
|
13
|
-
|
|
14
|
-
echo ""
|
|
15
|
-
echo "3. Testing direct localhost:"
|
|
16
|
-
curl -s http://localhost:8080/health | jq .
|
|
17
|
-
|
|
18
|
-
echo ""
|
|
19
|
-
echo "4. Checking Claude config file:"
|
|
20
|
-
if [ -f ~/.config/claude/config.json ]; then
|
|
21
|
-
echo " Config exists:"
|
|
22
|
-
cat ~/.config/claude/config.json | jq .api 2>/dev/null || cat ~/.config/claude/config.json
|
|
23
|
-
else
|
|
24
|
-
echo " No config file found"
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
echo ""
|
|
28
|
-
echo "5. Last 5 requests in server log:"
|
|
29
|
-
tail -100 /tmp/lynkr.log | grep "Request started" | tail -5 | sed 's/^/ /'
|
|
30
|
-
|
|
31
|
-
echo ""
|
|
32
|
-
echo "======================================"
|
|
33
|
-
echo "Please share this output!"
|
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();
|