@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/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@ebowwa/daemons",
3
+ "version": "0.5.0",
4
+ "description": "Cross-platform daemon management and AI orchestration (systemd, launchd, schtasks)",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "daemons-telegram": "./dist/bin/telegram-cli.js",
10
+ "daemons-discord": "./dist/bin/discord-cli.js",
11
+ "daemons-manager": "./dist/bin/manager.js"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./daemon": {
19
+ "types": "./dist/daemon.d.ts",
20
+ "import": "./dist/daemon.js"
21
+ },
22
+ "./agent": {
23
+ "types": "./dist/agent.d.ts",
24
+ "import": "./dist/agent.js"
25
+ },
26
+ "./hooks": {
27
+ "types": "./dist/hooks.d.ts",
28
+ "import": "./dist/hooks.js"
29
+ },
30
+ "./tools": {
31
+ "types": "./dist/tools.d.ts",
32
+ "import": "./dist/tools.js"
33
+ },
34
+ "./state": {
35
+ "types": "./dist/state.d.ts",
36
+ "import": "./dist/state.js"
37
+ },
38
+ "./channels": {
39
+ "types": "./dist/channels/index.d.ts",
40
+ "import": "./dist/channels/index.js"
41
+ }
42
+ },
43
+ "scripts": {
44
+ "build": "bun build ./src/index.ts --outdir ./dist --target bun --format esm && bun build ./bin/telegram-cli.ts --outdir ./dist/bin --target bun && bun build ./bin/discord-cli.ts --outdir ./dist/bin --target bun && bun build ./bin/manager.ts --outdir ./dist/bin --target bun",
45
+ "build:types": "tsc --emitDeclarationOnly --skipLibCheck",
46
+ "dev": "bun --watch src/index.ts",
47
+ "test": "bun test",
48
+ "lint": "eslint src --ext .ts",
49
+ "clean": "rm -rf dist",
50
+ "telegram": "bun run dist/bin/telegram-cli.js",
51
+ "discord": "bun run dist/bin/discord-cli.js",
52
+ "manager": "bun run dist/bin/manager.js",
53
+ "status": "bun run dist/bin/manager.js status"
54
+ },
55
+ "dependencies": {
56
+ "@ebowwa/ai": "^0.3.0",
57
+ "@ebowwa/channel-telegram": "^1.13.0",
58
+ "@ebowwa/channel-types": "^0.1.1",
59
+ "@ebowwa/codespaces-types": "^1.4.5",
60
+ "@ebowwa/structured-prompts": "^0.3.2",
61
+ "@ebowwa/teammates": "^0.1.2",
62
+ "discord.js": "^14.16.3",
63
+ "zod": "^4.3.5"
64
+ },
65
+ "devDependencies": {
66
+ "@types/bun": "catalog:dev",
67
+ "@types/node": "catalog:dev",
68
+ "typescript": "catalog:",
69
+ "bun-types": "catalog:dev"
70
+ },
71
+ "files": [
72
+ "dist",
73
+ "src",
74
+ "README.md"
75
+ ],
76
+ "keywords": [
77
+ "glm",
78
+ "daemon",
79
+ "agent",
80
+ "autonomous",
81
+ "ai",
82
+ "telegram",
83
+ "discord",
84
+ "bot",
85
+ "chatbot",
86
+ "channels"
87
+ ],
88
+ "peerDependencies": {
89
+ "@ebowwa/trajectory": ">=0.1.0"
90
+ },
91
+ "optionalDependencies": {
92
+ "@ebowwa/trajectory": "^0.1.0"
93
+ }
94
+ }
package/src/agent.ts ADDED
@@ -0,0 +1,111 @@
1
+ /**
2
+ * GLM Agent - Individual GLM-powered agent
3
+ *
4
+ * Wraps GLM 4.7 API with tool access and hook integration.
5
+ */
6
+
7
+ import type { GLMAgentConfig, GLMToolResult } from "./types.js";
8
+ import { GLMClient } from "@ebowwa/ai";
9
+ import type { ChatMessage } from "@ebowwa/codespaces-types/runtime/ai";
10
+
11
+ export class GLMAgent {
12
+ private config: GLMAgentConfig;
13
+ private client: GLMClient;
14
+ private tools: Map<string, (args: unknown) => Promise<unknown>> = new Map();
15
+
16
+ constructor(config: GLMAgentConfig) {
17
+ this.config = config;
18
+ this.client = new GLMClient();
19
+ }
20
+
21
+ /**
22
+ * Execute a prompt and get response
23
+ */
24
+ async execute(prompt: string, tools?: Record<string, unknown>): Promise<string> {
25
+ const messages: ChatMessage[] = [
26
+ {
27
+ role: "system",
28
+ content: this.config.prompt,
29
+ },
30
+ {
31
+ role: "user",
32
+ content: prompt,
33
+ },
34
+ ];
35
+
36
+ // Add tool context if provided
37
+ if (tools) {
38
+ messages.push({
39
+ role: "user",
40
+ content: `\nAvailable tools: ${Object.keys(tools).join(", ")}`,
41
+ });
42
+ }
43
+
44
+ const response = await this.client.chatCompletion(messages, {
45
+ model: this.config.model || "glm-4.7",
46
+ temperature: this.config.temperature || 0.7,
47
+ maxTokens: this.config.maxTokens || 4096,
48
+ });
49
+
50
+ return response.choices[0]?.message?.content || "";
51
+ }
52
+
53
+ /**
54
+ * Execute a tool call
55
+ */
56
+ async executeTool(toolName: string, args: unknown): Promise<GLMToolResult> {
57
+ const start = Date.now();
58
+ const tool = this.tools.get(toolName);
59
+
60
+ if (!tool) {
61
+ return {
62
+ success: false,
63
+ error: `Tool not found: ${toolName}`,
64
+ duration: Date.now() - start,
65
+ };
66
+ }
67
+
68
+ try {
69
+ const result = await tool(args);
70
+ return {
71
+ success: true,
72
+ result,
73
+ duration: Date.now() - start,
74
+ };
75
+ } catch (error) {
76
+ return {
77
+ success: false,
78
+ error: error instanceof Error ? error.message : String(error),
79
+ duration: Date.now() - start,
80
+ };
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Register a tool
86
+ */
87
+ registerTool(name: string, handler: (args: unknown) => Promise<unknown>): void {
88
+ this.tools.set(name, handler);
89
+ }
90
+
91
+ /**
92
+ * Get available tools
93
+ */
94
+ getAvailableTools(): string[] {
95
+ return Array.from(this.tools.keys());
96
+ }
97
+
98
+ /**
99
+ * Get agent ID
100
+ */
101
+ get agentId(): string {
102
+ return this.config.agentId;
103
+ }
104
+
105
+ /**
106
+ * Get agent name
107
+ */
108
+ get name(): string {
109
+ return this.config.name;
110
+ }
111
+ }