beercan 0.1.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/LICENSE +21 -0
- package/README.md +187 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +546 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +29 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +49 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +61 -0
- package/dist/config.js.map +1 -0
- package/dist/core/gatekeeper.d.ts +163 -0
- package/dist/core/gatekeeper.d.ts.map +1 -0
- package/dist/core/gatekeeper.js +247 -0
- package/dist/core/gatekeeper.js.map +1 -0
- package/dist/core/job-queue.d.ts +61 -0
- package/dist/core/job-queue.d.ts.map +1 -0
- package/dist/core/job-queue.js +123 -0
- package/dist/core/job-queue.js.map +1 -0
- package/dist/core/logger.d.ts +22 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +65 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/role-templates.d.ts +3 -0
- package/dist/core/role-templates.d.ts.map +1 -0
- package/dist/core/role-templates.js +179 -0
- package/dist/core/role-templates.js.map +1 -0
- package/dist/core/roles.d.ts +94 -0
- package/dist/core/roles.d.ts.map +1 -0
- package/dist/core/roles.js +206 -0
- package/dist/core/roles.js.map +1 -0
- package/dist/core/runner.d.ts +76 -0
- package/dist/core/runner.d.ts.map +1 -0
- package/dist/core/runner.js +307 -0
- package/dist/core/runner.js.map +1 -0
- package/dist/events/daemon.d.ts +9 -0
- package/dist/events/daemon.d.ts.map +1 -0
- package/dist/events/daemon.js +29 -0
- package/dist/events/daemon.js.map +1 -0
- package/dist/events/event-bus.d.ts +35 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/event-bus.js +41 -0
- package/dist/events/event-bus.js.map +1 -0
- package/dist/events/index.d.ts +41 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +57 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/sources/filesystem-source.d.ts +23 -0
- package/dist/events/sources/filesystem-source.d.ts.map +1 -0
- package/dist/events/sources/filesystem-source.js +95 -0
- package/dist/events/sources/filesystem-source.js.map +1 -0
- package/dist/events/sources/macos-source.d.ts +23 -0
- package/dist/events/sources/macos-source.d.ts.map +1 -0
- package/dist/events/sources/macos-source.js +123 -0
- package/dist/events/sources/macos-source.js.map +1 -0
- package/dist/events/sources/polling-source.d.ts +23 -0
- package/dist/events/sources/polling-source.d.ts.map +1 -0
- package/dist/events/sources/polling-source.js +47 -0
- package/dist/events/sources/polling-source.js.map +1 -0
- package/dist/events/sources/webhook-source.d.ts +23 -0
- package/dist/events/sources/webhook-source.d.ts.map +1 -0
- package/dist/events/sources/webhook-source.js +132 -0
- package/dist/events/sources/webhook-source.js.map +1 -0
- package/dist/events/trigger-manager.d.ts +78 -0
- package/dist/events/trigger-manager.d.ts.map +1 -0
- package/dist/events/trigger-manager.js +130 -0
- package/dist/events/trigger-manager.js.map +1 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +225 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +99 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +143 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/tool-adapter.d.ts +20 -0
- package/dist/mcp/tool-adapter.d.ts.map +1 -0
- package/dist/mcp/tool-adapter.js +29 -0
- package/dist/mcp/tool-adapter.js.map +1 -0
- package/dist/memory/embeddings.d.ts +28 -0
- package/dist/memory/embeddings.d.ts.map +1 -0
- package/dist/memory/embeddings.js +90 -0
- package/dist/memory/embeddings.js.map +1 -0
- package/dist/memory/hybrid-search.d.ts +31 -0
- package/dist/memory/hybrid-search.d.ts.map +1 -0
- package/dist/memory/hybrid-search.js +114 -0
- package/dist/memory/hybrid-search.js.map +1 -0
- package/dist/memory/index.d.ts +55 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +175 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/knowledge-graph.d.ts +21 -0
- package/dist/memory/knowledge-graph.d.ts.map +1 -0
- package/dist/memory/knowledge-graph.js +118 -0
- package/dist/memory/knowledge-graph.js.map +1 -0
- package/dist/memory/schemas.d.ts +187 -0
- package/dist/memory/schemas.d.ts.map +1 -0
- package/dist/memory/schemas.js +75 -0
- package/dist/memory/schemas.js.map +1 -0
- package/dist/memory/sqlite-vec-store.d.ts +22 -0
- package/dist/memory/sqlite-vec-store.d.ts.map +1 -0
- package/dist/memory/sqlite-vec-store.js +37 -0
- package/dist/memory/sqlite-vec-store.js.map +1 -0
- package/dist/memory/working-memory.d.ts +22 -0
- package/dist/memory/working-memory.d.ts.map +1 -0
- package/dist/memory/working-memory.js +53 -0
- package/dist/memory/working-memory.js.map +1 -0
- package/dist/scheduler/index.d.ts +3 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +2 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/scheduler/scheduler.d.ts +82 -0
- package/dist/scheduler/scheduler.d.ts.map +1 -0
- package/dist/scheduler/scheduler.js +127 -0
- package/dist/scheduler/scheduler.js.map +1 -0
- package/dist/schemas.d.ts +328 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +77 -0
- package/dist/schemas.js.map +1 -0
- package/dist/storage/database.d.ts +97 -0
- package/dist/storage/database.d.ts.map +1 -0
- package/dist/storage/database.js +685 -0
- package/dist/storage/database.js.map +1 -0
- package/dist/tools/builtin/filesystem.d.ts +11 -0
- package/dist/tools/builtin/filesystem.d.ts.map +1 -0
- package/dist/tools/builtin/filesystem.js +137 -0
- package/dist/tools/builtin/filesystem.js.map +1 -0
- package/dist/tools/builtin/memory.d.ts +13 -0
- package/dist/tools/builtin/memory.d.ts.map +1 -0
- package/dist/tools/builtin/memory.js +299 -0
- package/dist/tools/builtin/memory.js.map +1 -0
- package/dist/tools/builtin/notification.d.ts +5 -0
- package/dist/tools/builtin/notification.d.ts.map +1 -0
- package/dist/tools/builtin/notification.js +36 -0
- package/dist/tools/builtin/notification.js.map +1 -0
- package/dist/tools/builtin/web.d.ts +7 -0
- package/dist/tools/builtin/web.d.ts.map +1 -0
- package/dist/tools/builtin/web.js +191 -0
- package/dist/tools/builtin/web.js.map +1 -0
- package/dist/tools/registry.d.ts +36 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +49 -0
- package/dist/tools/registry.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ── Agent Role Schema ────────────────────────────────────────
|
|
3
|
+
export const AgentRoleSchema = z.object({
|
|
4
|
+
/** Unique role identifier, e.g. "coder", "reviewer", "manager" */
|
|
5
|
+
id: z.string(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
description: z.string(),
|
|
8
|
+
/** System prompt injected when this agent is active */
|
|
9
|
+
systemPrompt: z.string(),
|
|
10
|
+
/** Which tools this role is allowed to use. ["*"] = all project tools */
|
|
11
|
+
allowedTools: z.array(z.string()).default(["*"]),
|
|
12
|
+
/** Model override — some roles need heavier reasoning */
|
|
13
|
+
model: z.string().optional(),
|
|
14
|
+
/** Temperature override */
|
|
15
|
+
temperature: z.number().min(0).max(1).optional(),
|
|
16
|
+
/**
|
|
17
|
+
* When does this agent get invoked in a bloop?
|
|
18
|
+
* - "primary" → runs the main bloop cycle
|
|
19
|
+
* - "review" → called after primary produces output
|
|
20
|
+
* - "validate" → called after review to verify / run tests
|
|
21
|
+
* - "plan" → called at the start to break down the goal
|
|
22
|
+
* - "summarize" → called at the end to produce final output
|
|
23
|
+
*/
|
|
24
|
+
phase: z.enum(["plan", "primary", "review", "validate", "summarize"]).default("primary"),
|
|
25
|
+
/** Max iterations this specific agent can run within its phase */
|
|
26
|
+
maxIterations: z.number().default(20),
|
|
27
|
+
});
|
|
28
|
+
// ── Bloop Team Schema ─────────────────────────────────────────
|
|
29
|
+
// Defines which agents participate in a bloop and in what order
|
|
30
|
+
export const BloopTeamSchema = z.object({
|
|
31
|
+
/**
|
|
32
|
+
* Pipeline defines execution order.
|
|
33
|
+
* Each stage runs its assigned agent(s) before moving to the next.
|
|
34
|
+
* A stage can have multiple agents (they see each other's output).
|
|
35
|
+
*/
|
|
36
|
+
pipeline: z.array(z.object({
|
|
37
|
+
phase: z.enum(["plan", "primary", "review", "validate", "summarize"]),
|
|
38
|
+
roleId: z.string(),
|
|
39
|
+
/** If true, this phase can send work back to a previous phase */
|
|
40
|
+
canReject: z.boolean().optional(),
|
|
41
|
+
/** Phase to return to on rejection */
|
|
42
|
+
rejectTo: z.enum(["plan", "primary", "review", "validate", "summarize"]).optional(),
|
|
43
|
+
})),
|
|
44
|
+
/** Max full pipeline cycles (plan→primary→review→validate) before forced completion */
|
|
45
|
+
maxCycles: z.number().default(3),
|
|
46
|
+
});
|
|
47
|
+
// ── Built-in Roles ───────────────────────────────────────────
|
|
48
|
+
export const BUILTIN_ROLES = {
|
|
49
|
+
manager: {
|
|
50
|
+
id: "manager",
|
|
51
|
+
name: "Manager",
|
|
52
|
+
description: "Breaks down goals into tasks, coordinates work, decides when done.",
|
|
53
|
+
systemPrompt: `You are the Manager agent in the BeerCan system. Your responsibilities:
|
|
54
|
+
|
|
55
|
+
1. PLANNING: Break down the user's goal into concrete, actionable sub-tasks.
|
|
56
|
+
2. DELEGATION: Decide which tasks need coding, research, or other specialist work.
|
|
57
|
+
3. EVALUATION: Review outputs from other agents and decide if the goal is met.
|
|
58
|
+
4. COMPLETION: When satisfied, produce a clear summary of what was accomplished.
|
|
59
|
+
|
|
60
|
+
You think strategically. You don't write code yourself — you describe what needs to be built,
|
|
61
|
+
what files to create/modify, and what the acceptance criteria are.
|
|
62
|
+
|
|
63
|
+
When evaluating work from other agents:
|
|
64
|
+
- If the work meets the goal → respond with <decision>APPROVE</decision>
|
|
65
|
+
- If changes are needed → respond with <decision>REVISE</decision> and explain what to fix
|
|
66
|
+
- If the approach is fundamentally wrong → respond with <decision>REJECT</decision> and re-plan
|
|
67
|
+
|
|
68
|
+
Be concise. Be decisive. Don't waffle.`,
|
|
69
|
+
allowedTools: ["read_file", "list_directory", "memory_search", "memory_query_graph", "memory_scratch"],
|
|
70
|
+
phase: "plan",
|
|
71
|
+
maxIterations: 10,
|
|
72
|
+
},
|
|
73
|
+
coder: {
|
|
74
|
+
id: "coder",
|
|
75
|
+
name: "Coder",
|
|
76
|
+
description: "Writes, modifies, and debugs code. Has full filesystem and exec access.",
|
|
77
|
+
systemPrompt: `You are the Coder agent in the BeerCan system. Your responsibilities:
|
|
78
|
+
|
|
79
|
+
1. Write clean, well-structured TypeScript/JavaScript code.
|
|
80
|
+
2. Follow the plan provided by the Manager agent.
|
|
81
|
+
3. Create files, modify existing code, run commands as needed.
|
|
82
|
+
4. After making changes, verify they work by running relevant commands.
|
|
83
|
+
|
|
84
|
+
Rules:
|
|
85
|
+
- Write production-quality code with proper error handling.
|
|
86
|
+
- Use TypeScript with strict types. No 'any' unless absolutely necessary.
|
|
87
|
+
- Keep files focused — one concern per file.
|
|
88
|
+
- Add brief JSDoc comments on exported functions.
|
|
89
|
+
- If something is unclear in the plan, make a reasonable decision and document it.
|
|
90
|
+
- After writing code, always try to verify it compiles/runs.
|
|
91
|
+
|
|
92
|
+
You have access to: read_file, write_file, list_directory, exec_command.`,
|
|
93
|
+
allowedTools: ["read_file", "write_file", "list_directory", "exec_command", "memory_search", "memory_store", "memory_update", "memory_link", "memory_scratch"],
|
|
94
|
+
phase: "primary",
|
|
95
|
+
maxIterations: 20,
|
|
96
|
+
},
|
|
97
|
+
reviewer: {
|
|
98
|
+
id: "reviewer",
|
|
99
|
+
name: "Reviewer",
|
|
100
|
+
description: "Reviews code for quality, bugs, security issues, and adherence to plan.",
|
|
101
|
+
systemPrompt: `You are the Reviewer agent in the BeerCan system. Your responsibilities:
|
|
102
|
+
|
|
103
|
+
1. Read the code produced by the Coder agent.
|
|
104
|
+
2. Check for: bugs, security issues, edge cases, code quality, adherence to the plan.
|
|
105
|
+
3. Verify the code is well-structured and maintainable.
|
|
106
|
+
4. Check that error handling is proper and types are correct.
|
|
107
|
+
|
|
108
|
+
Your output format:
|
|
109
|
+
- Start with an overall assessment: PASS, NEEDS_CHANGES, or FAIL
|
|
110
|
+
- List specific issues found (if any) with file paths and line references
|
|
111
|
+
- Suggest concrete fixes, not vague complaints
|
|
112
|
+
|
|
113
|
+
If PASS: respond with <decision>APPROVE</decision>
|
|
114
|
+
If NEEDS_CHANGES: respond with <decision>REVISE</decision> and list required changes
|
|
115
|
+
If FAIL: respond with <decision>REJECT</decision> and explain why
|
|
116
|
+
|
|
117
|
+
Be thorough but pragmatic. Don't nitpick style if functionality is correct.
|
|
118
|
+
Focus on things that would actually cause problems.`,
|
|
119
|
+
allowedTools: ["read_file", "list_directory", "exec_command", "memory_search", "memory_query_graph"],
|
|
120
|
+
phase: "review",
|
|
121
|
+
maxIterations: 5,
|
|
122
|
+
},
|
|
123
|
+
tester: {
|
|
124
|
+
id: "tester",
|
|
125
|
+
name: "Tester",
|
|
126
|
+
description: "Validates code by running tests, checking builds, verifying behavior.",
|
|
127
|
+
systemPrompt: `You are the Tester agent in the BeerCan system. Your responsibilities:
|
|
128
|
+
|
|
129
|
+
1. Verify the code produced by the Coder agent actually works.
|
|
130
|
+
2. Run build commands, execute scripts, check for runtime errors.
|
|
131
|
+
3. Write and run simple validation tests if appropriate.
|
|
132
|
+
4. Check edge cases and error conditions.
|
|
133
|
+
|
|
134
|
+
Your process:
|
|
135
|
+
1. Read the relevant files to understand what was built
|
|
136
|
+
2. Run any build/compile commands
|
|
137
|
+
3. Execute the code or tests
|
|
138
|
+
4. Report results
|
|
139
|
+
|
|
140
|
+
If everything passes: respond with <decision>APPROVE</decision>
|
|
141
|
+
If tests fail: respond with <decision>REVISE</decision> with exact error output
|
|
142
|
+
If fundamentally broken: respond with <decision>REJECT</decision>
|
|
143
|
+
|
|
144
|
+
Always include the actual command output in your response.`,
|
|
145
|
+
allowedTools: ["read_file", "write_file", "list_directory", "exec_command", "memory_search", "memory_scratch"],
|
|
146
|
+
phase: "validate",
|
|
147
|
+
maxIterations: 10,
|
|
148
|
+
},
|
|
149
|
+
solo: {
|
|
150
|
+
id: "solo",
|
|
151
|
+
name: "Solo",
|
|
152
|
+
description: "General-purpose single agent. Does everything — plan, code, review, test.",
|
|
153
|
+
systemPrompt: `You are a general-purpose agent in the BeerCan system. You handle all aspects of the task:
|
|
154
|
+
planning, implementation, review, and validation.
|
|
155
|
+
|
|
156
|
+
Work methodically:
|
|
157
|
+
1. Understand the goal
|
|
158
|
+
2. Plan your approach
|
|
159
|
+
3. Implement it using the tools available
|
|
160
|
+
4. Verify your work
|
|
161
|
+
5. Summarize what you did
|
|
162
|
+
|
|
163
|
+
When your goal is achieved, clearly state DONE and provide a summary.`,
|
|
164
|
+
allowedTools: ["*"],
|
|
165
|
+
phase: "primary",
|
|
166
|
+
maxIterations: 30,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
// ── Preset Teams ─────────────────────────────────────────────
|
|
170
|
+
export const PRESET_TEAMS = {
|
|
171
|
+
/** Solo agent — simplest setup, one agent does everything */
|
|
172
|
+
solo: {
|
|
173
|
+
pipeline: [
|
|
174
|
+
{ phase: "primary", roleId: "solo" },
|
|
175
|
+
],
|
|
176
|
+
maxCycles: 1,
|
|
177
|
+
},
|
|
178
|
+
/** Coder + Reviewer — write then review */
|
|
179
|
+
code_review: {
|
|
180
|
+
pipeline: [
|
|
181
|
+
{ phase: "primary", roleId: "coder" },
|
|
182
|
+
{ phase: "review", roleId: "reviewer", canReject: true, rejectTo: "primary" },
|
|
183
|
+
],
|
|
184
|
+
maxCycles: 3,
|
|
185
|
+
},
|
|
186
|
+
/** Full team — plan, code, review, test */
|
|
187
|
+
full_team: {
|
|
188
|
+
pipeline: [
|
|
189
|
+
{ phase: "plan", roleId: "manager" },
|
|
190
|
+
{ phase: "primary", roleId: "coder" },
|
|
191
|
+
{ phase: "review", roleId: "reviewer", canReject: true, rejectTo: "primary" },
|
|
192
|
+
{ phase: "validate", roleId: "tester", canReject: true, rejectTo: "primary" },
|
|
193
|
+
],
|
|
194
|
+
maxCycles: 3,
|
|
195
|
+
},
|
|
196
|
+
/** Manager + Coder — planned execution without formal review */
|
|
197
|
+
managed: {
|
|
198
|
+
pipeline: [
|
|
199
|
+
{ phase: "plan", roleId: "manager" },
|
|
200
|
+
{ phase: "primary", roleId: "coder" },
|
|
201
|
+
{ phase: "summarize", roleId: "manager" },
|
|
202
|
+
],
|
|
203
|
+
maxCycles: 2,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../../src/core/roles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gEAAgE;AAEhE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,kEAAkE;IAClE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,uDAAuD;IACvD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,yEAAyE;IACzE,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;IAChD,yDAAyD;IACzD,KAAK,EAAE,CAAC,CAAC,M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AE,CAAC;KACb;CACF,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
import { BeerCanDB } from "../storage/database.js";
|
|
3
|
+
import { ToolRegistry } from "../tools/registry.js";
|
|
4
|
+
import { MemoryManager } from "../memory/index.js";
|
|
5
|
+
import type { Bloop, Project } from "../schemas.js";
|
|
6
|
+
import type { AgentRole, BloopTeam } from "./roles.js";
|
|
7
|
+
export interface RunBloopOptions {
|
|
8
|
+
project: Project;
|
|
9
|
+
goal: string;
|
|
10
|
+
team?: BloopTeam;
|
|
11
|
+
parentBloopId?: string;
|
|
12
|
+
/** Extra context injected into every agent's system prompt */
|
|
13
|
+
extraContext?: string;
|
|
14
|
+
/** Callback for real-time output */
|
|
15
|
+
onEvent?: (event: BloopEvent) => void;
|
|
16
|
+
}
|
|
17
|
+
export type BloopEvent = {
|
|
18
|
+
type: "phase_start";
|
|
19
|
+
phase: string;
|
|
20
|
+
roleId: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "agent_message";
|
|
23
|
+
role: string;
|
|
24
|
+
content: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: "tool_call";
|
|
27
|
+
tool: string;
|
|
28
|
+
input: unknown;
|
|
29
|
+
} | {
|
|
30
|
+
type: "tool_result";
|
|
31
|
+
tool: string;
|
|
32
|
+
output: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "decision";
|
|
35
|
+
decision: string;
|
|
36
|
+
reason: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: "cycle";
|
|
39
|
+
cycle: number;
|
|
40
|
+
maxCycles: number;
|
|
41
|
+
} | {
|
|
42
|
+
type: "complete";
|
|
43
|
+
result: unknown;
|
|
44
|
+
} | {
|
|
45
|
+
type: "error";
|
|
46
|
+
error: string;
|
|
47
|
+
};
|
|
48
|
+
export declare class BloopRunner {
|
|
49
|
+
private client;
|
|
50
|
+
private db;
|
|
51
|
+
private tools;
|
|
52
|
+
private memory;
|
|
53
|
+
private roles;
|
|
54
|
+
private currentBloopCtx;
|
|
55
|
+
constructor(db: BeerCanDB, tools: ToolRegistry, client: Anthropic, memory: MemoryManager);
|
|
56
|
+
/** Returns the currently executing bloop context (for memory tools) */
|
|
57
|
+
getCurrentBloopContext(): {
|
|
58
|
+
bloopId: string;
|
|
59
|
+
projectId: string;
|
|
60
|
+
projectSlug: string;
|
|
61
|
+
} | null;
|
|
62
|
+
/** Register a custom role */
|
|
63
|
+
registerRole(role: AgentRole): void;
|
|
64
|
+
/** Register multiple roles at once (for gatekeeper dynamic roles) */
|
|
65
|
+
registerRoles(roles: AgentRole[]): void;
|
|
66
|
+
/** Unregister a dynamic role by ID (does not remove built-in roles) */
|
|
67
|
+
unregisterRole(roleId: string): void;
|
|
68
|
+
/** Main entry point — create and run a Bloop */
|
|
69
|
+
run(options: RunBloopOptions): Promise<Bloop>;
|
|
70
|
+
private executePipeline;
|
|
71
|
+
private executeAgent;
|
|
72
|
+
private buildSystemPrompt;
|
|
73
|
+
private resolveTools;
|
|
74
|
+
private extractDecision;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAI1C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAgC,OAAO,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;I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AAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa;IAUxF,uEAAuE;IACvE,sBAAsB,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAI5F,6BAA6B;IAC7B,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAInC,qEAAqE;IACrE,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI;IAMvC,uEAAuE;IACvE,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKpC,gDAAgD;IAC1C,GAAG,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC;YAwErC,eAAe;YAqFf,YAAY;IA2I1B,OAAO,CAAC,iBAAiB;IAkCzB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,eAAe;CAaxB"}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { v4 as uuid } from "uuid";
|
|
2
|
+
import { getConfig } from "../config.js";
|
|
3
|
+
import { BUILTIN_ROLES, PRESET_TEAMS } from "./roles.js";
|
|
4
|
+
// ── Bloop Runner ──────────────────────────────────────────────
|
|
5
|
+
export class BloopRunner {
|
|
6
|
+
client;
|
|
7
|
+
db;
|
|
8
|
+
tools;
|
|
9
|
+
memory;
|
|
10
|
+
roles;
|
|
11
|
+
currentBloopCtx = null;
|
|
12
|
+
constructor(db, tools, client, memory) {
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.db = db;
|
|
15
|
+
this.tools = tools;
|
|
16
|
+
this.memory = memory;
|
|
17
|
+
// Load built-in roles
|
|
18
|
+
this.roles = new Map(Object.entries(BUILTIN_ROLES));
|
|
19
|
+
}
|
|
20
|
+
/** Returns the currently executing bloop context (for memory tools) */
|
|
21
|
+
getCurrentBloopContext() {
|
|
22
|
+
return this.currentBloopCtx;
|
|
23
|
+
}
|
|
24
|
+
/** Register a custom role */
|
|
25
|
+
registerRole(role) {
|
|
26
|
+
this.roles.set(role.id, role);
|
|
27
|
+
}
|
|
28
|
+
/** Register multiple roles at once (for gatekeeper dynamic roles) */
|
|
29
|
+
registerRoles(roles) {
|
|
30
|
+
for (const role of roles) {
|
|
31
|
+
this.roles.set(role.id, role);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Unregister a dynamic role by ID (does not remove built-in roles) */
|
|
35
|
+
unregisterRole(roleId) {
|
|
36
|
+
if (BUILTIN_ROLES[roleId])
|
|
37
|
+
return;
|
|
38
|
+
this.roles.delete(roleId);
|
|
39
|
+
}
|
|
40
|
+
/** Main entry point — create and run a Bloop */
|
|
41
|
+
async run(options) {
|
|
42
|
+
const { project, goal, parentBloopId, onEvent } = options;
|
|
43
|
+
const team = options.team ?? PRESET_TEAMS.solo;
|
|
44
|
+
const config = getConfig();
|
|
45
|
+
const now = new Date().toISOString();
|
|
46
|
+
// Create the Bloop record
|
|
47
|
+
const bloop = {
|
|
48
|
+
id: uuid(),
|
|
49
|
+
projectId: project.id,
|
|
50
|
+
parentBloopId: parentBloopId ?? null,
|
|
51
|
+
trigger: parentBloopId ? "child_of" : "manual",
|
|
52
|
+
status: "running",
|
|
53
|
+
goal,
|
|
54
|
+
messages: [],
|
|
55
|
+
result: null,
|
|
56
|
+
toolCalls: [],
|
|
57
|
+
tokensUsed: 0,
|
|
58
|
+
iterations: 0,
|
|
59
|
+
maxIterations: config.maxBloopIterations,
|
|
60
|
+
createdAt: now,
|
|
61
|
+
updatedAt: now,
|
|
62
|
+
completedAt: null,
|
|
63
|
+
};
|
|
64
|
+
this.db.createBloop(bloop);
|
|
65
|
+
// Set bloop context for memory tools
|
|
66
|
+
this.currentBloopCtx = { bloopId: bloop.id, projectId: project.id, projectSlug: project.slug };
|
|
67
|
+
// Initialize working memory scope
|
|
68
|
+
this.memory.getWorkingMemory().createScope(bloop.id);
|
|
69
|
+
// Retrieve relevant past context from vector memory
|
|
70
|
+
const memoryContext = await this.memory.retrieveContext(project.slug, goal, 5);
|
|
71
|
+
if (memoryContext) {
|
|
72
|
+
options = {
|
|
73
|
+
...options,
|
|
74
|
+
extraContext: (options.extraContext ?? "") + memoryContext,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const result = await this.executePipeline(bloop, project, team, options);
|
|
79
|
+
bloop.status = "completed";
|
|
80
|
+
bloop.result = result;
|
|
81
|
+
bloop.completedAt = new Date().toISOString();
|
|
82
|
+
bloop.updatedAt = new Date().toISOString();
|
|
83
|
+
this.db.updateBloop(bloop);
|
|
84
|
+
// Store result in vector memory for future retrieval
|
|
85
|
+
await this.memory.storeBloopResult(bloop, project.slug);
|
|
86
|
+
onEvent?.({ type: "complete", result });
|
|
87
|
+
return bloop;
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
bloop.status = "failed";
|
|
91
|
+
bloop.result = { error: err.message };
|
|
92
|
+
bloop.updatedAt = new Date().toISOString();
|
|
93
|
+
this.db.updateBloop(bloop);
|
|
94
|
+
onEvent?.({ type: "error", error: err.message });
|
|
95
|
+
return bloop;
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
// Clean up working memory and bloop context
|
|
99
|
+
this.memory.getWorkingMemory().cleanup(bloop.id);
|
|
100
|
+
this.currentBloopCtx = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// ── Pipeline Execution ───────────────────────────────────
|
|
104
|
+
async executePipeline(bloop, project, team, options) {
|
|
105
|
+
const { onEvent } = options;
|
|
106
|
+
let pipelineContext = ""; // accumulated output passed between phases
|
|
107
|
+
let cycle = 0;
|
|
108
|
+
while (cycle < team.maxCycles) {
|
|
109
|
+
cycle++;
|
|
110
|
+
onEvent?.({ type: "cycle", cycle, maxCycles: team.maxCycles });
|
|
111
|
+
let shouldRestart = false;
|
|
112
|
+
for (const stage of team.pipeline) {
|
|
113
|
+
const role = this.roles.get(stage.roleId);
|
|
114
|
+
if (!role) {
|
|
115
|
+
throw new Error(`Unknown role: ${stage.roleId}. Register it first.`);
|
|
116
|
+
}
|
|
117
|
+
onEvent?.({ type: "phase_start", phase: stage.phase, roleId: stage.roleId });
|
|
118
|
+
const phaseResult = await this.executeAgent(bloop, project, role, pipelineContext, options);
|
|
119
|
+
pipelineContext += `\n\n--- ${role.name} (${stage.phase}) ---\n${phaseResult.content}`;
|
|
120
|
+
// Check for decisions from review/validate phases
|
|
121
|
+
const decision = this.extractDecision(phaseResult.content);
|
|
122
|
+
if (decision) {
|
|
123
|
+
onEvent?.({
|
|
124
|
+
type: "decision",
|
|
125
|
+
decision: decision.verdict,
|
|
126
|
+
reason: decision.reason,
|
|
127
|
+
});
|
|
128
|
+
if (decision.verdict === "REJECT" &&
|
|
129
|
+
stage.canReject &&
|
|
130
|
+
stage.rejectTo) {
|
|
131
|
+
// Reset pipeline context and restart from the reject-to phase
|
|
132
|
+
pipelineContext = `REJECTED by ${role.name}: ${decision.reason}\n\nOriginal goal: ${bloop.goal}`;
|
|
133
|
+
shouldRestart = true;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (decision.verdict === "REVISE" &&
|
|
137
|
+
stage.canReject &&
|
|
138
|
+
stage.rejectTo) {
|
|
139
|
+
pipelineContext += `\n\nREVISION REQUESTED by ${role.name}: ${decision.reason}`;
|
|
140
|
+
shouldRestart = true;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (!shouldRestart) {
|
|
146
|
+
// Pipeline completed without rejection
|
|
147
|
+
return {
|
|
148
|
+
summary: pipelineContext,
|
|
149
|
+
cycles: cycle,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Exhausted max cycles
|
|
154
|
+
return {
|
|
155
|
+
summary: pipelineContext,
|
|
156
|
+
cycles: cycle,
|
|
157
|
+
warning: "Max pipeline cycles reached",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
// ── Single Agent Execution ───────────────────────────────
|
|
161
|
+
async executeAgent(bloop, project, role, pipelineContext, options) {
|
|
162
|
+
const config = getConfig();
|
|
163
|
+
const model = role.model ?? config.defaultModel;
|
|
164
|
+
// Build system prompt
|
|
165
|
+
const systemPrompt = this.buildSystemPrompt(role, project, bloop.goal, pipelineContext, options.extraContext);
|
|
166
|
+
// Resolve allowed tools for this role within this project
|
|
167
|
+
const roleTools = this.resolveTools(role.allowedTools, project.allowedTools);
|
|
168
|
+
const anthropicTools = this.tools.toAnthropicTools(roleTools);
|
|
169
|
+
// Agent conversation (local to this phase execution)
|
|
170
|
+
const messages = [
|
|
171
|
+
{
|
|
172
|
+
role: "user",
|
|
173
|
+
content: pipelineContext
|
|
174
|
+
? `Goal: ${bloop.goal}\n\nContext from previous phases:\n${pipelineContext}`
|
|
175
|
+
: `Goal: ${bloop.goal}`,
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
let iterations = 0;
|
|
179
|
+
let finalContent = "";
|
|
180
|
+
while (iterations < role.maxIterations) {
|
|
181
|
+
iterations++;
|
|
182
|
+
bloop.iterations++;
|
|
183
|
+
const response = await this.client.messages.create({
|
|
184
|
+
model,
|
|
185
|
+
max_tokens: 4096,
|
|
186
|
+
system: systemPrompt,
|
|
187
|
+
tools: anthropicTools.length > 0 ? anthropicTools : undefined,
|
|
188
|
+
messages,
|
|
189
|
+
});
|
|
190
|
+
// Track token usage
|
|
191
|
+
bloop.tokensUsed += (response.usage?.input_tokens ?? 0) + (response.usage?.output_tokens ?? 0);
|
|
192
|
+
// Process response blocks
|
|
193
|
+
let hasToolUse = false;
|
|
194
|
+
const assistantContent = response.content;
|
|
195
|
+
const toolResults = [];
|
|
196
|
+
for (const block of assistantContent) {
|
|
197
|
+
if (block.type === "text") {
|
|
198
|
+
finalContent = block.text;
|
|
199
|
+
options.onEvent?.({
|
|
200
|
+
type: "agent_message",
|
|
201
|
+
role: role.id,
|
|
202
|
+
content: block.text,
|
|
203
|
+
});
|
|
204
|
+
// Store in bloop history
|
|
205
|
+
const msg = {
|
|
206
|
+
role: "assistant",
|
|
207
|
+
content: `[${role.name}] ${block.text}`,
|
|
208
|
+
timestamp: new Date().toISOString(),
|
|
209
|
+
};
|
|
210
|
+
bloop.messages.push(msg);
|
|
211
|
+
}
|
|
212
|
+
if (block.type === "tool_use") {
|
|
213
|
+
hasToolUse = true;
|
|
214
|
+
options.onEvent?.({
|
|
215
|
+
type: "tool_call",
|
|
216
|
+
tool: block.name,
|
|
217
|
+
input: block.input,
|
|
218
|
+
});
|
|
219
|
+
const start = Date.now();
|
|
220
|
+
const result = await this.tools.execute(block.name, block.input);
|
|
221
|
+
const durationMs = Date.now() - start;
|
|
222
|
+
const toolRecord = {
|
|
223
|
+
id: block.id,
|
|
224
|
+
toolName: block.name,
|
|
225
|
+
input: block.input,
|
|
226
|
+
output: result.output,
|
|
227
|
+
error: result.error,
|
|
228
|
+
durationMs,
|
|
229
|
+
timestamp: new Date().toISOString(),
|
|
230
|
+
};
|
|
231
|
+
bloop.toolCalls.push(toolRecord);
|
|
232
|
+
const resultText = result.output ?? `ERROR: ${result.error}`;
|
|
233
|
+
options.onEvent?.({
|
|
234
|
+
type: "tool_result",
|
|
235
|
+
tool: block.name,
|
|
236
|
+
output: resultText.length > 200
|
|
237
|
+
? resultText.slice(0, 200) + "..."
|
|
238
|
+
: resultText,
|
|
239
|
+
});
|
|
240
|
+
toolResults.push({
|
|
241
|
+
type: "tool_result",
|
|
242
|
+
tool_use_id: block.id,
|
|
243
|
+
content: resultText,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// If there were tool calls, feed results back
|
|
248
|
+
if (hasToolUse) {
|
|
249
|
+
messages.push({ role: "assistant", content: assistantContent });
|
|
250
|
+
messages.push({ role: "user", content: toolResults });
|
|
251
|
+
// Save progress
|
|
252
|
+
bloop.updatedAt = new Date().toISOString();
|
|
253
|
+
this.db.updateBloop(bloop);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
// No tool calls → agent is done with this phase
|
|
257
|
+
if (response.stop_reason === "end_turn") {
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return { content: finalContent };
|
|
262
|
+
}
|
|
263
|
+
// ── Helpers ──────────────────────────────────────────────
|
|
264
|
+
buildSystemPrompt(role, project, goal, pipelineContext, extraContext) {
|
|
265
|
+
const parts = [role.systemPrompt];
|
|
266
|
+
// Inject project context
|
|
267
|
+
if (Object.keys(project.context).length > 0) {
|
|
268
|
+
parts.push(`\n--- Project Context (${project.name}) ---\n${JSON.stringify(project.context, null, 2)}`);
|
|
269
|
+
}
|
|
270
|
+
if (extraContext) {
|
|
271
|
+
parts.push(`\n--- Additional Context ---\n${extraContext}`);
|
|
272
|
+
}
|
|
273
|
+
const sysLines = [
|
|
274
|
+
`Project: ${project.name}`,
|
|
275
|
+
`Your Role: ${role.name} (${role.id})`,
|
|
276
|
+
`Goal: ${goal}`,
|
|
277
|
+
];
|
|
278
|
+
if (project.workDir) {
|
|
279
|
+
sysLines.push(`Working Directory: ${project.workDir}`);
|
|
280
|
+
sysLines.push(`IMPORTANT: All file paths should be relative to or within ${project.workDir}. Use this as the cwd for exec_command.`);
|
|
281
|
+
}
|
|
282
|
+
parts.push(`\n--- System Info ---\n${sysLines.join("\n")}`);
|
|
283
|
+
return parts.join("\n");
|
|
284
|
+
}
|
|
285
|
+
resolveTools(roleTools, projectTools) {
|
|
286
|
+
// If either is wildcard, use the other as constraint
|
|
287
|
+
if (roleTools.includes("*") && projectTools.includes("*"))
|
|
288
|
+
return ["*"];
|
|
289
|
+
if (roleTools.includes("*"))
|
|
290
|
+
return projectTools;
|
|
291
|
+
if (projectTools.includes("*"))
|
|
292
|
+
return roleTools;
|
|
293
|
+
// Intersection
|
|
294
|
+
return roleTools.filter((t) => projectTools.includes(t));
|
|
295
|
+
}
|
|
296
|
+
extractDecision(content) {
|
|
297
|
+
const match = content.match(/<decision>(APPROVE|REVISE|REJECT)<\/decision>/);
|
|
298
|
+
if (!match)
|
|
299
|
+
return null;
|
|
300
|
+
// Extract reason: everything after the decision tag, or the paragraph before it
|
|
301
|
+
const afterDecision = content.split(match[0])[1]?.trim() || "";
|
|
302
|
+
const beforeDecision = content.split(match[0])[0]?.trim() || "";
|
|
303
|
+
const reason = afterDecision || beforeDecision.split("\n").pop() || "";
|
|
304
|
+
return { verdict: match[1], reason };
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAyBzD,iEAAiE;AAEjE,MAAM,OAAO,WAAW;IACd,MAAM,CAAY;IAClB,EAAE,CAAY;IACd,KAAK,CAAe;IACpB,MAAM,CAAgB;IACtB,KAAK,CAAyB;IAC9B,eAAe,GAAuE,IAAI,CAAC;IAEnG,YAAY,EAAa,EAAE,KAAmB,EAAE,MAAiB,EAAE,MAAqB;QACtF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,sBAAsB;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,uEAAuE;IACvE,sBAAsB;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,6BAA6B;IA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CAAC;QAC7E,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,gFAAgF;QAChF,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC/D,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,aAAa,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;QAEvE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BeerCanEngine } from "../index.js";
|
|
2
|
+
import type { Scheduler } from "../scheduler/scheduler.js";
|
|
3
|
+
import type { EventManager } from "./index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Start the BeerCan daemon: runs scheduler + event system.
|
|
6
|
+
* Handles graceful shutdown on SIGTERM/SIGINT.
|
|
7
|
+
*/
|
|
8
|
+
export declare function startDaemon(engine: BeerCanEngine, scheduler: Scheduler, eventManager: EventManager): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=daemon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../../src/events/daemon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
|