Skip to content

Commit c57885f

Browse files
[developer] Auto-commit: Implement Core Feature
1 parent 33f1531 commit c57885f

3 files changed

Lines changed: 160 additions & 61 deletions

File tree

scripts/simple-swarm-demo.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,19 @@ async function runSimpleSwarm() {
5656
console.log('🆔 Swarm registered:', swarmId);
5757

5858
// Launch with minimal configuration
59-
const result = await coordinator.launchSwarm({
60-
agents: [
59+
const result = await coordinator.launchSwarm(
60+
task.description,
61+
[
6162
{
62-
role: 'demonstrator',
63+
role: 'developer',
6364
specialization: 'basic-functionality',
64-
task: 'Show basic swarm operations',
6565
},
6666
],
67-
task: task.description,
68-
enableRalphBridge: false, // Disable Ralph bridge to avoid database issues
69-
});
67+
{
68+
enableRalphBridge: false, // Disable Ralph bridge to avoid database issues
69+
enableGitWorkflow: false, // Already disabled in coordinator init
70+
}
71+
);
7072

7173
console.log('🚀 Swarm launched successfully!');
7274
console.log('📊 Result:', {

src/integrations/ralph/bridge/ralph-stackmemory-bridge.ts

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ export class RalphStackMemoryBridge {
3838
private sessionManager: SessionManager;
3939
private recoveryState?: RecoveryState;
4040
private readonly ralphDir = '.ralph';
41+
private readonly requiresDatabase: boolean;
4142

42-
constructor(options?: BridgeOptions) {
43+
constructor(options?: BridgeOptions & { useStackMemory?: boolean }) {
4344
// Initialize configuration
4445
this.config = this.mergeConfig(options?.config);
4546

47+
// Check if database/StackMemory features are required
48+
this.requiresDatabase = options?.useStackMemory !== false;
49+
4650
// Initialize managers
4751
this.state = {
4852
initialized: false,
@@ -87,18 +91,26 @@ export class RalphStackMemoryBridge {
8791

8892
this.state.currentSession = session;
8993

90-
// Initialize frame manager with session database
91-
if (session.database && session.projectId) {
92-
this.frameManager = new FrameManager(
93-
session.database,
94-
session.projectId,
95-
{
96-
skipContextBridge: true,
97-
}
98-
);
94+
// Initialize frame manager with session database if required
95+
if (this.requiresDatabase) {
96+
if (session.database && session.projectId) {
97+
this.frameManager = new FrameManager(
98+
session.database,
99+
session.projectId,
100+
{
101+
skipContextBridge: true,
102+
}
103+
);
104+
} else {
105+
throw new Error(
106+
'Session database not available for FrameManager initialization. ' +
107+
'If StackMemory features are not needed, set useStackMemory: false in options'
108+
);
109+
}
99110
} else {
100-
throw new Error(
101-
'Session database not available for FrameManager initialization'
111+
// Database not required, skip frame manager initialization
112+
logger.info(
113+
'Running without StackMemory database (useStackMemory: false)'
102114
);
103115
}
104116

@@ -580,6 +592,21 @@ export class RalphStackMemoryBridge {
580592
* Create root frame for Ralph loop
581593
*/
582594
private async createRootFrame(state: RalphLoopState): Promise<Frame> {
595+
if (!this.requiresDatabase) {
596+
// Return a mock frame when database is not required
597+
return {
598+
frame_id: `mock-${state.loopId}`,
599+
type: 'task' as FrameType,
600+
name: `ralph-${state.loopId}`,
601+
inputs: {
602+
task: state.task,
603+
criteria: state.criteria,
604+
loopId: state.loopId,
605+
},
606+
created_at: Date.now(),
607+
} as Frame;
608+
}
609+
583610
if (!this.frameManager) {
584611
throw new Error('Frame manager not initialized');
585612
}
@@ -926,7 +953,8 @@ export class RalphStackMemoryBridge {
926953
* Save iteration frame to StackMemory
927954
*/
928955
private async saveIterationFrame(iteration: RalphIteration): Promise<void> {
929-
if (!this.frameManager || !this.state.activeLoop) return;
956+
if (!this.requiresDatabase || !this.frameManager || !this.state.activeLoop)
957+
return;
930958

931959
const frame: Partial<Frame> = {
932960
type: 'subtask' as FrameType,

0 commit comments

Comments
 (0)