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
|
@@ -1,259 +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
|
-
/**
|
|
7
|
-
* Classic ELIZA patterns with therapeutic file operations
|
|
8
|
-
*/
|
|
9
|
-
export const 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
|
-
/**
|
|
201
|
-
* Deterministic hash function for reproducible response selection.
|
|
202
|
-
* Uses a simple djb2-like hash.
|
|
203
|
-
*/
|
|
204
|
-
export function hashString(str) {
|
|
205
|
-
let hash = 5381;
|
|
206
|
-
for (let i = 0; i < str.length; i++) {
|
|
207
|
-
hash = (hash << 5) + hash + str.charCodeAt(i);
|
|
208
|
-
hash = hash & hash; // Convert to 32-bit integer
|
|
209
|
-
}
|
|
210
|
-
return Math.abs(hash);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Substitute template placeholders with matched groups and date.
|
|
214
|
-
*/
|
|
215
|
-
export function substituteTemplate(template, match) {
|
|
216
|
-
if (!template)
|
|
217
|
-
return "";
|
|
218
|
-
let result = template;
|
|
219
|
-
// Replace capture group placeholders {0}, {1}, etc.
|
|
220
|
-
for (let i = 1; i < match.length; i++) {
|
|
221
|
-
result = result.replace(new RegExp(`\\{${i - 1}\\}`, "g"), match[i] || "");
|
|
222
|
-
}
|
|
223
|
-
// Replace {date} placeholder
|
|
224
|
-
result = result.replace(/\{date\}/g, new Date().toISOString());
|
|
225
|
-
return result;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Match input against ELIZA patterns and return deterministic response.
|
|
229
|
-
*/
|
|
230
|
-
export function matchPattern(input) {
|
|
231
|
-
const normalized = input.trim();
|
|
232
|
-
for (const pattern of ELIZA_PATTERNS) {
|
|
233
|
-
const match = normalized.match(pattern.pattern);
|
|
234
|
-
if (match) {
|
|
235
|
-
// Select response deterministically based on input hash
|
|
236
|
-
const responseIndex = hashString(normalized) % pattern.responses.length;
|
|
237
|
-
let response = pattern.responses[responseIndex];
|
|
238
|
-
// Replace capture groups in response
|
|
239
|
-
for (let i = 1; i < match.length; i++) {
|
|
240
|
-
response = response.replace(new RegExp(`\\{${i - 1}\\}`, "g"), match[i] || "");
|
|
241
|
-
}
|
|
242
|
-
// Prepare file action if any
|
|
243
|
-
let fileAction;
|
|
244
|
-
if (pattern.fileAction) {
|
|
245
|
-
const fileName = substituteTemplate(pattern.fileAction.fileNameTemplate, match).trim();
|
|
246
|
-
const content = substituteTemplate(pattern.fileAction.contentTemplate, match);
|
|
247
|
-
fileAction = {
|
|
248
|
-
type: pattern.fileAction.type,
|
|
249
|
-
fileName,
|
|
250
|
-
content: content || undefined,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
return { response, fileAction };
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
// Should never reach here due to fallback pattern, but just in case
|
|
257
|
-
return { response: "Please tell me more." };
|
|
258
|
-
}
|
|
259
|
-
//# sourceMappingURL=patterns.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../../../src/agents/eliza/patterns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,oBAAoB;IACpB;QACE,OAAO,EAAE,+EAA+E;QACxF,SAAS,EAAE;YACT,mCAAmC;YACnC,uCAAuC;YACvC,yCAAyC;YACzC,6CAA6C;SAC9C;KACF;IAED,kBAAkB;IAClB;QACE,OAAO,EAAE,YAAY;QACrB,SAAS,EAAE;YACT,6BAA6B;YAC7B,6BAA6B;YAC7B,wCAAwC;YACx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"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ELIZA tool name mappings
|
|
3
|
-
*
|
|
4
|
-
* Maps ELIZA tool names (Claude-compatible) to canonical tool names.
|
|
5
|
-
*/
|
|
6
|
-
export const ELIZA_TOOL_MAPPINGS = {
|
|
7
|
-
Write: "write",
|
|
8
|
-
Read: "read",
|
|
9
|
-
Bash: "shell",
|
|
10
|
-
Edit: "edit",
|
|
11
|
-
Glob: "glob",
|
|
12
|
-
Grep: "grep",
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/agents/eliza/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAA2B;IACzD,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACb,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Google Gemini CLI Agent Definition
|
|
3
|
-
*/
|
|
4
|
-
import type { AgentDefinition } from "../../core/agent";
|
|
5
|
-
/**
|
|
6
|
-
* Google Gemini CLI agent definition.
|
|
7
|
-
*
|
|
8
|
-
* Interacts with the Gemini CLI tool which outputs JSON lines.
|
|
9
|
-
*/
|
|
10
|
-
export declare const geminiAgent: AgentDefinition;
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/gemini/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,kBAAkB,CAAA;AAKzB;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,eA4CzB,CAAA"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Google Gemini CLI Agent Definition
|
|
3
|
-
*/
|
|
4
|
-
import { parseGeminiLine } from "./parser";
|
|
5
|
-
import { GEMINI_TOOL_MAPPINGS } from "./tools";
|
|
6
|
-
/**
|
|
7
|
-
* Google Gemini CLI agent definition.
|
|
8
|
-
*
|
|
9
|
-
* Interacts with the Gemini CLI tool which outputs JSON lines.
|
|
10
|
-
*/
|
|
11
|
-
export const geminiAgent = {
|
|
12
|
-
name: "gemini",
|
|
13
|
-
toolMappings: GEMINI_TOOL_MAPPINGS,
|
|
14
|
-
capabilities: {
|
|
15
|
-
supportsSystemPrompt: false,
|
|
16
|
-
supportsResume: true,
|
|
17
|
-
},
|
|
18
|
-
buildCommand(options) {
|
|
19
|
-
const args = [];
|
|
20
|
-
// Stream JSON for event parsing
|
|
21
|
-
args.push("--output-format", "stream-json");
|
|
22
|
-
// Enable full tool access (shell, file writes, etc.) - safe in sandbox environment
|
|
23
|
-
args.push("--yolo");
|
|
24
|
-
// Add model if specified (e.g., "gemini-2.0-flash", "gemini-1.5-pro")
|
|
25
|
-
if (options.model) {
|
|
26
|
-
args.push("--model", options.model);
|
|
27
|
-
}
|
|
28
|
-
// Resume session if provided
|
|
29
|
-
if (options.sessionId) {
|
|
30
|
-
args.push("--resume", options.sessionId);
|
|
31
|
-
}
|
|
32
|
-
// Add prompt with -p flag if provided
|
|
33
|
-
if (options.prompt) {
|
|
34
|
-
args.push("-p", options.prompt);
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
cmd: "gemini",
|
|
38
|
-
args,
|
|
39
|
-
env: options.env,
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
parse(line, context) {
|
|
43
|
-
return parseGeminiLine(line, this.toolMappings, context);
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|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AA"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gemini CLI output parser
|
|
3
|
-
*
|
|
4
|
-
* Pure function for parsing Gemini CLI JSON output.
|
|
5
|
-
* Note: Gemini requires stateful parsing for tool output buffering.
|
|
6
|
-
*
|
|
7
|
-
* Reference schema (from actual CLI output):
|
|
8
|
-
* { type: "init", session_id }
|
|
9
|
-
* { type: "message", role, content, delta? }
|
|
10
|
-
* { type: "tool_use", tool_name, tool_id, parameters } ← tool starts
|
|
11
|
-
* { type: "tool_result", tool_id, status, output? } ← tool ends
|
|
12
|
-
* { type: "result", status, stats } ← turn end
|
|
13
|
-
*
|
|
14
|
-
* Legacy schema (older CLI versions — kept for compatibility):
|
|
15
|
-
* { type: "assistant.delta", text }
|
|
16
|
-
* { type: "tool.start", name, input? }
|
|
17
|
-
* { type: "tool.delta", text }
|
|
18
|
-
* { type: "tool.end" }
|
|
19
|
-
* { type: "assistant.complete" }
|
|
20
|
-
*/
|
|
21
|
-
import type { Event } from "../../types/events";
|
|
22
|
-
import type { ParseContext } from "../../core/agent";
|
|
23
|
-
/**
|
|
24
|
-
* Parse a line of Gemini CLI output into event(s).
|
|
25
|
-
*
|
|
26
|
-
* Uses context.state for stateful tracking:
|
|
27
|
-
* - pendingToolIds: Map<tool_id, true> — tracks tool_use events awaiting their tool_result
|
|
28
|
-
* - toolOutputBuffer: string — legacy streaming buffer
|
|
29
|
-
*/
|
|
30
|
-
export declare function parseGeminiLine(line: string, toolMappings: Record<string, string>, context: ParseContext): Event | Event[] | null;
|
|
31
|
-
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/agents/gemini/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA6EpD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,EAAE,YAAY,GACpB,KAAK,GAAG,KAAK,EAAE,GAAG,IAAI,CAwFxB"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gemini CLI output parser
|
|
3
|
-
*
|
|
4
|
-
* Pure function for parsing Gemini CLI JSON output.
|
|
5
|
-
* Note: Gemini requires stateful parsing for tool output buffering.
|
|
6
|
-
*
|
|
7
|
-
* Reference schema (from actual CLI output):
|
|
8
|
-
* { type: "init", session_id }
|
|
9
|
-
* { type: "message", role, content, delta? }
|
|
10
|
-
* { type: "tool_use", tool_name, tool_id, parameters } ← tool starts
|
|
11
|
-
* { type: "tool_result", tool_id, status, output? } ← tool ends
|
|
12
|
-
* { type: "result", status, stats } ← turn end
|
|
13
|
-
*
|
|
14
|
-
* Legacy schema (older CLI versions — kept for compatibility):
|
|
15
|
-
* { type: "assistant.delta", text }
|
|
16
|
-
* { type: "tool.start", name, input? }
|
|
17
|
-
* { type: "tool.delta", text }
|
|
18
|
-
* { type: "tool.end" }
|
|
19
|
-
* { type: "assistant.complete" }
|
|
20
|
-
*/
|
|
21
|
-
import { createToolStartEvent, normalizeToolName } from "../../core/tools";
|
|
22
|
-
import { safeJsonParse } from "../../utils/json";
|
|
23
|
-
/**
|
|
24
|
-
* Parse a line of Gemini CLI output into event(s).
|
|
25
|
-
*
|
|
26
|
-
* Uses context.state for stateful tracking:
|
|
27
|
-
* - pendingToolIds: Map<tool_id, true> — tracks tool_use events awaiting their tool_result
|
|
28
|
-
* - toolOutputBuffer: string — legacy streaming buffer
|
|
29
|
-
*/
|
|
30
|
-
export function parseGeminiLine(line, toolMappings, context) {
|
|
31
|
-
const json = safeJsonParse(line);
|
|
32
|
-
if (!json) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
// Session init
|
|
36
|
-
if (json.type === "init") {
|
|
37
|
-
return { type: "session", id: json.session_id };
|
|
38
|
-
}
|
|
39
|
-
// Assistant text delta (legacy format)
|
|
40
|
-
if (json.type === "assistant.delta") {
|
|
41
|
-
return { type: "token", text: json.text };
|
|
42
|
-
}
|
|
43
|
-
// Message event (current Gemini format) — text only, tool calls are separate
|
|
44
|
-
if (json.type === "message") {
|
|
45
|
-
if (json.role === "assistant" && json.content) {
|
|
46
|
-
return { type: "token", text: json.content };
|
|
47
|
-
}
|
|
48
|
-
// Skip user messages
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
// Result event — marks turn completion
|
|
52
|
-
if (json.type === "result") {
|
|
53
|
-
return { type: "end" };
|
|
54
|
-
}
|
|
55
|
-
// ── Current Gemini format: tool_use + tool_result ──────────────────────────
|
|
56
|
-
// tool_use: the agent is invoking a tool.
|
|
57
|
-
// We emit tool_start immediately, and stash the tool_id so we can pair the output.
|
|
58
|
-
if (json.type === "tool_use") {
|
|
59
|
-
const name = normalizeToolName(json.tool_name.toLowerCase(), toolMappings);
|
|
60
|
-
// Track pending tool_id → tool event pairing in parse context
|
|
61
|
-
if (!context.state.pendingToolIds) {
|
|
62
|
-
context.state.pendingToolIds = {};
|
|
63
|
-
}
|
|
64
|
-
// Store the normalized name so tool_result can reference it (not strictly needed but aids debugging)
|
|
65
|
-
;
|
|
66
|
-
context.state.pendingToolIds[json.tool_id] = name;
|
|
67
|
-
return createToolStartEvent(name, json.parameters, toolMappings);
|
|
68
|
-
}
|
|
69
|
-
// tool_result: the tool invocation completed, contains stdout/stderr in output.
|
|
70
|
-
// We pair it with the most recently started tool_use via tool_id.
|
|
71
|
-
if (json.type === "tool_result") {
|
|
72
|
-
// Clean up the tracked tool_id
|
|
73
|
-
if (context.state.pendingToolIds) {
|
|
74
|
-
delete context.state.pendingToolIds[json.tool_id];
|
|
75
|
-
}
|
|
76
|
-
const output = typeof json.output === "string" && json.output.trim()
|
|
77
|
-
? json.output.trim()
|
|
78
|
-
: undefined;
|
|
79
|
-
return { type: "tool_end", output };
|
|
80
|
-
}
|
|
81
|
-
// ── Legacy Gemini streaming format ────────────────────────────────────────
|
|
82
|
-
// Tool start (legacy)
|
|
83
|
-
if (json.type === "tool.start") {
|
|
84
|
-
context.state.toolOutputBuffer = "";
|
|
85
|
-
const name = normalizeToolName(json.name.toLowerCase(), toolMappings);
|
|
86
|
-
return createToolStartEvent(name, json.input, toolMappings);
|
|
87
|
-
}
|
|
88
|
-
// Tool delta (streaming tool input or output)
|
|
89
|
-
if (json.type === "tool.delta") {
|
|
90
|
-
const buffer = context.state.toolOutputBuffer ?? "";
|
|
91
|
-
context.state.toolOutputBuffer = buffer + json.text;
|
|
92
|
-
return { type: "tool_delta", text: json.text };
|
|
93
|
-
}
|
|
94
|
-
// Tool end
|
|
95
|
-
if (json.type === "tool.end") {
|
|
96
|
-
const output = (context.state.toolOutputBuffer ?? "").trim() || undefined;
|
|
97
|
-
context.state.toolOutputBuffer = "";
|
|
98
|
-
return { type: "tool_end", output };
|
|
99
|
-
}
|
|
100
|
-
// Assistant complete (legacy format)
|
|
101
|
-
if (json.type === "assistant.complete") {
|
|
102
|
-
return { type: "end" };
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/agents/gemini/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AA2EhD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,YAAoC,EACpC,OAAqB;IAErB,MAAM,IAAI,GAAG,a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D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAChD,CAAC;IAED,WAAW;IACX,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC7B,MAAM,MAAM,GACV,CAAE,OAAO,CAAC,KAAK,CAAC,gBAA2B,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,SAAS,CAAA;QACxE,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,EAAE,CAAA;QACnC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;IACrC,CAAC;IAED,qCAAqC;IACrC,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QACvC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/agents/gemini/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAgBvD,CAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gemini tool name mappings
|
|
3
|
-
*
|
|
4
|
-
* Maps Gemini CLI tool names to canonical tool names.
|
|
5
|
-
*/
|
|
6
|
-
export const GEMINI_TOOL_MAPPINGS = {
|
|
7
|
-
// Shell / command execution
|
|
8
|
-
execute_code: "shell",
|
|
9
|
-
run_command: "shell",
|
|
10
|
-
run_shell_command: "shell",
|
|
11
|
-
bash: "shell",
|
|
12
|
-
// File operations
|
|
13
|
-
write_file: "write",
|
|
14
|
-
write_todos: "write",
|
|
15
|
-
read_file: "read",
|
|
16
|
-
apply_patch: "edit",
|
|
17
|
-
replace: "edit",
|
|
18
|
-
// Search
|
|
19
|
-
glob_file_search: "glob",
|
|
20
|
-
list_directory: "glob",
|
|
21
|
-
grep_search: "grep",
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/agents/gemini/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,4BAA4B;IAC5B,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,iBAAiB,EAAE,OAAO;IAC1B,IAAI,EAAE,OAAO;IACb,kBAAkB;IAClB,UAAU,EAAE,OAAO;IACnB,WAAW,EAAE,OAAO;IACpB,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,MAAM;IACf,SAAS;IACT,gBAAgB,EAAE,MAAM;IACxB,cAAc,EAAE,MAAM;IACtB,WAAW,EAAE,MAAM;CACpB,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Goose CLI Agent Definition
|
|
3
|
-
*/
|
|
4
|
-
import type { AgentDefinition } from "../../core/agent";
|
|
5
|
-
/**
|
|
6
|
-
* Goose CLI agent definition.
|
|
7
|
-
*
|
|
8
|
-
* Interacts with the Goose CLI tool (Block's open source AI coding agent).
|
|
9
|
-
*/
|
|
10
|
-
export declare const gooseAgent: AgentDefinition;
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/goose/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAyC,MAAM,kBAAkB,CAAA;AA2B9F;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,eAyDxB,CAAA"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Goose CLI Agent Definition
|
|
3
|
-
*/
|
|
4
|
-
import { parseGooseLine } from "./parser";
|
|
5
|
-
import { GOOSE_TOOL_MAPPINGS } from "./tools";
|
|
6
|
-
/**
|
|
7
|
-
* Determine the goose provider and model based on the model name and environment.
|
|
8
|
-
* Goose supports multiple providers: openai, anthropic, ollama, etc.
|
|
9
|
-
*/
|
|
10
|
-
function getGooseProviderAndModel(model, env) {
|
|
11
|
-
// If model contains "claude", use anthropic provider
|
|
12
|
-
if (model?.toLowerCase().includes("claude")) {
|
|
13
|
-
return { provider: "anthropic", model: model };
|
|
14
|
-
}
|
|
15
|
-
// If ANTHROPIC_API_KEY is set but not OPENAI_API_KEY, use anthropic
|
|
16
|
-
if (env?.ANTHROPIC_API_KEY && !env?.OPENAI_API_KEY) {
|
|
17
|
-
return { provider: "anthropic", model: model || "claude-sonnet-4-5" };
|
|
18
|
-
}
|
|
19
|
-
// Default to OpenAI provider
|
|
20
|
-
return { provider: "openai", model: model || "gpt-4o" };
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Goose CLI agent definition.
|
|
24
|
-
*
|
|
25
|
-
* Interacts with the Goose CLI tool (Block's open source AI coding agent).
|
|
26
|
-
*/
|
|
27
|
-
export const gooseAgent = {
|
|
28
|
-
name: "goose",
|
|
29
|
-
toolMappings: GOOSE_TOOL_MAPPINGS,
|
|
30
|
-
capabilities: {
|
|
31
|
-
supportsSystemPrompt: true,
|
|
32
|
-
supportsResume: true,
|
|
33
|
-
},
|
|
34
|
-
buildCommand(options) {
|
|
35
|
-
const gooseArgs = [];
|
|
36
|
-
// Use run subcommand for non-interactive execution
|
|
37
|
-
gooseArgs.push("run");
|
|
38
|
-
// Enable JSON streaming output for machine-readable events
|
|
39
|
-
gooseArgs.push("--output-format", "stream-json");
|
|
40
|
-
// Determine provider and model based on model name and environment
|
|
41
|
-
const { provider, model } = getGooseProviderAndModel(options.model, options.env);
|
|
42
|
-
gooseArgs.push("--provider", provider);
|
|
43
|
-
gooseArgs.push("--model", model);
|
|
44
|
-
// Add prompt as text input
|
|
45
|
-
if (options.prompt) {
|
|
46
|
-
gooseArgs.push("--text", options.prompt);
|
|
47
|
-
}
|
|
48
|
-
// Apply system prompt via --system flag when provided
|
|
49
|
-
if (options.systemPrompt) {
|
|
50
|
-
gooseArgs.push("--system", options.systemPrompt);
|
|
51
|
-
}
|
|
52
|
-
// Session handling: goose resumes the most recent session when --resume is used
|
|
53
|
-
// First message (no sessionId): creates new session
|
|
54
|
-
// Subsequent messages (has sessionId): resumes most recent session
|
|
55
|
-
if (options.sessionId) {
|
|
56
|
-
gooseArgs.push("--resume");
|
|
57
|
-
}
|
|
58
|
-
// Build the goose command string (will be passed to bash -c)
|
|
59
|
-
const gooseCmd = ["goose", ...gooseArgs].map(arg => {
|
|
60
|
-
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
61
|
-
}).join(" ");
|
|
62
|
-
// Wrap in bash to ensure PATH includes ~/.local/bin where goose installs
|
|
63
|
-
return {
|
|
64
|
-
cmd: "bash",
|
|
65
|
-
args: ["-c", `export PATH="$HOME/.local/bin:$PATH" && ${gooseCmd}`],
|
|
66
|
-
env: options.env,
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
parse(line, context) {
|
|
70
|
-
return parseGooseLine(line, this.toolMappings, context);
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/goose/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE7C;;;GAGG;AACH,SAAS,wBAAwB,CAC/B,KAAyB,EACzB,GAAuC;IAEvC,qDAAqD;IACrD,IAAI,KAAK,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CA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