intent-hub 0.1.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/.claude/settings.local.json +7 -0
- package/.turbo/cache/019f5ae385027cb1-meta.json +1 -0
- package/.turbo/cache/019f5ae385027cb1.tar.zst +0 -0
- package/.turbo/cache/040af6112a552a64-meta.json +1 -0
- package/.turbo/cache/040af6112a552a64.tar.zst +0 -0
- package/.turbo/cache/11195eac3ca5c6ce-meta.json +1 -0
- package/.turbo/cache/11195eac3ca5c6ce.tar.zst +0 -0
- package/.turbo/cache/13d11166efdf11cf-meta.json +1 -0
- package/.turbo/cache/13d11166efdf11cf.tar.zst +0 -0
- package/.turbo/cache/19af1af3b136706c-meta.json +1 -0
- package/.turbo/cache/19af1af3b136706c.tar.zst +0 -0
- package/.turbo/cache/1d33efac91c05b50-meta.json +1 -0
- package/.turbo/cache/1d33efac91c05b50.tar.zst +0 -0
- package/.turbo/cache/200b85a612af2d13-meta.json +1 -0
- package/.turbo/cache/200b85a612af2d13.tar.zst +0 -0
- package/.turbo/cache/210308c9ea929858-meta.json +1 -0
- package/.turbo/cache/210308c9ea929858.tar.zst +0 -0
- package/.turbo/cache/38df8e44c617835e-meta.json +1 -0
- package/.turbo/cache/38df8e44c617835e.tar.zst +0 -0
- package/.turbo/cache/3e449de5ef60a7a0-meta.json +1 -0
- package/.turbo/cache/3e449de5ef60a7a0.tar.zst +0 -0
- package/.turbo/cache/51ff024a97c2b4f5-meta.json +1 -0
- package/.turbo/cache/51ff024a97c2b4f5.tar.zst +0 -0
- package/.turbo/cache/54bc756eeebb377a-meta.json +1 -0
- package/.turbo/cache/54bc756eeebb377a.tar.zst +0 -0
- package/.turbo/cache/5ed6a840acafc873-meta.json +1 -0
- package/.turbo/cache/5ed6a840acafc873.tar.zst +0 -0
- package/.turbo/cache/6702dc24e5ca3c2e-meta.json +1 -0
- package/.turbo/cache/6702dc24e5ca3c2e.tar.zst +0 -0
- package/.turbo/cache/725c72cf71ea854f-meta.json +1 -0
- package/.turbo/cache/725c72cf71ea854f.tar.zst +0 -0
- package/.turbo/cache/7344ca28d348037a-meta.json +1 -0
- package/.turbo/cache/7344ca28d348037a.tar.zst +0 -0
- package/.turbo/cache/748fb444cdc0b78c-meta.json +1 -0
- package/.turbo/cache/748fb444cdc0b78c.tar.zst +0 -0
- package/.turbo/cache/789677c36fe7fb98-meta.json +1 -0
- package/.turbo/cache/789677c36fe7fb98.tar.zst +0 -0
- package/.turbo/cache/89ff6c6f38dd4a18-meta.json +1 -0
- package/.turbo/cache/89ff6c6f38dd4a18.tar.zst +0 -0
- package/.turbo/cache/8dbc92d00de0c92e-meta.json +1 -0
- package/.turbo/cache/8dbc92d00de0c92e.tar.zst +0 -0
- package/.turbo/cache/8eb03f40082b9441-meta.json +1 -0
- package/.turbo/cache/8eb03f40082b9441.tar.zst +0 -0
- package/.turbo/cache/9157134d4b916017-meta.json +1 -0
- package/.turbo/cache/9157134d4b916017.tar.zst +0 -0
- package/.turbo/cache/94219ffd32b48e93-meta.json +1 -0
- package/.turbo/cache/94219ffd32b48e93.tar.zst +0 -0
- package/.turbo/cache/95c1d160b4fa84eb-meta.json +1 -0
- package/.turbo/cache/95c1d160b4fa84eb.tar.zst +0 -0
- package/.turbo/cache/998833ea02dfb225-meta.json +1 -0
- package/.turbo/cache/998833ea02dfb225.tar.zst +0 -0
- package/.turbo/cache/a5974ef6ade3eb90-meta.json +1 -0
- package/.turbo/cache/a5974ef6ade3eb90.tar.zst +0 -0
- package/.turbo/cache/aab811809257decb-meta.json +1 -0
- package/.turbo/cache/aab811809257decb.tar.zst +0 -0
- package/.turbo/cache/ab2f82a54da854fd-meta.json +1 -0
- package/.turbo/cache/ab2f82a54da854fd.tar.zst +0 -0
- package/.turbo/cache/abbf4d95d62a7303-meta.json +1 -0
- package/.turbo/cache/abbf4d95d62a7303.tar.zst +0 -0
- package/.turbo/cache/af4441f519f9ce50-meta.json +1 -0
- package/.turbo/cache/af4441f519f9ce50.tar.zst +0 -0
- package/.turbo/cache/b9b85aaaf03d00a6-meta.json +1 -0
- package/.turbo/cache/b9b85aaaf03d00a6.tar.zst +0 -0
- package/.turbo/cache/cd58ee8721bbfed7-meta.json +1 -0
- package/.turbo/cache/cd58ee8721bbfed7.tar.zst +0 -0
- package/.turbo/cache/d285e48b8afa30b5-meta.json +1 -0
- package/.turbo/cache/d285e48b8afa30b5.tar.zst +0 -0
- package/.turbo/cache/d33e90229142acce-meta.json +1 -0
- package/.turbo/cache/d33e90229142acce.tar.zst +0 -0
- package/.turbo/cache/d57839a0d3b04540-meta.json +1 -0
- package/.turbo/cache/d57839a0d3b04540.tar.zst +0 -0
- package/.turbo/cache/d8554ef2c8b6e5eb-meta.json +1 -0
- package/.turbo/cache/d8554ef2c8b6e5eb.tar.zst +0 -0
- package/.turbo/cache/dc7375b51290e102-meta.json +1 -0
- package/.turbo/cache/dc7375b51290e102.tar.zst +0 -0
- package/.turbo/cache/e5310fe547fdbf0a-meta.json +1 -0
- package/.turbo/cache/e5310fe547fdbf0a.tar.zst +0 -0
- package/.turbo/cache/f12bb5f2f188758d-meta.json +1 -0
- package/.turbo/cache/f12bb5f2f188758d.tar.zst +0 -0
- package/.turbo/cache/f2db5af0c0b4d23f-meta.json +1 -0
- package/.turbo/cache/f2db5af0c0b4d23f.tar.zst +0 -0
- package/.turbo/cache/f8935ade01a88cd7-meta.json +1 -0
- package/.turbo/cache/f8935ade01a88cd7.tar.zst +0 -0
- package/.turbo/cache/f982b8dd966f823a-meta.json +1 -0
- package/.turbo/cache/f982b8dd966f823a.tar.zst +0 -0
- package/.turbo/cache/f9d4036dd350ba1a-meta.json +1 -0
- package/.turbo/cache/f9d4036dd350ba1a.tar.zst +0 -0
- package/README.md +661 -0
- package/README_ko.md +577 -0
- package/bun.lock +135 -0
- package/package.json +26 -0
- package/packages/agent/.turbo/turbo-build.log +5 -0
- package/packages/agent/.turbo/turbo-typecheck.log +1 -0
- package/packages/agent/dist/connection/hub-client.d.ts +33 -0
- package/packages/agent/dist/connection/hub-client.d.ts.map +1 -0
- package/packages/agent/dist/connection/index.d.ts +2 -0
- package/packages/agent/dist/connection/index.d.ts.map +1 -0
- package/packages/agent/dist/hooks/index.d.ts +3 -0
- package/packages/agent/dist/hooks/index.d.ts.map +1 -0
- package/packages/agent/dist/hooks/intent-hub-hooks.d.ts +47 -0
- package/packages/agent/dist/hooks/intent-hub-hooks.d.ts.map +1 -0
- package/packages/agent/dist/index.d.ts +6 -0
- package/packages/agent/dist/index.d.ts.map +1 -0
- package/packages/agent/dist/index.js +3315 -0
- package/packages/agent/dist/plugin/index.d.ts +3 -0
- package/packages/agent/dist/plugin/index.d.ts.map +1 -0
- package/packages/agent/dist/plugin/intent-hub-plugin.d.ts +54 -0
- package/packages/agent/dist/plugin/intent-hub-plugin.d.ts.map +1 -0
- package/packages/agent/package.json +32 -0
- package/packages/agent/src/connection/hub-client.ts +152 -0
- package/packages/agent/src/connection/index.ts +1 -0
- package/packages/agent/src/hooks/index.ts +2 -0
- package/packages/agent/src/hooks/intent-hub-hooks.ts +245 -0
- package/packages/agent/src/index.ts +5 -0
- package/packages/agent/src/plugin/index.ts +2 -0
- package/packages/agent/src/plugin/intent-hub-plugin.ts +153 -0
- package/packages/agent/tsconfig.json +9 -0
- package/packages/hub/.turbo/turbo-build.log +6 -0
- package/packages/hub/.turbo/turbo-typecheck.log +1 -0
- package/packages/hub/dist/api/dashboard.d.ts +17 -0
- package/packages/hub/dist/api/dashboard.d.ts.map +1 -0
- package/packages/hub/dist/cli.d.ts +3 -0
- package/packages/hub/dist/cli.d.ts.map +1 -0
- package/packages/hub/dist/cli.js +7719 -0
- package/packages/hub/dist/core/conflict-detector.d.ts +36 -0
- package/packages/hub/dist/core/conflict-detector.d.ts.map +1 -0
- package/packages/hub/dist/core/index.d.ts +7 -0
- package/packages/hub/dist/core/index.d.ts.map +1 -0
- package/packages/hub/dist/core/intent-analyzer.d.ts +8 -0
- package/packages/hub/dist/core/intent-analyzer.d.ts.map +1 -0
- package/packages/hub/dist/core/lock-manager.d.ts +13 -0
- package/packages/hub/dist/core/lock-manager.d.ts.map +1 -0
- package/packages/hub/dist/core/orchestrator.d.ts +46 -0
- package/packages/hub/dist/core/orchestrator.d.ts.map +1 -0
- package/packages/hub/dist/index.d.ts +9 -0
- package/packages/hub/dist/index.d.ts.map +1 -0
- package/packages/hub/dist/index.js +4686 -0
- package/packages/hub/dist/llm/index.d.ts +7 -0
- package/packages/hub/dist/llm/index.d.ts.map +1 -0
- package/packages/hub/dist/llm/negotiation-engine.d.ts +40 -0
- package/packages/hub/dist/llm/negotiation-engine.d.ts.map +1 -0
- package/packages/hub/dist/llm/provider.d.ts +46 -0
- package/packages/hub/dist/llm/provider.d.ts.map +1 -0
- package/packages/hub/dist/llm/smart-analyzer.d.ts +20 -0
- package/packages/hub/dist/llm/smart-analyzer.d.ts.map +1 -0
- package/packages/hub/dist/server/hub-server.d.ts +35 -0
- package/packages/hub/dist/server/hub-server.d.ts.map +1 -0
- package/packages/hub/dist/server/index.d.ts +5 -0
- package/packages/hub/dist/server/index.d.ts.map +1 -0
- package/packages/hub/dist/server/message-handler.d.ts +18 -0
- package/packages/hub/dist/server/message-handler.d.ts.map +1 -0
- package/packages/hub/dist/server/smart-hub-server.d.ts +43 -0
- package/packages/hub/dist/server/smart-hub-server.d.ts.map +1 -0
- package/packages/hub/dist/state/index.d.ts +2 -0
- package/packages/hub/dist/state/index.d.ts.map +1 -0
- package/packages/hub/dist/state/session-manager.d.ts +19 -0
- package/packages/hub/dist/state/session-manager.d.ts.map +1 -0
- package/packages/hub/dist/tunnel/index.d.ts +14 -0
- package/packages/hub/dist/tunnel/index.d.ts.map +1 -0
- package/packages/hub/package.json +54 -0
- package/packages/hub/src/api/dashboard.ts +261 -0
- package/packages/hub/src/cli.ts +193 -0
- package/packages/hub/src/core/conflict-detector.ts +138 -0
- package/packages/hub/src/core/index.ts +6 -0
- package/packages/hub/src/core/intent-analyzer.ts +112 -0
- package/packages/hub/src/core/lock-manager.ts +95 -0
- package/packages/hub/src/core/orchestrator.ts +255 -0
- package/packages/hub/src/index.ts +8 -0
- package/packages/hub/src/llm/index.ts +17 -0
- package/packages/hub/src/llm/negotiation-engine.ts +297 -0
- package/packages/hub/src/llm/provider.ts +175 -0
- package/packages/hub/src/llm/smart-analyzer.ts +169 -0
- package/packages/hub/src/server/hub-server.ts +219 -0
- package/packages/hub/src/server/index.ts +4 -0
- package/packages/hub/src/server/message-handler.ts +111 -0
- package/packages/hub/src/server/smart-hub-server.ts +374 -0
- package/packages/hub/src/state/index.ts +1 -0
- package/packages/hub/src/state/session-manager.ts +59 -0
- package/packages/hub/src/tunnel/index.ts +153 -0
- package/packages/hub/tsconfig.json +9 -0
- package/packages/shared/.turbo/turbo-build.log +5 -0
- package/packages/shared/.turbo/turbo-typecheck.log +1 -0
- package/packages/shared/dist/index.d.ts +3 -0
- package/packages/shared/dist/index.d.ts.map +1 -0
- package/packages/shared/dist/index.js +50 -0
- package/packages/shared/dist/types/domain.d.ts +50 -0
- package/packages/shared/dist/types/domain.d.ts.map +1 -0
- package/packages/shared/dist/types/index.d.ts +4 -0
- package/packages/shared/dist/types/index.d.ts.map +1 -0
- package/packages/shared/dist/types/intent.d.ts +24 -0
- package/packages/shared/dist/types/intent.d.ts.map +1 -0
- package/packages/shared/dist/types/message.d.ts +151 -0
- package/packages/shared/dist/types/message.d.ts.map +1 -0
- package/packages/shared/dist/utils/id.d.ts +6 -0
- package/packages/shared/dist/utils/id.d.ts.map +1 -0
- package/packages/shared/dist/utils/index.d.ts +3 -0
- package/packages/shared/dist/utils/index.d.ts.map +1 -0
- package/packages/shared/dist/utils/message.d.ts +5 -0
- package/packages/shared/dist/utils/message.d.ts.map +1 -0
- package/packages/shared/package.json +33 -0
- package/packages/shared/src/index.ts +2 -0
- package/packages/shared/src/types/domain.ts +57 -0
- package/packages/shared/src/types/index.ts +3 -0
- package/packages/shared/src/types/intent.ts +34 -0
- package/packages/shared/src/types/message.ts +188 -0
- package/packages/shared/src/utils/id.ts +21 -0
- package/packages/shared/src/utils/index.ts +2 -0
- package/packages/shared/src/utils/message.ts +30 -0
- package/packages/shared/tsconfig.json +9 -0
- package/scripts/test-e2e.ts +194 -0
- package/scripts/test-mvp2.ts +167 -0
- package/scripts/test-mvp3.ts +405 -0
- package/tsconfig.json +19 -0
- package/turbo.json +22 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { WebSocketServer, WebSocket } from 'ws';
|
|
2
|
+
|
|
3
|
+
const PORT = 9878;
|
|
4
|
+
|
|
5
|
+
console.log('🧪 Direct Integration Test\n');
|
|
6
|
+
console.log('━'.repeat(50));
|
|
7
|
+
|
|
8
|
+
const clients = new Map<string, { socket: WebSocket; userId: string; username: string }>();
|
|
9
|
+
const locks = new Map<string, { userId: string; username: string }>();
|
|
10
|
+
|
|
11
|
+
const wss = new WebSocketServer({ port: PORT });
|
|
12
|
+
console.log(`[Server] Started on port ${PORT}`);
|
|
13
|
+
|
|
14
|
+
wss.on('connection', (socket) => {
|
|
15
|
+
console.log('[Server] New connection');
|
|
16
|
+
|
|
17
|
+
socket.on('message', (data) => {
|
|
18
|
+
const msg = JSON.parse(data.toString());
|
|
19
|
+
console.log(`[Server] Received: ${msg.type}`);
|
|
20
|
+
|
|
21
|
+
if (msg.type === 'agent:connect') {
|
|
22
|
+
const sessionId = `ses_${Date.now()}`;
|
|
23
|
+
clients.set(sessionId, {
|
|
24
|
+
socket,
|
|
25
|
+
userId: msg.payload.userId,
|
|
26
|
+
username: msg.payload.username,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
socket.send(JSON.stringify({
|
|
30
|
+
type: 'hub:connected',
|
|
31
|
+
timestamp: Date.now(),
|
|
32
|
+
messageId: `msg_${Date.now()}`,
|
|
33
|
+
payload: { sessionId, activeLocks: [] },
|
|
34
|
+
}));
|
|
35
|
+
console.log(`[Server] Client connected: ${msg.payload.username}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (msg.type === 'agent:intent:submit') {
|
|
39
|
+
const prompt = msg.payload.prompt.toLowerCase();
|
|
40
|
+
let domain = 'general';
|
|
41
|
+
|
|
42
|
+
if (prompt.includes('oauth') || prompt.includes('로그인') || prompt.includes('auth')) {
|
|
43
|
+
domain = 'auth';
|
|
44
|
+
} else if (prompt.includes('결제') || prompt.includes('payment')) {
|
|
45
|
+
domain = 'payment';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let client: { socket: WebSocket; userId: string; username: string } | undefined;
|
|
49
|
+
for (const c of clients.values()) {
|
|
50
|
+
if (c.socket === socket) {
|
|
51
|
+
client = c;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!client) return;
|
|
56
|
+
|
|
57
|
+
const existingLock = locks.get(domain);
|
|
58
|
+
if (existingLock && existingLock.userId !== client.userId) {
|
|
59
|
+
socket.send(JSON.stringify({
|
|
60
|
+
type: 'hub:lock:blocked',
|
|
61
|
+
timestamp: Date.now(),
|
|
62
|
+
messageId: `msg_${Date.now()}`,
|
|
63
|
+
payload: {
|
|
64
|
+
intentId: `int_${Date.now()}`,
|
|
65
|
+
blockedBy: [{ domain, username: existingLock.username, intentSummary: 'working' }],
|
|
66
|
+
},
|
|
67
|
+
}));
|
|
68
|
+
console.log(`[Server] ${client.username} BLOCKED on ${domain} by ${existingLock.username}`);
|
|
69
|
+
} else {
|
|
70
|
+
locks.set(domain, { userId: client.userId, username: client.username });
|
|
71
|
+
socket.send(JSON.stringify({
|
|
72
|
+
type: 'hub:lock:acquired',
|
|
73
|
+
timestamp: Date.now(),
|
|
74
|
+
messageId: `msg_${Date.now()}`,
|
|
75
|
+
payload: { intentId: `int_${Date.now()}`, domains: [domain] },
|
|
76
|
+
}));
|
|
77
|
+
console.log(`[Server] ${client.username} ACQUIRED lock on ${domain}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
async function sleep(ms: number) {
|
|
84
|
+
return new Promise(r => setTimeout(r, ms));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function runTest() {
|
|
88
|
+
await sleep(300);
|
|
89
|
+
|
|
90
|
+
console.log('\n[Test] Connecting Alice...');
|
|
91
|
+
const alice = new WebSocket(`ws://localhost:${PORT}`);
|
|
92
|
+
|
|
93
|
+
await new Promise<void>((resolve) => {
|
|
94
|
+
alice.on('open', () => {
|
|
95
|
+
alice.send(JSON.stringify({
|
|
96
|
+
type: 'agent:connect',
|
|
97
|
+
timestamp: Date.now(),
|
|
98
|
+
messageId: 'msg_1',
|
|
99
|
+
payload: { userId: 'alice', username: 'Alice', projectPath: '/p' },
|
|
100
|
+
}));
|
|
101
|
+
});
|
|
102
|
+
alice.on('message', (data) => {
|
|
103
|
+
const msg = JSON.parse(data.toString());
|
|
104
|
+
if (msg.type === 'hub:connected') {
|
|
105
|
+
console.log('[Test] Alice connected!');
|
|
106
|
+
resolve();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
console.log('[Test] Connecting Bob...');
|
|
112
|
+
const bob = new WebSocket(`ws://localhost:${PORT}`);
|
|
113
|
+
|
|
114
|
+
await new Promise<void>((resolve) => {
|
|
115
|
+
bob.on('open', () => {
|
|
116
|
+
bob.send(JSON.stringify({
|
|
117
|
+
type: 'agent:connect',
|
|
118
|
+
timestamp: Date.now(),
|
|
119
|
+
messageId: 'msg_2',
|
|
120
|
+
payload: { userId: 'bob', username: 'Bob', projectPath: '/p' },
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
bob.on('message', (data) => {
|
|
124
|
+
const msg = JSON.parse(data.toString());
|
|
125
|
+
if (msg.type === 'hub:connected') {
|
|
126
|
+
console.log('[Test] Bob connected!');
|
|
127
|
+
resolve();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const results: string[] = [];
|
|
133
|
+
|
|
134
|
+
alice.on('message', (data) => {
|
|
135
|
+
const msg = JSON.parse(data.toString());
|
|
136
|
+
if (msg.type === 'hub:lock:acquired') {
|
|
137
|
+
results.push(`Alice ACQUIRED ${msg.payload.domains.join(',')}`);
|
|
138
|
+
} else if (msg.type === 'hub:lock:blocked') {
|
|
139
|
+
results.push(`Alice BLOCKED`);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
bob.on('message', (data) => {
|
|
144
|
+
const msg = JSON.parse(data.toString());
|
|
145
|
+
if (msg.type === 'hub:lock:acquired') {
|
|
146
|
+
results.push(`Bob ACQUIRED ${msg.payload.domains.join(',')}`);
|
|
147
|
+
} else if (msg.type === 'hub:lock:blocked') {
|
|
148
|
+
results.push(`Bob BLOCKED`);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
console.log('\n[Test] Alice: "Google OAuth 로그인"');
|
|
153
|
+
alice.send(JSON.stringify({
|
|
154
|
+
type: 'agent:intent:submit',
|
|
155
|
+
timestamp: Date.now(),
|
|
156
|
+
messageId: 'msg_3',
|
|
157
|
+
payload: { prompt: 'Google OAuth 로그인' },
|
|
158
|
+
}));
|
|
159
|
+
await sleep(100);
|
|
160
|
+
|
|
161
|
+
console.log('[Test] Bob: "로그인 세션 관리"');
|
|
162
|
+
bob.send(JSON.stringify({
|
|
163
|
+
type: 'agent:intent:submit',
|
|
164
|
+
timestamp: Date.now(),
|
|
165
|
+
messageId: 'msg_4',
|
|
166
|
+
payload: { prompt: '로그인 세션 관리' },
|
|
167
|
+
}));
|
|
168
|
+
await sleep(100);
|
|
169
|
+
|
|
170
|
+
console.log('[Test] Bob: "결제 기능"');
|
|
171
|
+
bob.send(JSON.stringify({
|
|
172
|
+
type: 'agent:intent:submit',
|
|
173
|
+
timestamp: Date.now(),
|
|
174
|
+
messageId: 'msg_5',
|
|
175
|
+
payload: { prompt: '결제 기능' },
|
|
176
|
+
}));
|
|
177
|
+
await sleep(200);
|
|
178
|
+
|
|
179
|
+
console.log('\n━'.repeat(50));
|
|
180
|
+
console.log('Results:', results);
|
|
181
|
+
|
|
182
|
+
const pass = results.includes('Alice ACQUIRED auth') &&
|
|
183
|
+
results.includes('Bob BLOCKED') &&
|
|
184
|
+
results.includes('Bob ACQUIRED payment');
|
|
185
|
+
|
|
186
|
+
console.log(pass ? '\n✅ TEST PASSED!' : '\n❌ TEST FAILED');
|
|
187
|
+
|
|
188
|
+
alice.close();
|
|
189
|
+
bob.close();
|
|
190
|
+
wss.close();
|
|
191
|
+
process.exit(pass ? 0 : 1);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
runTest().catch(console.error);
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Orchestrator,
|
|
3
|
+
type OrchestratorConfig,
|
|
4
|
+
type IntentRequest,
|
|
5
|
+
} from '../packages/hub/dist/index.js';
|
|
6
|
+
|
|
7
|
+
console.log('🧪 MVP 2 - LLM Negotiation E2E Test\n');
|
|
8
|
+
console.log('━'.repeat(60));
|
|
9
|
+
|
|
10
|
+
class TestMockProvider {
|
|
11
|
+
name = 'test-mock';
|
|
12
|
+
|
|
13
|
+
async complete() {
|
|
14
|
+
return { content: 'mock response', model: 'test' };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async completeJSON<T>(messages: Array<{ role: string; content: string }>): Promise<T> {
|
|
18
|
+
const lastMessage = messages[messages.length - 1]?.content || '';
|
|
19
|
+
|
|
20
|
+
if (lastMessage.includes('OAuth') || lastMessage.includes('oauth')) {
|
|
21
|
+
return {
|
|
22
|
+
domain: 'auth',
|
|
23
|
+
subdomain: 'oauth',
|
|
24
|
+
affectedFiles: ['src/auth/oauth.ts'],
|
|
25
|
+
semanticTags: ['login', 'oauth', 'google'],
|
|
26
|
+
estimatedScope: 'medium',
|
|
27
|
+
dependencies: [],
|
|
28
|
+
summary: 'OAuth implementation',
|
|
29
|
+
} as T;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (lastMessage.includes('세션') || lastMessage.includes('session')) {
|
|
33
|
+
return {
|
|
34
|
+
domain: 'auth',
|
|
35
|
+
subdomain: 'session',
|
|
36
|
+
affectedFiles: ['src/auth/session.ts'],
|
|
37
|
+
semanticTags: ['session', 'login'],
|
|
38
|
+
estimatedScope: 'medium',
|
|
39
|
+
dependencies: ['auth'],
|
|
40
|
+
summary: 'Session management',
|
|
41
|
+
} as T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (lastMessage.includes('결제') || lastMessage.includes('payment')) {
|
|
45
|
+
return {
|
|
46
|
+
domain: 'payment',
|
|
47
|
+
subdomain: 'checkout',
|
|
48
|
+
affectedFiles: ['src/payment/checkout.ts'],
|
|
49
|
+
semanticTags: ['payment', 'checkout'],
|
|
50
|
+
estimatedScope: 'medium',
|
|
51
|
+
dependencies: [],
|
|
52
|
+
summary: 'Payment checkout',
|
|
53
|
+
} as T;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
domain: 'general',
|
|
58
|
+
affectedFiles: [],
|
|
59
|
+
semanticTags: [],
|
|
60
|
+
estimatedScope: 'small',
|
|
61
|
+
dependencies: [],
|
|
62
|
+
summary: 'General task',
|
|
63
|
+
} as T;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function runTest() {
|
|
68
|
+
const provider = new TestMockProvider() as any;
|
|
69
|
+
const notifications: Array<{ sessionId: string; event: string; data: any }> = [];
|
|
70
|
+
|
|
71
|
+
const config: OrchestratorConfig = {
|
|
72
|
+
useLLMAnalysis: true,
|
|
73
|
+
autoNegotiate: false,
|
|
74
|
+
conflictThreshold: 'medium',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const orchestrator = new Orchestrator(
|
|
78
|
+
provider,
|
|
79
|
+
config,
|
|
80
|
+
(sessionId, event, data) => {
|
|
81
|
+
notifications.push({ sessionId, event, data });
|
|
82
|
+
console.log(` 📢 Notification to ${sessionId}: ${event}`);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
console.log('\n1️⃣ Alice: "Google OAuth 구현"\n');
|
|
87
|
+
|
|
88
|
+
const aliceResponse = await orchestrator.processIntent({
|
|
89
|
+
sessionId: 'ses_alice',
|
|
90
|
+
userId: 'alice',
|
|
91
|
+
username: 'Alice',
|
|
92
|
+
prompt: 'Google OAuth 로그인 구현해줘',
|
|
93
|
+
});
|
|
94
|
+
console.log(` Status: ${aliceResponse.status}`);
|
|
95
|
+
console.log(` Domain: ${aliceResponse.domains.join(', ')}`);
|
|
96
|
+
console.log(` Analysis: ${aliceResponse.analysis.summary}`);
|
|
97
|
+
|
|
98
|
+
console.log('\n2️⃣ Bob: "세션 관리 구현" (같은 auth 도메인)\n');
|
|
99
|
+
|
|
100
|
+
const bobResponse = await orchestrator.processIntent({
|
|
101
|
+
sessionId: 'ses_bob',
|
|
102
|
+
userId: 'bob',
|
|
103
|
+
username: 'Bob',
|
|
104
|
+
prompt: '로그인 세션 관리 기능 추가해줘',
|
|
105
|
+
});
|
|
106
|
+
console.log(` Status: ${bobResponse.status}`);
|
|
107
|
+
console.log(` Domain: ${bobResponse.domains.join(', ')}`);
|
|
108
|
+
if (bobResponse.blockedBy) {
|
|
109
|
+
console.log(` Blocked by: ${bobResponse.blockedBy.map(b => `${b.username} (${b.reason})`).join(', ')}`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log('\n3️⃣ Carol: "결제 기능" (다른 도메인)\n');
|
|
113
|
+
|
|
114
|
+
const carolResponse = await orchestrator.processIntent({
|
|
115
|
+
sessionId: 'ses_carol',
|
|
116
|
+
userId: 'carol',
|
|
117
|
+
username: 'Carol',
|
|
118
|
+
prompt: '결제 기능 추가해줘',
|
|
119
|
+
});
|
|
120
|
+
console.log(` Status: ${carolResponse.status}`);
|
|
121
|
+
console.log(` Domain: ${carolResponse.domains.join(', ')}`);
|
|
122
|
+
|
|
123
|
+
console.log('\n4️⃣ Alice 작업 완료 → Bob 재시도\n');
|
|
124
|
+
|
|
125
|
+
orchestrator.completeIntent(aliceResponse.intentId, 'alice');
|
|
126
|
+
console.log(' Alice completed her work');
|
|
127
|
+
|
|
128
|
+
const bobRetry = await orchestrator.processIntent({
|
|
129
|
+
sessionId: 'ses_bob',
|
|
130
|
+
userId: 'bob',
|
|
131
|
+
username: 'Bob',
|
|
132
|
+
prompt: '로그인 세션 관리 기능 추가해줘',
|
|
133
|
+
});
|
|
134
|
+
console.log(` Bob retry status: ${bobRetry.status}`);
|
|
135
|
+
|
|
136
|
+
console.log('\n' + '━'.repeat(60));
|
|
137
|
+
|
|
138
|
+
const status = orchestrator.getStatus();
|
|
139
|
+
console.log(`\n📊 Orchestrator Status:`);
|
|
140
|
+
console.log(` Active intents: ${status.activeIntents}`);
|
|
141
|
+
console.log(` Active locks: ${status.activeLocks}`);
|
|
142
|
+
|
|
143
|
+
const aliceApproved = aliceResponse.status === 'approved';
|
|
144
|
+
const bobBlocked = bobResponse.status === 'blocked';
|
|
145
|
+
const carolApproved = carolResponse.status === 'approved';
|
|
146
|
+
const bobRetryApproved = bobRetry.status === 'approved';
|
|
147
|
+
|
|
148
|
+
console.log('\n' + '━'.repeat(60));
|
|
149
|
+
|
|
150
|
+
if (aliceApproved && bobBlocked && carolApproved && bobRetryApproved) {
|
|
151
|
+
console.log('\n✅ MVP 2 Test PASSED!\n');
|
|
152
|
+
console.log(' ✓ Alice approved (auth:oauth)');
|
|
153
|
+
console.log(' ✓ Bob blocked (same domain conflict)');
|
|
154
|
+
console.log(' ✓ Carol approved (different domain: payment)');
|
|
155
|
+
console.log(' ✓ Bob retry approved (after Alice completed)');
|
|
156
|
+
} else {
|
|
157
|
+
console.log('\n❌ MVP 2 Test FAILED!\n');
|
|
158
|
+
console.log(` Alice: ${aliceResponse.status} (expected: approved)`);
|
|
159
|
+
console.log(` Bob: ${bobResponse.status} (expected: blocked)`);
|
|
160
|
+
console.log(` Carol: ${carolResponse.status} (expected: approved)`);
|
|
161
|
+
console.log(` Bob retry: ${bobRetry.status} (expected: approved)`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
process.exit(aliceApproved && bobBlocked && carolApproved && bobRetryApproved ? 0 : 1);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
runTest().catch(console.error);
|