@ebowwa/daemons 0.5.0 → 0.7.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/dist/core.d.ts +89 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +346 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -125340
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +36 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +19 -63
- package/src/core.ts +476 -0
- package/src/index.ts +23 -101
- package/src/types.ts +24 -301
- package/dist/bin/discord-cli.js +0 -124118
- package/dist/bin/manager.js +0 -143
- package/dist/bin/telegram-cli.js +0 -124114
- package/src/agent.ts +0 -111
- package/src/channels/base.ts +0 -573
- package/src/channels/discord.ts +0 -306
- package/src/channels/index.ts +0 -169
- package/src/channels/telegram.ts +0 -315
- package/src/daemon.ts +0 -534
- package/src/hooks.ts +0 -97
- package/src/memory.ts +0 -369
- package/src/skills/coding/commit.ts +0 -202
- package/src/skills/coding/execute-subtask.ts +0 -136
- package/src/skills/coding/fix-issues.ts +0 -126
- package/src/skills/coding/index.ts +0 -26
- package/src/skills/coding/plan-task.ts +0 -158
- package/src/skills/coding/quality-check.ts +0 -155
- package/src/skills/index.ts +0 -65
- package/src/skills/registry.ts +0 -380
- package/src/skills/shared/index.ts +0 -21
- package/src/skills/shared/reflect.ts +0 -156
- package/src/skills/shared/review.ts +0 -201
- package/src/skills/shared/trajectory.ts +0 -319
- package/src/skills/trading/analyze-market.ts +0 -144
- package/src/skills/trading/check-risk.ts +0 -176
- package/src/skills/trading/execute-trade.ts +0 -185
- package/src/skills/trading/generate-signal.ts +0 -160
- package/src/skills/trading/index.ts +0 -26
- package/src/skills/trading/monitor-position.ts +0 -179
- package/src/skills/types.ts +0 -235
- package/src/skills/workflows.ts +0 -340
- package/src/state.ts +0 -77
- package/src/tools.ts +0 -134
- package/src/workflow.ts +0 -341
- package/src/workflows/coding.ts +0 -580
- package/src/workflows/index.ts +0 -61
- package/src/workflows/trading.ts +0 -608
package/src/index.ts
CHANGED
|
@@ -1,111 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @ebowwa/daemons
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Framework for building daemons.
|
|
5
|
+
* Provides DaemonCore primitive with lifecycle, signals, channels, HTTP API, state persistence.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { DaemonCore } from "@ebowwa/daemons";
|
|
10
|
+
*
|
|
11
|
+
* class MyDaemon extends DaemonCore {
|
|
12
|
+
* async start() {
|
|
13
|
+
* // Register channels, set up handlers
|
|
14
|
+
* await super.start();
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
7
18
|
*
|
|
8
19
|
* @module @ebowwa/daemons
|
|
9
20
|
*/
|
|
10
21
|
|
|
11
|
-
//
|
|
12
|
-
export { GLMDaemon, type GLMDaemonConfigWithWorkflow } from "./daemon.js";
|
|
13
|
-
|
|
14
|
-
// Agent class
|
|
15
|
-
export { GLMAgent } from "./agent.js";
|
|
16
|
-
|
|
17
|
-
// Supporting systems
|
|
18
|
-
export { HookSystem } from "./hooks.js";
|
|
19
|
-
export { ToolBridge } from "./tools.js";
|
|
20
|
-
export { StateManager } from "./state.js";
|
|
21
|
-
|
|
22
|
-
// Workflow system
|
|
23
|
-
export {
|
|
24
|
-
// Classes
|
|
25
|
-
BaseWorkflow,
|
|
26
|
-
WorkflowRegistry,
|
|
27
|
-
workflowRegistry,
|
|
28
|
-
// Functions
|
|
29
|
-
initializeWorkflows,
|
|
30
|
-
getWorkflow,
|
|
31
|
-
getDefaultWorkflow,
|
|
32
|
-
// Built-in workflows
|
|
33
|
-
CodingWorkflow,
|
|
34
|
-
codingWorkflow,
|
|
35
|
-
CODING_PHASES,
|
|
36
|
-
CODING_TRANSITIONS,
|
|
37
|
-
CODING_WORKFLOW_CONFIG,
|
|
38
|
-
TradingWorkflow,
|
|
39
|
-
tradingWorkflow,
|
|
40
|
-
TRADING_PHASES,
|
|
41
|
-
TRADING_TRANSITIONS,
|
|
42
|
-
TRADING_WORKFLOW_CONFIG,
|
|
43
|
-
// Types
|
|
44
|
-
type GLMWorkflowPhase,
|
|
45
|
-
type GLMWorkflowContext,
|
|
46
|
-
type GLMWorkflowPhaseResult,
|
|
47
|
-
type GLMWorkflowTransition,
|
|
48
|
-
type GLMWorkflowConfig,
|
|
49
|
-
type GLMWorkflowExecutor,
|
|
50
|
-
type CodingPhase,
|
|
51
|
-
type TradingPhase,
|
|
52
|
-
} from "./workflows/index.js";
|
|
53
|
-
|
|
54
|
-
// Built-in tools - re-exported from @ebowwa/ai/tools for convenience
|
|
22
|
+
// Generic daemon core
|
|
55
23
|
export {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
type ToolCall,
|
|
64
|
-
type ToolExecutorOptions,
|
|
65
|
-
type ToolExecutionResult,
|
|
66
|
-
} from "@ebowwa/ai/tools";
|
|
67
|
-
|
|
68
|
-
// Memory systems
|
|
69
|
-
export {
|
|
70
|
-
ConversationMemory,
|
|
71
|
-
NumericConversationMemory,
|
|
72
|
-
StringConversationMemory,
|
|
73
|
-
type ConversationMessage,
|
|
74
|
-
type ConversationMemoryConfig,
|
|
75
|
-
} from "./memory.js";
|
|
76
|
-
|
|
77
|
-
// Communication channels
|
|
78
|
-
export {
|
|
79
|
-
BaseChannel,
|
|
80
|
-
TelegramChannel,
|
|
81
|
-
DiscordChannel,
|
|
82
|
-
ChannelRegistry,
|
|
83
|
-
type BaseChannelConfig,
|
|
84
|
-
type TelegramChannelConfig,
|
|
85
|
-
type DiscordChannelConfig,
|
|
86
|
-
type MessageContext,
|
|
87
|
-
type RouteResult,
|
|
88
|
-
type MessageClassification,
|
|
89
|
-
} from "./channels/index.js";
|
|
24
|
+
DaemonCore,
|
|
25
|
+
type DaemonCoreConfig,
|
|
26
|
+
type DaemonCoreState,
|
|
27
|
+
type CoreHookName,
|
|
28
|
+
type CoreHookCallback,
|
|
29
|
+
type DaemonPlugin,
|
|
30
|
+
} from "./core.js";
|
|
90
31
|
|
|
91
32
|
// Types
|
|
92
33
|
export * from "./types.js";
|
|
93
|
-
|
|
94
|
-
// Convenience function to create and start a daemon
|
|
95
|
-
import { GLMDaemon } from "./daemon.js";
|
|
96
|
-
import type { GLMDaemonConfig } from "./types.js";
|
|
97
|
-
|
|
98
|
-
export async function createGLMDaemon(
|
|
99
|
-
config: GLMDaemonConfig
|
|
100
|
-
): Promise<GLMDaemon> {
|
|
101
|
-
const daemon = new GLMDaemon(config);
|
|
102
|
-
return daemon;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export async function startGLMDaemon(
|
|
106
|
-
config: GLMDaemonConfig,
|
|
107
|
-
prompt: string
|
|
108
|
-
): Promise<string> {
|
|
109
|
-
const daemon = new GLMDaemon(config);
|
|
110
|
-
return await daemon.start(prompt);
|
|
111
|
-
}
|
package/src/types.ts
CHANGED
|
@@ -1,314 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Daemons - Core Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Based on Ralph Iterative's SLAM pattern (State → Loop → Action → Memory).
|
|
4
|
+
* Minimal types for DaemonCore and VPSDaemon.
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
// ============================================================
|
|
8
|
+
// Generic Daemon Types
|
|
9
|
+
// ============================================================
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
* GLM Daemon state phases (SLAM pattern)
|
|
12
|
-
* @deprecated Skills now use string IDs directly (e.g., "/plan-task")
|
|
13
|
-
*/
|
|
14
|
-
export const GLM_PHASES = {
|
|
15
|
-
planning: "planning",
|
|
16
|
-
executing: "executing",
|
|
17
|
-
reflecting: "reflecting", // Checkpoint after N tools
|
|
18
|
-
paranoid: "paranoid",
|
|
19
|
-
reviewing: "reviewing",
|
|
20
|
-
fixing: "fixing",
|
|
21
|
-
committing: "committing",
|
|
22
|
-
complete: "complete",
|
|
23
|
-
} as const;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Legacy phase type for backwards compatibility
|
|
27
|
-
* @deprecated Skills now use string IDs (e.g., "/plan-task", "/execute-subtask")
|
|
28
|
-
*/
|
|
29
|
-
export type GLMPhase = keyof typeof GLM_PHASES;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* GLM Daemon configuration
|
|
33
|
-
*/
|
|
34
|
-
export interface GLMDaemonConfig {
|
|
35
|
-
/** Team name for multi-agent coordination */
|
|
36
|
-
teamName: string;
|
|
37
|
-
|
|
38
|
-
/** GLM model to use */
|
|
39
|
-
model?: string;
|
|
40
|
-
|
|
41
|
-
/** Working directory */
|
|
42
|
-
cwd: string;
|
|
11
|
+
export type DaemonStatus = "starting" | "running" | "stopping" | "stopped" | "error";
|
|
43
12
|
|
|
44
|
-
|
|
45
|
-
autoCommit?: boolean;
|
|
46
|
-
|
|
47
|
-
/** Enable automatic PR creation */
|
|
48
|
-
autoPR?: boolean;
|
|
49
|
-
|
|
50
|
-
/** Base branch for PRs */
|
|
51
|
-
baseBranch?: string;
|
|
52
|
-
|
|
53
|
-
/** Maximum iterations (0 = unlimited) */
|
|
54
|
-
maxIterations?: number;
|
|
55
|
-
|
|
56
|
-
/** Completion promise text */
|
|
57
|
-
completionPromise?: string;
|
|
58
|
-
|
|
59
|
-
/** Hooks configuration */
|
|
60
|
-
hooks?: GLMHooksConfig;
|
|
61
|
-
|
|
62
|
-
/** Tools configuration */
|
|
63
|
-
tools?: GLMToolsConfig;
|
|
64
|
-
|
|
65
|
-
/** Reflection checkpoint configuration */
|
|
66
|
-
reflection?: GLMReflectionConfig;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* GLM Daemon state (persisted to disk)
|
|
71
|
-
*/
|
|
72
|
-
export interface GLMDaemonState {
|
|
73
|
-
/** Original prompt/task */
|
|
74
|
-
prompt: string;
|
|
75
|
-
|
|
76
|
-
/** Completion promise (when to stop) */
|
|
77
|
-
promise: string;
|
|
78
|
-
|
|
79
|
-
/** Current iteration */
|
|
80
|
-
iteration: number;
|
|
81
|
-
|
|
82
|
-
/** Maximum iterations */
|
|
83
|
-
maxIterations: number;
|
|
84
|
-
|
|
85
|
-
/** Start timestamp */
|
|
86
|
-
startTime: string;
|
|
87
|
-
|
|
88
|
-
/** Last update timestamp */
|
|
89
|
-
lastUpdate: string;
|
|
90
|
-
|
|
91
|
-
/** Token usage tracking */
|
|
92
|
-
tokens: {
|
|
93
|
-
totalInput: number;
|
|
94
|
-
totalOutput: number;
|
|
95
|
-
byIteration: Array<{
|
|
96
|
-
iteration: number;
|
|
97
|
-
input: number;
|
|
98
|
-
output: number;
|
|
99
|
-
}>;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/** Files changed in this session */
|
|
103
|
-
filesChanged: string[];
|
|
104
|
-
|
|
105
|
-
/** Working memory */
|
|
106
|
-
workMemory: {
|
|
107
|
-
completedFiles: string[];
|
|
108
|
-
fileChecksums: Record<string, string>;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
/** SLAM state */
|
|
112
|
-
slam: {
|
|
113
|
-
enabled: boolean;
|
|
114
|
-
/** Current skill ID (e.g., "/plan-task", "/execute-subtask") or legacy phase */
|
|
115
|
-
phase: string;
|
|
116
|
-
/** Previous phase/skill (used to return after reflection) */
|
|
117
|
-
previousPhase?: string;
|
|
118
|
-
state: {
|
|
119
|
-
currentTask: string;
|
|
120
|
-
beliefs: Record<string, unknown>;
|
|
121
|
-
goals: string[];
|
|
122
|
-
};
|
|
123
|
-
subtasks: GLMSubtask[];
|
|
124
|
-
currentSubtask: string | null;
|
|
125
|
-
completedSubtasks: string[];
|
|
126
|
-
memory: {
|
|
127
|
-
actionsTaken: string[];
|
|
128
|
-
outcomes: Record<string, unknown>;
|
|
129
|
-
patterns: Record<string, unknown>;
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/** Git configuration */
|
|
134
|
-
git: {
|
|
135
|
-
enabled: boolean;
|
|
136
|
-
autoCommit: boolean;
|
|
137
|
-
autoPR: boolean;
|
|
138
|
-
baseBranch: string;
|
|
139
|
-
branchName: string;
|
|
140
|
-
branchCreated: boolean;
|
|
141
|
-
currentCommit: string;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/** Reflection checkpoint state */
|
|
145
|
-
reflection: {
|
|
146
|
-
/** Current tool call count in this chunk */
|
|
147
|
-
toolCount: number;
|
|
148
|
-
/** Total tool calls across all chunks */
|
|
149
|
-
totalToolCount: number;
|
|
150
|
-
/** Number of reflection checkpoints completed */
|
|
151
|
-
checkpointCount: number;
|
|
152
|
-
/** Timestamp of last reflection */
|
|
153
|
-
lastReflection: string | null;
|
|
154
|
-
/** Accumulated TL;DR summaries */
|
|
155
|
-
summaries: GLMReflectionSummary[];
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
/** Machine info */
|
|
159
|
-
machine?: {
|
|
160
|
-
cpu: { count: number; model: string; tier: string };
|
|
161
|
-
memory: { total: number; free: number; tier: string };
|
|
162
|
-
disk: { total: number; available: number; tier: string };
|
|
163
|
-
platform: { os: string; arch: string; isContainer: boolean };
|
|
164
|
-
capacity: string;
|
|
165
|
-
score: number;
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* GLM Subtask (for SLAM coordination)
|
|
171
|
-
*/
|
|
172
|
-
export interface GLMSubtask {
|
|
13
|
+
export interface Channel {
|
|
173
14
|
id: string;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
15
|
+
type: string;
|
|
16
|
+
start(): Promise<void>;
|
|
17
|
+
stop(): Promise<void>;
|
|
18
|
+
isRunning(): boolean;
|
|
19
|
+
send?(message: unknown): Promise<unknown>;
|
|
20
|
+
onMessage(handler: (msg: unknown) => Promise<void>): void;
|
|
180
21
|
}
|
|
181
22
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
onPreToolUse?: (tool: string, args: unknown) => Promise<boolean>;
|
|
189
|
-
onPostToolUse?: (tool: string, args: unknown, result: unknown) => Promise<void>;
|
|
190
|
-
onSubagentStart?: (subagentId: string) => Promise<void>;
|
|
191
|
-
onSubagentStop?: (subagentId: string, result: unknown) => Promise<void>;
|
|
192
|
-
onIterationStart?: (iteration: number) => Promise<void>;
|
|
193
|
-
onIterationEnd?: (iteration: number, result: unknown) => Promise<void>;
|
|
194
|
-
/** Called at each reflection checkpoint */
|
|
195
|
-
onReflection?: (state: GLMDaemonState, summary: GLMReflectionSummary) => Promise<void>;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* GLM Tools configuration
|
|
200
|
-
*/
|
|
201
|
-
export interface GLMToolsConfig {
|
|
202
|
-
/** Enable MCP tool access */
|
|
203
|
-
enableMCP?: boolean;
|
|
204
|
-
|
|
205
|
-
/** Allowed tools (whitelist) */
|
|
206
|
-
allowedTools?: string[];
|
|
207
|
-
|
|
208
|
-
/** Blocked tools (blacklist) */
|
|
209
|
-
blockedTools?: string[];
|
|
210
|
-
|
|
211
|
-
/** Tool timeout in ms */
|
|
212
|
-
toolTimeout?: number;
|
|
213
|
-
|
|
214
|
-
/** Max retries for failed tools */
|
|
215
|
-
maxRetries?: number;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Reflection checkpoint configuration
|
|
220
|
-
* Triggers TL;DR summary after N tool calls
|
|
221
|
-
*/
|
|
222
|
-
export interface GLMReflectionConfig {
|
|
223
|
-
/** Enable reflection checkpoints */
|
|
224
|
-
enabled: boolean;
|
|
225
|
-
|
|
226
|
-
/** Number of tools before reflection (default: 50) */
|
|
227
|
-
toolLimit: number;
|
|
228
|
-
|
|
229
|
-
/** Auto-continue after reflection (default: true) */
|
|
230
|
-
autoContinue: boolean;
|
|
231
|
-
|
|
232
|
-
/** Save reflection summaries to file */
|
|
233
|
-
saveToFile?: string;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* GLM Agent (individual GLM-powered agent)
|
|
238
|
-
*/
|
|
239
|
-
export interface GLMAgentConfig {
|
|
240
|
-
/** Agent ID */
|
|
241
|
-
agentId: string;
|
|
242
|
-
|
|
243
|
-
/** Agent name */
|
|
244
|
-
name: string;
|
|
245
|
-
|
|
246
|
-
/** System prompt */
|
|
247
|
-
prompt: string;
|
|
248
|
-
|
|
249
|
-
/** Model to use */
|
|
250
|
-
model?: string;
|
|
251
|
-
|
|
252
|
-
/** Temperature (0-1) */
|
|
253
|
-
temperature?: number;
|
|
254
|
-
|
|
255
|
-
/** Max tokens */
|
|
256
|
-
maxTokens?: number;
|
|
257
|
-
|
|
258
|
-
/** Tools this agent can use */
|
|
259
|
-
tools?: string[];
|
|
260
|
-
|
|
261
|
-
/** Assigned subtasks */
|
|
262
|
-
assignedSubtasks?: string[];
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* GLM Tool execution result
|
|
267
|
-
* @deprecated Use ToolExecutionResult from @ebowwa/codespaces-types/runtime/tools
|
|
268
|
-
*/
|
|
269
|
-
export interface GLMToolResult {
|
|
270
|
-
success: boolean;
|
|
271
|
-
result?: unknown;
|
|
272
|
-
error?: string;
|
|
273
|
-
duration: number;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Reflection summary generated at checkpoint
|
|
278
|
-
*/
|
|
279
|
-
export interface GLMReflectionSummary {
|
|
280
|
-
/** Checkpoint number */
|
|
281
|
-
checkpoint: number;
|
|
282
|
-
/** Timestamp */
|
|
23
|
+
export interface ChannelMessage {
|
|
24
|
+
id: string;
|
|
25
|
+
channelId: string;
|
|
26
|
+
type: "text" | "command" | "event";
|
|
27
|
+
content: string;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
283
29
|
timestamp: string;
|
|
284
|
-
/** Tools used in this chunk */
|
|
285
|
-
toolsUsed: number;
|
|
286
|
-
/** Phase/skill when reflection occurred */
|
|
287
|
-
phase: string;
|
|
288
|
-
/** TL;DR summary */
|
|
289
|
-
summary: string;
|
|
290
|
-
/** Key accomplishments */
|
|
291
|
-
accomplishments: string[];
|
|
292
|
-
/** Next steps identified */
|
|
293
|
-
nextSteps: string[];
|
|
294
|
-
/** Issues/blockers found */
|
|
295
|
-
issues: string[];
|
|
296
30
|
}
|
|
297
31
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
status: "starting" | "running" | "complete" | "error" | "stopped";
|
|
304
|
-
/** Current skill ID or phase */
|
|
305
|
-
phase: string;
|
|
306
|
-
iteration: number;
|
|
307
|
-
prompt: string;
|
|
308
|
-
currentTask?: string;
|
|
309
|
-
totalSubtasks: number;
|
|
310
|
-
completedSubtasks: number;
|
|
311
|
-
startedAt: string;
|
|
312
|
-
lastUpdate: string;
|
|
313
|
-
processId?: number;
|
|
32
|
+
export interface HealthStatus {
|
|
33
|
+
status: "healthy" | "degraded" | "unhealthy";
|
|
34
|
+
uptime: number;
|
|
35
|
+
channels: Record<string, { running: boolean; error?: string }>;
|
|
36
|
+
checks: Record<string, { passed: boolean; message?: string }>;
|
|
314
37
|
}
|