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
package/.dockerignore ADDED
@@ -0,0 +1,33 @@
1
+ # Docker-related
2
+ .dockerignore
3
+ *.log
4
+ Dockerfile
5
+ docker-compose.yml
6
+
7
+ # Dependencies (will be installed in build)
8
+ node_modules/
9
+
10
+ # Build output (will be rebuilt)
11
+ .next/
12
+
13
+ # Environment secrets
14
+ .env
15
+ .env.local
16
+ .env.*.local
17
+
18
+ # Development data
19
+ data/
20
+ workspace/
21
+
22
+ # Git
23
+ .git/
24
+ .gitmodules
25
+
26
+ # Reference submodule (not needed in production)
27
+ vendor/
28
+
29
+ # Documentation
30
+ *.md
31
+ LICENSE
32
+ DISTILLATION-MANIFESTO.md
33
+ THIRD-PARTY-NOTICES.md
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 20
@@ -0,0 +1,394 @@
1
+ # IdeaCo Architecture
2
+
3
+ > Internal architecture documentation for IdeaCo — the AI Employee Management System.
4
+
5
+ ---
6
+
7
+ ## System Overview
8
+
9
+ IdeaCo is a layered AI enterprise simulator where every component maps to a real-world company metaphor. The system is organized into five clear layers:
10
+
11
+ ```
12
+ ┌─────────────────────────────────────────────────────┐
13
+ │ 👤 User (Boss) │
14
+ │ Chat interface / Mailbox │
15
+ ├─────────────────────────────────────────────────────┤
16
+ │ 🧑‍💼 Secretary │
17
+ │ Intent parsing · HR coordination · Reporting │
18
+ ├─────────────────────────────────────────────────────┤
19
+ │ 🏢 Organization Layer │
20
+ │ Company · Department · Team · Requirement │
21
+ ├─────────────────────────────────────────────────────┤
22
+ │ 👥 Employee Layer │
23
+ │ Memory · Personality · Skills · Prompt · Lifecycle│
24
+ ├─────────────────────────────────────────────────────┤
25
+ │ 🤖 Agent Layer │
26
+ │ LLM Agent · CLI Agent · Web Agent │
27
+ │ (Unified interface, zero business logic) │
28
+ └─────────────────────────────────────────────────────┘
29
+ ```
30
+
31
+ ### Layer Responsibilities
32
+
33
+ | Layer | Module | Responsibility |
34
+ |-------|--------|----------------|
35
+ | **User** | Frontend / Mailbox | Boss gives orders, views progress, and manages the company |
36
+ | **Secretary** | `secretary.js` | Understands boss intent, coordinates HR, dispatches tasks, reports progress |
37
+ | **Organization** | `company.js` / `department.js` / `team.js` / `requirement.js` | Company structure, department lifecycle, requirement workflow, group chat containers |
38
+ | **Employee** | `base-employee.js` / `lifecycle.js` / `memory/` | The atomic management unit — wraps an Agent with memory, personality, skills, and autonomous behavior |
39
+ | **Agent** | `base-agent.js` → LLMAgent / CLIAgent / WebAgent | Pure LLM communication engine. Zero business logic. Uniform `chat()` interface |
40
+
41
+ ---
42
+
43
+ ## Agent Layer
44
+
45
+ The Agent layer is a **pure communication engine** — it only handles LLM input/output and is completely decoupled from business logic. All three agent types expose the same abstract interface:
46
+
47
+ ```
48
+ BaseAgent (abstract)
49
+ ├── LLMAgent — OpenAI-compatible API (API key auth)
50
+ ├── CLIAgent — Local CLI tools (Claude Code, Codex, CodeBuddy)
51
+ └── WebAgent — Browser DOM automation (ChatGPT Web, Claude Web)
52
+ ```
53
+
54
+ **Unified Interface:**
55
+ - `chat(messages, options)` — Send a conversation request
56
+ - `chatWithTools(messages, toolExecutor, options)` — Conversation with tool calling
57
+ - `isAvailable()` / `canChat()` — Availability check
58
+ - `switchProvider(newProvider)` — Runtime provider switching
59
+ - `serialize()` / `deserialize()` — State persistence
60
+
61
+ **Internal differentiation (not exposed):**
62
+ - **LLMAgent**: Native function calling via OpenAI SDK
63
+ - **CLIAgent**: Subprocess execution, stdout parsing, fallback to LLM
64
+ - **WebAgent**: Hidden BrowserWindow DOM scripting, per-employee session isolation, tool-call simulation via prompt
65
+
66
+ ---
67
+
68
+ ## Employee Layer
69
+
70
+ An Employee is an Agent wrapped with **identity, memory, personality, and autonomous behavior**. It is the atomic management unit of the system.
71
+
72
+ ### Employee Lifecycle
73
+
74
+ ```
75
+ ┌──────────┐ ┌───────────┐ ┌─────────┐ ┌──────────────┐
76
+ │ 1. Init │───▶│2. Onboard │───▶│3. WakeUp│───▶│ 4. Poll Loop │◀─┐
77
+ └──────────┘ └───────────┘ └─────────┘ └──────┬───────┘ │
78
+ │ │
79
+ ▼ │
80
+ ┌────────────────┐ │
81
+ │ 5. Read Group │ │
82
+ │ Messages │ │
83
+ └───────┬────────┘ │
84
+ │ │
85
+ ▼ │
86
+ ┌────────────────┐ │
87
+ │ 6. Flow-of- │ │
88
+ │ Thought │ │
89
+ └───────┬────────┘ │
90
+ │ │
91
+ ┌─────┴─────┐ │
92
+ ▼ ▼ │
93
+ ┌─────────┐ ┌────────┐ │
94
+ │ Reply │ │ Silent │ │
95
+ └────┬────┘ └────┬───┘ │
96
+ │ │ │
97
+ ▼ │ │
98
+ ┌──────────┐ │ │
99
+ │ Trigger │ │ │
100
+ │ Others │────┘──────┘
101
+ └──────────┘
102
+ ```
103
+
104
+ #### Phase 1 — Initialization (Constructor)
105
+
106
+ - **Identity**: Name, gender, age, role, skill set
107
+ - **Agent Binding**: Attach an Agent instance (LLM / CLI / Web)
108
+ - **Personality Template**: Randomly assigned from 12 archetype pool (e.g., "Chatterbox", "Zen Slacker", "Anxious Perfectionist")
109
+ - **Memory System**: Initialize Memory instance (long-term + short-term + history summary + social impressions)
110
+ - **Toolbox**: Initialize AgentToolKit (shell, file I/O, search, etc.)
111
+
112
+ #### Phase 2 — Onboarding
113
+
114
+ The employee uses its own LLM capability to generate a self-introduction:
115
+
116
+ 1. Build a prompt containing its persona settings (name, role, personality archetype)
117
+ 2. Call `chat()` to have the LLM generate:
118
+ - **Self-introduction** — a paragraph about themselves
119
+ - **Signature** — a personal tagline
120
+ - **Personality description** — behavioral traits
121
+ 3. Persist generated content to employee state
122
+ 4. Send a greeting message to the Boss (`sendMailToBoss`)
123
+
124
+ #### Phase 3 — Wake Up
125
+
126
+ Triggered on app startup or session refresh. Injects full identity into the Agent's conversation context:
127
+
128
+ - **System Message**: Personal info, behavioral norms, skill list
129
+ - **Long-term Memory**: Top 20 entries by importance
130
+ - **Short-term Memory**: Top 10 active (non-expired) entries
131
+ - Calls `agent.chat()` to warm up the session — the Agent "remembers who it is"
132
+
133
+ #### Phase 4 — Poll Cycle
134
+
135
+ Each employee runs an independent random-interval timer:
136
+
137
+ - **Interval**: 10 seconds ~ 5 minutes (simulates human-like irregular checking behavior)
138
+ - **Each Cycle**: Scan all joined groups (work groups + lounge groups), check for unread messages
139
+ - **Lounge Groups**: After idle threshold, 15% chance of initiating a topic spontaneously
140
+
141
+ #### Phase 5 — Read Group Messages
142
+
143
+ When unread messages are detected:
144
+
145
+ 1. Separate **read messages** (old context) from **unread messages** (new, requiring response)
146
+ 2. Wait 5–20s random jitter (simulates "thinking/typing" time)
147
+ 3. Any messages arriving during jitter are absorbed into the unread batch
148
+ 4. Enter flow-of-thought phase
149
+
150
+ #### Phase 6 — Flow-of-Thought (Agent Think)
151
+
152
+ Constructs a full prompt context and calls the LLM for decision-making.
153
+
154
+ **Input (injected into LLM):**
155
+
156
+ | # | Input | Description |
157
+ |---|-------|-------------|
158
+ | 1 | Personal Info | Name, role, personality, speaking style |
159
+ | 2 | Settings & Abilities | Behavioral norms, role definition, skills |
160
+ | 3 | Scene Context | Group name, members, department mission, requirement description |
161
+ | 4 | Chat History | Last 20 messages (read/unread markers) |
162
+ | 5 | Memory | Rolling history summary + Long-term (top 15) + Short-term (top 10) |
163
+ | 6 | Social Memory | Relationship impressions of message senders (name, impression, affinity) |
164
+ | 7 | Dedup Hint | If colleagues already replied with similar content → "don't repeat others" |
165
+ | 8 | Perspective Seed | Random thinking angle ("pragmatic", "innovative", "risk-focused") to prevent opinion convergence |
166
+
167
+ **LLM Structured Output (JSON):**
168
+
169
+ ```json
170
+ {
171
+ "innerThoughts": "Internal monologue with personality and emotion",
172
+ "topicSaturation": 5,
173
+ "shouldSpeak": true,
174
+ "reason": "Why I decided to speak/stay silent",
175
+ "messages": [{ "content": "The actual reply" }],
176
+ "memorySummary": "Compressed summary of old messages",
177
+ "memoryOps": [
178
+ { "op": "add", "type": "long_term", "content": "...", "category": "fact", "importance": 8 },
179
+ { "op": "add", "type": "short_term", "content": "...", "ttl": 3600 },
180
+ { "op": "delete", "id": "mem_xxx" }
181
+ ],
182
+ "relationshipOps": [
183
+ { "employeeId": "emp_123", "name": "Alice", "impression": "Strong coder, reliable", "affinity": 75 }
184
+ ]
185
+ }
186
+ ```
187
+
188
+ ### Reply Decision Gates
189
+
190
+ After the LLM's flow-of-thought, the reply passes through multiple filter gates:
191
+
192
+ ```
193
+ LLM returns shouldSpeak=true
194
+
195
+
196
+ ┌─────────────────────┐ ┌──────────┐
197
+ │ Topic Saturation ≥7?│──▶ │ 🔇 Silent│
198
+ └─────────┬───────────┘ └──────────┘
199
+ │ No
200
+
201
+ ┌─────────────────────┐ ┌──────────┐
202
+ │ Anti-spam: Too many │──▶ │ 🔇 Silent│
203
+ │ messages in window? │ └──────────┘
204
+ └─────────┬───────────┘
205
+ │ No
206
+
207
+ ┌─────────────────────┐ ┌──────────┐
208
+ │ Cooldown active? │──▶ │ 🔇 Silent│
209
+ └─────────┬───────────┘ └──────────┘
210
+ │ No
211
+
212
+ ┌──────────┐
213
+ │ ✅ Speak │
214
+ └──────────┘
215
+ ```
216
+
217
+ | Gate | Mechanism | Parameters |
218
+ |------|-----------|------------|
219
+ | **Topic Saturation** | LLM self-rates 1–10; ≥ 7 forces silence | threshold = 7 |
220
+ | **Anti-spam (Work)** | Max 2 messages per 5-minute window | window=5min, max=2 |
221
+ | **Anti-spam (Lounge)** | Max 4 messages per 10-minute window | window=10min, max=4 |
222
+ | **Cooldown (Work)** | 60s silence after speaking | cooldown=60s |
223
+ | **Cooldown (Lounge)** | 30s silence after speaking | cooldown=30s |
224
+
225
+ ### Chain Reaction
226
+
227
+ After an employee sends a message:
228
+
229
+ 1. Message is written to the group chat log
230
+ 2. Send timestamp is recorded (for anti-spam)
231
+ 3. **Nudge all other group members** with random delay → triggers their `_processGroupMessages`, creating an autonomous conversation loop
232
+
233
+ ---
234
+
235
+ ## Memory System
236
+
237
+ ### Memory Architecture
238
+
239
+ ```
240
+ Memory
241
+ ├── 📜 historySummary — Rolling AI-compressed summary of old messages (per-group)
242
+ ├── 💾 longTerm — Permanent storage, sorted by importance (1–10), cap: 200
243
+ ├── ⚡ shortTerm — TTL-based auto-expiry, default 24h, cap: 20
244
+ └── 👥 relationships — Social impression table: Map<employeeId, {name, impression, affinity}>
245
+ ```
246
+
247
+ ### Per-Conversation Memory Input
248
+
249
+ | # | Input | Description |
250
+ |---|-------|-------------|
251
+ | 1 | Personal Info | Name, role, age, gender, personality, signature |
252
+ | 2 | Settings & Abilities | System prompt, skill list, behavioral norms |
253
+ | 3 | Scene Context | Group name, members, department mission, requirement |
254
+ | 4 | Chat History | Last 20 messages (read/unread markers) |
255
+ | 5 | Layered Memory | Long-term (top 15) + Short-term (top 10) + Rolling summary |
256
+ | 6 | Social Memory | Relationship impressions of message senders |
257
+
258
+ ### LLM Output → Memory Updates
259
+
260
+ | # | Output | Description |
261
+ |---|--------|-------------|
262
+ | 1 | Reply | `messages[]` — actual messages sent to group chat |
263
+ | 2 | Memory Ops | `memoryOps[]` — add/delete long-term & short-term entries with importance and category |
264
+ | 3 | History Summary | `memorySummary` — compressed key points, incrementally appended |
265
+ | 4 | Social Memory | `relationshipOps[]` — update impressions (≤200 chars) and affinity (1–100) |
266
+ | 5 | Actions | Tool calls (shell, file ops) or command execution |
267
+
268
+ ### Social Memory (Relationships)
269
+
270
+ Each employee maintains an impression table for every other employee (including the Boss):
271
+
272
+ | Field | Description |
273
+ |-------|-------------|
274
+ | `employeeId` | Target employee ID |
275
+ | `name` | Target name |
276
+ | `impression` | ≤200 characters (e.g., "Great coder, helped me debug, reliable") |
277
+ | `affinity` | 1–100 scale (1=hostile, 50=neutral, 100=best friend), ±5–15 per interaction |
278
+
279
+ - Social memories are only injected when the corresponding employee appears in the chat
280
+ - Affinity displayed as emoji: ❤️(≥80) 😊(≥60) 😐(≥40) 😒(≥20) 💢(<20)
281
+ - Token cost is minimal: ~200 chars per person, 10 colleagues ≈ 1000 tokens
282
+
283
+ ### Memory Management Strategies
284
+
285
+ | Strategy | Description |
286
+ |----------|-------------|
287
+ | **Incremental Ops** | AI uses `memoryOps` (add/delete/update), never full replacement — prevents accidental data loss |
288
+ | **Dedup Check** | New entries are checked against existing first 80 characters |
289
+ | **TTL Auto-cleanup** | Short-term memories expire automatically |
290
+ | **Importance Pruning** | When long-term exceeds 200 entries, lowest importance entries are dropped |
291
+ | **Rolling Compression** | When history summary grows too long, oldest summary segments are discarded |
292
+ | **Persistence** | All memory is serialized via `Memory.serialize()` to local storage |
293
+
294
+ ---
295
+
296
+ ## Project Structure
297
+
298
+ ```
299
+ IdeaCo/
300
+ ├── src/
301
+ │ ├── app/ # Next.js App Router + API Routes
302
+ │ │ └── api/ # RESTful endpoints for all features
303
+ │ ├── components/ # React UI components
304
+ │ │ ├── PixelOffice.jsx # Pixel-art virtual office
305
+ │ │ ├── GroupChatView.jsx # Group chat interface
306
+ │ │ ├── AgentDetailModal.jsx # Employee profile card
307
+ │ │ ├── RequirementDetail.jsx # Requirement workflow view
308
+ │ │ └── ...
309
+ │ ├── core/ # Core engine
310
+ │ │ ├── agent/ # Agent layer (LLM communication)
311
+ │ │ │ ├── base-agent.js # Abstract base class
312
+ │ │ │ ├── llm-agent/ # OpenAI-compatible API agent
313
+ │ │ │ ├── cli-agent/ # CLI tool agent (Claude Code, Codex, CodeBuddy)
314
+ │ │ │ └── web-agent/ # Browser-based web agent (ChatGPT Web)
315
+ │ │ ├── employee/ # Employee layer
316
+ │ │ │ ├── base-employee.js # Core employee logic
317
+ │ │ │ ├── lifecycle.js # Autonomous behavior (poll, think, reply)
318
+ │ │ │ ├── memory/ # Memory system (long/short-term, social)
319
+ │ │ │ ├── secretary.js # Secretary — boss's AI assistant
320
+ │ │ │ ├── skills.js # Skill management
321
+ │ │ │ ├── knowledge.js # Knowledge base integration
322
+ │ │ │ └── performance.js # Performance tracking
323
+ │ │ ├── organization/ # Organization layer
324
+ │ │ │ ├── company.js # Company entity & state machine
325
+ │ │ │ ├── department.js # Department lifecycle
326
+ │ │ │ ├── team.js # Cross-department task forces
327
+ │ │ │ ├── group-chat-loop.js # Group chat event loop
328
+ │ │ │ └── workforce/ # HR, talent market, role archetypes
329
+ │ │ ├── system/ # System services
330
+ │ │ │ ├── audit.js # Cost & usage auditing
331
+ │ │ │ ├── cron.js # Scheduled tasks
332
+ │ │ │ └── plugin.js # Plugin system
333
+ │ │ ├── prompts.js # All LLM prompt templates
334
+ │ │ ├── requirement.js # Requirement workflow engine
335
+ │ │ └── workspace.js # File workspace management
336
+ │ ├── lib/ # Frontend utilities
337
+ │ │ └── store.js # Zustand global state
338
+ │ └── locales/ # i18n (zh/en/ja/ko/es/de/fr)
339
+ ├── data/ # Runtime data (auto-created)
340
+ ├── workspace/ # Agent-produced files per department
341
+ ├── electron/ # Electron desktop app shell
342
+ ├── Dockerfile
343
+ ├── docker-compose.yml
344
+ └── package.json
345
+ ```
346
+
347
+ ---
348
+
349
+ ## Data Flow
350
+
351
+ ```
352
+ 👤 Boss
353
+
354
+ │ Chat message
355
+
356
+ 🧑‍💼 Secretary ──────────────────────────────────┐
357
+ │ │
358
+ │ Understands intent │ Simple task
359
+ │ │ → handles directly
360
+ ▼ ▼
361
+ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
362
+ │ Create Dept │ │ Create Team │ │ Direct Response │
363
+ └──────┬──────┘ └──────┬───────┘ └─────────────────┘
364
+ │ │
365
+ ▼ ▼
366
+ ┌─────────────┐ ┌──────────────┐
367
+ │ HR Hiring │ │ Assign Req │
368
+ └──────┬──────┘ └──────┬───────┘
369
+ │ │
370
+ ▼ ▼
371
+ ┌─────────────────────────────────────────┐
372
+ │ 💬 Group Chat │
373
+ │ │
374
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
375
+ │ │ Emp A │ │ Emp B │ │ Emp C │ │
376
+ │ │ (poll) │ │ (poll) │ │ (poll) │ │
377
+ │ └────┬────┘ └────┬────┘ └────┬────┘ │
378
+ │ │ │ │ │
379
+ │ ▼ ▼ ▼ │
380
+ │ ┌─────────────────────────────────┐ │
381
+ │ │ 🧠 Flow-of-Thought │ │
382
+ │ │ ┌────────┐ ┌───────┐ ┌──────┐ │ │
383
+ │ │ │ Memory │ │ Social│ │ Anti │ │ │
384
+ │ │ │ System │ │ Memory│ │ Spam │ │ │
385
+ │ │ └────────┘ └───────┘ └──────┘ │ │
386
+ │ └─────────────────────────────────┘ │
387
+ │ │ │
388
+ │ ▼ │
389
+ │ Reply → Nudge Others → Chain Reaction │
390
+ └─────────────────────────────────────────┘
391
+
392
+
393
+ 📁 Deliverables (workspace/)
394
+ ```
package/Dockerfile ADDED
@@ -0,0 +1,50 @@
1
+ FROM node:20-alpine AS base
2
+
3
+ # Install dependencies only when needed
4
+ FROM base AS deps
5
+ WORKDIR /app
6
+
7
+ # Copy package files
8
+ COPY package.json package-lock.json ./
9
+ RUN npm ci --omit=dev
10
+
11
+ # Build the application
12
+ FROM base AS builder
13
+ WORKDIR /app
14
+ COPY --from=deps /app/node_modules ./node_modules
15
+ COPY . .
16
+
17
+ # Remove vendor submodules (not needed for production)
18
+ RUN rm -rf vendor/
19
+
20
+ # Build Next.js
21
+ ENV NEXT_TELEMETRY_DISABLED=1
22
+ RUN npm run build
23
+
24
+ # Production image
25
+ FROM base AS runner
26
+ WORKDIR /app
27
+
28
+ ENV NODE_ENV=production
29
+ ENV NEXT_TELEMETRY_DISABLED=1
30
+
31
+ # Create non-root user
32
+ RUN addgroup --system --gid 1001 nodejs
33
+ RUN adduser --system --uid 1001 nextjs
34
+
35
+ # Copy built application
36
+ COPY --from=builder /app/public ./public
37
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
38
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
39
+
40
+ # Create data directories with proper permissions
41
+ RUN mkdir -p data/memories data/audit workspace && chown -R nextjs:nodejs data workspace
42
+
43
+ USER nextjs
44
+
45
+ EXPOSE 9999
46
+
47
+ ENV PORT=9999
48
+ ENV HOSTNAME="0.0.0.0"
49
+
50
+ CMD ["node", "server.js"]
package/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Idea Unlimited (金点子无限公司)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ This project includes code and design patterns inspired by or derived from:
26
+
27
+ - OpenClaw (https://github.com/openclaw/openclaw)
28
+ Copyright (c) 2025 Peter Steinberger — MIT License
29
+ See THIRD-PARTY-NOTICES.md for full license text.