-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_simulate_delegation.cjs
More file actions
89 lines (77 loc) · 3.21 KB
/
node_simulate_delegation.cjs
File metadata and controls
89 lines (77 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const { createClient } = require('@supabase/supabase-js');
const fs = require('fs');
const envPath = 'c:\\Users\\PureTrek\\Desktop\\DevGruGold\\suite\\.env';
const envContent = fs.readFileSync(envPath, 'utf8');
const env = {};
envContent.split('\n').forEach(line => {
const [key, value] = line.split('=');
if (key && value) {
let cleanValue = value.trim();
if (cleanValue.startsWith('"') && cleanValue.endsWith('"')) {
cleanValue = cleanValue.slice(1, -1);
}
env[key.trim()] = cleanValue;
}
});
const supabaseUrl = env['SUPABASE_URL'] || env['VITE_SUPABASE_URL'];
const supabaseKey = env['SUPABASE_SERVICE_ROLE_KEY'] || env['VITE_SUPABASE_PUBLISHABLE_KEY'];
if (!supabaseUrl || !supabaseKey) {
console.error('Missing VITE_SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY');
process.exit(1);
}
const supabase = createClient(supabaseUrl, supabaseKey);
// Define the 3 tasks requested by user
const TASKS = [
{
role: 'social-viral',
description: 'Create a viral tweet about our new 1.8K execution milestone. Make it punchy and use emojis.',
functionName: 'superduper-social-viral'
},
{
role: 'code-architect',
description: 'Design a scalable database schema for the new user loyalty system. Include points, tiers, and rewards.',
functionName: 'superduper-code-architect'
},
{
role: 'finance-investment',
description: 'Analyze the ROI of adding a new Nvidia H100 server for local inference vs renting cloud GPUs.',
functionName: 'superduper-finance-investment'
}
];
async function delegateTasks() {
console.log(`Starting Batch Delegation of ${TASKS.length} tasks...`);
for (const task of TASKS) {
console.log(`\n--------------------------------------------`);
console.log(`Delegating to [${task.role}]: "${task.description}"`);
console.log(`> Invoking Edge Function: ${task.functionName}`);
try {
// Simulate the call that toolExecutor makes
const { data, error } = await supabase.functions.invoke(task.functionName, {
body: {
action: 'process_task', // Matches superduperAgent.ts expectation
params: {
instruction: task.description,
context: { source: 'simulation_script' }
},
context: {
manager: 'BrowserSimulation',
delegated_at: new Date().toISOString()
}
}
});
if (error) {
console.error(`> FAILED to delegate:`, error);
} else {
console.log(`> SUCCESS. Agent Response:`);
// The agent response structure
const result = data.data?.result || data;
console.log(JSON.stringify(result, null, 2));
}
} catch (e) {
console.error(`> EXCEPTION:`, e);
}
}
console.log(`\n--------------------------------------------`);
console.log("Batch Delegation Complete.");
}
delegateTasks();