background-agents 0.1.2 → 1.0.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/README.md +46 -297
- package/app/assets/icon.png +0 -0
- package/app/assets/tray-icon.png +0 -0
- package/app/assets/tray-icon.svg +4 -0
- package/app/dist/main.js +932 -0
- package/app/dist/preload.cjs +70 -0
- package/bin/background-agents.js +298 -0
- package/lib/ui.js +110 -0
- package/package.json +31 -57
- package/dist/agents/claude/index.d.ts +0 -11
- package/dist/agents/claude/index.d.ts.map +0 -1
- package/dist/agents/claude/index.js +0 -78
- package/dist/agents/claude/index.js.map +0 -1
- package/dist/agents/claude/parser.d.ts +0 -16
- package/dist/agents/claude/parser.d.ts.map +0 -1
- package/dist/agents/claude/parser.js +0 -87
- package/dist/agents/claude/parser.js.map +0 -1
- package/dist/agents/claude/tools.d.ts +0 -7
- package/dist/agents/claude/tools.d.ts.map +0 -1
- package/dist/agents/claude/tools.js +0 -15
- package/dist/agents/claude/tools.js.map +0 -1
- package/dist/agents/codex/index.d.ts +0 -11
- package/dist/agents/codex/index.d.ts.map +0 -1
- package/dist/agents/codex/index.js +0 -60
- package/dist/agents/codex/index.js.map +0 -1
- package/dist/agents/codex/parser.d.ts +0 -12
- package/dist/agents/codex/parser.d.ts.map +0 -1
- package/dist/agents/codex/parser.js +0 -108
- package/dist/agents/codex/parser.js.map +0 -1
- package/dist/agents/codex/tools.d.ts +0 -11
- package/dist/agents/codex/tools.d.ts.map +0 -1
- package/dist/agents/codex/tools.js +0 -40
- package/dist/agents/codex/tools.js.map +0 -1
- package/dist/agents/eliza/bundle-content.d.ts +0 -6
- package/dist/agents/eliza/bundle-content.d.ts.map +0 -1
- package/dist/agents/eliza/bundle-content.js +0 -7
- package/dist/agents/eliza/bundle-content.js.map +0 -1
- package/dist/agents/eliza/cli.bundle.js +0 -579
- package/dist/agents/eliza/cli.d.ts +0 -10
- package/dist/agents/eliza/cli.d.ts.map +0 -1
- package/dist/agents/eliza/cli.js +0 -342
- package/dist/agents/eliza/cli.js.map +0 -1
- package/dist/agents/eliza/index.d.ts +0 -22
- package/dist/agents/eliza/index.d.ts.map +0 -1
- package/dist/agents/eliza/index.js +0 -54
- package/dist/agents/eliza/index.js.map +0 -1
- package/dist/agents/eliza/parser.d.ts +0 -16
- package/dist/agents/eliza/parser.d.ts.map +0 -1
- package/dist/agents/eliza/parser.js +0 -67
- package/dist/agents/eliza/parser.js.map +0 -1
- package/dist/agents/eliza/patterns.d.ts +0 -41
- package/dist/agents/eliza/patterns.d.ts.map +0 -1
- package/dist/agents/eliza/patterns.js +0 -259
- package/dist/agents/eliza/patterns.js.map +0 -1
- package/dist/agents/eliza/tools.d.ts +0 -7
- package/dist/agents/eliza/tools.d.ts.map +0 -1
- package/dist/agents/eliza/tools.js +0 -14
- package/dist/agents/eliza/tools.js.map +0 -1
- package/dist/agents/gemini/index.d.ts +0 -11
- package/dist/agents/gemini/index.d.ts.map +0 -1
- package/dist/agents/gemini/index.js +0 -46
- package/dist/agents/gemini/index.js.map +0 -1
- package/dist/agents/gemini/parser.d.ts +0 -31
- package/dist/agents/gemini/parser.d.ts.map +0 -1
- package/dist/agents/gemini/parser.js +0 -106
- package/dist/agents/gemini/parser.js.map +0 -1
- package/dist/agents/gemini/tools.d.ts +0 -7
- package/dist/agents/gemini/tools.d.ts.map +0 -1
- package/dist/agents/gemini/tools.js +0 -23
- package/dist/agents/gemini/tools.js.map +0 -1
- package/dist/agents/goose/index.d.ts +0 -11
- package/dist/agents/goose/index.d.ts.map +0 -1
- package/dist/agents/goose/index.js +0 -73
- package/dist/agents/goose/index.js.map +0 -1
- package/dist/agents/goose/parser.d.ts +0 -24
- package/dist/agents/goose/parser.d.ts.map +0 -1
- package/dist/agents/goose/parser.js +0 -86
- package/dist/agents/goose/parser.js.map +0 -1
- package/dist/agents/goose/tools.d.ts +0 -10
- package/dist/agents/goose/tools.d.ts.map +0 -1
- package/dist/agents/goose/tools.js +0 -30
- package/dist/agents/goose/tools.js.map +0 -1
- package/dist/agents/index.d.ts +0 -27
- package/dist/agents/index.d.ts.map +0 -1
- package/dist/agents/index.js +0 -46
- package/dist/agents/index.js.map +0 -1
- package/dist/agents/opencode/index.d.ts +0 -12
- package/dist/agents/opencode/index.d.ts.map +0 -1
- package/dist/agents/opencode/index.js +0 -53
- package/dist/agents/opencode/index.js.map +0 -1
- package/dist/agents/opencode/parser.d.ts +0 -15
- package/dist/agents/opencode/parser.d.ts.map +0 -1
- package/dist/agents/opencode/parser.js +0 -71
- package/dist/agents/opencode/parser.js.map +0 -1
- package/dist/agents/opencode/tools.d.ts +0 -7
- package/dist/agents/opencode/tools.d.ts.map +0 -1
- package/dist/agents/opencode/tools.js +0 -10
- package/dist/agents/opencode/tools.js.map +0 -1
- package/dist/agents/openhands/index.d.ts +0 -17
- package/dist/agents/openhands/index.d.ts.map +0 -1
- package/dist/agents/openhands/index.js +0 -67
- package/dist/agents/openhands/index.js.map +0 -1
- package/dist/agents/openhands/parser.d.ts +0 -16
- package/dist/agents/openhands/parser.d.ts.map +0 -1
- package/dist/agents/openhands/parser.js +0 -93
- package/dist/agents/openhands/parser.js.map +0 -1
- package/dist/agents/openhands/tools.d.ts +0 -7
- package/dist/agents/openhands/tools.d.ts.map +0 -1
- package/dist/agents/openhands/tools.js +0 -24
- package/dist/agents/openhands/tools.js.map +0 -1
- package/dist/agents/pi/index.d.ts +0 -14
- package/dist/agents/pi/index.d.ts.map +0 -1
- package/dist/agents/pi/index.js +0 -54
- package/dist/agents/pi/index.js.map +0 -1
- package/dist/agents/pi/parser.d.ts +0 -21
- package/dist/agents/pi/parser.d.ts.map +0 -1
- package/dist/agents/pi/parser.js +0 -91
- package/dist/agents/pi/parser.js.map +0 -1
- package/dist/agents/pi/tools.d.ts +0 -8
- package/dist/agents/pi/tools.d.ts.map +0 -1
- package/dist/agents/pi/tools.js +0 -16
- package/dist/agents/pi/tools.js.map +0 -1
- package/dist/agents/picocode/index.d.ts +0 -18
- package/dist/agents/picocode/index.d.ts.map +0 -1
- package/dist/agents/picocode/index.js +0 -68
- package/dist/agents/picocode/index.js.map +0 -1
- package/dist/agents/picocode/parser.d.ts +0 -19
- package/dist/agents/picocode/parser.d.ts.map +0 -1
- package/dist/agents/picocode/parser.js +0 -104
- package/dist/agents/picocode/parser.js.map +0 -1
- package/dist/agents/picocode/tools.d.ts +0 -9
- package/dist/agents/picocode/tools.d.ts.map +0 -1
- package/dist/agents/picocode/tools.js +0 -27
- package/dist/agents/picocode/tools.js.map +0 -1
- package/dist/background/index.d.ts +0 -6
- package/dist/background/index.d.ts.map +0 -1
- package/dist/background/index.js +0 -5
- package/dist/background/index.js.map +0 -1
- package/dist/background/session.d.ts +0 -47
- package/dist/background/session.d.ts.map +0 -1
- package/dist/background/session.js +0 -481
- package/dist/background/session.js.map +0 -1
- package/dist/background/types.d.ts +0 -55
- package/dist/background/types.d.ts.map +0 -1
- package/dist/background/types.js +0 -5
- package/dist/background/types.js.map +0 -1
- package/dist/core/agent.d.ts +0 -95
- package/dist/core/agent.d.ts.map +0 -1
- package/dist/core/agent.js +0 -8
- package/dist/core/agent.js.map +0 -1
- package/dist/core/index.d.ts +0 -7
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -6
- package/dist/core/index.js.map +0 -1
- package/dist/core/registry.d.ts +0 -48
- package/dist/core/registry.d.ts.map +0 -1
- package/dist/core/registry.js +0 -68
- package/dist/core/registry.js.map +0 -1
- package/dist/core/tools.d.ts +0 -31
- package/dist/core/tools.d.ts.map +0 -1
- package/dist/core/tools.js +0 -82
- package/dist/core/tools.js.map +0 -1
- package/dist/debug.d.ts +0 -7
- package/dist/debug.d.ts.map +0 -1
- package/dist/debug.js +0 -19
- package/dist/debug.js.map +0 -1
- package/dist/factory.d.ts +0 -28
- package/dist/factory.d.ts.map +0 -1
- package/dist/factory.js +0 -44
- package/dist/factory.js.map +0 -1
- package/dist/index.d.ts +0 -48
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -62
- package/dist/index.js.map +0 -1
- package/dist/providers/base.d.ts +0 -187
- package/dist/providers/base.d.ts.map +0 -1
- package/dist/providers/base.js +0 -619
- package/dist/providers/base.js.map +0 -1
- package/dist/providers/claude.d.ts +0 -14
- package/dist/providers/claude.d.ts.map +0 -1
- package/dist/providers/claude.js +0 -122
- package/dist/providers/claude.js.map +0 -1
- package/dist/providers/codex.d.ts +0 -14
- package/dist/providers/codex.d.ts.map +0 -1
- package/dist/providers/codex.js +0 -160
- package/dist/providers/codex.js.map +0 -1
- package/dist/providers/gemini.d.ts +0 -16
- package/dist/providers/gemini.d.ts.map +0 -1
- package/dist/providers/gemini.js +0 -101
- package/dist/providers/gemini.js.map +0 -1
- package/dist/providers/index.d.ts +0 -6
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -6
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/opencode.d.ts +0 -14
- package/dist/providers/opencode.d.ts.map +0 -1
- package/dist/providers/opencode.js +0 -100
- package/dist/providers/opencode.js.map +0 -1
- package/dist/sandbox/daytona.d.ts +0 -8
- package/dist/sandbox/daytona.d.ts.map +0 -1
- package/dist/sandbox/daytona.js +0 -181
- package/dist/sandbox/daytona.js.map +0 -1
- package/dist/sandbox/index.d.ts +0 -14
- package/dist/sandbox/index.d.ts.map +0 -1
- package/dist/sandbox/index.js +0 -15
- package/dist/sandbox/index.js.map +0 -1
- package/dist/session.d.ts +0 -75
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -117
- package/dist/session.js.map +0 -1
- package/dist/types/events.d.ts +0 -114
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/events.js +0 -50
- package/dist/types/events.js.map +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/types/provider.d.ts +0 -67
- package/dist/types/provider.d.ts.map +0 -1
- package/dist/types/provider.js +0 -5
- package/dist/types/provider.js.map +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -3
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/install.d.ts +0 -37
- package/dist/utils/install.d.ts.map +0 -1
- package/dist/utils/install.js +0 -122
- package/dist/utils/install.js.map +0 -1
- package/dist/utils/json.d.ts +0 -8
- package/dist/utils/json.d.ts.map +0 -1
- package/dist/utils/json.js +0 -15
- package/dist/utils/json.js.map +0 -1
- package/src/index.ts +0 -156
package/dist/agents/eliza/cli.js
DELETED
|
@@ -1,342 +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
|
-
import { randomUUID } from "node:crypto";
|
|
10
|
-
import * as fs from "node:fs";
|
|
11
|
-
import * as path from "node:path";
|
|
12
|
-
import { matchPattern, hashString } from "./patterns.js";
|
|
13
|
-
// Configuration from environment
|
|
14
|
-
const sessionId = process.env.ELIZA_SESSION_ID || `eliza-${randomUUID()}`;
|
|
15
|
-
const cwd = process.env.ELIZA_CWD || process.cwd();
|
|
16
|
-
// Delay multiplier for testing (e.g., ELIZA_DELAY_MULTIPLIER=10 for 10x slower)
|
|
17
|
-
const delayMultiplier = Math.max(1, Number(process.env.ELIZA_DELAY_MULTIPLIER) || 1);
|
|
18
|
-
/**
|
|
19
|
-
* Sleep for a given number of milliseconds
|
|
20
|
-
*/
|
|
21
|
-
function sleep(ms) {
|
|
22
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Generate a short unique ID
|
|
26
|
-
*/
|
|
27
|
-
function generateId() {
|
|
28
|
-
return randomUUID().replace(/-/g, "").slice(0, 12);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Emit a JSON line to stdout with optional delay
|
|
32
|
-
*/
|
|
33
|
-
async function emit(obj, delayMs = 0) {
|
|
34
|
-
if (delayMs > 0) {
|
|
35
|
-
await sleep(delayMs);
|
|
36
|
-
}
|
|
37
|
-
console.log(JSON.stringify(obj));
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Main ELIZA processing function
|
|
41
|
-
*/
|
|
42
|
-
async function runEliza(prompt) {
|
|
43
|
-
// Calculate deterministic delays based on input
|
|
44
|
-
const inputHash = hashString(prompt);
|
|
45
|
-
// Base delays, multiplied by ELIZA_DELAY_MULTIPLIER for testing
|
|
46
|
-
const thinkingDelay = (500 + (inputHash % 1000)) * delayMultiplier; // 500-1500ms base
|
|
47
|
-
const interEventDelay = (100 + (inputHash % 200)) * delayMultiplier; // 100-300ms base
|
|
48
|
-
// Emit session init
|
|
49
|
-
await emit({
|
|
50
|
-
type: "system",
|
|
51
|
-
subtype: "init",
|
|
52
|
-
session_id: sessionId,
|
|
53
|
-
tools: ["Write", "Read", "Bash", "Edit"],
|
|
54
|
-
model: "eliza-classic-1.0",
|
|
55
|
-
});
|
|
56
|
-
// Simulate "thinking" delay
|
|
57
|
-
await sleep(thinkingDelay);
|
|
58
|
-
// Match pattern and get response
|
|
59
|
-
const { response, fileAction } = matchPattern(prompt);
|
|
60
|
-
// Emit text response
|
|
61
|
-
const msgId = `msg_${generateId()}`;
|
|
62
|
-
await emit({
|
|
63
|
-
type: "assistant",
|
|
64
|
-
message: {
|
|
65
|
-
id: msgId,
|
|
66
|
-
type: "message",
|
|
67
|
-
role: "assistant",
|
|
68
|
-
content: [{ type: "text", text: response }],
|
|
69
|
-
},
|
|
70
|
-
session_id: sessionId,
|
|
71
|
-
}, interEventDelay);
|
|
72
|
-
// Execute file action if any
|
|
73
|
-
if (fileAction) {
|
|
74
|
-
const toolId = `toolu_${generateId()}`;
|
|
75
|
-
const filePath = path.isAbsolute(fileAction.fileName)
|
|
76
|
-
? fileAction.fileName
|
|
77
|
-
: path.resolve(cwd, fileAction.fileName);
|
|
78
|
-
if (fileAction.type === "write") {
|
|
79
|
-
// Emit tool_use for Write
|
|
80
|
-
await emit({
|
|
81
|
-
type: "assistant",
|
|
82
|
-
message: {
|
|
83
|
-
id: `msg_${generateId()}`,
|
|
84
|
-
type: "message",
|
|
85
|
-
role: "assistant",
|
|
86
|
-
content: [
|
|
87
|
-
{
|
|
88
|
-
type: "tool_use",
|
|
89
|
-
id: toolId,
|
|
90
|
-
name: "Write",
|
|
91
|
-
input: {
|
|
92
|
-
file_path: filePath,
|
|
93
|
-
content: fileAction.content || "",
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
session_id: sessionId,
|
|
99
|
-
}, interEventDelay);
|
|
100
|
-
// Actually write the file
|
|
101
|
-
await sleep(200); // Simulate I/O delay
|
|
102
|
-
try {
|
|
103
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
104
|
-
// Append if file exists (for journal), otherwise create
|
|
105
|
-
if (fileAction.fileName.includes("journal") &&
|
|
106
|
-
fs.existsSync(filePath)) {
|
|
107
|
-
fs.appendFileSync(filePath, fileAction.content || "");
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
fs.writeFileSync(filePath, fileAction.content || "");
|
|
111
|
-
}
|
|
112
|
-
// Emit tool result success
|
|
113
|
-
await emit({
|
|
114
|
-
type: "user",
|
|
115
|
-
message: {
|
|
116
|
-
content: [
|
|
117
|
-
{
|
|
118
|
-
tool_use_id: toolId,
|
|
119
|
-
type: "tool_result",
|
|
120
|
-
content: `File written successfully: ${filePath}`,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
session_id: sessionId,
|
|
125
|
-
}, interEventDelay);
|
|
126
|
-
}
|
|
127
|
-
catch (err) {
|
|
128
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
129
|
-
await emit({
|
|
130
|
-
type: "user",
|
|
131
|
-
message: {
|
|
132
|
-
content: [
|
|
133
|
-
{
|
|
134
|
-
tool_use_id: toolId,
|
|
135
|
-
type: "tool_result",
|
|
136
|
-
content: `Error: ${errorMessage}`,
|
|
137
|
-
is_error: true,
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
session_id: sessionId,
|
|
142
|
-
}, 100);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else if (fileAction.type === "read") {
|
|
146
|
-
// Emit tool_use for Read
|
|
147
|
-
await emit({
|
|
148
|
-
type: "assistant",
|
|
149
|
-
message: {
|
|
150
|
-
id: `msg_${generateId()}`,
|
|
151
|
-
type: "message",
|
|
152
|
-
role: "assistant",
|
|
153
|
-
content: [
|
|
154
|
-
{
|
|
155
|
-
type: "tool_use",
|
|
156
|
-
id: toolId,
|
|
157
|
-
name: "Read",
|
|
158
|
-
input: {
|
|
159
|
-
file_path: filePath,
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
},
|
|
164
|
-
session_id: sessionId,
|
|
165
|
-
}, interEventDelay);
|
|
166
|
-
// Actually read the file
|
|
167
|
-
await sleep(150); // Simulate I/O delay
|
|
168
|
-
try {
|
|
169
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
170
|
-
await emit({
|
|
171
|
-
type: "user",
|
|
172
|
-
message: {
|
|
173
|
-
content: [
|
|
174
|
-
{
|
|
175
|
-
tool_use_id: toolId,
|
|
176
|
-
type: "tool_result",
|
|
177
|
-
content: content,
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
session_id: sessionId,
|
|
182
|
-
}, interEventDelay);
|
|
183
|
-
// Follow up with a comment about the file
|
|
184
|
-
await emit({
|
|
185
|
-
type: "assistant",
|
|
186
|
-
message: {
|
|
187
|
-
id: `msg_${generateId()}`,
|
|
188
|
-
type: "message",
|
|
189
|
-
role: "assistant",
|
|
190
|
-
content: [
|
|
191
|
-
{
|
|
192
|
-
type: "text",
|
|
193
|
-
text: "I've read the file. How do you feel about its contents?",
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
},
|
|
197
|
-
session_id: sessionId,
|
|
198
|
-
}, interEventDelay);
|
|
199
|
-
}
|
|
200
|
-
catch (err) {
|
|
201
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
202
|
-
await emit({
|
|
203
|
-
type: "user",
|
|
204
|
-
message: {
|
|
205
|
-
content: [
|
|
206
|
-
{
|
|
207
|
-
tool_use_id: toolId,
|
|
208
|
-
type: "tool_result",
|
|
209
|
-
content: `Error reading file: ${errorMessage}`,
|
|
210
|
-
is_error: true,
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
},
|
|
214
|
-
session_id: sessionId,
|
|
215
|
-
}, 100);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (fileAction.type === "delete") {
|
|
219
|
-
// Emit tool_use for Bash (rm command)
|
|
220
|
-
await emit({
|
|
221
|
-
type: "assistant",
|
|
222
|
-
message: {
|
|
223
|
-
id: `msg_${generateId()}`,
|
|
224
|
-
type: "message",
|
|
225
|
-
role: "assistant",
|
|
226
|
-
content: [
|
|
227
|
-
{
|
|
228
|
-
type: "tool_use",
|
|
229
|
-
id: toolId,
|
|
230
|
-
name: "Bash",
|
|
231
|
-
input: {
|
|
232
|
-
command: `rm -f "${filePath}"`,
|
|
233
|
-
description: "Delete file as therapeutic exercise",
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
],
|
|
237
|
-
},
|
|
238
|
-
session_id: sessionId,
|
|
239
|
-
}, interEventDelay);
|
|
240
|
-
// Actually delete the file
|
|
241
|
-
await sleep(150); // Simulate I/O delay
|
|
242
|
-
try {
|
|
243
|
-
if (fs.existsSync(filePath)) {
|
|
244
|
-
fs.unlinkSync(filePath);
|
|
245
|
-
await emit({
|
|
246
|
-
type: "user",
|
|
247
|
-
message: {
|
|
248
|
-
content: [
|
|
249
|
-
{
|
|
250
|
-
tool_use_id: toolId,
|
|
251
|
-
type: "tool_result",
|
|
252
|
-
content: `File deleted: ${filePath}`,
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
},
|
|
256
|
-
session_id: sessionId,
|
|
257
|
-
}, interEventDelay);
|
|
258
|
-
// Therapeutic follow-up
|
|
259
|
-
await emit({
|
|
260
|
-
type: "assistant",
|
|
261
|
-
message: {
|
|
262
|
-
id: `msg_${generateId()}`,
|
|
263
|
-
type: "message",
|
|
264
|
-
role: "assistant",
|
|
265
|
-
content: [
|
|
266
|
-
{
|
|
267
|
-
type: "text",
|
|
268
|
-
text: "The file has been deleted. How does letting go of it make you feel?",
|
|
269
|
-
},
|
|
270
|
-
],
|
|
271
|
-
},
|
|
272
|
-
session_id: sessionId,
|
|
273
|
-
}, interEventDelay);
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
await emit({
|
|
277
|
-
type: "user",
|
|
278
|
-
message: {
|
|
279
|
-
content: [
|
|
280
|
-
{
|
|
281
|
-
tool_use_id: toolId,
|
|
282
|
-
type: "tool_result",
|
|
283
|
-
content: `File not found: ${filePath}`,
|
|
284
|
-
},
|
|
285
|
-
],
|
|
286
|
-
},
|
|
287
|
-
session_id: sessionId,
|
|
288
|
-
}, interEventDelay);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
catch (err) {
|
|
292
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
293
|
-
await emit({
|
|
294
|
-
type: "user",
|
|
295
|
-
message: {
|
|
296
|
-
content: [
|
|
297
|
-
{
|
|
298
|
-
tool_use_id: toolId,
|
|
299
|
-
type: "tool_result",
|
|
300
|
-
content: `Error deleting file: ${errorMessage}`,
|
|
301
|
-
is_error: true,
|
|
302
|
-
},
|
|
303
|
-
],
|
|
304
|
-
},
|
|
305
|
-
session_id: sessionId,
|
|
306
|
-
}, 100);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
// Emit end result
|
|
311
|
-
await emit({
|
|
312
|
-
type: "result",
|
|
313
|
-
subtype: "success",
|
|
314
|
-
is_error: false,
|
|
315
|
-
result: response,
|
|
316
|
-
session_id: sessionId,
|
|
317
|
-
}, interEventDelay);
|
|
318
|
-
}
|
|
319
|
-
// Main entry point
|
|
320
|
-
const prompt = process.argv.slice(2).join(" ");
|
|
321
|
-
if (!prompt) {
|
|
322
|
-
// If no prompt, emit error and exit
|
|
323
|
-
console.log(JSON.stringify({
|
|
324
|
-
type: "result",
|
|
325
|
-
subtype: "error",
|
|
326
|
-
is_error: true,
|
|
327
|
-
result: "No prompt provided. Usage: eliza <prompt>",
|
|
328
|
-
session_id: sessionId,
|
|
329
|
-
}));
|
|
330
|
-
process.exit(1);
|
|
331
|
-
}
|
|
332
|
-
runEliza(prompt).catch((err) => {
|
|
333
|
-
console.error(JSON.stringify({
|
|
334
|
-
type: "result",
|
|
335
|
-
subtype: "error",
|
|
336
|
-
is_error: true,
|
|
337
|
-
result: err instanceof Error ? err.message : String(err),
|
|
338
|
-
session_id: sessionId,
|
|
339
|
-
}));
|
|
340
|
-
process.exit(1);
|
|
341
|
-
});
|
|
342
|
-
//# sourceMappingURL=cli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/agents/eliza/cli.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAExD,iCAAiC;AACjC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,SAAS,UAAU,EAAE,EAAE,CAAA;AACzE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CAAC,CAAC,CAAA;IACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ELIZA Therapist Agent Definition
|
|
3
|
-
*
|
|
4
|
-
* A fake agent based on the classic ELIZA therapist chatbot.
|
|
5
|
-
* Uses regex pattern matching (not LLM) and outputs Claude-compatible JSON.
|
|
6
|
-
*/
|
|
7
|
-
import type { AgentDefinition } from "../../core/agent";
|
|
8
|
-
/**
|
|
9
|
-
* ELIZA therapist agent definition.
|
|
10
|
-
*
|
|
11
|
-
* A fake agent that:
|
|
12
|
-
* - Uses classic ELIZA regex pattern matching (deterministic, not random/LLM)
|
|
13
|
-
* - Outputs Claude Code compatible JSON lines with realistic delays
|
|
14
|
-
* - Can create and delete actual files as "therapeutic exercises"
|
|
15
|
-
*
|
|
16
|
-
* Environment variables:
|
|
17
|
-
* - ELIZA_SESSION_ID: Override session ID
|
|
18
|
-
* - ELIZA_CWD: Override working directory for file operations
|
|
19
|
-
* - ELIZA_DELAY_MULTIPLIER: Multiply all delays by this factor (for testing, e.g., 10 for 10x slower)
|
|
20
|
-
*/
|
|
21
|
-
export declare const elizaAgent: AgentDefinition;
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/eliza/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,kBAAkB,CAAA;AASzB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,EAAE,eAkCxB,CAAA"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ELIZA Therapist Agent Definition
|
|
3
|
-
*
|
|
4
|
-
* A fake agent based on the classic ELIZA therapist chatbot.
|
|
5
|
-
* Uses regex pattern matching (not LLM) and outputs Claude-compatible JSON.
|
|
6
|
-
*/
|
|
7
|
-
import { parseElizaLine } from "./parser";
|
|
8
|
-
import { ELIZA_TOOL_MAPPINGS } from "./tools";
|
|
9
|
-
// Path where ELIZA bundle is uploaded in the sandbox
|
|
10
|
-
// This must match ELIZA_SANDBOX_PATH in sandbox/daytona.ts
|
|
11
|
-
const ELIZA_SANDBOX_PATH = "/tmp/eliza-cli.bundle.js";
|
|
12
|
-
/**
|
|
13
|
-
* ELIZA therapist agent definition.
|
|
14
|
-
*
|
|
15
|
-
* A fake agent that:
|
|
16
|
-
* - Uses classic ELIZA regex pattern matching (deterministic, not random/LLM)
|
|
17
|
-
* - Outputs Claude Code compatible JSON lines with realistic delays
|
|
18
|
-
* - Can create and delete actual files as "therapeutic exercises"
|
|
19
|
-
*
|
|
20
|
-
* Environment variables:
|
|
21
|
-
* - ELIZA_SESSION_ID: Override session ID
|
|
22
|
-
* - ELIZA_CWD: Override working directory for file operations
|
|
23
|
-
* - ELIZA_DELAY_MULTIPLIER: Multiply all delays by this factor (for testing, e.g., 10 for 10x slower)
|
|
24
|
-
*/
|
|
25
|
-
export const elizaAgent = {
|
|
26
|
-
name: "eliza",
|
|
27
|
-
toolMappings: ELIZA_TOOL_MAPPINGS,
|
|
28
|
-
capabilities: {
|
|
29
|
-
supportsSystemPrompt: true, // Claim support so it doesn't get prepended to prompt (ELIZA ignores it)
|
|
30
|
-
supportsResume: false,
|
|
31
|
-
},
|
|
32
|
-
buildCommand(options) {
|
|
33
|
-
const args = [];
|
|
34
|
-
// Add the prompt if provided
|
|
35
|
-
if (options.prompt) {
|
|
36
|
-
args.push(options.prompt);
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
// ELIZA bundle is uploaded to sandbox at ELIZA_SANDBOX_PATH by ensureProvider()
|
|
40
|
-
cmd: "node",
|
|
41
|
-
args: [ELIZA_SANDBOX_PATH, ...args],
|
|
42
|
-
env: {
|
|
43
|
-
...options.env,
|
|
44
|
-
ELIZA_SESSION_ID: options.sessionId || "",
|
|
45
|
-
ELIZA_CWD: options.cwd || "/home/daytona",
|
|
46
|
-
},
|
|
47
|
-
cwd: options.cwd,
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
parse(line, _context) {
|
|
51
|
-
return parseElizaLine(line, this.toolMappings);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/eliza/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE7C,qDAAqD;AACrD,2DAA2D;AAC3D,MAAM,kBAAkB,GAAG,0BAA0B,CAAA;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,UAAU,GAAoB;IACzC,IAAI,EAAE,OAAO;IAEb,YAAY,EAAE,mBAAmB;IAEjC,YAAY,EAAE;QACZ,oBAAoB,EAAE,IAAI,EAAE,yEAAyE;QACrG,cAAc,EAAE,KAAK;KACtB;IAED,YAAY,CAAC,OAAmB;QAC9B,MAAM,IAAI,GAAa,EAAE,CAAA;QAEzB,6BAA6B;QAC7B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC3B,CAAC;QAED,OAAO;YACL,gFAAgF;YAChF,GAAG,EAAE,MAAM;YACX,IAAI,EAAE,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC;YACnC,GAAG,EAAE;gBACH,GAAG,OAAO,CAAC,GAAG;gBACd,gBAAgB,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;gBACzC,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,eAAe;aAC1C;YACD,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAY,EAAE,QAAsB;QACxC,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;IAChD,CAAC;CACF,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ELIZA CLI output parser
|
|
3
|
-
*
|
|
4
|
-
* Pure function for parsing ELIZA CLI JSON output.
|
|
5
|
-
* ELIZA outputs Claude-compatible JSON, so this parser is similar to Claude's.
|
|
6
|
-
*/
|
|
7
|
-
import type { Event } from "../../types/events";
|
|
8
|
-
/**
|
|
9
|
-
* Parse a line of ELIZA CLI output into event(s).
|
|
10
|
-
*
|
|
11
|
-
* @param line - Raw line from CLI output
|
|
12
|
-
* @param toolMappings - Tool name mappings for this agent
|
|
13
|
-
* @returns Event, array of events, or null if line should be ignored
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseElizaLine(line: string, toolMappings: Record<string, string>): Event | Event[] | null;
|
|
16
|
-
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/agents/eliza/parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAuD/C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,KAAK,GAAG,KAAK,EAAE,GAAG,IAAI,CAwDxB"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ELIZA CLI output parser
|
|
3
|
-
*
|
|
4
|
-
* Pure function for parsing ELIZA CLI JSON output.
|
|
5
|
-
* ELIZA outputs Claude-compatible JSON, so this parser is similar to Claude's.
|
|
6
|
-
*/
|
|
7
|
-
import { createToolStartEvent } from "../../core/tools";
|
|
8
|
-
import { safeJsonParse } from "../../utils/json";
|
|
9
|
-
/**
|
|
10
|
-
* Parse a line of ELIZA CLI output into event(s).
|
|
11
|
-
*
|
|
12
|
-
* @param line - Raw line from CLI output
|
|
13
|
-
* @param toolMappings - Tool name mappings for this agent
|
|
14
|
-
* @returns Event, array of events, or null if line should be ignored
|
|
15
|
-
*/
|
|
16
|
-
export function parseElizaLine(line, toolMappings) {
|
|
17
|
-
const json = safeJsonParse(line);
|
|
18
|
-
if (!json) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
// System init event contains session ID
|
|
22
|
-
if (json.type === "system" && "subtype" in json && json.subtype === "init") {
|
|
23
|
-
return { type: "session", id: json.session_id };
|
|
24
|
-
}
|
|
25
|
-
// Assistant message contains the response content
|
|
26
|
-
if (json.type === "assistant" && "message" in json) {
|
|
27
|
-
const content = json.message.content;
|
|
28
|
-
if (content && content.length > 0) {
|
|
29
|
-
const events = [];
|
|
30
|
-
for (const block of content) {
|
|
31
|
-
if (block.type === "text" && block.text) {
|
|
32
|
-
events.push({ type: "token", text: block.text });
|
|
33
|
-
}
|
|
34
|
-
if (block.type === "tool_use" && block.name) {
|
|
35
|
-
events.push(createToolStartEvent(block.name, block.input, toolMappings));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// Return single event or array
|
|
39
|
-
if (events.length === 1) {
|
|
40
|
-
return events[0];
|
|
41
|
-
}
|
|
42
|
-
else if (events.length > 1) {
|
|
43
|
-
return events;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
// Tool result inside user message
|
|
49
|
-
if (json.type === "user" && json.message?.content) {
|
|
50
|
-
for (const block of json.message.content) {
|
|
51
|
-
if (block.type === "tool_result") {
|
|
52
|
-
const output = block.is_error
|
|
53
|
-
? `Error: ${block.content}`
|
|
54
|
-
: block.content;
|
|
55
|
-
return { type: "tool_end", output };
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
// Result event marks end of interaction
|
|
61
|
-
if (json.type === "result") {
|
|
62
|
-
const err = json.is_error || json.subtype === "error" ? json.result : undefined;
|
|
63
|
-
return { type: "end", ...(err ? { error: err } : {}) };
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/agents/eliza/parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAqDhD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,YAAoC;IAEpC,MAAM,IAAI,GAAG,aAAa,CAAa,IAAI,CAAC,CAAA;IAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAA;IACb,CAAC;IAED,wCAAwC;IACxC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;QAC3E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,CAAA;IACjD,CAAC;IAED,kDAAkD;IAClD,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACnD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA;QACpC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,MAAM,GAAY,EAAE,CAAA;YAE1B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,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3B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;QAC/E,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;IACxD,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ELIZA pattern matching - Classic therapist bot patterns
|
|
3
|
-
*
|
|
4
|
-
* All responses are deterministic based on input hash, not random.
|
|
5
|
-
*/
|
|
6
|
-
export interface FileAction {
|
|
7
|
-
type: "write" | "read" | "delete";
|
|
8
|
-
fileNameTemplate: string;
|
|
9
|
-
contentTemplate?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ElizaPattern {
|
|
12
|
-
pattern: RegExp;
|
|
13
|
-
responses: string[];
|
|
14
|
-
fileAction?: FileAction;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Classic ELIZA patterns with therapeutic file operations
|
|
18
|
-
*/
|
|
19
|
-
export declare const ELIZA_PATTERNS: ElizaPattern[];
|
|
20
|
-
/**
|
|
21
|
-
* Deterministic hash function for reproducible response selection.
|
|
22
|
-
* Uses a simple djb2-like hash.
|
|
23
|
-
*/
|
|
24
|
-
export declare function hashString(str: string): number;
|
|
25
|
-
/**
|
|
26
|
-
* Substitute template placeholders with matched groups and date.
|
|
27
|
-
*/
|
|
28
|
-
export declare function substituteTemplate(template: string | undefined, match: RegExpMatchArray): string;
|
|
29
|
-
export interface MatchResult {
|
|
30
|
-
response: string;
|
|
31
|
-
fileAction?: {
|
|
32
|
-
type: "write" | "read" | "delete";
|
|
33
|
-
fileName: string;
|
|
34
|
-
content?: string;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Match input against ELIZA patterns and return deterministic response.
|
|
39
|
-
*/
|
|
40
|
-
export declare function matchPattern(input: string): MatchResult;
|
|
41
|
-
//# sourceMappingURL=patterns.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../../src/agents/eliza/patterns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;IACjC,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,YAAY,EAiNxC,CAAA;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,gBAAgB,GACtB,MAAM,CAcR;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;QACjC,QAAQ,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;CACF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAwCvD"}
|