copilot-liku-cli 0.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.
Files changed (71) hide show
  1. package/ARCHITECTURE.md +411 -0
  2. package/CONFIGURATION.md +302 -0
  3. package/CONTRIBUTING.md +225 -0
  4. package/ELECTRON_README.md +121 -0
  5. package/INSTALLATION.md +350 -0
  6. package/LICENSE.md +1 -0
  7. package/PROJECT_STATUS.md +229 -0
  8. package/QUICKSTART.md +255 -0
  9. package/README.md +167 -0
  10. package/TESTING.md +274 -0
  11. package/package.json +61 -0
  12. package/scripts/start.js +30 -0
  13. package/src/assets/tray-icon.png +0 -0
  14. package/src/cli/commands/agent.js +327 -0
  15. package/src/cli/commands/click.js +108 -0
  16. package/src/cli/commands/drag.js +85 -0
  17. package/src/cli/commands/find.js +109 -0
  18. package/src/cli/commands/keys.js +132 -0
  19. package/src/cli/commands/mouse.js +79 -0
  20. package/src/cli/commands/repl.js +290 -0
  21. package/src/cli/commands/screenshot.js +72 -0
  22. package/src/cli/commands/scroll.js +74 -0
  23. package/src/cli/commands/start.js +67 -0
  24. package/src/cli/commands/type.js +57 -0
  25. package/src/cli/commands/wait.js +84 -0
  26. package/src/cli/commands/window.js +104 -0
  27. package/src/cli/liku.js +249 -0
  28. package/src/cli/util/output.js +174 -0
  29. package/src/main/agents/base-agent.js +410 -0
  30. package/src/main/agents/builder.js +484 -0
  31. package/src/main/agents/index.js +62 -0
  32. package/src/main/agents/orchestrator.js +362 -0
  33. package/src/main/agents/researcher.js +511 -0
  34. package/src/main/agents/state-manager.js +344 -0
  35. package/src/main/agents/supervisor.js +365 -0
  36. package/src/main/agents/verifier.js +452 -0
  37. package/src/main/ai-service.js +1633 -0
  38. package/src/main/index.js +2208 -0
  39. package/src/main/inspect-service.js +467 -0
  40. package/src/main/system-automation.js +1186 -0
  41. package/src/main/ui-automation/config.js +76 -0
  42. package/src/main/ui-automation/core/helpers.js +41 -0
  43. package/src/main/ui-automation/core/index.js +15 -0
  44. package/src/main/ui-automation/core/powershell.js +82 -0
  45. package/src/main/ui-automation/elements/finder.js +274 -0
  46. package/src/main/ui-automation/elements/index.js +14 -0
  47. package/src/main/ui-automation/elements/wait.js +66 -0
  48. package/src/main/ui-automation/index.js +164 -0
  49. package/src/main/ui-automation/interactions/element-click.js +211 -0
  50. package/src/main/ui-automation/interactions/high-level.js +230 -0
  51. package/src/main/ui-automation/interactions/index.js +47 -0
  52. package/src/main/ui-automation/keyboard/index.js +15 -0
  53. package/src/main/ui-automation/keyboard/input.js +179 -0
  54. package/src/main/ui-automation/mouse/click.js +186 -0
  55. package/src/main/ui-automation/mouse/drag.js +88 -0
  56. package/src/main/ui-automation/mouse/index.js +30 -0
  57. package/src/main/ui-automation/mouse/movement.js +51 -0
  58. package/src/main/ui-automation/mouse/scroll.js +116 -0
  59. package/src/main/ui-automation/screenshot.js +183 -0
  60. package/src/main/ui-automation/window/index.js +23 -0
  61. package/src/main/ui-automation/window/manager.js +305 -0
  62. package/src/main/utils/time.js +62 -0
  63. package/src/main/visual-awareness.js +597 -0
  64. package/src/renderer/chat/chat.js +671 -0
  65. package/src/renderer/chat/index.html +725 -0
  66. package/src/renderer/chat/preload.js +112 -0
  67. package/src/renderer/overlay/index.html +648 -0
  68. package/src/renderer/overlay/overlay.js +782 -0
  69. package/src/renderer/overlay/preload.js +90 -0
  70. package/src/shared/grid-math.js +82 -0
  71. package/src/shared/inspect-types.js +230 -0
@@ -0,0 +1,362 @@
1
+ /**
2
+ * Agent Orchestrator
3
+ *
4
+ * Coordinates the multi-agent system, managing handoffs between
5
+ * Supervisor, Builder, Verifier, and Researcher agents.
6
+ *
7
+ * Responsibilities:
8
+ * - Create and manage agent instances
9
+ * - Route handoffs between agents
10
+ * - Manage session state and history
11
+ * - Provide unified API for external consumers
12
+ */
13
+
14
+ const EventEmitter = require('events');
15
+ const { SupervisorAgent } = require('./supervisor');
16
+ const { BuilderAgent } = require('./builder');
17
+ const { VerifierAgent } = require('./verifier');
18
+ const { ResearcherAgent } = require('./researcher');
19
+ const { AgentStateManager } = require('./state-manager');
20
+ const { AgentRole } = require('./base-agent');
21
+
22
+ class AgentOrchestrator extends EventEmitter {
23
+ constructor(options = {}) {
24
+ super();
25
+
26
+ this.stateManager = options.stateManager || new AgentStateManager();
27
+ this.aiService = options.aiService;
28
+
29
+ // Configuration
30
+ this.maxRecursionDepth = options.maxRecursionDepth || 3;
31
+ this.maxSubCalls = options.maxSubCalls || 10;
32
+ this.enableLongContext = options.enableLongContext !== false;
33
+
34
+ // Agent instances
35
+ this.agents = new Map();
36
+
37
+ // Session tracking
38
+ this.currentSession = null;
39
+ this.handoffHistory = [];
40
+
41
+ // Initialize default agents
42
+ this._initializeAgents();
43
+ }
44
+
45
+ _initializeAgents() {
46
+ const modelMetadata = this.aiService?.getModelMetadata?.() || {
47
+ modelId: 'unknown',
48
+ provider: 'unknown',
49
+ modelVersion: null,
50
+ capabilities: []
51
+ };
52
+
53
+ const commonOptions = {
54
+ aiService: this.aiService,
55
+ stateManager: this.stateManager,
56
+ orchestrator: this,
57
+ maxRecursionDepth: this.maxRecursionDepth,
58
+ maxSubCalls: this.maxSubCalls,
59
+ modelMetadata
60
+ };
61
+
62
+ // Create one instance of each agent type
63
+ this.agents.set(AgentRole.SUPERVISOR, new SupervisorAgent(commonOptions));
64
+ this.agents.set(AgentRole.BUILDER, new BuilderAgent(commonOptions));
65
+ this.agents.set(AgentRole.VERIFIER, new VerifierAgent(commonOptions));
66
+ this.agents.set(AgentRole.RESEARCHER, new ResearcherAgent(commonOptions));
67
+
68
+ // Register agents with state manager
69
+ for (const [role, agent] of this.agents) {
70
+ this.stateManager.registerAgent(agent.id, role, agent.capabilities);
71
+
72
+ // Forward agent events
73
+ agent.on('log', (entry) => this.emit('agent:log', entry));
74
+ agent.on('proof', (proof) => this.emit('agent:proof', proof));
75
+ agent.on('handoff', (handoff) => this.emit('agent:handoff', handoff));
76
+ }
77
+ }
78
+
79
+ // ===== Session Management =====
80
+
81
+ startSession(metadata = {}) {
82
+ const sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
83
+
84
+ this.currentSession = {
85
+ id: sessionId,
86
+ startedAt: new Date().toISOString(),
87
+ metadata,
88
+ tasks: [],
89
+ handoffs: []
90
+ };
91
+
92
+ this.stateManager.startSession(sessionId, metadata);
93
+ this.emit('session:start', this.currentSession);
94
+
95
+ return sessionId;
96
+ }
97
+
98
+ endSession(summary = {}) {
99
+ if (!this.currentSession) return null;
100
+
101
+ const session = {
102
+ ...this.currentSession,
103
+ endedAt: new Date().toISOString(),
104
+ summary
105
+ };
106
+
107
+ this.stateManager.endSession(session.id, summary);
108
+ this.emit('session:end', session);
109
+
110
+ // Reset all agents
111
+ for (const agent of this.agents.values()) {
112
+ agent.reset();
113
+ }
114
+
115
+ this.currentSession = null;
116
+ this.handoffHistory = [];
117
+
118
+ return session;
119
+ }
120
+
121
+ // ===== Task Execution =====
122
+
123
+ async execute(task, options = {}) {
124
+ // Start session if not already started
125
+ if (!this.currentSession) {
126
+ this.startSession({ task: task.description || task });
127
+ }
128
+
129
+ const context = {
130
+ sessionId: this.currentSession.id,
131
+ ...options
132
+ };
133
+
134
+ // Determine starting agent (default: Supervisor)
135
+ const startAgent = options.startAgent || AgentRole.SUPERVISOR;
136
+ const agent = this.agents.get(startAgent);
137
+
138
+ if (!agent) {
139
+ throw new Error(`Agent not found: ${startAgent}`);
140
+ }
141
+
142
+ this.emit('task:start', { task, agent: startAgent });
143
+
144
+ try {
145
+ if (options.enableCheckpoints !== false) {
146
+ await this.checkpoint('pre-execution');
147
+ }
148
+
149
+ const result = await agent.process(task, context);
150
+
151
+ if (options.enableCheckpoints !== false) {
152
+ await this.checkpoint('post-execution');
153
+ }
154
+
155
+ this.emit('task:complete', { task, result });
156
+
157
+ return {
158
+ success: result.success,
159
+ result,
160
+ session: this.currentSession.id,
161
+ handoffs: this.handoffHistory
162
+ };
163
+
164
+ } catch (error) {
165
+ if (options.enableCheckpoints !== false) {
166
+ await this.checkpoint('error-state');
167
+ }
168
+
169
+ this.emit('task:error', { task, error });
170
+
171
+ return {
172
+ success: false,
173
+ error: error.message,
174
+ session: this.currentSession.id,
175
+ handoffs: this.handoffHistory
176
+ };
177
+ }
178
+ }
179
+
180
+ // ===== Handoff Management =====
181
+
182
+ async executeHandoff(fromAgent, targetRole, context, message) {
183
+ const targetAgent = this.agents.get(targetRole);
184
+
185
+ if (!targetAgent) {
186
+ throw new Error(`Target agent not found: ${targetRole}`);
187
+ }
188
+
189
+ // Record handoff
190
+ const handoff = {
191
+ from: fromAgent.role,
192
+ to: targetRole,
193
+ message,
194
+ timestamp: new Date().toISOString()
195
+ };
196
+
197
+ this.handoffHistory.push(handoff);
198
+
199
+ if (this.currentSession) {
200
+ this.currentSession.handoffs.push(handoff);
201
+ }
202
+
203
+ this.emit('handoff:execute', handoff);
204
+
205
+ // Update state manager
206
+ this.stateManager.updateAgentActivity(targetAgent.id);
207
+
208
+ // Execute on target agent
209
+ const task = {
210
+ description: message,
211
+ fromAgent: fromAgent.role,
212
+ context
213
+ };
214
+
215
+ return targetAgent.process(task, context);
216
+ }
217
+
218
+ // ===== Checkpoint Management =====
219
+
220
+ async checkpoint(label = 'auto') {
221
+ if (!this.currentSession) return null;
222
+
223
+ const agentStates = Array.from(this.agents.entries()).map(([role, agent]) => ({
224
+ role,
225
+ state: agent.getState()
226
+ }));
227
+
228
+ const checkpoint = this.stateManager.createCheckpoint(
229
+ this.currentSession.id,
230
+ label,
231
+ agentStates,
232
+ this.handoffHistory
233
+ );
234
+
235
+ this.emit('checkpoint', checkpoint);
236
+ return checkpoint;
237
+ }
238
+
239
+ async restoreFromCheckpoint(checkpointId) {
240
+ const checkpoint = this.stateManager.getCheckpoint(checkpointId);
241
+ if (!checkpoint) {
242
+ throw new Error(`Checkpoint not found: ${checkpointId}`);
243
+ }
244
+
245
+ this.handoffHistory = [...checkpoint.handoffHistory];
246
+ this.emit('checkpoint:restored', checkpoint);
247
+
248
+ return checkpoint;
249
+ }
250
+
251
+ // ===== Agent Access =====
252
+
253
+ getAgent(role) {
254
+ return this.agents.get(role);
255
+ }
256
+
257
+ getSupervisor() {
258
+ return this.agents.get(AgentRole.SUPERVISOR);
259
+ }
260
+
261
+ getBuilder() {
262
+ return this.agents.get(AgentRole.BUILDER);
263
+ }
264
+
265
+ getVerifier() {
266
+ return this.agents.get(AgentRole.VERIFIER);
267
+ }
268
+
269
+ getResearcher() {
270
+ return this.agents.get(AgentRole.RESEARCHER);
271
+ }
272
+
273
+ // ===== Convenience Methods =====
274
+
275
+ async research(query, options = {}) {
276
+ return this.execute(query, {
277
+ ...options,
278
+ startAgent: AgentRole.RESEARCHER
279
+ });
280
+ }
281
+
282
+ async build(task, options = {}) {
283
+ return this.execute(task, {
284
+ ...options,
285
+ startAgent: AgentRole.BUILDER
286
+ });
287
+ }
288
+
289
+ async verify(changes, options = {}) {
290
+ return this.execute({ description: 'Verify changes', changes }, {
291
+ ...options,
292
+ startAgent: AgentRole.VERIFIER,
293
+ diffs: changes
294
+ });
295
+ }
296
+
297
+ async orchestrate(task, options = {}) {
298
+ // Full orchestration via Supervisor
299
+ return this.execute(task, {
300
+ ...options,
301
+ startAgent: AgentRole.SUPERVISOR
302
+ });
303
+ }
304
+
305
+ // ===== State & Diagnostics =====
306
+
307
+ getState() {
308
+ return {
309
+ session: this.currentSession,
310
+ agents: Array.from(this.agents.entries()).map(([role, agent]) => ({
311
+ role,
312
+ state: agent.getState()
313
+ })),
314
+ handoffHistory: this.handoffHistory,
315
+ stateManager: this.stateManager.getFullState(),
316
+ checkpoints: this.stateManager.listCheckpoints(this.currentSession?.id)
317
+ };
318
+ }
319
+
320
+ getStats() {
321
+ const state = this.stateManager.getFullState();
322
+
323
+ return {
324
+ sessions: state.sessions.length,
325
+ tasksCompleted: state.completed.length,
326
+ tasksFailed: state.failed.length,
327
+ tasksInProgress: state.inProgress.length,
328
+ tasksQueued: state.queue.length,
329
+ agents: Object.keys(state.agents).length
330
+ };
331
+ }
332
+
333
+ reset() {
334
+ // End current session
335
+ if (this.currentSession) {
336
+ this.endSession({ reason: 'reset' });
337
+ }
338
+
339
+ // Reset all agents
340
+ for (const agent of this.agents.values()) {
341
+ agent.reset();
342
+ }
343
+
344
+ // Clear history
345
+ this.handoffHistory = [];
346
+
347
+ this.emit('orchestrator:reset');
348
+ }
349
+
350
+ // ===== AI Service Configuration =====
351
+
352
+ setAIService(aiService) {
353
+ this.aiService = aiService;
354
+
355
+ // Update all agents
356
+ for (const agent of this.agents.values()) {
357
+ agent.aiService = aiService;
358
+ }
359
+ }
360
+ }
361
+
362
+ module.exports = { AgentOrchestrator };