ideaco 1.1.5

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 (159) hide show
  1. package/.dockerignore +33 -0
  2. package/.nvmrc +1 -0
  3. package/ARCHITECTURE.md +394 -0
  4. package/Dockerfile +50 -0
  5. package/LICENSE +29 -0
  6. package/README.md +206 -0
  7. package/bin/i18n.js +46 -0
  8. package/bin/ideaco.js +494 -0
  9. package/deploy.sh +15 -0
  10. package/docker-compose.yml +30 -0
  11. package/electron/main.cjs +986 -0
  12. package/electron/preload.cjs +14 -0
  13. package/electron/web-backends.cjs +854 -0
  14. package/jsconfig.json +8 -0
  15. package/next.config.mjs +34 -0
  16. package/package.json +134 -0
  17. package/postcss.config.mjs +6 -0
  18. package/public/demo/dashboard.png +0 -0
  19. package/public/demo/employee.png +0 -0
  20. package/public/demo/messages.png +0 -0
  21. package/public/demo/office.png +0 -0
  22. package/public/demo/requirement.png +0 -0
  23. package/public/logo.jpeg +0 -0
  24. package/public/logo.png +0 -0
  25. package/scripts/prepare-electron.js +67 -0
  26. package/scripts/release.js +76 -0
  27. package/src/app/api/agents/[agentId]/chat/route.js +70 -0
  28. package/src/app/api/agents/[agentId]/conversations/route.js +35 -0
  29. package/src/app/api/agents/[agentId]/route.js +106 -0
  30. package/src/app/api/avatar/route.js +104 -0
  31. package/src/app/api/browse-dir/route.js +44 -0
  32. package/src/app/api/chat/route.js +265 -0
  33. package/src/app/api/company/factory-reset/route.js +43 -0
  34. package/src/app/api/company/route.js +82 -0
  35. package/src/app/api/departments/[deptId]/agents/[agentId]/dismiss/route.js +19 -0
  36. package/src/app/api/departments/route.js +92 -0
  37. package/src/app/api/group-chat-loop/events/route.js +70 -0
  38. package/src/app/api/group-chat-loop/route.js +94 -0
  39. package/src/app/api/mailbox/route.js +100 -0
  40. package/src/app/api/messages/route.js +14 -0
  41. package/src/app/api/providers/[id]/configure/route.js +21 -0
  42. package/src/app/api/providers/[id]/refresh-cookie/route.js +38 -0
  43. package/src/app/api/providers/[id]/test-cookie/route.js +28 -0
  44. package/src/app/api/providers/route.js +11 -0
  45. package/src/app/api/requirements/route.js +242 -0
  46. package/src/app/api/secretary/route.js +65 -0
  47. package/src/app/api/system/cli-backends/route.js +91 -0
  48. package/src/app/api/system/cron/route.js +110 -0
  49. package/src/app/api/system/knowledge/route.js +104 -0
  50. package/src/app/api/system/plugins/route.js +40 -0
  51. package/src/app/api/system/skills/route.js +46 -0
  52. package/src/app/api/system/status/route.js +46 -0
  53. package/src/app/api/talent-market/[profileId]/recall/route.js +22 -0
  54. package/src/app/api/talent-market/[profileId]/route.js +17 -0
  55. package/src/app/api/talent-market/route.js +26 -0
  56. package/src/app/api/teams/route.js +773 -0
  57. package/src/app/api/ws-files/[departmentId]/file/route.js +27 -0
  58. package/src/app/api/ws-files/[departmentId]/files/route.js +22 -0
  59. package/src/app/globals.css +130 -0
  60. package/src/app/layout.jsx +40 -0
  61. package/src/app/page.jsx +97 -0
  62. package/src/components/AgentChatModal.jsx +164 -0
  63. package/src/components/AgentDetailModal.jsx +425 -0
  64. package/src/components/AgentSpyModal.jsx +481 -0
  65. package/src/components/AvatarGrid.jsx +29 -0
  66. package/src/components/BossProfileModal.jsx +162 -0
  67. package/src/components/CachedAvatar.jsx +77 -0
  68. package/src/components/ChatPanel.jsx +219 -0
  69. package/src/components/ChatShared.jsx +255 -0
  70. package/src/components/DepartmentDetail.jsx +842 -0
  71. package/src/components/DepartmentView.jsx +367 -0
  72. package/src/components/FileReference.jsx +260 -0
  73. package/src/components/FilesView.jsx +465 -0
  74. package/src/components/GroupChatView.jsx +799 -0
  75. package/src/components/Mailbox.jsx +926 -0
  76. package/src/components/MessagesView.jsx +112 -0
  77. package/src/components/OnboardingGuide.jsx +209 -0
  78. package/src/components/OrgTree.jsx +151 -0
  79. package/src/components/Overview.jsx +391 -0
  80. package/src/components/PixelOffice.jsx +2281 -0
  81. package/src/components/ProviderGrid.jsx +551 -0
  82. package/src/components/ProvidersBoard.jsx +16 -0
  83. package/src/components/RequirementDetail.jsx +1279 -0
  84. package/src/components/RequirementsBoard.jsx +187 -0
  85. package/src/components/SecretarySettings.jsx +295 -0
  86. package/src/components/SetupWizard.jsx +388 -0
  87. package/src/components/Sidebar.jsx +169 -0
  88. package/src/components/SystemMonitor.jsx +808 -0
  89. package/src/components/TalentMarket.jsx +183 -0
  90. package/src/components/TeamDetail.jsx +697 -0
  91. package/src/core/agent/base-agent.js +104 -0
  92. package/src/core/agent/chat-store.js +602 -0
  93. package/src/core/agent/cli-agent/backends/claude-code/README.md +52 -0
  94. package/src/core/agent/cli-agent/backends/claude-code/config.js +27 -0
  95. package/src/core/agent/cli-agent/backends/codebuddy/README.md +236 -0
  96. package/src/core/agent/cli-agent/backends/codebuddy/config.js +27 -0
  97. package/src/core/agent/cli-agent/backends/codex/README.md +51 -0
  98. package/src/core/agent/cli-agent/backends/codex/config.js +27 -0
  99. package/src/core/agent/cli-agent/backends/index.js +27 -0
  100. package/src/core/agent/cli-agent/backends/registry.js +580 -0
  101. package/src/core/agent/cli-agent/index.js +154 -0
  102. package/src/core/agent/index.js +60 -0
  103. package/src/core/agent/llm-agent/client.js +320 -0
  104. package/src/core/agent/llm-agent/index.js +97 -0
  105. package/src/core/agent/message-bus.js +211 -0
  106. package/src/core/agent/session.js +608 -0
  107. package/src/core/agent/tools.js +596 -0
  108. package/src/core/agent/web-agent/backends/base-backend.js +180 -0
  109. package/src/core/agent/web-agent/backends/chatgpt/client.js +146 -0
  110. package/src/core/agent/web-agent/backends/chatgpt/config.js +148 -0
  111. package/src/core/agent/web-agent/backends/chatgpt/dom-scripts.js +303 -0
  112. package/src/core/agent/web-agent/backends/index.js +91 -0
  113. package/src/core/agent/web-agent/index.js +278 -0
  114. package/src/core/agent/web-agent/web-client.js +407 -0
  115. package/src/core/employee/base-employee.js +1088 -0
  116. package/src/core/employee/index.js +35 -0
  117. package/src/core/employee/knowledge.js +327 -0
  118. package/src/core/employee/lifecycle.js +990 -0
  119. package/src/core/employee/memory/index.js +642 -0
  120. package/src/core/employee/memory/store.js +143 -0
  121. package/src/core/employee/performance.js +224 -0
  122. package/src/core/employee/secretary.js +625 -0
  123. package/src/core/employee/skills.js +398 -0
  124. package/src/core/index.js +38 -0
  125. package/src/core/organization/company.js +2600 -0
  126. package/src/core/organization/department.js +737 -0
  127. package/src/core/organization/group-chat-loop.js +264 -0
  128. package/src/core/organization/index.js +8 -0
  129. package/src/core/organization/persistence.js +111 -0
  130. package/src/core/organization/team.js +267 -0
  131. package/src/core/organization/workforce/hr.js +377 -0
  132. package/src/core/organization/workforce/providers.js +468 -0
  133. package/src/core/organization/workforce/role-archetypes.js +805 -0
  134. package/src/core/organization/workforce/talent-market.js +205 -0
  135. package/src/core/prompts.js +532 -0
  136. package/src/core/requirement.js +1789 -0
  137. package/src/core/system/audit.js +483 -0
  138. package/src/core/system/cron.js +449 -0
  139. package/src/core/system/index.js +7 -0
  140. package/src/core/system/plugin.js +2183 -0
  141. package/src/core/utils/json-parse.js +188 -0
  142. package/src/core/workspace.js +239 -0
  143. package/src/lib/api-i18n.js +211 -0
  144. package/src/lib/avatar.js +268 -0
  145. package/src/lib/client-store.js +1025 -0
  146. package/src/lib/config-validator.js +483 -0
  147. package/src/lib/format-time.js +22 -0
  148. package/src/lib/hooks.js +414 -0
  149. package/src/lib/i18n.js +134 -0
  150. package/src/lib/paths.js +23 -0
  151. package/src/lib/store.js +72 -0
  152. package/src/locales/de.js +393 -0
  153. package/src/locales/en.js +1054 -0
  154. package/src/locales/es.js +393 -0
  155. package/src/locales/fr.js +393 -0
  156. package/src/locales/ja.js +501 -0
  157. package/src/locales/ko.js +513 -0
  158. package/src/locales/zh.js +828 -0
  159. package/tailwind.config.mjs +11 -0
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Employee module — unified entry point.
3
+ *
4
+ * External code imports from here. Employees are the business-layer entities
5
+ * that hold identity, memory, skills, org structure, and delegate communication
6
+ * to their internal Agent (LLMAgent or CLIAgent).
7
+ *
8
+ * Usage:
9
+ * import { Employee, createEmployee, Secretary } from './employee/index.js';
10
+ */
11
+
12
+ import { Employee } from './base-employee.js';
13
+ import { Secretary, HRAssistant } from './secretary.js';
14
+ import { EmployeeLifecycle, InnerMonologue } from './lifecycle.js';
15
+
16
+ /**
17
+ * Create an Employee from a recruit config.
18
+ * @param {object} config - Recruit config (from HR.recruit() or similar)
19
+ * @returns {Employee}
20
+ */
21
+ export function createEmployee(config) {
22
+ return new Employee(config);
23
+ }
24
+
25
+ /**
26
+ * Deserialize an Employee from saved data.
27
+ * @param {object} data
28
+ * @param {object} [providerRegistry]
29
+ * @returns {Employee}
30
+ */
31
+ export function deserializeEmployee(data, providerRegistry) {
32
+ return Employee.deserialize(data, providerRegistry);
33
+ }
34
+
35
+ export { Employee, Secretary, HRAssistant, EmployeeLifecycle, InnerMonologue };
@@ -0,0 +1,327 @@
1
+ /**
2
+ * Knowledge Base System - Agent knowledge base management
3
+ *
4
+ * Distilled from OpenClaw's Memory system (vendor/openclaw/docs/concepts/memory.md)
5
+ * Re-implemented as an "enterprise knowledge base" management system
6
+ *
7
+ * Features:
8
+ * - Knowledge base creation and management
9
+ * - Document/entry CRUD operations
10
+ * - Per-agent or global knowledge base assignment
11
+ * - Keyword-based knowledge retrieval
12
+ * - Knowledge base statistics and monitoring
13
+ */
14
+ import { v4 as uuidv4 } from 'uuid';
15
+
16
+ /**
17
+ * Knowledge base types
18
+ */
19
+ export const KnowledgeType = {
20
+ GLOBAL: 'global', // Global knowledge base (accessible to all Agents)
21
+ DEPARTMENT: 'department', // Department-level knowledge base
22
+ AGENT: 'agent', // Agent personal knowledge base
23
+ };
24
+
25
+ /**
26
+ * Entry types
27
+ */
28
+ export const EntryType = {
29
+ FACT: 'fact', // Factual information
30
+ DECISION: 'decision', // Decision records
31
+ PROCEDURE: 'procedure', // Process/operation steps
32
+ REFERENCE: 'reference', // Reference documents
33
+ FAQ: 'faq', // Frequently asked questions
34
+ NOTE: 'note', // Notes/memos
35
+ };
36
+
37
+ /**
38
+ * Knowledge entry
39
+ */
40
+ class KnowledgeEntry {
41
+ constructor(config) {
42
+ this.id = config.id || uuidv4();
43
+ this.title = config.title;
44
+ this.content = config.content;
45
+ this.type = config.type || EntryType.NOTE;
46
+ this.tags = config.tags || [];
47
+ this.source = config.source || null; // Source (file path, URL, etc.)
48
+ this.importance = config.importance || 0.5; // Importance score 0-1
49
+ this.createdAt = config.createdAt || new Date();
50
+ this.updatedAt = config.updatedAt || new Date();
51
+ this.createdBy = config.createdBy || null; // Agent ID
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Knowledge base
57
+ */
58
+ class KnowledgeBase {
59
+ constructor(config) {
60
+ this.id = config.id || uuidv4();
61
+ this.name = config.name;
62
+ this.description = config.description || '';
63
+ this.type = config.type || KnowledgeType.GLOBAL;
64
+ this.ownerId = config.ownerId || null; // Agent ID or Department ID
65
+ this.entries = new Map();
66
+ this.createdAt = new Date();
67
+ this.enabled = true;
68
+ }
69
+
70
+ addEntry(entry) {
71
+ const e = entry instanceof KnowledgeEntry ? entry : new KnowledgeEntry(entry);
72
+ this.entries.set(e.id, e);
73
+ return e;
74
+ }
75
+
76
+ removeEntry(entryId) {
77
+ return this.entries.delete(entryId);
78
+ }
79
+
80
+ updateEntry(entryId, updates) {
81
+ const entry = this.entries.get(entryId);
82
+ if (!entry) return null;
83
+ Object.assign(entry, updates, { updatedAt: new Date() });
84
+ return entry;
85
+ }
86
+
87
+ getEntry(entryId) {
88
+ return this.entries.get(entryId) || null;
89
+ }
90
+
91
+ /**
92
+ * Keyword search entries
93
+ */
94
+ search(query, limit = 10) {
95
+ const q = query.toLowerCase();
96
+ const results = [];
97
+ for (const entry of this.entries.values()) {
98
+ const titleMatch = entry.title.toLowerCase().includes(q);
99
+ const contentMatch = entry.content.toLowerCase().includes(q);
100
+ const tagMatch = entry.tags.some(t => t.toLowerCase().includes(q));
101
+
102
+ if (titleMatch || contentMatch || tagMatch) {
103
+ // Simple scoring: title match has highest weight
104
+ let score = 0;
105
+ if (titleMatch) score += 3;
106
+ if (contentMatch) score += 1;
107
+ if (tagMatch) score += 2;
108
+ score += entry.importance;
109
+ results.push({ entry, score });
110
+ }
111
+ }
112
+ return results
113
+ .sort((a, b) => b.score - a.score)
114
+ .slice(0, limit)
115
+ .map(r => ({
116
+ ...r.entry,
117
+ relevanceScore: r.score,
118
+ }));
119
+ }
120
+
121
+ /**
122
+ * Get statistics
123
+ */
124
+ getStats() {
125
+ const entries = [...this.entries.values()];
126
+ const typeCounts = {};
127
+ entries.forEach(e => {
128
+ typeCounts[e.type] = (typeCounts[e.type] || 0) + 1;
129
+ });
130
+ return {
131
+ totalEntries: entries.length,
132
+ typeCounts,
133
+ lastUpdated: entries.length > 0
134
+ ? new Date(Math.max(...entries.map(e => new Date(e.updatedAt).getTime())))
135
+ : null,
136
+ };
137
+ }
138
+
139
+ listEntries(options = {}) {
140
+ let entries = [...this.entries.values()];
141
+ if (options.type) entries = entries.filter(e => e.type === options.type);
142
+ if (options.tag) entries = entries.filter(e => e.tags.includes(options.tag));
143
+ entries.sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt));
144
+ if (options.limit) entries = entries.slice(0, options.limit);
145
+ return entries;
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Knowledge manager - manages all knowledge bases
151
+ */
152
+ export class KnowledgeManager {
153
+ constructor() {
154
+ /** @type {Map<string, KnowledgeBase>} */
155
+ this.bases = new Map();
156
+ }
157
+
158
+ /**
159
+ * Create a knowledge base
160
+ */
161
+ create(config) {
162
+ const kb = new KnowledgeBase(config);
163
+ this.bases.set(kb.id, kb);
164
+ console.log(`📖 Knowledge base created: ${kb.name} (${kb.type})`);
165
+ return kb;
166
+ }
167
+
168
+ /**
169
+ * Get a knowledge base
170
+ */
171
+ get(kbId) {
172
+ return this.bases.get(kbId) || null;
173
+ }
174
+
175
+ /**
176
+ * Delete a knowledge base
177
+ */
178
+ delete(kbId) {
179
+ return this.bases.delete(kbId);
180
+ }
181
+
182
+ /**
183
+ * List all knowledge bases
184
+ */
185
+ list() {
186
+ return [...this.bases.values()].map(kb => ({
187
+ id: kb.id,
188
+ name: kb.name,
189
+ description: kb.description,
190
+ type: kb.type,
191
+ ownerId: kb.ownerId,
192
+ enabled: kb.enabled,
193
+ entryCount: kb.entries.size,
194
+ stats: kb.getStats(),
195
+ createdAt: kb.createdAt,
196
+ }));
197
+ }
198
+
199
+ /**
200
+ * Get all knowledge bases accessible to a specific Agent
201
+ * @param {string} agentId
202
+ * @param {string} departmentId
203
+ */
204
+ getAccessibleBases(agentId, departmentId = null) {
205
+ return [...this.bases.values()].filter(kb => {
206
+ if (!kb.enabled) return false;
207
+ if (kb.type === KnowledgeType.GLOBAL) return true;
208
+ if (kb.type === KnowledgeType.DEPARTMENT && kb.ownerId === departmentId) return true;
209
+ if (kb.type === KnowledgeType.AGENT && kb.ownerId === agentId) return true;
210
+ return false;
211
+ });
212
+ }
213
+
214
+ /**
215
+ * Search across knowledge bases
216
+ */
217
+ search(query, options = {}) {
218
+ const { agentId, departmentId, limit = 10 } = options;
219
+ const bases = agentId
220
+ ? this.getAccessibleBases(agentId, departmentId)
221
+ : [...this.bases.values()].filter(kb => kb.enabled);
222
+
223
+ const allResults = [];
224
+ for (const kb of bases) {
225
+ const results = kb.search(query, limit);
226
+ results.forEach(r => allResults.push({ ...r, knowledgeBaseId: kb.id, knowledgeBaseName: kb.name }));
227
+ }
228
+ return allResults
229
+ .sort((a, b) => b.relevanceScore - a.relevanceScore)
230
+ .slice(0, limit);
231
+ }
232
+
233
+ /**
234
+ * Add an entry to a knowledge base
235
+ */
236
+ addEntry(kbId, entryConfig) {
237
+ const kb = this.bases.get(kbId);
238
+ if (!kb) throw new Error(`Knowledge base not found: ${kbId}`);
239
+ return kb.addEntry(entryConfig);
240
+ }
241
+
242
+ /**
243
+ * Remove an entry from a knowledge base
244
+ */
245
+ removeEntry(kbId, entryId) {
246
+ const kb = this.bases.get(kbId);
247
+ if (!kb) throw new Error(`Knowledge base not found: ${kbId}`);
248
+ return kb.removeEntry(entryId);
249
+ }
250
+
251
+ /**
252
+ * Build knowledge base prompt (injected into Agent system prompt)
253
+ * @param {string} agentId
254
+ * @param {string} departmentId
255
+ * @returns {string}
256
+ */
257
+ buildKnowledgePrompt(agentId, departmentId = null) {
258
+ const bases = this.getAccessibleBases(agentId, departmentId);
259
+ if (bases.length === 0) return '';
260
+
261
+ const sections = bases.map(kb => {
262
+ const recent = kb.listEntries({ limit: 5 });
263
+ if (recent.length === 0) return null;
264
+ const items = recent.map(e =>
265
+ ` - [${e.type}] ${e.title}: ${e.content.slice(0, 200)}${e.content.length > 200 ? '...' : ''}`
266
+ ).join('\n');
267
+ return `### ${kb.name}\n${items}`;
268
+ }).filter(Boolean);
269
+
270
+ if (sections.length === 0) return '';
271
+ return `\n## Knowledge Base\nYou have access to the following knowledge:\n${sections.join('\n\n')}\n`;
272
+ }
273
+
274
+ /**
275
+ * Get overall statistics
276
+ */
277
+ getOverallStats() {
278
+ const bases = [...this.bases.values()];
279
+ let totalEntries = 0;
280
+ bases.forEach(kb => { totalEntries += kb.entries.size; });
281
+ return {
282
+ totalBases: bases.length,
283
+ enabledBases: bases.filter(kb => kb.enabled).length,
284
+ totalEntries,
285
+ byType: {
286
+ global: bases.filter(kb => kb.type === KnowledgeType.GLOBAL).length,
287
+ department: bases.filter(kb => kb.type === KnowledgeType.DEPARTMENT).length,
288
+ agent: bases.filter(kb => kb.type === KnowledgeType.AGENT).length,
289
+ },
290
+ };
291
+ }
292
+ }
293
+
294
+ // Global singleton
295
+ export const knowledgeManager = new KnowledgeManager();
296
+
297
+ // Create default global knowledge base
298
+ const globalKb = knowledgeManager.create({
299
+ name: 'Company Knowledge Base',
300
+ description: 'Shared knowledge base for all agents in the company',
301
+ type: KnowledgeType.GLOBAL,
302
+ });
303
+
304
+ // Add some example entries
305
+ globalKb.addEntry({
306
+ title: 'Code Review Standards',
307
+ content: 'All code must pass code review before merging. Reviews should check: correctness, readability, security, performance, and test coverage.',
308
+ type: EntryType.PROCEDURE,
309
+ tags: ['coding', 'review', 'standards'],
310
+ importance: 0.8,
311
+ });
312
+
313
+ globalKb.addEntry({
314
+ title: 'API Design Guidelines',
315
+ content: 'RESTful APIs should use proper HTTP methods (GET/POST/PUT/DELETE), return appropriate status codes, and include consistent error response formats.',
316
+ type: EntryType.REFERENCE,
317
+ tags: ['api', 'design', 'standards'],
318
+ importance: 0.7,
319
+ });
320
+
321
+ globalKb.addEntry({
322
+ title: 'Project File Structure',
323
+ content: 'Projects should follow a standard directory structure: src/ for source code, tests/ for tests, docs/ for documentation, config/ for configurations.',
324
+ type: EntryType.PROCEDURE,
325
+ tags: ['structure', 'organization', 'standards'],
326
+ importance: 0.6,
327
+ });