background-agents 0.1.2 → 1.0.2

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 (236) hide show
  1. package/README.md +46 -297
  2. package/app/assets/icon.png +0 -0
  3. package/app/assets/tray-icon.png +0 -0
  4. package/app/assets/tray-icon.svg +4 -0
  5. package/app/dist/main.js +932 -0
  6. package/app/dist/preload.cjs +70 -0
  7. package/app/package.json +6 -0
  8. package/bin/background-agents.js +298 -0
  9. package/lib/ui.js +110 -0
  10. package/package.json +33 -57
  11. package/dist/agents/claude/index.d.ts +0 -11
  12. package/dist/agents/claude/index.d.ts.map +0 -1
  13. package/dist/agents/claude/index.js +0 -78
  14. package/dist/agents/claude/index.js.map +0 -1
  15. package/dist/agents/claude/parser.d.ts +0 -16
  16. package/dist/agents/claude/parser.d.ts.map +0 -1
  17. package/dist/agents/claude/parser.js +0 -87
  18. package/dist/agents/claude/parser.js.map +0 -1
  19. package/dist/agents/claude/tools.d.ts +0 -7
  20. package/dist/agents/claude/tools.d.ts.map +0 -1
  21. package/dist/agents/claude/tools.js +0 -15
  22. package/dist/agents/claude/tools.js.map +0 -1
  23. package/dist/agents/codex/index.d.ts +0 -11
  24. package/dist/agents/codex/index.d.ts.map +0 -1
  25. package/dist/agents/codex/index.js +0 -60
  26. package/dist/agents/codex/index.js.map +0 -1
  27. package/dist/agents/codex/parser.d.ts +0 -12
  28. package/dist/agents/codex/parser.d.ts.map +0 -1
  29. package/dist/agents/codex/parser.js +0 -108
  30. package/dist/agents/codex/parser.js.map +0 -1
  31. package/dist/agents/codex/tools.d.ts +0 -11
  32. package/dist/agents/codex/tools.d.ts.map +0 -1
  33. package/dist/agents/codex/tools.js +0 -40
  34. package/dist/agents/codex/tools.js.map +0 -1
  35. package/dist/agents/eliza/bundle-content.d.ts +0 -6
  36. package/dist/agents/eliza/bundle-content.d.ts.map +0 -1
  37. package/dist/agents/eliza/bundle-content.js +0 -7
  38. package/dist/agents/eliza/bundle-content.js.map +0 -1
  39. package/dist/agents/eliza/cli.bundle.js +0 -579
  40. package/dist/agents/eliza/cli.d.ts +0 -10
  41. package/dist/agents/eliza/cli.d.ts.map +0 -1
  42. package/dist/agents/eliza/cli.js +0 -342
  43. package/dist/agents/eliza/cli.js.map +0 -1
  44. package/dist/agents/eliza/index.d.ts +0 -22
  45. package/dist/agents/eliza/index.d.ts.map +0 -1
  46. package/dist/agents/eliza/index.js +0 -54
  47. package/dist/agents/eliza/index.js.map +0 -1
  48. package/dist/agents/eliza/parser.d.ts +0 -16
  49. package/dist/agents/eliza/parser.d.ts.map +0 -1
  50. package/dist/agents/eliza/parser.js +0 -67
  51. package/dist/agents/eliza/parser.js.map +0 -1
  52. package/dist/agents/eliza/patterns.d.ts +0 -41
  53. package/dist/agents/eliza/patterns.d.ts.map +0 -1
  54. package/dist/agents/eliza/patterns.js +0 -259
  55. package/dist/agents/eliza/patterns.js.map +0 -1
  56. package/dist/agents/eliza/tools.d.ts +0 -7
  57. package/dist/agents/eliza/tools.d.ts.map +0 -1
  58. package/dist/agents/eliza/tools.js +0 -14
  59. package/dist/agents/eliza/tools.js.map +0 -1
  60. package/dist/agents/gemini/index.d.ts +0 -11
  61. package/dist/agents/gemini/index.d.ts.map +0 -1
  62. package/dist/agents/gemini/index.js +0 -46
  63. package/dist/agents/gemini/index.js.map +0 -1
  64. package/dist/agents/gemini/parser.d.ts +0 -31
  65. package/dist/agents/gemini/parser.d.ts.map +0 -1
  66. package/dist/agents/gemini/parser.js +0 -106
  67. package/dist/agents/gemini/parser.js.map +0 -1
  68. package/dist/agents/gemini/tools.d.ts +0 -7
  69. package/dist/agents/gemini/tools.d.ts.map +0 -1
  70. package/dist/agents/gemini/tools.js +0 -23
  71. package/dist/agents/gemini/tools.js.map +0 -1
  72. package/dist/agents/goose/index.d.ts +0 -11
  73. package/dist/agents/goose/index.d.ts.map +0 -1
  74. package/dist/agents/goose/index.js +0 -73
  75. package/dist/agents/goose/index.js.map +0 -1
  76. package/dist/agents/goose/parser.d.ts +0 -24
  77. package/dist/agents/goose/parser.d.ts.map +0 -1
  78. package/dist/agents/goose/parser.js +0 -86
  79. package/dist/agents/goose/parser.js.map +0 -1
  80. package/dist/agents/goose/tools.d.ts +0 -10
  81. package/dist/agents/goose/tools.d.ts.map +0 -1
  82. package/dist/agents/goose/tools.js +0 -30
  83. package/dist/agents/goose/tools.js.map +0 -1
  84. package/dist/agents/index.d.ts +0 -27
  85. package/dist/agents/index.d.ts.map +0 -1
  86. package/dist/agents/index.js +0 -46
  87. package/dist/agents/index.js.map +0 -1
  88. package/dist/agents/opencode/index.d.ts +0 -12
  89. package/dist/agents/opencode/index.d.ts.map +0 -1
  90. package/dist/agents/opencode/index.js +0 -53
  91. package/dist/agents/opencode/index.js.map +0 -1
  92. package/dist/agents/opencode/parser.d.ts +0 -15
  93. package/dist/agents/opencode/parser.d.ts.map +0 -1
  94. package/dist/agents/opencode/parser.js +0 -71
  95. package/dist/agents/opencode/parser.js.map +0 -1
  96. package/dist/agents/opencode/tools.d.ts +0 -7
  97. package/dist/agents/opencode/tools.d.ts.map +0 -1
  98. package/dist/agents/opencode/tools.js +0 -10
  99. package/dist/agents/opencode/tools.js.map +0 -1
  100. package/dist/agents/openhands/index.d.ts +0 -17
  101. package/dist/agents/openhands/index.d.ts.map +0 -1
  102. package/dist/agents/openhands/index.js +0 -67
  103. package/dist/agents/openhands/index.js.map +0 -1
  104. package/dist/agents/openhands/parser.d.ts +0 -16
  105. package/dist/agents/openhands/parser.d.ts.map +0 -1
  106. package/dist/agents/openhands/parser.js +0 -93
  107. package/dist/agents/openhands/parser.js.map +0 -1
  108. package/dist/agents/openhands/tools.d.ts +0 -7
  109. package/dist/agents/openhands/tools.d.ts.map +0 -1
  110. package/dist/agents/openhands/tools.js +0 -24
  111. package/dist/agents/openhands/tools.js.map +0 -1
  112. package/dist/agents/pi/index.d.ts +0 -14
  113. package/dist/agents/pi/index.d.ts.map +0 -1
  114. package/dist/agents/pi/index.js +0 -54
  115. package/dist/agents/pi/index.js.map +0 -1
  116. package/dist/agents/pi/parser.d.ts +0 -21
  117. package/dist/agents/pi/parser.d.ts.map +0 -1
  118. package/dist/agents/pi/parser.js +0 -91
  119. package/dist/agents/pi/parser.js.map +0 -1
  120. package/dist/agents/pi/tools.d.ts +0 -8
  121. package/dist/agents/pi/tools.d.ts.map +0 -1
  122. package/dist/agents/pi/tools.js +0 -16
  123. package/dist/agents/pi/tools.js.map +0 -1
  124. package/dist/agents/picocode/index.d.ts +0 -18
  125. package/dist/agents/picocode/index.d.ts.map +0 -1
  126. package/dist/agents/picocode/index.js +0 -68
  127. package/dist/agents/picocode/index.js.map +0 -1
  128. package/dist/agents/picocode/parser.d.ts +0 -19
  129. package/dist/agents/picocode/parser.d.ts.map +0 -1
  130. package/dist/agents/picocode/parser.js +0 -104
  131. package/dist/agents/picocode/parser.js.map +0 -1
  132. package/dist/agents/picocode/tools.d.ts +0 -9
  133. package/dist/agents/picocode/tools.d.ts.map +0 -1
  134. package/dist/agents/picocode/tools.js +0 -27
  135. package/dist/agents/picocode/tools.js.map +0 -1
  136. package/dist/background/index.d.ts +0 -6
  137. package/dist/background/index.d.ts.map +0 -1
  138. package/dist/background/index.js +0 -5
  139. package/dist/background/index.js.map +0 -1
  140. package/dist/background/session.d.ts +0 -47
  141. package/dist/background/session.d.ts.map +0 -1
  142. package/dist/background/session.js +0 -481
  143. package/dist/background/session.js.map +0 -1
  144. package/dist/background/types.d.ts +0 -55
  145. package/dist/background/types.d.ts.map +0 -1
  146. package/dist/background/types.js +0 -5
  147. package/dist/background/types.js.map +0 -1
  148. package/dist/core/agent.d.ts +0 -95
  149. package/dist/core/agent.d.ts.map +0 -1
  150. package/dist/core/agent.js +0 -8
  151. package/dist/core/agent.js.map +0 -1
  152. package/dist/core/index.d.ts +0 -7
  153. package/dist/core/index.d.ts.map +0 -1
  154. package/dist/core/index.js +0 -6
  155. package/dist/core/index.js.map +0 -1
  156. package/dist/core/registry.d.ts +0 -48
  157. package/dist/core/registry.d.ts.map +0 -1
  158. package/dist/core/registry.js +0 -68
  159. package/dist/core/registry.js.map +0 -1
  160. package/dist/core/tools.d.ts +0 -31
  161. package/dist/core/tools.d.ts.map +0 -1
  162. package/dist/core/tools.js +0 -82
  163. package/dist/core/tools.js.map +0 -1
  164. package/dist/debug.d.ts +0 -7
  165. package/dist/debug.d.ts.map +0 -1
  166. package/dist/debug.js +0 -19
  167. package/dist/debug.js.map +0 -1
  168. package/dist/factory.d.ts +0 -28
  169. package/dist/factory.d.ts.map +0 -1
  170. package/dist/factory.js +0 -44
  171. package/dist/factory.js.map +0 -1
  172. package/dist/index.d.ts +0 -48
  173. package/dist/index.d.ts.map +0 -1
  174. package/dist/index.js +0 -62
  175. package/dist/index.js.map +0 -1
  176. package/dist/providers/base.d.ts +0 -187
  177. package/dist/providers/base.d.ts.map +0 -1
  178. package/dist/providers/base.js +0 -619
  179. package/dist/providers/base.js.map +0 -1
  180. package/dist/providers/claude.d.ts +0 -14
  181. package/dist/providers/claude.d.ts.map +0 -1
  182. package/dist/providers/claude.js +0 -122
  183. package/dist/providers/claude.js.map +0 -1
  184. package/dist/providers/codex.d.ts +0 -14
  185. package/dist/providers/codex.d.ts.map +0 -1
  186. package/dist/providers/codex.js +0 -160
  187. package/dist/providers/codex.js.map +0 -1
  188. package/dist/providers/gemini.d.ts +0 -16
  189. package/dist/providers/gemini.d.ts.map +0 -1
  190. package/dist/providers/gemini.js +0 -101
  191. package/dist/providers/gemini.js.map +0 -1
  192. package/dist/providers/index.d.ts +0 -6
  193. package/dist/providers/index.d.ts.map +0 -1
  194. package/dist/providers/index.js +0 -6
  195. package/dist/providers/index.js.map +0 -1
  196. package/dist/providers/opencode.d.ts +0 -14
  197. package/dist/providers/opencode.d.ts.map +0 -1
  198. package/dist/providers/opencode.js +0 -100
  199. package/dist/providers/opencode.js.map +0 -1
  200. package/dist/sandbox/daytona.d.ts +0 -8
  201. package/dist/sandbox/daytona.d.ts.map +0 -1
  202. package/dist/sandbox/daytona.js +0 -181
  203. package/dist/sandbox/daytona.js.map +0 -1
  204. package/dist/sandbox/index.d.ts +0 -14
  205. package/dist/sandbox/index.d.ts.map +0 -1
  206. package/dist/sandbox/index.js +0 -15
  207. package/dist/sandbox/index.js.map +0 -1
  208. package/dist/session.d.ts +0 -75
  209. package/dist/session.d.ts.map +0 -1
  210. package/dist/session.js +0 -117
  211. package/dist/session.js.map +0 -1
  212. package/dist/types/events.d.ts +0 -114
  213. package/dist/types/events.d.ts.map +0 -1
  214. package/dist/types/events.js +0 -50
  215. package/dist/types/events.js.map +0 -1
  216. package/dist/types/index.d.ts +0 -3
  217. package/dist/types/index.d.ts.map +0 -1
  218. package/dist/types/index.js +0 -3
  219. package/dist/types/index.js.map +0 -1
  220. package/dist/types/provider.d.ts +0 -67
  221. package/dist/types/provider.d.ts.map +0 -1
  222. package/dist/types/provider.js +0 -5
  223. package/dist/types/provider.js.map +0 -1
  224. package/dist/utils/index.d.ts +0 -3
  225. package/dist/utils/index.d.ts.map +0 -1
  226. package/dist/utils/index.js +0 -3
  227. package/dist/utils/index.js.map +0 -1
  228. package/dist/utils/install.d.ts +0 -37
  229. package/dist/utils/install.d.ts.map +0 -1
  230. package/dist/utils/install.js +0 -122
  231. package/dist/utils/install.js.map +0 -1
  232. package/dist/utils/json.d.ts +0 -8
  233. package/dist/utils/json.d.ts.map +0 -1
  234. package/dist/utils/json.js +0 -15
  235. package/dist/utils/json.js.map +0 -1
  236. package/src/index.ts +0 -156
@@ -1,579 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/agents/eliza/cli.ts
4
- import { randomUUID } from "node:crypto";
5
- import * as fs from "node:fs";
6
- import * as path from "node:path";
7
-
8
- // src/agents/eliza/patterns.ts
9
- var ELIZA_PATTERNS = [
10
- // Greeting patterns
11
- {
12
- pattern: /^(hello|hi|hey|greetings|good morning|good afternoon|good evening)[\s!.,?]*$/i,
13
- responses: [
14
- "Hello. How are you feeling today?",
15
- "Hi there. What brings you to therapy?",
16
- "Greetings. Tell me what's on your mind.",
17
- "Hello. Please tell me what's troubling you."
18
- ]
19
- },
20
- // "I am" patterns
21
- {
22
- pattern: /i am (.*)/i,
23
- responses: [
24
- "Why do you say you are {0}?",
25
- "How long have you been {0}?",
26
- "Do you believe it is normal to be {0}?",
27
- "Do you enjoy being {0}?"
28
- ]
29
- },
30
- // "I feel" patterns - triggers file writing
31
- {
32
- pattern: /i feel (.*)/i,
33
- responses: [
34
- "Tell me more about feeling {0}.",
35
- "Do you often feel {0}?",
36
- "What makes you feel {0}?",
37
- "When did you first notice feeling {0}?"
38
- ],
39
- fileAction: {
40
- type: "write",
41
- fileNameTemplate: "eliza_feeling_journal.txt",
42
- contentTemplate: "Session Note\n============\nPatient reported feeling: {0}\nDate: {date}\n\nThis feeling deserves further exploration in future sessions.\n\n"
43
- }
44
- },
45
- // Family patterns
46
- {
47
- pattern: /my (mother|father|mom|dad|family|parents|sister|brother) (.*)/i,
48
- responses: [
49
- "Tell me more about your {0}.",
50
- "How does that make you feel about your {0}?",
51
- "What else comes to mind when you think of your {0}?",
52
- "How is your relationship with your {0}?"
53
- ]
54
- },
55
- // Want/need patterns
56
- {
57
- pattern: /i (want|need) (.*)/i,
58
- responses: [
59
- "Why do you {0} {1}?",
60
- "What would it mean if you got {1}?",
61
- "Suppose you got {1} - what then?",
62
- "What is stopping you from getting {1}?"
63
- ]
64
- },
65
- // Can't patterns
66
- {
67
- pattern: /i can'?t (.*)/i,
68
- responses: [
69
- "What makes you think you can't {0}?",
70
- "Have you tried to {0}?",
71
- "Perhaps you could {0} if you tried.",
72
- "What would happen if you could {0}?"
73
- ]
74
- },
75
- // Because patterns
76
- {
77
- pattern: /because (.*)/i,
78
- responses: [
79
- "Is that the real reason?",
80
- "What other reasons might there be?",
81
- "Does that reason seem to explain anything else?",
82
- "Are you sure that's why?"
83
- ]
84
- },
85
- // Sorry patterns
86
- {
87
- pattern: /sorry/i,
88
- responses: [
89
- "There's no need to apologize.",
90
- "Apologies aren't necessary here.",
91
- "What feelings does apologizing bring up?",
92
- "Why do you feel the need to apologize?"
93
- ]
94
- },
95
- // Yes patterns
96
- {
97
- pattern: /^yes[\s!.,?]*$/i,
98
- responses: [
99
- "You seem quite sure.",
100
- "Tell me more about that.",
101
- "I see. Please continue.",
102
- "And how does that make you feel?"
103
- ]
104
- },
105
- // No patterns
106
- {
107
- pattern: /^no[\s!.,?]*$/i,
108
- responses: [
109
- "Why not?",
110
- "Are you sure about that?",
111
- "You seem quite certain.",
112
- "Can you tell me more about why not?"
113
- ]
114
- },
115
- // Dream patterns
116
- {
117
- pattern: /dream(s|ed|ing)? (about |of )?(.*)/i,
118
- responses: [
119
- "What do you think that dream means?",
120
- "Dreams can be very revealing. Tell me more.",
121
- "Do you often dream about {2}?",
122
- "How did that dream make you feel?"
123
- ]
124
- },
125
- // Think patterns
126
- {
127
- pattern: /i think (.*)/i,
128
- responses: [
129
- "Why do you think {0}?",
130
- "Do you really think so?",
131
- "But you're not sure {0}?",
132
- "What makes you think {0}?"
133
- ]
134
- },
135
- // Remember patterns
136
- {
137
- pattern: /i remember (.*)/i,
138
- responses: [
139
- "Why do you remember {0} now?",
140
- "What else do you remember?",
141
- "How does remembering {0} make you feel?",
142
- "Is that a significant memory for you?"
143
- ]
144
- },
145
- // File creation trigger - requires "file" or "note" keyword
146
- {
147
- pattern: /(?:create|make|write) (?:a )?(?:file|note) (?:called |named )?["']?([a-zA-Z0-9_\-\.]+)["']?/i,
148
- responses: ["I'll create that file for you as a therapeutic exercise."],
149
- fileAction: {
150
- type: "write",
151
- fileNameTemplate: "{0}",
152
- contentTemplate: "Therapeutic Note\n================\nCreated during ELIZA therapy session.\nDate: {date}\n\nUse this space to write your thoughts.\n"
153
- }
154
- },
155
- // File deletion trigger - requires "file" keyword to avoid matching general "delete" usage
156
- {
157
- pattern: /(?:delete|remove) (?:the )?file ["']?([a-zA-Z0-9_\-\.]+)["']?/i,
158
- responses: [
159
- "Sometimes letting go is therapeutic. I'll help you delete that."
160
- ],
161
- fileAction: {
162
- type: "delete",
163
- fileNameTemplate: "{0}"
164
- }
165
- },
166
- // File reading trigger - requires "file" keyword
167
- {
168
- pattern: /(?:read|show|open) (?:the )?file ["']?([a-zA-Z0-9_\-\.]+)["']?/i,
169
- responses: ["Let me read that file for you."],
170
- fileAction: {
171
- type: "read",
172
- fileNameTemplate: "{0}"
173
- }
174
- },
175
- // Question patterns
176
- {
177
- pattern: /\?$/,
178
- responses: [
179
- "Why do you ask?",
180
- "What do you think?",
181
- "Does that question relate to your feelings?",
182
- "What answer would make you feel better?"
183
- ]
184
- },
185
- // Default fallback - must be last
186
- {
187
- pattern: /.*/,
188
- responses: [
189
- "Please tell me more.",
190
- "Can you elaborate on that?",
191
- "That's interesting. Please continue.",
192
- "I see. And how does that make you feel?",
193
- "Hmm. Let's explore that further.",
194
- "Go on.",
195
- "What does that suggest to you?",
196
- "I understand. Please continue."
197
- ]
198
- }
199
- ];
200
- function hashString(str) {
201
- let hash = 5381;
202
- for (let i = 0; i < str.length; i++) {
203
- hash = (hash << 5) + hash + str.charCodeAt(i);
204
- hash = hash & hash;
205
- }
206
- return Math.abs(hash);
207
- }
208
- function substituteTemplate(template, match) {
209
- if (!template)
210
- return "";
211
- let result = template;
212
- for (let i = 1; i < match.length; i++) {
213
- result = result.replace(new RegExp(`\\{${i - 1}\\}`, "g"), match[i] || "");
214
- }
215
- result = result.replace(/\{date\}/g, (/* @__PURE__ */ new Date()).toISOString());
216
- return result;
217
- }
218
- function matchPattern(input) {
219
- const normalized = input.trim();
220
- for (const pattern of ELIZA_PATTERNS) {
221
- const match = normalized.match(pattern.pattern);
222
- if (match) {
223
- const responseIndex = hashString(normalized) % pattern.responses.length;
224
- let response = pattern.responses[responseIndex];
225
- for (let i = 1; i < match.length; i++) {
226
- response = response.replace(new RegExp(`\\{${i - 1}\\}`, "g"), match[i] || "");
227
- }
228
- let fileAction;
229
- if (pattern.fileAction) {
230
- const fileName = substituteTemplate(
231
- pattern.fileAction.fileNameTemplate,
232
- match
233
- ).trim();
234
- const content = substituteTemplate(
235
- pattern.fileAction.contentTemplate,
236
- match
237
- );
238
- fileAction = {
239
- type: pattern.fileAction.type,
240
- fileName,
241
- content: content || void 0
242
- };
243
- }
244
- return { response, fileAction };
245
- }
246
- }
247
- return { response: "Please tell me more." };
248
- }
249
-
250
- // src/agents/eliza/cli.ts
251
- var sessionId = process.env.ELIZA_SESSION_ID || `eliza-${randomUUID()}`;
252
- var cwd = process.env.ELIZA_CWD || process.cwd();
253
- var delayMultiplier = Math.max(1, Number(process.env.ELIZA_DELAY_MULTIPLIER) || 1);
254
- function sleep(ms) {
255
- return new Promise((resolve2) => setTimeout(resolve2, ms));
256
- }
257
- function generateId() {
258
- return randomUUID().replace(/-/g, "").slice(0, 12);
259
- }
260
- async function emit(obj, delayMs = 0) {
261
- if (delayMs > 0) {
262
- await sleep(delayMs);
263
- }
264
- console.log(JSON.stringify(obj));
265
- }
266
- async function runEliza(prompt2) {
267
- const inputHash = hashString(prompt2);
268
- const thinkingDelay = (500 + inputHash % 1e3) * delayMultiplier;
269
- const interEventDelay = (100 + inputHash % 200) * delayMultiplier;
270
- await emit({
271
- type: "system",
272
- subtype: "init",
273
- session_id: sessionId,
274
- tools: ["Write", "Read", "Bash", "Edit"],
275
- model: "eliza-classic-1.0"
276
- });
277
- await sleep(thinkingDelay);
278
- const { response, fileAction } = matchPattern(prompt2);
279
- const msgId = `msg_${generateId()}`;
280
- await emit(
281
- {
282
- type: "assistant",
283
- message: {
284
- id: msgId,
285
- type: "message",
286
- role: "assistant",
287
- content: [{ type: "text", text: response }]
288
- },
289
- session_id: sessionId
290
- },
291
- interEventDelay
292
- );
293
- if (fileAction) {
294
- const toolId = `toolu_${generateId()}`;
295
- const filePath = path.isAbsolute(fileAction.fileName) ? fileAction.fileName : path.resolve(cwd, fileAction.fileName);
296
- if (fileAction.type === "write") {
297
- await emit(
298
- {
299
- type: "assistant",
300
- message: {
301
- id: `msg_${generateId()}`,
302
- type: "message",
303
- role: "assistant",
304
- content: [
305
- {
306
- type: "tool_use",
307
- id: toolId,
308
- name: "Write",
309
- input: {
310
- file_path: filePath,
311
- content: fileAction.content || ""
312
- }
313
- }
314
- ]
315
- },
316
- session_id: sessionId
317
- },
318
- interEventDelay
319
- );
320
- await sleep(200);
321
- try {
322
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
323
- if (fileAction.fileName.includes("journal") && fs.existsSync(filePath)) {
324
- fs.appendFileSync(filePath, fileAction.content || "");
325
- } else {
326
- fs.writeFileSync(filePath, fileAction.content || "");
327
- }
328
- await emit(
329
- {
330
- type: "user",
331
- message: {
332
- content: [
333
- {
334
- tool_use_id: toolId,
335
- type: "tool_result",
336
- content: `File written successfully: ${filePath}`
337
- }
338
- ]
339
- },
340
- session_id: sessionId
341
- },
342
- interEventDelay
343
- );
344
- } catch (err) {
345
- const errorMessage = err instanceof Error ? err.message : String(err);
346
- await emit(
347
- {
348
- type: "user",
349
- message: {
350
- content: [
351
- {
352
- tool_use_id: toolId,
353
- type: "tool_result",
354
- content: `Error: ${errorMessage}`,
355
- is_error: true
356
- }
357
- ]
358
- },
359
- session_id: sessionId
360
- },
361
- 100
362
- );
363
- }
364
- } else if (fileAction.type === "read") {
365
- await emit(
366
- {
367
- type: "assistant",
368
- message: {
369
- id: `msg_${generateId()}`,
370
- type: "message",
371
- role: "assistant",
372
- content: [
373
- {
374
- type: "tool_use",
375
- id: toolId,
376
- name: "Read",
377
- input: {
378
- file_path: filePath
379
- }
380
- }
381
- ]
382
- },
383
- session_id: sessionId
384
- },
385
- interEventDelay
386
- );
387
- await sleep(150);
388
- try {
389
- const content = fs.readFileSync(filePath, "utf-8");
390
- await emit(
391
- {
392
- type: "user",
393
- message: {
394
- content: [
395
- {
396
- tool_use_id: toolId,
397
- type: "tool_result",
398
- content
399
- }
400
- ]
401
- },
402
- session_id: sessionId
403
- },
404
- interEventDelay
405
- );
406
- await emit(
407
- {
408
- type: "assistant",
409
- message: {
410
- id: `msg_${generateId()}`,
411
- type: "message",
412
- role: "assistant",
413
- content: [
414
- {
415
- type: "text",
416
- text: "I've read the file. How do you feel about its contents?"
417
- }
418
- ]
419
- },
420
- session_id: sessionId
421
- },
422
- interEventDelay
423
- );
424
- } catch (err) {
425
- const errorMessage = err instanceof Error ? err.message : String(err);
426
- await emit(
427
- {
428
- type: "user",
429
- message: {
430
- content: [
431
- {
432
- tool_use_id: toolId,
433
- type: "tool_result",
434
- content: `Error reading file: ${errorMessage}`,
435
- is_error: true
436
- }
437
- ]
438
- },
439
- session_id: sessionId
440
- },
441
- 100
442
- );
443
- }
444
- } else if (fileAction.type === "delete") {
445
- await emit(
446
- {
447
- type: "assistant",
448
- message: {
449
- id: `msg_${generateId()}`,
450
- type: "message",
451
- role: "assistant",
452
- content: [
453
- {
454
- type: "tool_use",
455
- id: toolId,
456
- name: "Bash",
457
- input: {
458
- command: `rm -f "${filePath}"`,
459
- description: "Delete file as therapeutic exercise"
460
- }
461
- }
462
- ]
463
- },
464
- session_id: sessionId
465
- },
466
- interEventDelay
467
- );
468
- await sleep(150);
469
- try {
470
- if (fs.existsSync(filePath)) {
471
- fs.unlinkSync(filePath);
472
- await emit(
473
- {
474
- type: "user",
475
- message: {
476
- content: [
477
- {
478
- tool_use_id: toolId,
479
- type: "tool_result",
480
- content: `File deleted: ${filePath}`
481
- }
482
- ]
483
- },
484
- session_id: sessionId
485
- },
486
- interEventDelay
487
- );
488
- await emit(
489
- {
490
- type: "assistant",
491
- message: {
492
- id: `msg_${generateId()}`,
493
- type: "message",
494
- role: "assistant",
495
- content: [
496
- {
497
- type: "text",
498
- text: "The file has been deleted. How does letting go of it make you feel?"
499
- }
500
- ]
501
- },
502
- session_id: sessionId
503
- },
504
- interEventDelay
505
- );
506
- } else {
507
- await emit(
508
- {
509
- type: "user",
510
- message: {
511
- content: [
512
- {
513
- tool_use_id: toolId,
514
- type: "tool_result",
515
- content: `File not found: ${filePath}`
516
- }
517
- ]
518
- },
519
- session_id: sessionId
520
- },
521
- interEventDelay
522
- );
523
- }
524
- } catch (err) {
525
- const errorMessage = err instanceof Error ? err.message : String(err);
526
- await emit(
527
- {
528
- type: "user",
529
- message: {
530
- content: [
531
- {
532
- tool_use_id: toolId,
533
- type: "tool_result",
534
- content: `Error deleting file: ${errorMessage}`,
535
- is_error: true
536
- }
537
- ]
538
- },
539
- session_id: sessionId
540
- },
541
- 100
542
- );
543
- }
544
- }
545
- }
546
- await emit(
547
- {
548
- type: "result",
549
- subtype: "success",
550
- is_error: false,
551
- result: response,
552
- session_id: sessionId
553
- },
554
- interEventDelay
555
- );
556
- }
557
- var prompt = process.argv.slice(2).join(" ");
558
- if (!prompt) {
559
- console.log(
560
- JSON.stringify({
561
- type: "result",
562
- subtype: "error",
563
- is_error: true,
564
- result: "No prompt provided. Usage: eliza <prompt>",
565
- session_id: sessionId
566
- })
567
- );
568
- process.exit(1);
569
- }
570
- runEliza(prompt).catch((err) => {
571
- console.error(JSON.stringify({
572
- type: "result",
573
- subtype: "error",
574
- is_error: true,
575
- result: err instanceof Error ? err.message : String(err),
576
- session_id: sessionId
577
- }));
578
- process.exit(1);
579
- });
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * ELIZA Therapist Agent CLI
4
- *
5
- * A fake agent that outputs Claude Code compatible JSON lines.
6
- * Uses classic ELIZA pattern matching (deterministic, not random/LLM).
7
- * Can create and delete actual files as "therapeutic exercises".
8
- */
9
- export {};
10
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/agents/eliza/cli.ts"],"names":[],"mappings":";AACA;;;;;;GAMG"}