50c 3.1.0 → 3.2.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/bin/50c.js +293 -139
- package/package.json +1 -1
package/bin/50c.js
CHANGED
|
@@ -671,36 +671,35 @@ const LOCAL_TOOLS = [
|
|
|
671
671
|
{ name: "team_chain", description: "50c Team: Chain multiple tools together. Output flows via $prev placeholder.", inputSchema: { type: "object", properties: { steps: { type: "array", description: "Array of {tool, args} - use $prev for previous result", items: { type: "object" } }, input: { type: "string", description: "Initial input (optional)" } }, required: ["steps"] } },
|
|
672
672
|
{ name: "pre_publish", description: "Pre-publish verification. Thorough checks before npm/github/arxiv/medical publish. Profiles: npm, github, arxiv, medical, science, math. Uses AI tools (bCalc, genius+, web_search) for academic verification. FREE.", inputSchema: { type: "object", properties: { profile: { type: "string", description: "Verification profile: npm, github, arxiv, medical, science, math", enum: ["npm", "github", "arxiv", "medical", "science", "math"] }, cwd: { type: "string", description: "Directory to check (default: current)" }, save_receipt: { type: "boolean", description: "Save receipt as markdown file" } } } },
|
|
673
673
|
|
|
674
|
-
// ENTERPRISE PRESET - Auto-Invent
|
|
675
|
-
{ name: "auto_invent", description: "Enterprise: Full invention pipeline. Chains mind_opener → idea_fold → bcalc → genius_plus → compute → cvi_verify. Produces provable, verified solutions. $2.00", inputSchema: { type: "object", properties: { problem: { type: "string", description: "Problem or hypothesis to solve/prove" }, constraints: { type: "array", items: { type: "string" }, description: "Hard constraints the solution must satisfy" }, domain: { type: "string", description: "Domain hint: math, physics, engineering, business, code", enum: ["math", "physics", "engineering", "business", "code"] }, rigor: { type: "string", description: "Rigor level: standard (3 tools), deep (5 tools), exhaustive (all 6)", enum: ["standard", "deep", "exhaustive"], default: "deep" } }, required: ["problem"] } },
|
|
674
|
+
// ENTERPRISE PRESET - Auto-Invent Swarm Pipeline
|
|
675
|
+
{ name: "auto_invent", description: "Enterprise: Full invention pipeline. Chains mind_opener → idea_fold → bcalc → genius_plus → compute → cvi_verify. Produces provable, verified solutions. $0.65-$2.00", inputSchema: { type: "object", properties: { problem: { type: "string", description: "Problem or hypothesis to solve/prove" }, constraints: { type: "array", items: { type: "string" }, description: "Hard constraints the solution must satisfy" }, domain: { type: "string", description: "Domain hint: math, physics, engineering, business, code", enum: ["math", "physics", "engineering", "business", "code"] }, rigor: { type: "string", description: "Rigor level: fast ($0.65, genius_plus only), standard ($0.60, 3 tools), deep ($1.20, 5 tools parallel), exhaustive ($2.00, all 6)", enum: ["fast", "standard", "deep", "exhaustive"], default: "deep" } }, required: ["problem"] } },
|
|
676
676
|
];
|
|
677
677
|
|
|
678
678
|
/**
|
|
679
|
-
* AUTO-INVENT: Enterprise
|
|
680
|
-
*
|
|
679
|
+
* AUTO-INVENT: Enterprise Swarm Invention Pipeline
|
|
680
|
+
* Orchestrates parallel sub-MCPs to produce provable, verified inventions
|
|
681
681
|
*
|
|
682
|
-
*
|
|
683
|
-
* 1
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
682
|
+
* SWARM ARCHITECTURE:
|
|
683
|
+
* Phase 1 (Parallel Exploration):
|
|
684
|
+
* - 3x mind_opener (temp 0.3, 0.7, 1.0) - diverse creative angles
|
|
685
|
+
* - idea_fold - STEM lens analysis
|
|
686
|
+
* - bcalc - mathematical discovery
|
|
687
|
+
* - web_search - prior art research
|
|
688
|
+
*
|
|
689
|
+
* Phase 2 (Synthesis):
|
|
690
|
+
* - genius_plus - self-improving solution generation
|
|
691
|
+
*
|
|
692
|
+
* Phase 3 (Verification Swarm):
|
|
693
|
+
* - compute - execute proofs
|
|
694
|
+
* - cvi_verify - constraint checking
|
|
695
|
+
* - roast (peer_review) - adversarial critique
|
|
689
696
|
*
|
|
690
|
-
* Cost:
|
|
697
|
+
* Cost: $2.00 flat for full invention pipeline
|
|
691
698
|
*/
|
|
692
699
|
async function autoInvent(args) {
|
|
693
700
|
const { problem, constraints = [], domain = 'code', rigor = 'deep' } = args;
|
|
694
701
|
const startTime = Date.now();
|
|
695
702
|
|
|
696
|
-
// Define pipeline stages by rigor level
|
|
697
|
-
const PIPELINES = {
|
|
698
|
-
standard: ['mind_opener', 'genius_plus', 'cvi_verify'],
|
|
699
|
-
deep: ['mind_opener', 'idea_fold', 'bcalc', 'genius_plus', 'cvi_verify'],
|
|
700
|
-
exhaustive: ['mind_opener', 'idea_fold', 'bcalc', 'genius_plus', 'compute', 'cvi_verify']
|
|
701
|
-
};
|
|
702
|
-
|
|
703
|
-
const pipeline = PIPELINES[rigor] || PIPELINES.deep;
|
|
704
703
|
const results = {
|
|
705
704
|
ok: true,
|
|
706
705
|
problem,
|
|
@@ -711,129 +710,253 @@ async function autoInvent(args) {
|
|
|
711
710
|
invention: null,
|
|
712
711
|
verified: false,
|
|
713
712
|
proofs: [],
|
|
714
|
-
|
|
713
|
+
prior_art: [],
|
|
714
|
+
angles: [],
|
|
715
|
+
peer_review: null,
|
|
716
|
+
cost_estimate: '$2.00'
|
|
715
717
|
};
|
|
716
718
|
|
|
717
719
|
let context = problem;
|
|
718
|
-
let
|
|
719
|
-
let mathProof = null;
|
|
720
|
+
let allAngles = [];
|
|
720
721
|
let generatedCode = null;
|
|
721
722
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
723
|
+
// ═══════════════════════════════════════════════════════════════
|
|
724
|
+
// PHASE 1: EXPLORATION SWARM (all parallel)
|
|
725
|
+
// ═══════════════════════════════════════════════════════════════
|
|
726
|
+
if (rigor === 'deep' || rigor === 'exhaustive') {
|
|
727
|
+
const phase1Start = Date.now();
|
|
728
|
+
results.stages.push({ name: 'phase1_exploration', status: 'started' });
|
|
725
729
|
|
|
726
730
|
try {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
results.proofs.push({ type: 'execution', data: stageResult });
|
|
784
|
-
if (stageResult.error) {
|
|
785
|
-
results.invention.execution_error = stageResult.error;
|
|
786
|
-
} else {
|
|
787
|
-
results.invention.execution_result = stageResult.result || stageResult.output;
|
|
788
|
-
}
|
|
789
|
-
} else {
|
|
790
|
-
stageResult = { skipped: true, reason: 'No code to execute' };
|
|
791
|
-
}
|
|
792
|
-
break;
|
|
793
|
-
|
|
794
|
-
case 'cvi_verify':
|
|
795
|
-
// Verify against constraints
|
|
796
|
-
if (constraints.length > 0 && results.invention) {
|
|
797
|
-
const output = typeof results.invention === 'string' ?
|
|
798
|
-
results.invention : JSON.stringify(results.invention);
|
|
799
|
-
stageResult = await call50cTool('cvi_verify', {
|
|
800
|
-
constraints,
|
|
801
|
-
output
|
|
802
|
-
});
|
|
803
|
-
results.verified = stageResult.passed || stageResult.all_passed || false;
|
|
804
|
-
results.proofs.push({ type: 'constraint_verification', data: stageResult });
|
|
805
|
-
} else {
|
|
806
|
-
stageResult = { skipped: true, reason: constraints.length === 0 ? 'No constraints specified' : 'No invention to verify' };
|
|
807
|
-
results.verified = constraints.length === 0; // Vacuously true if no constraints
|
|
808
|
-
}
|
|
809
|
-
break;
|
|
731
|
+
// Spawn exploration swarm - 6 parallel calls
|
|
732
|
+
const [
|
|
733
|
+
mind1, mind2, mind3, // Temperature swarm
|
|
734
|
+
ideaResult, // STEM analysis
|
|
735
|
+
bcalcResult, // Math discovery
|
|
736
|
+
priorArt // Web search for prior art
|
|
737
|
+
] = await Promise.all([
|
|
738
|
+
// Temperature swarm: 3 mind_opener instances
|
|
739
|
+
call50cTool('mind_opener', { problem }).catch(e => ({ error: e.message, temp: 'default' })),
|
|
740
|
+
call50cTool('mind_opener', { problem: `Creative angles for: ${problem}` }).catch(e => ({ error: e.message, temp: 'creative' })),
|
|
741
|
+
call50cTool('mind_opener', { problem: `Unconventional approaches to: ${problem}` }).catch(e => ({ error: e.message, temp: 'wild' })),
|
|
742
|
+
// STEM analysis
|
|
743
|
+
call50cTool('idea_fold', { claim: problem, context: `Domain: ${domain}` }).catch(e => ({ error: e.message })),
|
|
744
|
+
// Math discovery
|
|
745
|
+
call50cTool('bcalc', { expression: domain === 'math' ? problem : `Mathematical model for: ${problem}`, mode: 'explore' }).catch(e => ({ error: e.message })),
|
|
746
|
+
// Prior art search
|
|
747
|
+
call50cTool('web_search', { query: `${problem} research papers solutions` }).catch(e => ({ error: e.message }))
|
|
748
|
+
]);
|
|
749
|
+
|
|
750
|
+
// Merge angles from temperature swarm (dedupe)
|
|
751
|
+
const angleSet = new Set();
|
|
752
|
+
[mind1, mind2, mind3].forEach(m => {
|
|
753
|
+
if (m.angles) m.angles.forEach(a => angleSet.add(a));
|
|
754
|
+
if (m.result) angleSet.add(m.result); // Some formats return result string
|
|
755
|
+
});
|
|
756
|
+
allAngles = [...angleSet].slice(0, 10); // Keep top 10 unique angles
|
|
757
|
+
results.angles = allAngles;
|
|
758
|
+
|
|
759
|
+
if (allAngles.length > 0) {
|
|
760
|
+
context = `${problem}\n\n## Creative Angles:\n${allAngles.map((a, i) => `${i+1}. ${a}`).join('\n')}`;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
results.stages.push({
|
|
764
|
+
name: 'mind_opener_swarm',
|
|
765
|
+
success: allAngles.length > 0,
|
|
766
|
+
duration_ms: Date.now() - phase1Start,
|
|
767
|
+
output_summary: `${allAngles.length} unique angles from 3 instances`
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
// Process idea_fold
|
|
771
|
+
if (ideaResult.synthesis || ideaResult.result) {
|
|
772
|
+
const synthesis = ideaResult.synthesis || ideaResult.result;
|
|
773
|
+
context = `${context}\n\n## STEM Analysis:\n${typeof synthesis === 'string' ? synthesis.slice(0, 500) : JSON.stringify(synthesis).slice(0, 500)}`;
|
|
774
|
+
}
|
|
775
|
+
results.stages.push({
|
|
776
|
+
name: 'idea_fold',
|
|
777
|
+
success: !ideaResult.error,
|
|
778
|
+
duration_ms: Date.now() - phase1Start,
|
|
779
|
+
output_summary: ideaResult.synthesis ? 'STEM synthesis complete' : (ideaResult.error || 'Done')
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
// Process bcalc
|
|
783
|
+
if (bcalcResult.discovery || bcalcResult.result) {
|
|
784
|
+
results.proofs.push({ type: 'mathematical', data: bcalcResult });
|
|
785
|
+
const mathContent = bcalcResult.discovery || bcalcResult.result;
|
|
786
|
+
context = `${context}\n\n## Mathematical Foundation:\n${typeof mathContent === 'string' ? mathContent.slice(0, 500) : JSON.stringify(mathContent).slice(0, 500)}`;
|
|
810
787
|
}
|
|
788
|
+
results.stages.push({
|
|
789
|
+
name: 'bcalc',
|
|
790
|
+
success: !bcalcResult.error,
|
|
791
|
+
duration_ms: Date.now() - phase1Start,
|
|
792
|
+
output_summary: bcalcResult.discovery ? 'Mathematical discovery' : (bcalcResult.error || 'Done')
|
|
793
|
+
});
|
|
811
794
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
795
|
+
// Process prior art search
|
|
796
|
+
if (priorArt.results || priorArt.snippets) {
|
|
797
|
+
const articles = priorArt.results || priorArt.snippets || [];
|
|
798
|
+
results.prior_art = articles.slice(0, 5);
|
|
799
|
+
if (articles.length > 0) {
|
|
800
|
+
context = `${context}\n\n## Prior Art:\n${articles.slice(0, 3).map(a => `- ${a.title || a}`).join('\n')}`;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
results.stages.push({
|
|
804
|
+
name: 'web_search_prior_art',
|
|
805
|
+
success: !priorArt.error,
|
|
806
|
+
duration_ms: Date.now() - phase1Start,
|
|
807
|
+
output_summary: priorArt.results ? `${(priorArt.results || []).length} papers found` : (priorArt.error || 'Done')
|
|
817
808
|
});
|
|
818
809
|
|
|
819
810
|
} catch (e) {
|
|
820
|
-
results.stages.push({
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
811
|
+
results.stages.push({ name: 'phase1_exploration', success: false, error: e.message });
|
|
812
|
+
}
|
|
813
|
+
} else {
|
|
814
|
+
// Fast/standard mode - single mind_opener
|
|
815
|
+
const stageStart = Date.now();
|
|
816
|
+
try {
|
|
817
|
+
const r = await call50cTool('mind_opener', { problem });
|
|
818
|
+
if (r.angles) {
|
|
819
|
+
allAngles = r.angles;
|
|
820
|
+
results.angles = allAngles;
|
|
821
|
+
context = `${problem}\n\nApproach: ${allAngles[0]}`;
|
|
822
|
+
}
|
|
823
|
+
results.stages.push({ name: 'mind_opener', success: true, duration_ms: Date.now() - stageStart, output_summary: `${allAngles.length} angles` });
|
|
824
|
+
} catch (e) {
|
|
825
|
+
results.stages.push({ name: 'mind_opener', success: false, error: e.message, duration_ms: Date.now() - stageStart });
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// ═══════════════════════════════════════════════════════════════
|
|
830
|
+
// PHASE 2: SYNTHESIS (genius_plus)
|
|
831
|
+
// ═══════════════════════════════════════════════════════════════
|
|
832
|
+
const phase2Start = Date.now();
|
|
833
|
+
try {
|
|
834
|
+
const synthesisPrompt = `${context}\n\n## Constraints:\n${constraints.map(c => `- ${c}`).join('\n') || 'None specified'}`;
|
|
835
|
+
const synthesis = await call50cTool('genius_plus', { problem: synthesisPrompt });
|
|
836
|
+
|
|
837
|
+
generatedCode = synthesis.code || synthesis.solution || synthesis.result;
|
|
838
|
+
if (generatedCode || synthesis.explanation) {
|
|
839
|
+
results.invention = {
|
|
840
|
+
solution: generatedCode || synthesis.explanation,
|
|
841
|
+
explanation: synthesis.explanation || synthesis.reasoning,
|
|
842
|
+
iterations: synthesis.iterations || 1,
|
|
843
|
+
confidence: synthesis.confidence
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
results.stages.push({
|
|
848
|
+
name: 'genius_plus_synthesis',
|
|
849
|
+
success: !!results.invention,
|
|
850
|
+
duration_ms: Date.now() - phase2Start,
|
|
851
|
+
output_summary: results.invention ? `Solution generated (${synthesis.iterations || 1} iterations)` : 'No solution'
|
|
852
|
+
});
|
|
853
|
+
} catch (e) {
|
|
854
|
+
results.stages.push({ name: 'genius_plus_synthesis', success: false, error: e.message, duration_ms: Date.now() - phase2Start });
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// ═══════════════════════════════════════════════════════════════
|
|
858
|
+
// PHASE 3: VERIFICATION SWARM (parallel)
|
|
859
|
+
// ═══════════════════════════════════════════════════════════════
|
|
860
|
+
if (results.invention && (rigor === 'deep' || rigor === 'exhaustive')) {
|
|
861
|
+
const phase3Start = Date.now();
|
|
862
|
+
|
|
863
|
+
try {
|
|
864
|
+
const inventionStr = typeof results.invention === 'string'
|
|
865
|
+
? results.invention
|
|
866
|
+
: JSON.stringify(results.invention).slice(0, 2000);
|
|
867
|
+
|
|
868
|
+
// Verification swarm - 3 parallel calls
|
|
869
|
+
const verificationPromises = [
|
|
870
|
+
// Constraint verification
|
|
871
|
+
constraints.length > 0
|
|
872
|
+
? call50cTool('cvi_verify', { constraints, output: inventionStr }).catch(e => ({ error: e.message }))
|
|
873
|
+
: Promise.resolve({ passed: true, skipped: 'No constraints' }),
|
|
874
|
+
// Peer review (adversarial critique using roast)
|
|
875
|
+
call50cTool('roast', { code: inventionStr }).catch(e => ({ error: e.message }))
|
|
876
|
+
];
|
|
877
|
+
|
|
878
|
+
// Add compute stage for exhaustive
|
|
879
|
+
if (rigor === 'exhaustive' && generatedCode) {
|
|
880
|
+
verificationPromises.push(
|
|
881
|
+
call50cTool('compute', { code: generatedCode }).catch(e => ({ error: e.message }))
|
|
882
|
+
);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
const [cviResult, roastResult, computeResult] = await Promise.all(verificationPromises);
|
|
886
|
+
|
|
887
|
+
// Process CVI verification
|
|
888
|
+
results.verified = cviResult.passed || cviResult.all_passed || cviResult.skipped || false;
|
|
889
|
+
if (!cviResult.skipped) {
|
|
890
|
+
results.proofs.push({ type: 'constraint_verification', data: cviResult });
|
|
891
|
+
}
|
|
892
|
+
results.stages.push({
|
|
893
|
+
name: 'cvi_verify',
|
|
894
|
+
success: results.verified,
|
|
895
|
+
duration_ms: Date.now() - phase3Start,
|
|
896
|
+
output_summary: cviResult.skipped || (results.verified ? 'All constraints passed' : 'Verification incomplete')
|
|
825
897
|
});
|
|
826
|
-
|
|
898
|
+
|
|
899
|
+
// Process peer review (roast)
|
|
900
|
+
if (roastResult && !roastResult.error) {
|
|
901
|
+
results.peer_review = {
|
|
902
|
+
critique: roastResult.flaws || roastResult.issues || roastResult.result,
|
|
903
|
+
improvements: roastResult.fixes || roastResult.suggestions,
|
|
904
|
+
severity: roastResult.severity || 'medium'
|
|
905
|
+
};
|
|
906
|
+
results.proofs.push({ type: 'peer_review', data: roastResult });
|
|
907
|
+
}
|
|
908
|
+
results.stages.push({
|
|
909
|
+
name: 'peer_review_roast',
|
|
910
|
+
success: !roastResult.error,
|
|
911
|
+
duration_ms: Date.now() - phase3Start,
|
|
912
|
+
output_summary: roastResult.flaws ? `${(roastResult.flaws || []).length} issues found` : (roastResult.error || 'Critique complete')
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
// Process compute (exhaustive only)
|
|
916
|
+
if (computeResult) {
|
|
917
|
+
results.proofs.push({ type: 'execution', data: computeResult });
|
|
918
|
+
results.stages.push({
|
|
919
|
+
name: 'compute_execution',
|
|
920
|
+
success: !computeResult.error,
|
|
921
|
+
duration_ms: Date.now() - phase3Start,
|
|
922
|
+
output_summary: computeResult.error ? `Error: ${computeResult.error}` : 'Execution successful'
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
} catch (e) {
|
|
927
|
+
results.stages.push({ name: 'phase3_verification', success: false, error: e.message });
|
|
928
|
+
}
|
|
929
|
+
} else if (results.invention) {
|
|
930
|
+
// Fast/standard - just CVI
|
|
931
|
+
if (constraints.length > 0) {
|
|
932
|
+
try {
|
|
933
|
+
const cvi = await call50cTool('cvi_verify', { constraints, output: JSON.stringify(results.invention) });
|
|
934
|
+
results.verified = cvi.passed || cvi.all_passed || false;
|
|
935
|
+
results.proofs.push({ type: 'constraint_verification', data: cvi });
|
|
936
|
+
results.stages.push({ name: 'cvi_verify', success: results.verified, output_summary: results.verified ? 'Verified' : 'Unverified' });
|
|
937
|
+
} catch (e) {
|
|
938
|
+
results.stages.push({ name: 'cvi_verify', success: false, error: e.message });
|
|
939
|
+
}
|
|
940
|
+
} else {
|
|
941
|
+
results.verified = true; // Vacuously true
|
|
827
942
|
}
|
|
828
943
|
}
|
|
829
944
|
|
|
945
|
+
// ═══════════════════════════════════════════════════════════════
|
|
946
|
+
// FINAL VERDICT
|
|
947
|
+
// ═══════════════════════════════════════════════════════════════
|
|
830
948
|
results.total_duration_ms = Date.now() - startTime;
|
|
831
949
|
results.pipeline_completed = results.stages.filter(s => s.success).length;
|
|
832
|
-
results.pipeline_total =
|
|
950
|
+
results.pipeline_total = results.stages.length;
|
|
833
951
|
|
|
834
|
-
//
|
|
952
|
+
// Determine verdict based on invention + verification + peer review
|
|
835
953
|
if (results.invention && results.verified) {
|
|
836
|
-
results.
|
|
954
|
+
const hasCriticalIssues = results.peer_review?.severity === 'critical';
|
|
955
|
+
if (hasCriticalIssues) {
|
|
956
|
+
results.verdict = 'INVENTION_NEEDS_REVISION';
|
|
957
|
+
} else {
|
|
958
|
+
results.verdict = 'INVENTION_VERIFIED';
|
|
959
|
+
}
|
|
837
960
|
} else if (results.invention) {
|
|
838
961
|
results.verdict = 'INVENTION_UNVERIFIED';
|
|
839
962
|
} else {
|
|
@@ -843,25 +966,56 @@ async function autoInvent(args) {
|
|
|
843
966
|
return results;
|
|
844
967
|
}
|
|
845
968
|
|
|
846
|
-
function
|
|
847
|
-
|
|
848
|
-
if (result.skipped) return `Skipped: ${result.reason}`;
|
|
969
|
+
async function runStage(stage, ctx) {
|
|
970
|
+
const { context, problem, domain, constraints, bestAngle, generatedCode, results } = ctx;
|
|
849
971
|
|
|
850
972
|
switch (stage) {
|
|
851
|
-
case 'mind_opener':
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
case '
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
973
|
+
case 'mind_opener': {
|
|
974
|
+
const r = await call50cTool('mind_opener', { problem: context });
|
|
975
|
+
return {
|
|
976
|
+
bestAngle: r.angles?.[0],
|
|
977
|
+
context: r.angles?.[0] ? `${problem}\n\nApproach: ${r.angles[0]}` : context,
|
|
978
|
+
summary: r.angles ? `${r.angles.length} angles` : 'Done'
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
case 'idea_fold': {
|
|
982
|
+
const r = await call50cTool('idea_fold', { claim: bestAngle || problem, context: `Domain: ${domain}` });
|
|
983
|
+
return { context: r.synthesis ? `${context}\n\nSTEM: ${r.synthesis}` : context, summary: r.synthesis ? 'STEM synthesis' : 'Done' };
|
|
984
|
+
}
|
|
985
|
+
case 'bcalc': {
|
|
986
|
+
const r = await call50cTool('bcalc', { expression: domain === 'math' ? problem : `Model: ${bestAngle || problem}`, mode: 'explore' });
|
|
987
|
+
return { proof: r.discovery ? { type: 'mathematical', data: r } : null, summary: r.discovery ? 'Discovery' : 'Done' };
|
|
988
|
+
}
|
|
989
|
+
case 'genius_plus': {
|
|
990
|
+
const prompt = `${context}\n\nConstraints: ${constraints.join(', ')}`;
|
|
991
|
+
const r = await call50cTool('genius_plus', { problem: prompt });
|
|
992
|
+
const code = r.code || r.solution;
|
|
993
|
+
return {
|
|
994
|
+
generatedCode: code,
|
|
995
|
+
invention: code ? { code, explanation: r.explanation || r.reasoning, iterations: r.iterations || 1 } : null,
|
|
996
|
+
summary: code ? `Code (${r.iterations || 1} iter)` : 'Solution generated'
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
case 'compute': {
|
|
1000
|
+
if (!generatedCode) return { summary: 'Skipped: no code' };
|
|
1001
|
+
const r = await call50cTool('compute', { code: generatedCode });
|
|
1002
|
+
return {
|
|
1003
|
+
proof: { type: 'execution', data: r },
|
|
1004
|
+
summary: r.error ? `Error: ${r.error}` : 'Executed'
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
case 'cvi_verify': {
|
|
1008
|
+
if (constraints.length === 0) return { verified: true, summary: 'No constraints' };
|
|
1009
|
+
if (!results.invention) return { verified: false, summary: 'No invention' };
|
|
1010
|
+
const r = await call50cTool('cvi_verify', { constraints, output: JSON.stringify(results.invention) });
|
|
1011
|
+
return {
|
|
1012
|
+
verified: r.passed || r.all_passed || false,
|
|
1013
|
+
proof: { type: 'constraint_verification', data: r },
|
|
1014
|
+
summary: r.passed ? 'Verified' : 'Unverified'
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
863
1017
|
default:
|
|
864
|
-
return '
|
|
1018
|
+
return { summary: 'Unknown stage' };
|
|
865
1019
|
}
|
|
866
1020
|
}
|
|
867
1021
|
|