@stackmemoryai/stackmemory 1.12.0 → 1.14.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 +131 -64
- package/README.md +3 -1
- package/bin/claude-sm +16 -1
- package/bin/claude-smd +16 -1
- package/bin/codex-smd +16 -1
- package/bin/gemini-sm +16 -1
- package/bin/hermes-sm +21 -0
- package/bin/hermes-smd +21 -0
- package/bin/opencode-sm +16 -1
- package/dist/src/cli/codex-sm.js +51 -11
- package/dist/src/cli/commands/brain.js +206 -0
- package/dist/src/cli/commands/company-os.js +184 -0
- package/dist/src/cli/commands/context.js +5 -0
- package/dist/src/cli/commands/operator.js +127 -0
- package/dist/src/cli/commands/orchestrate.js +2 -0
- package/dist/src/cli/commands/orchestrator.js +3 -2
- package/dist/src/cli/commands/patterns.js +254 -0
- package/dist/src/cli/commands/portal.js +161 -0
- package/dist/src/cli/commands/scaffold.js +92 -0
- package/dist/src/cli/commands/setup.js +1 -4
- package/dist/src/cli/commands/sync.js +253 -0
- package/dist/src/cli/commands/tasks.js +130 -1
- package/dist/src/cli/commands/vision.js +221 -0
- package/dist/src/cli/hermes-sm.js +224 -0
- package/dist/src/cli/index.js +15 -10
- package/dist/src/cli/utils/real-cli-bin.js +72 -0
- package/dist/src/core/brain/brain-store.js +187 -0
- package/dist/src/core/brain/brain-sync.js +193 -0
- package/dist/src/core/brain/index.js +78 -0
- package/dist/src/core/brain/types.js +10 -0
- package/dist/src/core/cache/token-estimator.js +24 -1
- package/dist/src/core/config/feature-flags.js +2 -6
- package/dist/src/core/context/frame-database.js +44 -0
- package/dist/src/core/context/recursive-context-manager.js +1 -1
- package/dist/src/core/context/rehydration.js +2 -1
- package/dist/src/core/database/sqlite-adapter.js +14 -1
- package/dist/src/core/models/model-router.js +33 -1
- package/dist/src/core/models/provider-pricing.js +58 -4
- package/dist/src/core/patterns/index.js +22 -0
- package/dist/src/core/patterns/pattern-applier.js +39 -0
- package/dist/src/core/patterns/pattern-observer.js +157 -0
- package/dist/src/core/patterns/pattern-store.js +259 -0
- package/dist/src/core/patterns/types.js +19 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js +5 -4
- package/dist/src/core/retrieval/unified-context-assembler.js +11 -66
- package/dist/src/core/skill-packs/types.js +14 -1
- package/dist/src/core/storage/cloud-sync-manager.js +116 -0
- package/dist/src/core/storage/cloud-sync.js +574 -0
- package/dist/src/core/storage/two-tier-storage.js +5 -1
- package/dist/src/core/tasks/master-tasks-template.js +43 -0
- package/dist/src/core/tasks/md-task-parser.js +138 -0
- package/dist/src/core/vision/index.js +27 -0
- package/dist/src/core/vision/signals.js +79 -0
- package/dist/src/core/vision/types.js +22 -0
- package/dist/src/core/vision/vision-file.js +146 -0
- package/dist/src/core/vision/vision-loop.js +220 -0
- package/dist/src/core/wiki/wiki-compiler.js +103 -1
- package/dist/src/daemon/daemon-config.js +45 -0
- package/dist/src/daemon/services/desire-path-service.js +566 -0
- package/dist/src/daemon/services/research-stream-service.js +320 -0
- package/dist/src/daemon/services/telemetry-service.js +192 -0
- package/dist/src/daemon/unified-daemon.js +28 -1
- package/dist/src/features/browser/cli-browser-agent.js +417 -0
- package/dist/src/features/browser/stagehand-workflows.js +578 -0
- package/dist/src/features/operator/adapter-factory.js +62 -0
- package/dist/src/features/operator/browser-adapter.js +109 -0
- package/dist/src/features/operator/desktop-adapter.js +125 -0
- package/dist/src/features/operator/index.js +39 -0
- package/dist/src/features/operator/llm-decision.js +137 -0
- package/dist/src/features/operator/operator-logger.js +92 -0
- package/dist/src/features/operator/overnight-runner.js +327 -0
- package/dist/src/features/operator/screen-adapter.js +91 -0
- package/dist/src/features/operator/session-manager.js +127 -0
- package/dist/src/features/operator/state-machine.js +227 -0
- package/dist/src/features/operator/task-queue.js +81 -0
- package/dist/src/features/portal/index.js +26 -0
- package/dist/src/features/portal/server.js +240 -0
- package/dist/src/features/portal/types.js +14 -0
- package/dist/src/features/portal/ui.js +195 -0
- package/dist/src/features/tasks/task-aware-context.js +2 -1
- package/dist/src/features/tui/simple-monitor.js +0 -23
- package/dist/src/features/tui/swarm-monitor.js +8 -66
- package/dist/src/{integrations/diffmem/index.js → features/web/client/hooks/use-socket.js} +6 -5
- package/dist/src/features/web/client/lib/utils.js +12 -0
- package/dist/src/features/web/client/stores/session-store.js +12 -0
- package/dist/src/features/web/server/gcp-billing.js +76 -0
- package/dist/src/features/web/server/index.js +10 -0
- package/dist/src/features/web/server/spend-calculator.js +228 -0
- package/dist/src/hooks/schemas.js +4 -1
- package/dist/src/integrations/anthropic/client.js +3 -2
- package/dist/src/integrations/claude-code/agent-bridge.js +0 -3
- package/dist/src/integrations/claude-code/subagent-client.js +218 -11
- package/dist/src/integrations/claude-code/task-coordinator.js +2 -1
- package/dist/src/integrations/linear/webhook-retry.js +196 -0
- package/dist/src/integrations/linear/webhook-server.js +18 -22
- package/dist/src/integrations/mcp/handlers/cloud-sync-handlers.js +101 -0
- package/dist/src/integrations/mcp/handlers/index.js +27 -52
- package/dist/src/integrations/mcp/server.js +122 -335
- package/dist/src/integrations/mcp/tool-alias-registry.js +0 -73
- package/dist/src/integrations/mcp/tool-definitions.js +111 -510
- package/dist/src/mcp/stackmemory-mcp-server.js +404 -379
- package/dist/src/orchestrators/multimodal/determinism.js +2 -1
- package/dist/src/orchestrators/multimodal/harness.js +2 -1
- package/dist/src/skills/recursive-agent-orchestrator.js +2 -4
- package/dist/src/utils/process-cleanup.js +1 -7
- package/docs/README.md +42 -0
- package/docs/guides/README_INSTALL.md +208 -0
- package/package.json +18 -9
- package/scripts/claude-code-wrapper.sh +11 -0
- package/scripts/claude-sm-setup.sh +12 -1
- package/scripts/codex-wrapper.sh +11 -0
- package/scripts/git-hooks/branch-context-manager.sh +11 -0
- package/scripts/git-hooks/post-checkout-stackmemory.sh +11 -0
- package/scripts/git-hooks/post-commit-stackmemory.sh +11 -0
- package/scripts/git-hooks/pre-commit-stackmemory.sh +11 -0
- package/scripts/hooks/cleanup-shell.sh +12 -1
- package/scripts/hooks/task-complete.sh +12 -1
- package/scripts/install-code-execution-hooks.sh +12 -1
- package/scripts/install-sweep-hook.sh +12 -0
- package/scripts/install.sh +11 -0
- package/scripts/opencode-wrapper.sh +11 -0
- package/scripts/portal/cloud-init.yaml +69 -0
- package/scripts/portal/setup.sh +69 -0
- package/scripts/portal/stackmemory-portal.service +34 -0
- package/scripts/setup-claude-integration.sh +12 -1
- package/scripts/smoke-init-db.sh +23 -0
- package/scripts/stackmemory-daemon.sh +11 -0
- package/scripts/verify-dist.cjs +11 -4
- package/dist/src/cli/commands/ralph.js +0 -1053
- package/dist/src/hooks/diffmem-hooks.js +0 -376
- package/dist/src/integrations/diffmem/client.js +0 -208
- package/dist/src/integrations/diffmem/config.js +0 -14
- package/dist/src/integrations/greptile/client.js +0 -101
- package/dist/src/integrations/greptile/config.js +0 -14
- package/dist/src/integrations/greptile/index.js +0 -11
- package/dist/src/integrations/mcp/handlers/cross-search-handlers.js +0 -188
- package/dist/src/integrations/mcp/handlers/diffmem-handlers.js +0 -455
- package/dist/src/integrations/mcp/handlers/greptile-handlers.js +0 -456
- package/dist/src/integrations/mcp/handlers/provider-handlers.js +0 -227
- package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js +0 -863
- package/dist/src/integrations/ralph/context/context-budget-manager.js +0 -308
- package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +0 -354
- package/dist/src/integrations/ralph/index.js +0 -17
- package/dist/src/integrations/ralph/learning/pattern-learner.js +0 -416
- package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js +0 -448
- package/dist/src/integrations/ralph/loopmax.js +0 -488
- package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js +0 -293
- package/dist/src/integrations/ralph/monitoring/swarm-registry.js +0 -107
- package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js +0 -508
- package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js +0 -407
- package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js +0 -495
- package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js +0 -387
- package/dist/src/integrations/ralph/performance/performance-optimizer.js +0 -357
- package/dist/src/integrations/ralph/recovery/crash-recovery.js +0 -461
- package/dist/src/integrations/ralph/state/state-reconciler.js +0 -420
- package/dist/src/integrations/ralph/swarm/git-workflow-manager.js +0 -444
- package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +0 -1005
- package/dist/src/integrations/ralph/visualization/ralph-debugger.js +0 -635
- package/scripts/ralph-loop-implementation.js +0 -404
- /package/dist/src/{integrations/diffmem/types.js → core/storage/cloud-sync-types.js} +0 -0
- /package/dist/src/{integrations/greptile → features/operator}/types.js +0 -0
- /package/dist/src/{integrations/ralph/types.js → features/web/client/next-env.d.js} +0 -0
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
-
import { dirname as __pathDirname } from 'path';
|
|
3
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = __pathDirname(__filename);
|
|
5
|
-
import { v4 as uuidv4 } from "uuid";
|
|
6
|
-
import { logger } from "../../../core/monitoring/logger.js";
|
|
7
|
-
import { SwarmCoordinator } from "../swarm/swarm-coordinator.js";
|
|
8
|
-
import { RalphStackMemoryBridge } from "../bridge/ralph-stackmemory-bridge.js";
|
|
9
|
-
class OracleWorkerCoordinator extends SwarmCoordinator {
|
|
10
|
-
oracle;
|
|
11
|
-
workerPool;
|
|
12
|
-
reviewerPool;
|
|
13
|
-
costTracker;
|
|
14
|
-
constructor(config) {
|
|
15
|
-
super({
|
|
16
|
-
maxAgents: config.maxWorkers + 2,
|
|
17
|
-
// Workers + Oracle + Reviewer
|
|
18
|
-
coordinationInterval: config.coordinationInterval,
|
|
19
|
-
enableDynamicPlanning: true,
|
|
20
|
-
pathologicalBehaviorDetection: true
|
|
21
|
-
});
|
|
22
|
-
this.oracle = config.oracle;
|
|
23
|
-
this.workerPool = config.workers;
|
|
24
|
-
this.reviewerPool = config.reviewers;
|
|
25
|
-
this.costTracker = {
|
|
26
|
-
oracleSpent: 0,
|
|
27
|
-
workerSpent: 0,
|
|
28
|
-
reviewerSpent: 0,
|
|
29
|
-
totalBudget: config.costBudget || 10
|
|
30
|
-
// $10 default
|
|
31
|
-
};
|
|
32
|
-
logger.info("Oracle/Worker coordinator initialized", {
|
|
33
|
-
oracle: this.oracle.model,
|
|
34
|
-
workers: this.workerPool.length,
|
|
35
|
-
budget: this.costTracker.totalBudget
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Launch swarm with Oracle/Worker pattern
|
|
40
|
-
*/
|
|
41
|
-
async launchOracleWorkerSwarm(projectDescription, taskHints) {
|
|
42
|
-
logger.info("Launching Oracle/Worker swarm", {
|
|
43
|
-
project: projectDescription.substring(0, 100)
|
|
44
|
-
});
|
|
45
|
-
const oracleTaskId = await this.createOracleTask(
|
|
46
|
-
"project_planning",
|
|
47
|
-
projectDescription,
|
|
48
|
-
taskHints
|
|
49
|
-
);
|
|
50
|
-
const decomposition = await this.executeOracleTask(oracleTaskId);
|
|
51
|
-
const workerTasks = this.allocateTasksToWorkers(decomposition);
|
|
52
|
-
const workerPromises = workerTasks.map(
|
|
53
|
-
(task) => this.executeWorkerTask(task)
|
|
54
|
-
);
|
|
55
|
-
const reviewTaskId = await this.scheduleOracleReview(decomposition);
|
|
56
|
-
const [workerResults, reviewResult] = await Promise.all([
|
|
57
|
-
Promise.allSettled(workerPromises),
|
|
58
|
-
this.executeOracleTask(reviewTaskId)
|
|
59
|
-
]);
|
|
60
|
-
const swarmId = await this.integrateResults(workerResults, reviewResult);
|
|
61
|
-
this.logCostAnalysis();
|
|
62
|
-
return swarmId;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Create planning task for Oracle
|
|
66
|
-
*/
|
|
67
|
-
async createOracleTask(type, description, hints) {
|
|
68
|
-
const taskId = uuidv4();
|
|
69
|
-
const oraclePrompt = this.buildOraclePrompt(type, description, hints);
|
|
70
|
-
const estimatedTokens = this.estimateTokens(oraclePrompt);
|
|
71
|
-
logger.info("Oracle task created", {
|
|
72
|
-
taskId,
|
|
73
|
-
type,
|
|
74
|
-
estimatedTokens,
|
|
75
|
-
estimatedCost: estimatedTokens * this.oracle.costPerToken
|
|
76
|
-
});
|
|
77
|
-
return taskId;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Build specialized prompt for Oracle model
|
|
81
|
-
*/
|
|
82
|
-
buildOraclePrompt(type, description, hints) {
|
|
83
|
-
const basePrompt = `
|
|
84
|
-
# ORACLE ROLE: Strategic Planning & Coordination
|
|
85
|
-
|
|
86
|
-
You are the Oracle in an Oracle/Worker pattern. Your role:
|
|
87
|
-
- HIGH-LEVEL STRATEGIC thinking
|
|
88
|
-
- TASK DECOMPOSITION for worker agents
|
|
89
|
-
- QUALITY CONTROL and review
|
|
90
|
-
- COORDINATION between workers
|
|
91
|
-
- ERROR CORRECTION and replanning
|
|
92
|
-
|
|
93
|
-
## Project Context
|
|
94
|
-
${description}
|
|
95
|
-
|
|
96
|
-
${hints ? `## Hints & Context
|
|
97
|
-
${hints.map((h) => `- ${h}`).join("\n")}` : ""}
|
|
98
|
-
|
|
99
|
-
## Your Oracle Responsibilities
|
|
100
|
-
1. **Decompose** this project into discrete, parallelizable tasks
|
|
101
|
-
2. **Assign complexity levels** (low/medium/high) to guide worker selection
|
|
102
|
-
3. **Define acceptance criteria** for each task
|
|
103
|
-
4. **Identify dependencies** between tasks
|
|
104
|
-
5. **Plan coordination touchpoints** for integration
|
|
105
|
-
|
|
106
|
-
## Worker Constraints
|
|
107
|
-
- Workers are smaller models optimized for focused execution
|
|
108
|
-
- Workers excel at: implementation, testing, documentation, simple analysis
|
|
109
|
-
- Workers struggle with: complex architecture, strategic decisions, cross-cutting concerns
|
|
110
|
-
|
|
111
|
-
## Output Required
|
|
112
|
-
Provide a detailed task decomposition in JSON format:
|
|
113
|
-
|
|
114
|
-
\`\`\`json
|
|
115
|
-
{
|
|
116
|
-
"project_summary": "Brief overview",
|
|
117
|
-
"task_decomposition": [
|
|
118
|
-
{
|
|
119
|
-
"id": "unique-id",
|
|
120
|
-
"title": "Task name",
|
|
121
|
-
"description": "Detailed description",
|
|
122
|
-
"complexity": "low|medium|high",
|
|
123
|
-
"type": "implementation|testing|documentation|analysis",
|
|
124
|
-
"estimated_effort": "1-5 scale",
|
|
125
|
-
"worker_requirements": ["specific capabilities needed"],
|
|
126
|
-
"acceptance_criteria": ["criterion 1", "criterion 2"],
|
|
127
|
-
"dependencies": ["task-id-1", "task-id-2"]
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
"coordination_plan": {
|
|
131
|
-
"integration_points": ["When to sync between workers"],
|
|
132
|
-
"review_checkpoints": ["When Oracle should review progress"],
|
|
133
|
-
"risk_mitigation": ["Potential issues and solutions"]
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
\`\`\`
|
|
137
|
-
|
|
138
|
-
Remember: Your intelligence is expensive. Focus on high-value strategic thinking that workers cannot do effectively.
|
|
139
|
-
`;
|
|
140
|
-
return basePrompt;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Execute Oracle task with high-end model
|
|
144
|
-
*/
|
|
145
|
-
async executeOracleTask(taskId) {
|
|
146
|
-
logger.info("Executing Oracle task", { taskId });
|
|
147
|
-
const ralph = new RalphStackMemoryBridge({
|
|
148
|
-
baseDir: `.oracle/${taskId}`,
|
|
149
|
-
maxIterations: 3,
|
|
150
|
-
// Oracle should be efficient
|
|
151
|
-
useStackMemory: true
|
|
152
|
-
});
|
|
153
|
-
const result = await ralph.run();
|
|
154
|
-
const tokens = this.estimateTokens(result);
|
|
155
|
-
const cost = tokens * this.oracle.costPerToken;
|
|
156
|
-
this.costTracker.oracleSpent += cost;
|
|
157
|
-
logger.info("Oracle task completed", {
|
|
158
|
-
taskId,
|
|
159
|
-
tokensUsed: tokens,
|
|
160
|
-
cost: cost.toFixed(4)
|
|
161
|
-
});
|
|
162
|
-
return this.parseTaskDecomposition(result);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Allocate decomposed tasks to worker models
|
|
166
|
-
*/
|
|
167
|
-
allocateTasksToWorkers(decomposition) {
|
|
168
|
-
const allocatedTasks = [];
|
|
169
|
-
for (const task of decomposition) {
|
|
170
|
-
const workerModel = this.selectWorkerForTask(task);
|
|
171
|
-
const _workerPrompt = this.buildWorkerPrompt(task, workerModel);
|
|
172
|
-
allocatedTasks.push({
|
|
173
|
-
...task,
|
|
174
|
-
assignedModel: "worker"
|
|
175
|
-
});
|
|
176
|
-
logger.debug("Task allocated to worker", {
|
|
177
|
-
taskId: task.id,
|
|
178
|
-
complexity: task.complexity,
|
|
179
|
-
worker: workerModel.model
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
return allocatedTasks;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Select optimal worker model for task complexity
|
|
186
|
-
*/
|
|
187
|
-
selectWorkerForTask(task) {
|
|
188
|
-
if (task.complexity === "high") {
|
|
189
|
-
return this.workerPool[0];
|
|
190
|
-
} else {
|
|
191
|
-
return this.workerPool.reduce(
|
|
192
|
-
(cheapest, current) => current.costPerToken < cheapest.costPerToken ? current : cheapest
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Build focused prompt for worker models
|
|
198
|
-
*/
|
|
199
|
-
buildWorkerPrompt(task, _worker) {
|
|
200
|
-
return `
|
|
201
|
-
# WORKER ROLE: Focused Task Execution
|
|
202
|
-
|
|
203
|
-
You are a specialized worker in an Oracle/Worker pattern.
|
|
204
|
-
|
|
205
|
-
## Your Task
|
|
206
|
-
${task.type}: ${task.title}
|
|
207
|
-
|
|
208
|
-
${task.description}
|
|
209
|
-
|
|
210
|
-
## Success Criteria
|
|
211
|
-
${task.acceptanceCriteria.map((c) => `- ${c}`).join("\n")}
|
|
212
|
-
|
|
213
|
-
## Worker Guidelines
|
|
214
|
-
- FOCUS on this specific task only
|
|
215
|
-
- IMPLEMENT according to the specifications provided
|
|
216
|
-
- ASK for clarification if requirements are unclear
|
|
217
|
-
- COMMUNICATE progress through shared context
|
|
218
|
-
- COMPLETE the task efficiently without over-engineering
|
|
219
|
-
|
|
220
|
-
## Constraints
|
|
221
|
-
- You are optimized for execution, not planning
|
|
222
|
-
- Stay within your assigned scope
|
|
223
|
-
- Collaborate with other workers through shared context
|
|
224
|
-
- The Oracle will handle integration and review
|
|
225
|
-
|
|
226
|
-
Execute your task now.
|
|
227
|
-
`;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Execute worker task with cost tracking
|
|
231
|
-
*/
|
|
232
|
-
async executeWorkerTask(task) {
|
|
233
|
-
logger.info("Executing worker task", {
|
|
234
|
-
taskId: task.id,
|
|
235
|
-
complexity: task.complexity
|
|
236
|
-
});
|
|
237
|
-
const ralph = new RalphStackMemoryBridge({
|
|
238
|
-
baseDir: `.workers/${task.id}`,
|
|
239
|
-
maxIterations: task.complexity === "low" ? 3 : 7,
|
|
240
|
-
useStackMemory: true
|
|
241
|
-
});
|
|
242
|
-
const result = await ralph.run();
|
|
243
|
-
const workerModel = this.selectWorkerForTask(task);
|
|
244
|
-
const tokens = this.estimateTokens(result);
|
|
245
|
-
const cost = tokens * workerModel.costPerToken;
|
|
246
|
-
this.costTracker.workerSpent += cost;
|
|
247
|
-
logger.info("Worker task completed", {
|
|
248
|
-
taskId: task.id,
|
|
249
|
-
tokensUsed: tokens,
|
|
250
|
-
cost: cost.toFixed(4)
|
|
251
|
-
});
|
|
252
|
-
return result;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Schedule Oracle review of worker progress
|
|
256
|
-
*/
|
|
257
|
-
async scheduleOracleReview(decomposition) {
|
|
258
|
-
const reviewTaskId = uuidv4();
|
|
259
|
-
logger.info("Oracle review scheduled", {
|
|
260
|
-
reviewTaskId,
|
|
261
|
-
tasksToReview: decomposition.length
|
|
262
|
-
});
|
|
263
|
-
return reviewTaskId;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Integrate worker results under Oracle coordination
|
|
267
|
-
*/
|
|
268
|
-
async integrateResults(workerResults, _reviewResult) {
|
|
269
|
-
const swarmId = uuidv4();
|
|
270
|
-
const successfulTasks = workerResults.filter(
|
|
271
|
-
(result) => result.status === "fulfilled"
|
|
272
|
-
).length;
|
|
273
|
-
logger.info("Integration completed", {
|
|
274
|
-
swarmId,
|
|
275
|
-
totalTasks: workerResults.length,
|
|
276
|
-
successfulTasks,
|
|
277
|
-
successRate: (successfulTasks / workerResults.length * 100).toFixed(1)
|
|
278
|
-
});
|
|
279
|
-
return swarmId;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Parse task decomposition from Oracle output
|
|
283
|
-
*/
|
|
284
|
-
parseTaskDecomposition(_output) {
|
|
285
|
-
return [];
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Estimate token usage for cost calculation
|
|
289
|
-
*/
|
|
290
|
-
estimateTokens(text) {
|
|
291
|
-
return Math.ceil(text.length / 4);
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Log cost analysis and efficiency metrics
|
|
295
|
-
*/
|
|
296
|
-
logCostAnalysis() {
|
|
297
|
-
const total = this.costTracker.oracleSpent + this.costTracker.workerSpent + this.costTracker.reviewerSpent;
|
|
298
|
-
const savings = this.calculateTraditionalCost() - total;
|
|
299
|
-
logger.info("Oracle/Worker Cost Analysis", {
|
|
300
|
-
oracleSpent: `$${this.costTracker.oracleSpent.toFixed(4)}`,
|
|
301
|
-
workerSpent: `$${this.costTracker.workerSpent.toFixed(4)}`,
|
|
302
|
-
totalSpent: `$${total.toFixed(4)}`,
|
|
303
|
-
budgetUsed: `${(total / this.costTracker.totalBudget * 100).toFixed(1)}%`,
|
|
304
|
-
estimatedSavings: `$${savings.toFixed(4)}`,
|
|
305
|
-
efficiency: `${(this.costTracker.workerSpent / total * 100).toFixed(1)}% worker tasks`
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Calculate what this would cost with all-Oracle approach
|
|
310
|
-
*/
|
|
311
|
-
calculateTraditionalCost() {
|
|
312
|
-
const _totalSpent = this.costTracker.oracleSpent + this.costTracker.workerSpent + this.costTracker.reviewerSpent;
|
|
313
|
-
const avgWorkerCost = this.workerPool[0]?.costPerToken || 1e-3;
|
|
314
|
-
const workerTokensAsOracle = this.costTracker.workerSpent / avgWorkerCost;
|
|
315
|
-
return this.costTracker.oracleSpent + workerTokensAsOracle * this.oracle.costPerToken;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
const defaultModelConfigs = {
|
|
319
|
-
oracle: [
|
|
320
|
-
{
|
|
321
|
-
tier: "oracle",
|
|
322
|
-
provider: "claude",
|
|
323
|
-
model: "claude-sonnet-4-5-20250929",
|
|
324
|
-
costPerToken: 3e-3,
|
|
325
|
-
// $3/1M input tokens
|
|
326
|
-
capabilities: [
|
|
327
|
-
"strategic_planning",
|
|
328
|
-
"complex_reasoning",
|
|
329
|
-
"task_decomposition",
|
|
330
|
-
"quality_review",
|
|
331
|
-
"error_correction"
|
|
332
|
-
]
|
|
333
|
-
}
|
|
334
|
-
],
|
|
335
|
-
worker: [
|
|
336
|
-
{
|
|
337
|
-
tier: "worker",
|
|
338
|
-
provider: "claude",
|
|
339
|
-
model: "claude-haiku-4-5-20251001",
|
|
340
|
-
costPerToken: 8e-4,
|
|
341
|
-
// $0.80/1M input tokens
|
|
342
|
-
capabilities: [
|
|
343
|
-
"code_implementation",
|
|
344
|
-
"unit_testing",
|
|
345
|
-
"documentation",
|
|
346
|
-
"simple_analysis",
|
|
347
|
-
"data_processing"
|
|
348
|
-
]
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
tier: "worker",
|
|
352
|
-
provider: "openai",
|
|
353
|
-
model: "gpt-4o-mini",
|
|
354
|
-
costPerToken: 15e-5,
|
|
355
|
-
// $0.15/1M input tokens
|
|
356
|
-
capabilities: [
|
|
357
|
-
"rapid_prototyping",
|
|
358
|
-
"script_writing",
|
|
359
|
-
"basic_testing",
|
|
360
|
-
"formatting",
|
|
361
|
-
"simple_refactoring"
|
|
362
|
-
]
|
|
363
|
-
}
|
|
364
|
-
],
|
|
365
|
-
reviewer: [
|
|
366
|
-
{
|
|
367
|
-
tier: "reviewer",
|
|
368
|
-
provider: "claude",
|
|
369
|
-
model: "claude-3-sonnet-20240229",
|
|
370
|
-
costPerToken: 3e-3,
|
|
371
|
-
// $3/1M input tokens
|
|
372
|
-
capabilities: [
|
|
373
|
-
"code_review",
|
|
374
|
-
"quality_assessment",
|
|
375
|
-
"integration_testing",
|
|
376
|
-
"performance_analysis",
|
|
377
|
-
"security_review"
|
|
378
|
-
]
|
|
379
|
-
}
|
|
380
|
-
]
|
|
381
|
-
};
|
|
382
|
-
var oracle_worker_pattern_default = OracleWorkerCoordinator;
|
|
383
|
-
export {
|
|
384
|
-
OracleWorkerCoordinator,
|
|
385
|
-
oracle_worker_pattern_default as default,
|
|
386
|
-
defaultModelConfigs
|
|
387
|
-
};
|