@ebowwa/daemons 0.5.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.
Files changed (42) hide show
  1. package/README.md +264 -0
  2. package/dist/bin/discord-cli.js +124118 -0
  3. package/dist/bin/manager.js +143 -0
  4. package/dist/bin/telegram-cli.js +124114 -0
  5. package/dist/index.js +125340 -0
  6. package/package.json +94 -0
  7. package/src/agent.ts +111 -0
  8. package/src/channels/base.ts +573 -0
  9. package/src/channels/discord.ts +306 -0
  10. package/src/channels/index.ts +169 -0
  11. package/src/channels/telegram.ts +315 -0
  12. package/src/daemon.ts +534 -0
  13. package/src/hooks.ts +97 -0
  14. package/src/index.ts +111 -0
  15. package/src/memory.ts +369 -0
  16. package/src/skills/coding/commit.ts +202 -0
  17. package/src/skills/coding/execute-subtask.ts +136 -0
  18. package/src/skills/coding/fix-issues.ts +126 -0
  19. package/src/skills/coding/index.ts +26 -0
  20. package/src/skills/coding/plan-task.ts +158 -0
  21. package/src/skills/coding/quality-check.ts +155 -0
  22. package/src/skills/index.ts +65 -0
  23. package/src/skills/registry.ts +380 -0
  24. package/src/skills/shared/index.ts +21 -0
  25. package/src/skills/shared/reflect.ts +156 -0
  26. package/src/skills/shared/review.ts +201 -0
  27. package/src/skills/shared/trajectory.ts +319 -0
  28. package/src/skills/trading/analyze-market.ts +144 -0
  29. package/src/skills/trading/check-risk.ts +176 -0
  30. package/src/skills/trading/execute-trade.ts +185 -0
  31. package/src/skills/trading/generate-signal.ts +160 -0
  32. package/src/skills/trading/index.ts +26 -0
  33. package/src/skills/trading/monitor-position.ts +179 -0
  34. package/src/skills/types.ts +235 -0
  35. package/src/skills/workflows.ts +340 -0
  36. package/src/state.ts +77 -0
  37. package/src/tools.ts +134 -0
  38. package/src/types.ts +314 -0
  39. package/src/workflow.ts +341 -0
  40. package/src/workflows/coding.ts +580 -0
  41. package/src/workflows/index.ts +61 -0
  42. package/src/workflows/trading.ts +608 -0
package/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # @ebowwa/daemons
2
+
3
+ Autonomous agent daemon framework with hooks, tools, and teammates.
4
+
5
+ ## Overview
6
+
7
+ Daemons is an autonomous AI agent daemon framework. It implements the **SLAM pattern** (State → Loop → Action → Memory) for relentless task execution.
8
+
9
+ ### Features
10
+
11
+ - **AI Integration**: Uses `@ebowwa/ai` for LLM API calls
12
+ - **SLAM Pattern**: State → Loop → Action → Memory execution model
13
+ - **Hook System**: Pre/post tool use, subagent lifecycle, iteration events
14
+ - **Tool Access**: MCP server integration for tool execution
15
+ - **Multi-Agent Coordination**: Uses `@ebowwa/teammates` for parallel execution
16
+ - **Git Worktree Isolation**: Parallel task execution in isolated environments
17
+ - **State Persistence**: Crash recovery with JSON state files
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ bun add @ebowwa/daemons
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```typescript
28
+ import { startDaemon } from "@ebowwa/daemons";
29
+
30
+ const teamName = await startDaemon(
31
+ {
32
+ teamName: "my-agent",
33
+ cwd: process.cwd(),
34
+ model: "glm-4.7",
35
+ enableWorktree: true,
36
+ autoCommit: true,
37
+ completionPromise: "TASK_COMPLETE",
38
+ },
39
+ "Build a REST API for user authentication"
40
+ );
41
+
42
+ console.log(`Daemon started: ${teamName}`);
43
+ ```
44
+
45
+ ## Architecture
46
+
47
+ ### SLAM Pattern
48
+
49
+ GLM Daemon follows the SLAM pattern for autonomous execution:
50
+
51
+ ```
52
+ State → Loop → Action → Memory
53
+ ```
54
+
55
+ **Phases:**
56
+ 1. **Planning** - Break task into subtasks
57
+ 2. **Executing** - Work on current subtask
58
+ 3. **Paranoid** - Quality check after every edit
59
+ 4. **Reviewing** - Final quality review
60
+ 5. **Fixing** - Fix issues found
61
+ 6. **Committing** - Commit changes
62
+ 7. **Complete** - Task finished
63
+
64
+ ### State File
65
+
66
+ State is persisted to `.glm-daemon.json` in the working directory:
67
+
68
+ ```json
69
+ {
70
+ "prompt": "the original task",
71
+ "promise": "TASK_COMPLETE",
72
+ "iteration": 0,
73
+ "maxIterations": 0,
74
+ "startTime": "2026-02-06T04:30:00.000Z",
75
+ "lastUpdate": "2026-02-06T04:30:00.000Z",
76
+ "tokens": {
77
+ "totalInput": 0,
78
+ "totalOutput": 0
79
+ },
80
+ "slam": {
81
+ "enabled": true,
82
+ "phase": "planning",
83
+ "subtasks": [],
84
+ "currentSubtask": null,
85
+ "completedSubtasks": []
86
+ },
87
+ "git": {
88
+ "enabled": true,
89
+ "autoCommit": true,
90
+ "autoPR": false
91
+ }
92
+ }
93
+ ```
94
+
95
+ ## Configuration
96
+
97
+ ```typescript
98
+ interface GLMDaemonConfig {
99
+ teamName: string; // Team name for coordination
100
+ model?: string; // GLM model (default: glm-4.7)
101
+ cwd: string; // Working directory
102
+ enableWorktree?: boolean; // Git worktree isolation
103
+ autoCommit?: boolean; // Auto-commit changes
104
+ autoPR?: boolean; // Auto-create PR
105
+ baseBranch?: string; // Base branch for PR
106
+ maxIterations?: number; // Max iterations (0 = unlimited)
107
+ completionPromise?: string; // Completion text
108
+ hooks?: GLMHooksConfig; // Hook configuration
109
+ tools?: GLMToolsConfig; // Tool configuration
110
+ }
111
+ ```
112
+
113
+ ## Hooks
114
+
115
+ Configure hooks for lifecycle events:
116
+
117
+ ```typescript
118
+ const daemon = await createGLMDaemon({
119
+ teamName: "my-agent",
120
+ cwd: process.cwd(),
121
+ hooks: {
122
+ onSessionStart: async (state) => {
123
+ console.log("Session starting:", state.prompt);
124
+ },
125
+ onPreToolUse: async (tool, args) => {
126
+ console.log("Using tool:", tool);
127
+ return true; // Allow tool use
128
+ },
129
+ onIterationEnd: async (iteration, result) => {
130
+ console.log("Iteration complete:", iteration);
131
+ },
132
+ },
133
+ });
134
+ ```
135
+
136
+ Available hooks:
137
+ - `onSessionStart` - Session begins
138
+ - `onSessionEnd` - Session ends
139
+ - `onPreToolUse` - Before tool use (can block)
140
+ - `onPostToolUse` - After tool use
141
+ - `onSubagentStart` - Subagent spawns
142
+ - `onSubagentStop` - Subagent stops
143
+ - `onIterationStart` - Iteration begins
144
+ - `onIterationEnd` - Iteration ends
145
+
146
+ ## Tools
147
+
148
+ GLM Daemon integrates with MCP servers for tool access:
149
+
150
+ ```typescript
151
+ const daemon = await createGLMDaemon({
152
+ teamName: "my-agent",
153
+ cwd: process.cwd(),
154
+ tools: {
155
+ enableMCP: true,
156
+ allowedTools: ["Read", "Write", "Edit", "Bash"],
157
+ toolTimeout: 30000,
158
+ maxRetries: 3,
159
+ },
160
+ });
161
+ ```
162
+
163
+ ## Multi-Agent Coordination
164
+
165
+ GLM Daemon uses `@ebowwa/teammates` for multi-agent coordination:
166
+
167
+ ```typescript
168
+ import { Team, Teammate } from "@ebowwa/teammates";
169
+
170
+ const team = await Team.create({
171
+ name: "my-team",
172
+ description: "Build a REST API",
173
+ });
174
+
175
+ const explorer = await Teammate.create("my-team", {
176
+ name: "explorer",
177
+ subagentType: "Explore",
178
+ prompt: "Explore the codebase",
179
+ model: "glm-4.7",
180
+ });
181
+
182
+ await explorer.sendTo("team-lead", "Found 50 TypeScript files");
183
+ ```
184
+
185
+ ## Git Worktree Isolation
186
+
187
+ For parallel task execution, use git worktrees:
188
+
189
+ ```typescript
190
+ const daemon = await createGLMDaemon({
191
+ teamName: "my-agent",
192
+ cwd: process.cwd(),
193
+ enableWorktree: true,
194
+ autoCommit: true,
195
+ });
196
+
197
+ // Creates worktree at: worktrees/glm-1234567890/
198
+ // Creates feature branch: feat/glm-1234567890
199
+ ```
200
+
201
+ ## API Reference
202
+
203
+ ### Classes
204
+
205
+ #### `GLMDaemon`
206
+
207
+ Main daemon orchestrator.
208
+
209
+ **Methods:**
210
+ - `start(prompt: string)` - Start daemon with a prompt
211
+ - `stop()` - Stop the daemon
212
+ - `getStatus()` - Get current status
213
+
214
+ #### `GLMAgent`
215
+
216
+ Individual GLM-powered agent.
217
+
218
+ **Methods:**
219
+ - `execute(prompt: string)` - Execute a prompt
220
+ - `executeTool(toolName: string, args)` - Execute a tool
221
+ - `registerTool(name, handler)` - Register a tool
222
+
223
+ #### `HookSystem`
224
+
225
+ Hook lifecycle management.
226
+
227
+ **Methods:**
228
+ - `register(event, handler)` - Register a hook
229
+ - `execute(event, ...args)` - Execute hooks for event
230
+ - `clear(event)` - Clear hooks for event
231
+
232
+ #### `ToolBridge`
233
+
234
+ MCP tool integration.
235
+
236
+ **Methods:**
237
+ - `getAvailableTools()` - Get available tools
238
+ - `isToolAllowed(toolName)` - Check if tool is allowed
239
+ - `executeTool(toolName, args)` - Execute a tool
240
+
241
+ #### `StateManager`
242
+
243
+ State persistence.
244
+
245
+ **Methods:**
246
+ - `load()` - Load state from disk
247
+ - `save(state)` - Save state to disk
248
+ - `update(updates)` - Update state (merge)
249
+ - `delete()` - Delete state file
250
+
251
+ #### `WorktreeManager`
252
+
253
+ Git worktree isolation.
254
+
255
+ **Methods:**
256
+ - `createWorktree()` - Create a new worktree
257
+ - `createBranch()` - Create a feature branch
258
+ - `commitChanges(options)` - Commit changes
259
+ - `createPullRequest(options)` - Create PR
260
+ - `cleanup()` - Clean up worktree
261
+
262
+ ## License
263
+
264
+ MIT