deepthinking-mcp 6.0.0 → 6.1.1
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/dist/index.js +1386 -150
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -1243,13 +1243,10 @@ var init_sanitization = __esm({
|
|
|
1243
1243
|
}
|
|
1244
1244
|
});
|
|
1245
1245
|
|
|
1246
|
-
// src/utils/logger.ts
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
var LogLevel, DEFAULT_CONFIG, Logger;
|
|
1251
|
-
var init_logger = __esm({
|
|
1252
|
-
"src/utils/logger.ts"() {
|
|
1246
|
+
// src/utils/logger-types.ts
|
|
1247
|
+
var LogLevel;
|
|
1248
|
+
var init_logger_types = __esm({
|
|
1249
|
+
"src/utils/logger-types.ts"() {
|
|
1253
1250
|
init_esm_shims();
|
|
1254
1251
|
LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
1255
1252
|
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
@@ -1259,6 +1256,18 @@ var init_logger = __esm({
|
|
|
1259
1256
|
LogLevel2[LogLevel2["SILENT"] = 4] = "SILENT";
|
|
1260
1257
|
return LogLevel2;
|
|
1261
1258
|
})(LogLevel || {});
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
|
|
1262
|
+
// src/utils/logger.ts
|
|
1263
|
+
function createLogger(config) {
|
|
1264
|
+
return new Logger(config);
|
|
1265
|
+
}
|
|
1266
|
+
var DEFAULT_CONFIG, Logger;
|
|
1267
|
+
var init_logger = __esm({
|
|
1268
|
+
"src/utils/logger.ts"() {
|
|
1269
|
+
init_esm_shims();
|
|
1270
|
+
init_logger_types();
|
|
1262
1271
|
DEFAULT_CONFIG = {
|
|
1263
1272
|
minLevel: 1 /* INFO */,
|
|
1264
1273
|
enableConsole: true,
|
|
@@ -5198,153 +5207,1268 @@ var init_formal_logic = __esm({
|
|
|
5198
5207
|
}
|
|
5199
5208
|
});
|
|
5200
5209
|
|
|
5201
|
-
// src/export/visual/
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
}
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
}
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5210
|
+
// src/export/visual/mathematics.ts
|
|
5211
|
+
function exportMathematicsDerivation(thought, options) {
|
|
5212
|
+
const { format, colorScheme = "default", includeLabels = true, includeMetrics = true } = options;
|
|
5213
|
+
switch (format) {
|
|
5214
|
+
case "mermaid":
|
|
5215
|
+
return mathematicsToMermaid(thought, colorScheme, includeLabels, includeMetrics);
|
|
5216
|
+
case "dot":
|
|
5217
|
+
return mathematicsToDOT(thought, includeLabels, includeMetrics);
|
|
5218
|
+
case "ascii":
|
|
5219
|
+
return mathematicsToASCII(thought);
|
|
5220
|
+
default:
|
|
5221
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5224
|
+
function mathematicsToMermaid(thought, colorScheme, includeLabels, includeMetrics) {
|
|
5225
|
+
let mermaid = "graph TB\n";
|
|
5226
|
+
const typeId = sanitizeId(`type_${thought.thoughtType || "proof"}`);
|
|
5227
|
+
const typeLabel = includeLabels ? (thought.thoughtType || "Proof").replace(/_/g, " ") : typeId;
|
|
5228
|
+
mermaid += ` ${typeId}[["${typeLabel}"]]
|
|
5229
|
+
`;
|
|
5230
|
+
if (thought.proofStrategy) {
|
|
5231
|
+
const strategyId = sanitizeId("strategy");
|
|
5232
|
+
const strategyLabel = thought.proofStrategy.type;
|
|
5233
|
+
mermaid += ` ${strategyId}(["${strategyLabel}"])
|
|
5234
|
+
`;
|
|
5235
|
+
mermaid += ` ${typeId} --> ${strategyId}
|
|
5236
|
+
`;
|
|
5237
|
+
let prevStepId = strategyId;
|
|
5238
|
+
thought.proofStrategy.steps.forEach((step, index) => {
|
|
5239
|
+
const stepId = sanitizeId(`step_${index}`);
|
|
5240
|
+
const stepLabel = includeLabels ? step.slice(0, 40) + (step.length > 40 ? "..." : "") : `Step ${index + 1}`;
|
|
5241
|
+
mermaid += ` ${stepId}["${stepLabel}"]
|
|
5242
|
+
`;
|
|
5243
|
+
mermaid += ` ${prevStepId} --> ${stepId}
|
|
5244
|
+
`;
|
|
5245
|
+
prevStepId = stepId;
|
|
5246
|
+
});
|
|
5247
|
+
if (includeMetrics) {
|
|
5248
|
+
const completenessId = sanitizeId("completeness");
|
|
5249
|
+
const completenessLabel = `Completeness: ${(thought.proofStrategy.completeness * 100).toFixed(0)}%`;
|
|
5250
|
+
mermaid += ` ${completenessId}{{${completenessLabel}}}
|
|
5251
|
+
`;
|
|
5252
|
+
mermaid += ` ${prevStepId} --> ${completenessId}
|
|
5253
|
+
`;
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
if (thought.mathematicalModel) {
|
|
5257
|
+
const modelId = sanitizeId("model");
|
|
5258
|
+
const modelLabel = thought.mathematicalModel.symbolic || "Mathematical Model";
|
|
5259
|
+
mermaid += ` ${modelId}["${modelLabel}"]
|
|
5260
|
+
`;
|
|
5261
|
+
mermaid += ` ${typeId} --> ${modelId}
|
|
5262
|
+
`;
|
|
5263
|
+
}
|
|
5264
|
+
if (thought.theorems && thought.theorems.length > 0) {
|
|
5265
|
+
thought.theorems.forEach((theorem, index) => {
|
|
5266
|
+
const theoremId = sanitizeId(`theorem_${index}`);
|
|
5267
|
+
const theoremLabel = theorem.name || `Theorem ${index + 1}`;
|
|
5268
|
+
mermaid += ` ${theoremId}[/"${theoremLabel}"/]
|
|
5269
|
+
`;
|
|
5270
|
+
mermaid += ` ${typeId} --> ${theoremId}
|
|
5271
|
+
`;
|
|
5272
|
+
});
|
|
5273
|
+
}
|
|
5274
|
+
if (thought.assumptions && thought.assumptions.length > 0) {
|
|
5275
|
+
const assumptionsId = sanitizeId("assumptions");
|
|
5276
|
+
mermaid += ` ${assumptionsId}>"Assumptions: ${thought.assumptions.length}"]
|
|
5277
|
+
`;
|
|
5278
|
+
}
|
|
5279
|
+
if (colorScheme !== "monochrome") {
|
|
5280
|
+
const colors = colorScheme === "pastel" ? { type: "#e8f4e8", strategy: "#fff3e0"} : { type: "#90EE90", strategy: "#FFD700"};
|
|
5281
|
+
mermaid += `
|
|
5282
|
+
style ${typeId} fill:${colors.type}
|
|
5283
|
+
`;
|
|
5284
|
+
if (thought.proofStrategy) {
|
|
5285
|
+
mermaid += ` style ${sanitizeId("strategy")} fill:${colors.strategy}
|
|
5286
|
+
`;
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
return mermaid;
|
|
5290
|
+
}
|
|
5291
|
+
function mathematicsToDOT(thought, includeLabels, includeMetrics) {
|
|
5292
|
+
let dot = "digraph MathematicsDerivation {\n";
|
|
5293
|
+
dot += " rankdir=TB;\n";
|
|
5294
|
+
dot += " node [shape=box, style=rounded];\n\n";
|
|
5295
|
+
const typeId = sanitizeId(`type_${thought.thoughtType || "proof"}`);
|
|
5296
|
+
const typeLabel = includeLabels ? (thought.thoughtType || "Proof").replace(/_/g, " ") : typeId;
|
|
5297
|
+
dot += ` ${typeId} [label="${typeLabel}", shape=doubleoctagon];
|
|
5298
|
+
`;
|
|
5299
|
+
if (thought.proofStrategy) {
|
|
5300
|
+
const strategyId = sanitizeId("strategy");
|
|
5301
|
+
dot += ` ${strategyId} [label="${thought.proofStrategy.type}", shape=ellipse];
|
|
5302
|
+
`;
|
|
5303
|
+
dot += ` ${typeId} -> ${strategyId};
|
|
5304
|
+
`;
|
|
5305
|
+
let prevStepId = strategyId;
|
|
5306
|
+
thought.proofStrategy.steps.forEach((step, index) => {
|
|
5307
|
+
const stepId = sanitizeId(`step_${index}`);
|
|
5308
|
+
const stepLabel = includeLabels ? step.slice(0, 30).replace(/"/g, '\\"') : `Step ${index + 1}`;
|
|
5309
|
+
dot += ` ${stepId} [label="${stepLabel}"];
|
|
5310
|
+
`;
|
|
5311
|
+
dot += ` ${prevStepId} -> ${stepId};
|
|
5312
|
+
`;
|
|
5313
|
+
prevStepId = stepId;
|
|
5314
|
+
});
|
|
5315
|
+
if (includeMetrics) {
|
|
5316
|
+
const completenessId = sanitizeId("completeness");
|
|
5317
|
+
dot += ` ${completenessId} [label="${(thought.proofStrategy.completeness * 100).toFixed(0)}%", shape=diamond];
|
|
5318
|
+
`;
|
|
5319
|
+
dot += ` ${prevStepId} -> ${completenessId};
|
|
5320
|
+
`;
|
|
5321
|
+
}
|
|
5322
|
+
}
|
|
5323
|
+
if (thought.theorems) {
|
|
5324
|
+
thought.theorems.forEach((theorem, index) => {
|
|
5325
|
+
const theoremId = sanitizeId(`theorem_${index}`);
|
|
5326
|
+
dot += ` ${theoremId} [label="${theorem.name || `Theorem ${index + 1}`}", shape=parallelogram];
|
|
5327
|
+
`;
|
|
5328
|
+
dot += ` ${typeId} -> ${theoremId};
|
|
5329
|
+
`;
|
|
5330
|
+
});
|
|
5331
|
+
}
|
|
5332
|
+
dot += "}\n";
|
|
5333
|
+
return dot;
|
|
5334
|
+
}
|
|
5335
|
+
function mathematicsToASCII(thought) {
|
|
5336
|
+
let ascii = "Mathematics Derivation:\n";
|
|
5337
|
+
ascii += "=======================\n\n";
|
|
5338
|
+
ascii += `Type: ${(thought.thoughtType || "proof").replace(/_/g, " ")}
|
|
5339
|
+
`;
|
|
5340
|
+
ascii += `Uncertainty: ${(thought.uncertainty * 100).toFixed(1)}%
|
|
5341
|
+
|
|
5342
|
+
`;
|
|
5343
|
+
if (thought.mathematicalModel) {
|
|
5344
|
+
ascii += "Mathematical Model:\n";
|
|
5345
|
+
ascii += ` LaTeX: ${thought.mathematicalModel.latex}
|
|
5346
|
+
`;
|
|
5347
|
+
ascii += ` Symbolic: ${thought.mathematicalModel.symbolic}
|
|
5348
|
+
`;
|
|
5349
|
+
if (thought.mathematicalModel.ascii) {
|
|
5350
|
+
ascii += ` ASCII: ${thought.mathematicalModel.ascii}
|
|
5351
|
+
`;
|
|
5352
|
+
}
|
|
5353
|
+
ascii += "\n";
|
|
5354
|
+
}
|
|
5355
|
+
if (thought.proofStrategy) {
|
|
5356
|
+
ascii += `Proof Strategy: ${thought.proofStrategy.type}
|
|
5357
|
+
`;
|
|
5358
|
+
ascii += `Completeness: ${(thought.proofStrategy.completeness * 100).toFixed(0)}%
|
|
5359
|
+
`;
|
|
5360
|
+
ascii += "Steps:\n";
|
|
5361
|
+
thought.proofStrategy.steps.forEach((step, index) => {
|
|
5362
|
+
ascii += ` ${index + 1}. ${step}
|
|
5363
|
+
`;
|
|
5364
|
+
});
|
|
5365
|
+
if (thought.proofStrategy.baseCase) {
|
|
5366
|
+
ascii += `Base Case: ${thought.proofStrategy.baseCase}
|
|
5367
|
+
`;
|
|
5368
|
+
}
|
|
5369
|
+
if (thought.proofStrategy.inductiveStep) {
|
|
5370
|
+
ascii += `Inductive Step: ${thought.proofStrategy.inductiveStep}
|
|
5371
|
+
`;
|
|
5372
|
+
}
|
|
5373
|
+
ascii += "\n";
|
|
5374
|
+
}
|
|
5375
|
+
if (thought.theorems && thought.theorems.length > 0) {
|
|
5376
|
+
ascii += "Theorems:\n";
|
|
5377
|
+
thought.theorems.forEach((theorem, index) => {
|
|
5378
|
+
ascii += ` [${index + 1}] ${theorem.name}: ${theorem.statement}
|
|
5379
|
+
`;
|
|
5380
|
+
if (theorem.hypotheses.length > 0) {
|
|
5381
|
+
ascii += ` Hypotheses: ${theorem.hypotheses.join(", ")}
|
|
5382
|
+
`;
|
|
5266
5383
|
}
|
|
5267
|
-
|
|
5384
|
+
ascii += ` Conclusion: ${theorem.conclusion}
|
|
5385
|
+
`;
|
|
5386
|
+
});
|
|
5387
|
+
ascii += "\n";
|
|
5388
|
+
}
|
|
5389
|
+
if (thought.assumptions && thought.assumptions.length > 0) {
|
|
5390
|
+
ascii += "Assumptions:\n";
|
|
5391
|
+
thought.assumptions.forEach((assumption, index) => {
|
|
5392
|
+
ascii += ` ${index + 1}. ${assumption}
|
|
5393
|
+
`;
|
|
5394
|
+
});
|
|
5395
|
+
ascii += "\n";
|
|
5396
|
+
}
|
|
5397
|
+
if (thought.dependencies && thought.dependencies.length > 0) {
|
|
5398
|
+
ascii += "Dependencies:\n";
|
|
5399
|
+
thought.dependencies.forEach((dep, index) => {
|
|
5400
|
+
ascii += ` ${index + 1}. ${dep}
|
|
5401
|
+
`;
|
|
5402
|
+
});
|
|
5403
|
+
}
|
|
5404
|
+
return ascii;
|
|
5405
|
+
}
|
|
5406
|
+
var init_mathematics = __esm({
|
|
5407
|
+
"src/export/visual/mathematics.ts"() {
|
|
5408
|
+
init_esm_shims();
|
|
5409
|
+
init_utils();
|
|
5268
5410
|
}
|
|
5269
5411
|
});
|
|
5270
5412
|
|
|
5271
|
-
// src/
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
}
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5413
|
+
// src/export/visual/physics.ts
|
|
5414
|
+
function exportPhysicsVisualization(thought, options) {
|
|
5415
|
+
const { format, colorScheme = "default", includeLabels = true, includeMetrics = true } = options;
|
|
5416
|
+
switch (format) {
|
|
5417
|
+
case "mermaid":
|
|
5418
|
+
return physicsToMermaid(thought, colorScheme, includeLabels, includeMetrics);
|
|
5419
|
+
case "dot":
|
|
5420
|
+
return physicsToDOT(thought, includeLabels, includeMetrics);
|
|
5421
|
+
case "ascii":
|
|
5422
|
+
return physicsToASCII(thought);
|
|
5423
|
+
default:
|
|
5424
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
5425
|
+
}
|
|
5426
|
+
}
|
|
5427
|
+
function physicsToMermaid(thought, colorScheme, includeLabels, includeMetrics) {
|
|
5428
|
+
let mermaid = "graph TB\n";
|
|
5429
|
+
const typeId = sanitizeId(`type_${thought.thoughtType || "physics"}`);
|
|
5430
|
+
const typeLabel = includeLabels ? (thought.thoughtType || "Physics").replace(/_/g, " ") : typeId;
|
|
5431
|
+
mermaid += ` ${typeId}[["${typeLabel}"]]
|
|
5432
|
+
`;
|
|
5433
|
+
if (thought.tensorProperties) {
|
|
5434
|
+
const tensorId = sanitizeId("tensor");
|
|
5435
|
+
const rankLabel = `Rank (${thought.tensorProperties.rank[0]},${thought.tensorProperties.rank[1]})`;
|
|
5436
|
+
mermaid += ` ${tensorId}(["${rankLabel}"])
|
|
5437
|
+
`;
|
|
5438
|
+
mermaid += ` ${typeId} --> ${tensorId}
|
|
5439
|
+
`;
|
|
5440
|
+
const compId = sanitizeId("components");
|
|
5441
|
+
const compLabel = includeLabels ? thought.tensorProperties.components.slice(0, 30) + (thought.tensorProperties.components.length > 30 ? "..." : "") : "Components";
|
|
5442
|
+
mermaid += ` ${compId}["${compLabel}"]
|
|
5443
|
+
`;
|
|
5444
|
+
mermaid += ` ${tensorId} --> ${compId}
|
|
5445
|
+
`;
|
|
5446
|
+
if (thought.tensorProperties.symmetries.length > 0) {
|
|
5447
|
+
const symId = sanitizeId("symmetries");
|
|
5448
|
+
mermaid += ` ${symId}{{"Symmetries: ${thought.tensorProperties.symmetries.length}"}}
|
|
5449
|
+
`;
|
|
5450
|
+
mermaid += ` ${tensorId} --> ${symId}
|
|
5451
|
+
`;
|
|
5452
|
+
}
|
|
5453
|
+
if (thought.tensorProperties.invariants.length > 0) {
|
|
5454
|
+
const invId = sanitizeId("invariants");
|
|
5455
|
+
mermaid += ` ${invId}{{"Invariants: ${thought.tensorProperties.invariants.length}"}}
|
|
5456
|
+
`;
|
|
5457
|
+
mermaid += ` ${tensorId} --> ${invId}
|
|
5458
|
+
`;
|
|
5459
|
+
}
|
|
5460
|
+
}
|
|
5461
|
+
if (thought.physicalInterpretation) {
|
|
5462
|
+
const interpId = sanitizeId("interpretation");
|
|
5463
|
+
const interpLabel = thought.physicalInterpretation.quantity;
|
|
5464
|
+
mermaid += ` ${interpId}[/"${interpLabel}"/]
|
|
5465
|
+
`;
|
|
5466
|
+
mermaid += ` ${typeId} --> ${interpId}
|
|
5467
|
+
`;
|
|
5468
|
+
const unitsId = sanitizeId("units");
|
|
5469
|
+
mermaid += ` ${unitsId}(["${thought.physicalInterpretation.units}"])
|
|
5470
|
+
`;
|
|
5471
|
+
mermaid += ` ${interpId} --> ${unitsId}
|
|
5472
|
+
`;
|
|
5473
|
+
if (thought.physicalInterpretation.conservationLaws.length > 0) {
|
|
5474
|
+
thought.physicalInterpretation.conservationLaws.forEach((law, index) => {
|
|
5475
|
+
const lawId = sanitizeId(`conservation_${index}`);
|
|
5476
|
+
const lawLabel = includeLabels ? law.slice(0, 25) + (law.length > 25 ? "..." : "") : `Law ${index + 1}`;
|
|
5477
|
+
mermaid += ` ${lawId}>"${lawLabel}"]
|
|
5478
|
+
`;
|
|
5479
|
+
mermaid += ` ${interpId} --> ${lawId}
|
|
5480
|
+
`;
|
|
5481
|
+
});
|
|
5482
|
+
}
|
|
5483
|
+
}
|
|
5484
|
+
if (thought.fieldTheoryContext) {
|
|
5485
|
+
const fieldId = sanitizeId("field_theory");
|
|
5486
|
+
mermaid += ` ${fieldId}[("Field Theory")]
|
|
5487
|
+
`;
|
|
5488
|
+
mermaid += ` ${typeId} --> ${fieldId}
|
|
5489
|
+
`;
|
|
5490
|
+
thought.fieldTheoryContext.fields.forEach((field, index) => {
|
|
5491
|
+
const fId = sanitizeId(`field_${index}`);
|
|
5492
|
+
mermaid += ` ${fId}["${field}"]
|
|
5493
|
+
`;
|
|
5494
|
+
mermaid += ` ${fieldId} --> ${fId}
|
|
5495
|
+
`;
|
|
5496
|
+
});
|
|
5497
|
+
const symGroupId = sanitizeId("symmetry_group");
|
|
5498
|
+
mermaid += ` ${symGroupId}{{"${thought.fieldTheoryContext.symmetryGroup}"}}
|
|
5499
|
+
`;
|
|
5500
|
+
mermaid += ` ${fieldId} --> ${symGroupId}
|
|
5501
|
+
`;
|
|
5502
|
+
}
|
|
5503
|
+
if (includeMetrics) {
|
|
5504
|
+
const uncertId = sanitizeId("uncertainty");
|
|
5505
|
+
const uncertLabel = `Uncertainty: ${(thought.uncertainty * 100).toFixed(1)}%`;
|
|
5506
|
+
mermaid += ` ${uncertId}{{${uncertLabel}}}
|
|
5507
|
+
`;
|
|
5508
|
+
}
|
|
5509
|
+
if (thought.assumptions && thought.assumptions.length > 0) {
|
|
5510
|
+
const assumptionsId = sanitizeId("assumptions");
|
|
5511
|
+
mermaid += ` ${assumptionsId}>"Assumptions: ${thought.assumptions.length}"]
|
|
5512
|
+
`;
|
|
5513
|
+
}
|
|
5514
|
+
if (colorScheme !== "monochrome") {
|
|
5515
|
+
const colors = colorScheme === "pastel" ? { type: "#e3f2fd", tensor: "#fff3e0", interp: "#e8f5e9" } : { type: "#87CEEB", tensor: "#FFD700", interp: "#90EE90" };
|
|
5516
|
+
mermaid += `
|
|
5517
|
+
style ${typeId} fill:${colors.type}
|
|
5518
|
+
`;
|
|
5519
|
+
if (thought.tensorProperties) {
|
|
5520
|
+
mermaid += ` style ${sanitizeId("tensor")} fill:${colors.tensor}
|
|
5521
|
+
`;
|
|
5522
|
+
}
|
|
5523
|
+
if (thought.physicalInterpretation) {
|
|
5524
|
+
mermaid += ` style ${sanitizeId("interpretation")} fill:${colors.interp}
|
|
5525
|
+
`;
|
|
5526
|
+
}
|
|
5527
|
+
}
|
|
5528
|
+
return mermaid;
|
|
5529
|
+
}
|
|
5530
|
+
function physicsToDOT(thought, includeLabels, includeMetrics) {
|
|
5531
|
+
let dot = "digraph PhysicsVisualization {\n";
|
|
5532
|
+
dot += " rankdir=TB;\n";
|
|
5533
|
+
dot += " node [shape=box, style=rounded];\n\n";
|
|
5534
|
+
const typeId = sanitizeId(`type_${thought.thoughtType || "physics"}`);
|
|
5535
|
+
const typeLabel = includeLabels ? (thought.thoughtType || "Physics").replace(/_/g, " ") : typeId;
|
|
5536
|
+
dot += ` ${typeId} [label="${typeLabel}", shape=doubleoctagon];
|
|
5537
|
+
`;
|
|
5538
|
+
if (thought.tensorProperties) {
|
|
5539
|
+
const tensorId = sanitizeId("tensor");
|
|
5540
|
+
const rankLabel = `Rank (${thought.tensorProperties.rank[0]},${thought.tensorProperties.rank[1]})`;
|
|
5541
|
+
dot += ` ${tensorId} [label="${rankLabel}", shape=ellipse];
|
|
5542
|
+
`;
|
|
5543
|
+
dot += ` ${typeId} -> ${tensorId};
|
|
5544
|
+
`;
|
|
5545
|
+
const compId = sanitizeId("components");
|
|
5546
|
+
const compLabel = includeLabels ? thought.tensorProperties.components.slice(0, 25).replace(/"/g, '\\"') : "Components";
|
|
5547
|
+
dot += ` ${compId} [label="${compLabel}"];
|
|
5548
|
+
`;
|
|
5549
|
+
dot += ` ${tensorId} -> ${compId};
|
|
5550
|
+
`;
|
|
5551
|
+
const transId = sanitizeId("transformation");
|
|
5552
|
+
dot += ` ${transId} [label="${thought.tensorProperties.transformation}", shape=diamond];
|
|
5553
|
+
`;
|
|
5554
|
+
dot += ` ${tensorId} -> ${transId};
|
|
5555
|
+
`;
|
|
5556
|
+
}
|
|
5557
|
+
if (thought.physicalInterpretation) {
|
|
5558
|
+
const interpId = sanitizeId("interpretation");
|
|
5559
|
+
dot += ` ${interpId} [label="${thought.physicalInterpretation.quantity}", shape=parallelogram];
|
|
5560
|
+
`;
|
|
5561
|
+
dot += ` ${typeId} -> ${interpId};
|
|
5562
|
+
`;
|
|
5563
|
+
const unitsId = sanitizeId("units");
|
|
5564
|
+
dot += ` ${unitsId} [label="${thought.physicalInterpretation.units}", shape=ellipse];
|
|
5565
|
+
`;
|
|
5566
|
+
dot += ` ${interpId} -> ${unitsId};
|
|
5567
|
+
`;
|
|
5568
|
+
thought.physicalInterpretation.conservationLaws.forEach((law, index) => {
|
|
5569
|
+
const lawId = sanitizeId(`conservation_${index}`);
|
|
5570
|
+
const lawLabel = includeLabels ? law.slice(0, 20).replace(/"/g, '\\"') : `Law ${index + 1}`;
|
|
5571
|
+
dot += ` ${lawId} [label="${lawLabel}", shape=hexagon];
|
|
5572
|
+
`;
|
|
5573
|
+
dot += ` ${interpId} -> ${lawId};
|
|
5574
|
+
`;
|
|
5575
|
+
});
|
|
5576
|
+
}
|
|
5577
|
+
if (thought.fieldTheoryContext) {
|
|
5578
|
+
const fieldId = sanitizeId("field_theory");
|
|
5579
|
+
dot += ` ${fieldId} [label="Field Theory", shape=cylinder];
|
|
5580
|
+
`;
|
|
5581
|
+
dot += ` ${typeId} -> ${fieldId};
|
|
5582
|
+
`;
|
|
5583
|
+
thought.fieldTheoryContext.fields.forEach((field, index) => {
|
|
5584
|
+
const fId = sanitizeId(`field_${index}`);
|
|
5585
|
+
dot += ` ${fId} [label="${field}"];
|
|
5586
|
+
`;
|
|
5587
|
+
dot += ` ${fieldId} -> ${fId};
|
|
5588
|
+
`;
|
|
5589
|
+
});
|
|
5590
|
+
const symGroupId = sanitizeId("symmetry_group");
|
|
5591
|
+
dot += ` ${symGroupId} [label="${thought.fieldTheoryContext.symmetryGroup}", shape=diamond];
|
|
5592
|
+
`;
|
|
5593
|
+
dot += ` ${fieldId} -> ${symGroupId};
|
|
5594
|
+
`;
|
|
5595
|
+
}
|
|
5596
|
+
if (includeMetrics) {
|
|
5597
|
+
const uncertId = sanitizeId("uncertainty");
|
|
5598
|
+
dot += ` ${uncertId} [label="${(thought.uncertainty * 100).toFixed(1)}%", shape=diamond];
|
|
5599
|
+
`;
|
|
5600
|
+
}
|
|
5601
|
+
dot += "}\n";
|
|
5602
|
+
return dot;
|
|
5603
|
+
}
|
|
5604
|
+
function physicsToASCII(thought) {
|
|
5605
|
+
let ascii = "Physics Analysis:\n";
|
|
5606
|
+
ascii += "=================\n\n";
|
|
5607
|
+
ascii += `Type: ${(thought.thoughtType || "physics").replace(/_/g, " ")}
|
|
5608
|
+
`;
|
|
5609
|
+
ascii += `Uncertainty: ${(thought.uncertainty * 100).toFixed(1)}%
|
|
5610
|
+
|
|
5611
|
+
`;
|
|
5612
|
+
if (thought.tensorProperties) {
|
|
5613
|
+
ascii += "Tensor Properties:\n";
|
|
5614
|
+
ascii += ` Rank: (${thought.tensorProperties.rank[0]}, ${thought.tensorProperties.rank[1]})
|
|
5615
|
+
`;
|
|
5616
|
+
ascii += ` Components: ${thought.tensorProperties.components}
|
|
5617
|
+
`;
|
|
5618
|
+
ascii += ` LaTeX: ${thought.tensorProperties.latex}
|
|
5619
|
+
`;
|
|
5620
|
+
ascii += ` Transformation: ${thought.tensorProperties.transformation}
|
|
5621
|
+
`;
|
|
5622
|
+
if (thought.tensorProperties.indexStructure) {
|
|
5623
|
+
ascii += ` Index Structure: ${thought.tensorProperties.indexStructure}
|
|
5624
|
+
`;
|
|
5625
|
+
}
|
|
5626
|
+
if (thought.tensorProperties.coordinateSystem) {
|
|
5627
|
+
ascii += ` Coordinate System: ${thought.tensorProperties.coordinateSystem}
|
|
5628
|
+
`;
|
|
5629
|
+
}
|
|
5630
|
+
if (thought.tensorProperties.symmetries.length > 0) {
|
|
5631
|
+
ascii += " Symmetries:\n";
|
|
5632
|
+
thought.tensorProperties.symmetries.forEach((sym, index) => {
|
|
5633
|
+
ascii += ` ${index + 1}. ${sym}
|
|
5634
|
+
`;
|
|
5635
|
+
});
|
|
5636
|
+
}
|
|
5637
|
+
if (thought.tensorProperties.invariants.length > 0) {
|
|
5638
|
+
ascii += " Invariants:\n";
|
|
5639
|
+
thought.tensorProperties.invariants.forEach((inv, index) => {
|
|
5640
|
+
ascii += ` ${index + 1}. ${inv}
|
|
5641
|
+
`;
|
|
5642
|
+
});
|
|
5643
|
+
}
|
|
5644
|
+
ascii += "\n";
|
|
5645
|
+
}
|
|
5646
|
+
if (thought.physicalInterpretation) {
|
|
5647
|
+
ascii += "Physical Interpretation:\n";
|
|
5648
|
+
ascii += ` Quantity: ${thought.physicalInterpretation.quantity}
|
|
5649
|
+
`;
|
|
5650
|
+
ascii += ` Units: ${thought.physicalInterpretation.units}
|
|
5651
|
+
`;
|
|
5652
|
+
if (thought.physicalInterpretation.conservationLaws.length > 0) {
|
|
5653
|
+
ascii += " Conservation Laws:\n";
|
|
5654
|
+
thought.physicalInterpretation.conservationLaws.forEach((law, index) => {
|
|
5655
|
+
ascii += ` ${index + 1}. ${law}
|
|
5656
|
+
`;
|
|
5657
|
+
});
|
|
5658
|
+
}
|
|
5659
|
+
if (thought.physicalInterpretation.constraints && thought.physicalInterpretation.constraints.length > 0) {
|
|
5660
|
+
ascii += " Constraints:\n";
|
|
5661
|
+
thought.physicalInterpretation.constraints.forEach((constraint, index) => {
|
|
5662
|
+
ascii += ` ${index + 1}. ${constraint}
|
|
5663
|
+
`;
|
|
5664
|
+
});
|
|
5665
|
+
}
|
|
5666
|
+
if (thought.physicalInterpretation.observables && thought.physicalInterpretation.observables.length > 0) {
|
|
5667
|
+
ascii += " Observables:\n";
|
|
5668
|
+
thought.physicalInterpretation.observables.forEach((obs, index) => {
|
|
5669
|
+
ascii += ` ${index + 1}. ${obs}
|
|
5670
|
+
`;
|
|
5671
|
+
});
|
|
5672
|
+
}
|
|
5673
|
+
ascii += "\n";
|
|
5674
|
+
}
|
|
5675
|
+
if (thought.fieldTheoryContext) {
|
|
5676
|
+
ascii += "Field Theory Context:\n";
|
|
5677
|
+
ascii += ` Symmetry Group: ${thought.fieldTheoryContext.symmetryGroup}
|
|
5678
|
+
`;
|
|
5679
|
+
if (thought.fieldTheoryContext.fields.length > 0) {
|
|
5680
|
+
ascii += " Fields:\n";
|
|
5681
|
+
thought.fieldTheoryContext.fields.forEach((field, index) => {
|
|
5682
|
+
ascii += ` ${index + 1}. ${field}
|
|
5683
|
+
`;
|
|
5684
|
+
});
|
|
5685
|
+
}
|
|
5686
|
+
if (thought.fieldTheoryContext.interactions.length > 0) {
|
|
5687
|
+
ascii += " Interactions:\n";
|
|
5688
|
+
thought.fieldTheoryContext.interactions.forEach((interaction, index) => {
|
|
5689
|
+
ascii += ` ${index + 1}. ${interaction}
|
|
5690
|
+
`;
|
|
5691
|
+
});
|
|
5692
|
+
}
|
|
5693
|
+
if (thought.fieldTheoryContext.gaugeSymmetries && thought.fieldTheoryContext.gaugeSymmetries.length > 0) {
|
|
5694
|
+
ascii += " Gauge Symmetries:\n";
|
|
5695
|
+
thought.fieldTheoryContext.gaugeSymmetries.forEach((gauge, index) => {
|
|
5696
|
+
ascii += ` ${index + 1}. ${gauge}
|
|
5697
|
+
`;
|
|
5698
|
+
});
|
|
5699
|
+
}
|
|
5700
|
+
ascii += "\n";
|
|
5701
|
+
}
|
|
5702
|
+
if (thought.assumptions && thought.assumptions.length > 0) {
|
|
5703
|
+
ascii += "Assumptions:\n";
|
|
5704
|
+
thought.assumptions.forEach((assumption, index) => {
|
|
5705
|
+
ascii += ` ${index + 1}. ${assumption}
|
|
5706
|
+
`;
|
|
5707
|
+
});
|
|
5708
|
+
ascii += "\n";
|
|
5709
|
+
}
|
|
5710
|
+
if (thought.dependencies && thought.dependencies.length > 0) {
|
|
5711
|
+
ascii += "Dependencies:\n";
|
|
5712
|
+
thought.dependencies.forEach((dep, index) => {
|
|
5713
|
+
ascii += ` ${index + 1}. ${dep}
|
|
5714
|
+
`;
|
|
5715
|
+
});
|
|
5716
|
+
}
|
|
5717
|
+
return ascii;
|
|
5718
|
+
}
|
|
5719
|
+
var init_physics = __esm({
|
|
5720
|
+
"src/export/visual/physics.ts"() {
|
|
5721
|
+
init_esm_shims();
|
|
5722
|
+
init_utils();
|
|
5723
|
+
}
|
|
5724
|
+
});
|
|
5725
|
+
|
|
5726
|
+
// src/export/visual/hybrid.ts
|
|
5727
|
+
function exportHybridOrchestration(thought, options) {
|
|
5728
|
+
const { format, colorScheme = "default", includeLabels = true, includeMetrics = true } = options;
|
|
5729
|
+
switch (format) {
|
|
5730
|
+
case "mermaid":
|
|
5731
|
+
return hybridToMermaid(thought, colorScheme, includeLabels, includeMetrics);
|
|
5732
|
+
case "dot":
|
|
5733
|
+
return hybridToDOT(thought, includeLabels, includeMetrics);
|
|
5734
|
+
case "ascii":
|
|
5735
|
+
return hybridToASCII(thought);
|
|
5736
|
+
default:
|
|
5737
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5740
|
+
function hybridToMermaid(thought, colorScheme, includeLabels, includeMetrics) {
|
|
5741
|
+
let mermaid = "graph TB\n";
|
|
5742
|
+
const hybridId = sanitizeId("hybrid_mode");
|
|
5743
|
+
mermaid += ` ${hybridId}(("Hybrid Mode"))
|
|
5744
|
+
`;
|
|
5745
|
+
const primaryId = sanitizeId(`primary_${thought.primaryMode}`);
|
|
5746
|
+
const primaryLabel = includeLabels ? thought.primaryMode.charAt(0).toUpperCase() + thought.primaryMode.slice(1) : primaryId;
|
|
5747
|
+
mermaid += ` ${primaryId}[["${primaryLabel}"]]
|
|
5748
|
+
`;
|
|
5749
|
+
mermaid += ` ${hybridId} ==> ${primaryId}
|
|
5750
|
+
`;
|
|
5751
|
+
if (thought.secondaryFeatures && thought.secondaryFeatures.length > 0) {
|
|
5752
|
+
const secondaryId = sanitizeId("secondary_features");
|
|
5753
|
+
mermaid += ` ${secondaryId}(["Secondary Features"])
|
|
5754
|
+
`;
|
|
5755
|
+
mermaid += ` ${hybridId} --> ${secondaryId}
|
|
5756
|
+
`;
|
|
5757
|
+
thought.secondaryFeatures.forEach((feature, index) => {
|
|
5758
|
+
const featureId = sanitizeId(`feature_${index}`);
|
|
5759
|
+
const featureLabel = includeLabels ? feature.slice(0, 30) + (feature.length > 30 ? "..." : "") : `Feature ${index + 1}`;
|
|
5760
|
+
mermaid += ` ${featureId}["${featureLabel}"]
|
|
5761
|
+
`;
|
|
5762
|
+
mermaid += ` ${secondaryId} --> ${featureId}
|
|
5763
|
+
`;
|
|
5764
|
+
});
|
|
5765
|
+
}
|
|
5766
|
+
if (thought.switchReason) {
|
|
5767
|
+
const switchId = sanitizeId("switch_reason");
|
|
5768
|
+
const switchLabel = includeLabels ? thought.switchReason.slice(0, 40) + (thought.switchReason.length > 40 ? "..." : "") : "Switch Reason";
|
|
5769
|
+
mermaid += ` ${switchId}>"${switchLabel}"]
|
|
5770
|
+
`;
|
|
5771
|
+
mermaid += ` ${hybridId} -.-> ${switchId}
|
|
5772
|
+
`;
|
|
5773
|
+
}
|
|
5774
|
+
if (thought.stage) {
|
|
5775
|
+
const stageId = sanitizeId(`stage_${thought.stage}`);
|
|
5776
|
+
const stageLabel = thought.stage.replace(/_/g, " ");
|
|
5777
|
+
mermaid += ` ${stageId}{{"Stage: ${stageLabel}"}}
|
|
5778
|
+
`;
|
|
5779
|
+
mermaid += ` ${primaryId} --> ${stageId}
|
|
5780
|
+
`;
|
|
5781
|
+
}
|
|
5782
|
+
if (thought.mathematicalModel) {
|
|
5783
|
+
const modelId = sanitizeId("math_model");
|
|
5784
|
+
const modelLabel = thought.mathematicalModel.symbolic || "Mathematical Model";
|
|
5785
|
+
mermaid += ` ${modelId}["${modelLabel}"]
|
|
5786
|
+
`;
|
|
5787
|
+
mermaid += ` ${primaryId} --> ${modelId}
|
|
5788
|
+
`;
|
|
5789
|
+
}
|
|
5790
|
+
if (thought.tensorProperties) {
|
|
5791
|
+
const tensorId = sanitizeId("tensor");
|
|
5792
|
+
const tensorLabel = `Tensor (${thought.tensorProperties.rank[0]},${thought.tensorProperties.rank[1]})`;
|
|
5793
|
+
mermaid += ` ${tensorId}[/"${tensorLabel}"/]
|
|
5794
|
+
`;
|
|
5795
|
+
mermaid += ` ${primaryId} --> ${tensorId}
|
|
5796
|
+
`;
|
|
5797
|
+
}
|
|
5798
|
+
if (thought.physicalInterpretation) {
|
|
5799
|
+
const physId = sanitizeId("physical");
|
|
5800
|
+
mermaid += ` ${physId}[/"${thought.physicalInterpretation.quantity}"/]
|
|
5801
|
+
`;
|
|
5802
|
+
mermaid += ` ${primaryId} --> ${physId}
|
|
5803
|
+
`;
|
|
5804
|
+
}
|
|
5805
|
+
if (includeMetrics && thought.uncertainty !== void 0) {
|
|
5806
|
+
const uncertId = sanitizeId("uncertainty");
|
|
5807
|
+
const uncertLabel = `Uncertainty: ${(thought.uncertainty * 100).toFixed(1)}%`;
|
|
5808
|
+
mermaid += ` ${uncertId}{{${uncertLabel}}}
|
|
5809
|
+
`;
|
|
5810
|
+
}
|
|
5811
|
+
if (thought.assumptions && thought.assumptions.length > 0) {
|
|
5812
|
+
const assumptionsId = sanitizeId("assumptions");
|
|
5813
|
+
mermaid += ` ${assumptionsId}>"Assumptions: ${thought.assumptions.length}"]
|
|
5814
|
+
`;
|
|
5815
|
+
}
|
|
5816
|
+
if (thought.dependencies && thought.dependencies.length > 0) {
|
|
5817
|
+
const depsId = sanitizeId("dependencies");
|
|
5818
|
+
mermaid += ` ${depsId}>"Dependencies: ${thought.dependencies.length}"]
|
|
5819
|
+
`;
|
|
5820
|
+
}
|
|
5821
|
+
if (colorScheme !== "monochrome") {
|
|
5822
|
+
const colors = colorScheme === "pastel" ? { hybrid: "#e8f4e8", primary: "#e3f2fd", secondary: "#fff3e0" } : { hybrid: "#90EE90", primary: "#87CEEB", secondary: "#FFD700" };
|
|
5823
|
+
mermaid += `
|
|
5824
|
+
style ${hybridId} fill:${colors.hybrid}
|
|
5825
|
+
`;
|
|
5826
|
+
mermaid += ` style ${primaryId} fill:${colors.primary}
|
|
5827
|
+
`;
|
|
5828
|
+
if (thought.secondaryFeatures && thought.secondaryFeatures.length > 0) {
|
|
5829
|
+
mermaid += ` style ${sanitizeId("secondary_features")} fill:${colors.secondary}
|
|
5830
|
+
`;
|
|
5831
|
+
}
|
|
5832
|
+
}
|
|
5833
|
+
return mermaid;
|
|
5834
|
+
}
|
|
5835
|
+
function hybridToDOT(thought, includeLabels, includeMetrics) {
|
|
5836
|
+
let dot = "digraph HybridOrchestration {\n";
|
|
5837
|
+
dot += " rankdir=TB;\n";
|
|
5838
|
+
dot += " node [shape=box, style=rounded];\n\n";
|
|
5839
|
+
const hybridId = sanitizeId("hybrid_mode");
|
|
5840
|
+
dot += ` ${hybridId} [label="Hybrid Mode", shape=doubleoctagon];
|
|
5841
|
+
`;
|
|
5842
|
+
const primaryId = sanitizeId(`primary_${thought.primaryMode}`);
|
|
5843
|
+
const primaryLabel = thought.primaryMode.charAt(0).toUpperCase() + thought.primaryMode.slice(1);
|
|
5844
|
+
dot += ` ${primaryId} [label="${primaryLabel}", shape=box, style="filled,rounded", fillcolor=lightblue];
|
|
5845
|
+
`;
|
|
5846
|
+
dot += ` ${hybridId} -> ${primaryId} [style=bold, penwidth=2];
|
|
5847
|
+
`;
|
|
5848
|
+
if (thought.secondaryFeatures && thought.secondaryFeatures.length > 0) {
|
|
5849
|
+
const secondaryId = sanitizeId("secondary_features");
|
|
5850
|
+
dot += ` ${secondaryId} [label="Secondary Features", shape=ellipse];
|
|
5851
|
+
`;
|
|
5852
|
+
dot += ` ${hybridId} -> ${secondaryId};
|
|
5853
|
+
`;
|
|
5854
|
+
thought.secondaryFeatures.forEach((feature, index) => {
|
|
5855
|
+
const featureId = sanitizeId(`feature_${index}`);
|
|
5856
|
+
const featureLabel = includeLabels ? feature.slice(0, 25).replace(/"/g, '\\"') : `Feature ${index + 1}`;
|
|
5857
|
+
dot += ` ${featureId} [label="${featureLabel}"];
|
|
5858
|
+
`;
|
|
5859
|
+
dot += ` ${secondaryId} -> ${featureId};
|
|
5860
|
+
`;
|
|
5861
|
+
});
|
|
5862
|
+
}
|
|
5863
|
+
if (thought.switchReason) {
|
|
5864
|
+
const switchId = sanitizeId("switch_reason");
|
|
5865
|
+
const switchLabel = includeLabels ? thought.switchReason.slice(0, 30).replace(/"/g, '\\"') : "Switch Reason";
|
|
5866
|
+
dot += ` ${switchId} [label="${switchLabel}", shape=note];
|
|
5867
|
+
`;
|
|
5868
|
+
dot += ` ${hybridId} -> ${switchId} [style=dashed];
|
|
5869
|
+
`;
|
|
5870
|
+
}
|
|
5871
|
+
if (thought.stage) {
|
|
5872
|
+
const stageId = sanitizeId(`stage_${thought.stage}`);
|
|
5873
|
+
dot += ` ${stageId} [label="${thought.stage.replace(/_/g, " ")}", shape=diamond];
|
|
5874
|
+
`;
|
|
5875
|
+
dot += ` ${primaryId} -> ${stageId};
|
|
5876
|
+
`;
|
|
5877
|
+
}
|
|
5878
|
+
if (thought.mathematicalModel) {
|
|
5879
|
+
const modelId = sanitizeId("math_model");
|
|
5880
|
+
const modelLabel = thought.mathematicalModel.symbolic ? thought.mathematicalModel.symbolic.slice(0, 25).replace(/"/g, '\\"') : "Math Model";
|
|
5881
|
+
dot += ` ${modelId} [label="${modelLabel}", shape=parallelogram];
|
|
5882
|
+
`;
|
|
5883
|
+
dot += ` ${primaryId} -> ${modelId};
|
|
5884
|
+
`;
|
|
5885
|
+
}
|
|
5886
|
+
if (thought.tensorProperties) {
|
|
5887
|
+
const tensorId = sanitizeId("tensor");
|
|
5888
|
+
dot += ` ${tensorId} [label="Tensor (${thought.tensorProperties.rank[0]},${thought.tensorProperties.rank[1]})", shape=parallelogram];
|
|
5889
|
+
`;
|
|
5890
|
+
dot += ` ${primaryId} -> ${tensorId};
|
|
5891
|
+
`;
|
|
5892
|
+
}
|
|
5893
|
+
if (thought.physicalInterpretation) {
|
|
5894
|
+
const physId = sanitizeId("physical");
|
|
5895
|
+
dot += ` ${physId} [label="${thought.physicalInterpretation.quantity}", shape=parallelogram];
|
|
5896
|
+
`;
|
|
5897
|
+
dot += ` ${primaryId} -> ${physId};
|
|
5898
|
+
`;
|
|
5899
|
+
}
|
|
5900
|
+
if (includeMetrics && thought.uncertainty !== void 0) {
|
|
5901
|
+
const uncertId = sanitizeId("uncertainty");
|
|
5902
|
+
dot += ` ${uncertId} [label="${(thought.uncertainty * 100).toFixed(1)}%", shape=diamond];
|
|
5903
|
+
`;
|
|
5904
|
+
}
|
|
5905
|
+
dot += "}\n";
|
|
5906
|
+
return dot;
|
|
5907
|
+
}
|
|
5908
|
+
function hybridToASCII(thought) {
|
|
5909
|
+
let ascii = "Hybrid Mode Orchestration:\n";
|
|
5910
|
+
ascii += "==========================\n\n";
|
|
5911
|
+
ascii += `Primary Mode: ${thought.primaryMode.charAt(0).toUpperCase() + thought.primaryMode.slice(1)}
|
|
5912
|
+
`;
|
|
5913
|
+
if (thought.stage) {
|
|
5914
|
+
ascii += `Current Stage: ${thought.stage.replace(/_/g, " ")}
|
|
5915
|
+
`;
|
|
5916
|
+
}
|
|
5917
|
+
if (thought.uncertainty !== void 0) {
|
|
5918
|
+
ascii += `Uncertainty: ${(thought.uncertainty * 100).toFixed(1)}%
|
|
5919
|
+
`;
|
|
5920
|
+
}
|
|
5921
|
+
ascii += "\n";
|
|
5922
|
+
if (thought.switchReason) {
|
|
5923
|
+
ascii += `Switch Reason: ${thought.switchReason}
|
|
5924
|
+
|
|
5925
|
+
`;
|
|
5926
|
+
}
|
|
5927
|
+
if (thought.secondaryFeatures && thought.secondaryFeatures.length > 0) {
|
|
5928
|
+
ascii += "Secondary Features:\n";
|
|
5929
|
+
thought.secondaryFeatures.forEach((feature, index) => {
|
|
5930
|
+
ascii += ` ${index + 1}. ${feature}
|
|
5931
|
+
`;
|
|
5932
|
+
});
|
|
5933
|
+
ascii += "\n";
|
|
5934
|
+
}
|
|
5935
|
+
if (thought.mathematicalModel) {
|
|
5936
|
+
ascii += "Mathematical Model:\n";
|
|
5937
|
+
ascii += ` LaTeX: ${thought.mathematicalModel.latex}
|
|
5938
|
+
`;
|
|
5939
|
+
ascii += ` Symbolic: ${thought.mathematicalModel.symbolic}
|
|
5940
|
+
`;
|
|
5941
|
+
if (thought.mathematicalModel.ascii) {
|
|
5942
|
+
ascii += ` ASCII: ${thought.mathematicalModel.ascii}
|
|
5943
|
+
`;
|
|
5944
|
+
}
|
|
5945
|
+
ascii += "\n";
|
|
5946
|
+
}
|
|
5947
|
+
if (thought.tensorProperties) {
|
|
5948
|
+
ascii += "Tensor Properties:\n";
|
|
5949
|
+
ascii += ` Rank: (${thought.tensorProperties.rank[0]}, ${thought.tensorProperties.rank[1]})
|
|
5950
|
+
`;
|
|
5951
|
+
ascii += ` Components: ${thought.tensorProperties.components}
|
|
5952
|
+
`;
|
|
5953
|
+
ascii += ` Transformation: ${thought.tensorProperties.transformation}
|
|
5954
|
+
`;
|
|
5955
|
+
if (thought.tensorProperties.symmetries.length > 0) {
|
|
5956
|
+
ascii += " Symmetries:\n";
|
|
5957
|
+
thought.tensorProperties.symmetries.forEach((sym, index) => {
|
|
5958
|
+
ascii += ` ${index + 1}. ${sym}
|
|
5959
|
+
`;
|
|
5960
|
+
});
|
|
5961
|
+
}
|
|
5962
|
+
ascii += "\n";
|
|
5963
|
+
}
|
|
5964
|
+
if (thought.physicalInterpretation) {
|
|
5965
|
+
ascii += "Physical Interpretation:\n";
|
|
5966
|
+
ascii += ` Quantity: ${thought.physicalInterpretation.quantity}
|
|
5967
|
+
`;
|
|
5968
|
+
ascii += ` Units: ${thought.physicalInterpretation.units}
|
|
5969
|
+
`;
|
|
5970
|
+
if (thought.physicalInterpretation.conservationLaws.length > 0) {
|
|
5971
|
+
ascii += " Conservation Laws:\n";
|
|
5972
|
+
thought.physicalInterpretation.conservationLaws.forEach((law, index) => {
|
|
5973
|
+
ascii += ` ${index + 1}. ${law}
|
|
5974
|
+
`;
|
|
5975
|
+
});
|
|
5976
|
+
}
|
|
5977
|
+
ascii += "\n";
|
|
5978
|
+
}
|
|
5979
|
+
if (thought.assumptions && thought.assumptions.length > 0) {
|
|
5980
|
+
ascii += "Assumptions:\n";
|
|
5981
|
+
thought.assumptions.forEach((assumption, index) => {
|
|
5982
|
+
ascii += ` ${index + 1}. ${assumption}
|
|
5983
|
+
`;
|
|
5984
|
+
});
|
|
5985
|
+
ascii += "\n";
|
|
5986
|
+
}
|
|
5987
|
+
if (thought.dependencies && thought.dependencies.length > 0) {
|
|
5988
|
+
ascii += "Dependencies:\n";
|
|
5989
|
+
thought.dependencies.forEach((dep, index) => {
|
|
5990
|
+
ascii += ` ${index + 1}. ${dep}
|
|
5991
|
+
`;
|
|
5992
|
+
});
|
|
5993
|
+
ascii += "\n";
|
|
5994
|
+
}
|
|
5995
|
+
if (thought.revisionReason) {
|
|
5996
|
+
ascii += `Revision Reason: ${thought.revisionReason}
|
|
5997
|
+
`;
|
|
5998
|
+
}
|
|
5999
|
+
return ascii;
|
|
6000
|
+
}
|
|
6001
|
+
var init_hybrid = __esm({
|
|
6002
|
+
"src/export/visual/hybrid.ts"() {
|
|
6003
|
+
init_esm_shims();
|
|
6004
|
+
init_utils();
|
|
6005
|
+
}
|
|
6006
|
+
});
|
|
6007
|
+
|
|
6008
|
+
// src/export/visual/metareasoning.ts
|
|
6009
|
+
function exportMetaReasoningVisualization(thought, options) {
|
|
6010
|
+
const { format, colorScheme = "default", includeLabels = true, includeMetrics = true } = options;
|
|
6011
|
+
switch (format) {
|
|
6012
|
+
case "mermaid":
|
|
6013
|
+
return metaReasoningToMermaid(thought, colorScheme, includeLabels, includeMetrics);
|
|
6014
|
+
case "dot":
|
|
6015
|
+
return metaReasoningToDOT(thought, includeLabels, includeMetrics);
|
|
6016
|
+
case "ascii":
|
|
6017
|
+
return metaReasoningToASCII(thought);
|
|
6018
|
+
default:
|
|
6019
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
6020
|
+
}
|
|
6021
|
+
}
|
|
6022
|
+
function metaReasoningToMermaid(thought, colorScheme, includeLabels, includeMetrics) {
|
|
6023
|
+
let mermaid = "graph TB\n";
|
|
6024
|
+
const metaId = sanitizeId("meta_reasoning");
|
|
6025
|
+
mermaid += ` ${metaId}(("Meta-Reasoning"))
|
|
6026
|
+
`;
|
|
6027
|
+
const currentId = sanitizeId("current_strategy");
|
|
6028
|
+
const currentLabel = includeLabels ? thought.currentStrategy.approach : "Current Strategy";
|
|
6029
|
+
mermaid += ` ${currentId}[["${currentLabel}"]]
|
|
6030
|
+
`;
|
|
6031
|
+
mermaid += ` ${metaId} ==> ${currentId}
|
|
6032
|
+
`;
|
|
6033
|
+
const modeId = sanitizeId("current_mode");
|
|
6034
|
+
mermaid += ` ${modeId}(["Mode: ${thought.currentStrategy.mode}"])
|
|
6035
|
+
`;
|
|
6036
|
+
mermaid += ` ${currentId} --> ${modeId}
|
|
6037
|
+
`;
|
|
6038
|
+
const evalId = sanitizeId("evaluation");
|
|
6039
|
+
mermaid += ` ${evalId}{{"Effectiveness: ${(thought.strategyEvaluation.effectiveness * 100).toFixed(0)}%"}}
|
|
6040
|
+
`;
|
|
6041
|
+
mermaid += ` ${currentId} --> ${evalId}
|
|
6042
|
+
`;
|
|
6043
|
+
if (thought.strategyEvaluation.issues.length > 0) {
|
|
6044
|
+
const issuesId = sanitizeId("issues");
|
|
6045
|
+
mermaid += ` ${issuesId}>"Issues: ${thought.strategyEvaluation.issues.length}"]
|
|
6046
|
+
`;
|
|
6047
|
+
mermaid += ` ${evalId} --> ${issuesId}
|
|
6048
|
+
`;
|
|
6049
|
+
}
|
|
6050
|
+
if (thought.strategyEvaluation.strengths.length > 0) {
|
|
6051
|
+
const strengthsId = sanitizeId("strengths");
|
|
6052
|
+
mermaid += ` ${strengthsId}>"Strengths: ${thought.strategyEvaluation.strengths.length}"]
|
|
6053
|
+
`;
|
|
6054
|
+
mermaid += ` ${evalId} --> ${strengthsId}
|
|
6055
|
+
`;
|
|
6056
|
+
}
|
|
6057
|
+
if (thought.alternativeStrategies.length > 0) {
|
|
6058
|
+
const altsId = sanitizeId("alternatives");
|
|
6059
|
+
mermaid += ` ${altsId}(["Alternative Strategies"])
|
|
6060
|
+
`;
|
|
6061
|
+
mermaid += ` ${metaId} --> ${altsId}
|
|
6062
|
+
`;
|
|
6063
|
+
thought.alternativeStrategies.forEach((alt, index) => {
|
|
6064
|
+
const altId = sanitizeId(`alt_${index}`);
|
|
6065
|
+
const altLabel = includeLabels ? `${alt.mode}: ${(alt.recommendationScore * 100).toFixed(0)}%` : `Alt ${index + 1}`;
|
|
6066
|
+
mermaid += ` ${altId}["${altLabel}"]
|
|
6067
|
+
`;
|
|
6068
|
+
mermaid += ` ${altsId} --> ${altId}
|
|
6069
|
+
`;
|
|
6070
|
+
});
|
|
6071
|
+
}
|
|
6072
|
+
const recId = sanitizeId("recommendation");
|
|
6073
|
+
const recLabel = `${thought.recommendation.action}${thought.recommendation.targetMode ? ` \u2192 ${thought.recommendation.targetMode}` : ""}`;
|
|
6074
|
+
mermaid += ` ${recId}[/"${recLabel}"/]
|
|
6075
|
+
`;
|
|
6076
|
+
mermaid += ` ${metaId} ==> ${recId}
|
|
6077
|
+
`;
|
|
6078
|
+
if (includeMetrics) {
|
|
6079
|
+
const confId = sanitizeId("rec_confidence");
|
|
6080
|
+
mermaid += ` ${confId}{{"Confidence: ${(thought.recommendation.confidence * 100).toFixed(0)}%"}}
|
|
6081
|
+
`;
|
|
6082
|
+
mermaid += ` ${recId} --> ${confId}
|
|
6083
|
+
`;
|
|
6084
|
+
}
|
|
6085
|
+
if (includeMetrics) {
|
|
6086
|
+
const qualityId = sanitizeId("quality");
|
|
6087
|
+
const qualityLabel = `Quality: ${(thought.qualityMetrics.overallQuality * 100).toFixed(0)}%`;
|
|
6088
|
+
mermaid += ` ${qualityId}{{"${qualityLabel}"}}
|
|
6089
|
+
`;
|
|
6090
|
+
mermaid += ` ${metaId} -.-> ${qualityId}
|
|
6091
|
+
`;
|
|
6092
|
+
}
|
|
6093
|
+
const resourceId = sanitizeId("resources");
|
|
6094
|
+
mermaid += ` ${resourceId}[("Complexity: ${thought.resourceAllocation.complexityLevel}")]
|
|
6095
|
+
`;
|
|
6096
|
+
mermaid += ` ${metaId} -.-> ${resourceId}
|
|
6097
|
+
`;
|
|
6098
|
+
const sessionId = sanitizeId("session");
|
|
6099
|
+
mermaid += ` ${sessionId}>"Thoughts: ${thought.sessionContext.totalThoughts}"]
|
|
6100
|
+
`;
|
|
6101
|
+
mermaid += ` ${metaId} -.-> ${sessionId}
|
|
6102
|
+
`;
|
|
6103
|
+
if (colorScheme !== "monochrome") {
|
|
6104
|
+
const colors = colorScheme === "pastel" ? { meta: "#f3e5f5", current: "#e3f2fd", rec: "#e8f5e9", alt: "#fff3e0" } : { meta: "#DDA0DD", current: "#87CEEB", rec: "#90EE90", alt: "#FFD700" };
|
|
6105
|
+
mermaid += `
|
|
6106
|
+
style ${metaId} fill:${colors.meta}
|
|
6107
|
+
`;
|
|
6108
|
+
mermaid += ` style ${currentId} fill:${colors.current}
|
|
6109
|
+
`;
|
|
6110
|
+
mermaid += ` style ${recId} fill:${colors.rec}
|
|
6111
|
+
`;
|
|
6112
|
+
if (thought.alternativeStrategies.length > 0) {
|
|
6113
|
+
mermaid += ` style ${sanitizeId("alternatives")} fill:${colors.alt}
|
|
6114
|
+
`;
|
|
6115
|
+
}
|
|
6116
|
+
}
|
|
6117
|
+
return mermaid;
|
|
6118
|
+
}
|
|
6119
|
+
function metaReasoningToDOT(thought, includeLabels, includeMetrics) {
|
|
6120
|
+
let dot = "digraph MetaReasoning {\n";
|
|
6121
|
+
dot += " rankdir=TB;\n";
|
|
6122
|
+
dot += " node [shape=box, style=rounded];\n\n";
|
|
6123
|
+
dot += " subgraph cluster_current {\n";
|
|
6124
|
+
dot += ' label="Current Strategy";\n';
|
|
6125
|
+
dot += " style=filled;\n";
|
|
6126
|
+
dot += " fillcolor=lightblue;\n";
|
|
6127
|
+
const currentId = sanitizeId("current_strategy");
|
|
6128
|
+
const currentLabel = includeLabels ? thought.currentStrategy.approach.slice(0, 30).replace(/"/g, '\\"') : "Current Strategy";
|
|
6129
|
+
dot += ` ${currentId} [label="${currentLabel}"];
|
|
6130
|
+
`;
|
|
6131
|
+
const modeId = sanitizeId("current_mode");
|
|
6132
|
+
dot += ` ${modeId} [label="${thought.currentStrategy.mode}", shape=ellipse];
|
|
6133
|
+
`;
|
|
6134
|
+
dot += ` ${currentId} -> ${modeId};
|
|
6135
|
+
`;
|
|
6136
|
+
if (includeMetrics) {
|
|
6137
|
+
const evalId = sanitizeId("evaluation");
|
|
6138
|
+
dot += ` ${evalId} [label="Eff: ${(thought.strategyEvaluation.effectiveness * 100).toFixed(0)}%", shape=diamond];
|
|
6139
|
+
`;
|
|
6140
|
+
dot += ` ${currentId} -> ${evalId};
|
|
6141
|
+
`;
|
|
6142
|
+
}
|
|
6143
|
+
dot += " }\n\n";
|
|
6144
|
+
if (thought.alternativeStrategies.length > 0) {
|
|
6145
|
+
dot += " subgraph cluster_alternatives {\n";
|
|
6146
|
+
dot += ' label="Alternatives";\n';
|
|
6147
|
+
dot += " style=filled;\n";
|
|
6148
|
+
dot += " fillcolor=lightyellow;\n";
|
|
6149
|
+
thought.alternativeStrategies.forEach((alt, index) => {
|
|
6150
|
+
const altId = sanitizeId(`alt_${index}`);
|
|
6151
|
+
const altLabel = `${alt.mode}\\n${(alt.recommendationScore * 100).toFixed(0)}%`;
|
|
6152
|
+
dot += ` ${altId} [label="${altLabel}"];
|
|
6153
|
+
`;
|
|
6154
|
+
});
|
|
6155
|
+
dot += " }\n\n";
|
|
6156
|
+
}
|
|
6157
|
+
const recId = sanitizeId("recommendation");
|
|
6158
|
+
const recLabel = `${thought.recommendation.action}${thought.recommendation.targetMode ? `\\n\u2192 ${thought.recommendation.targetMode}` : ""}`;
|
|
6159
|
+
dot += ` ${recId} [label="${recLabel}", shape=hexagon, style="filled", fillcolor=lightgreen];
|
|
6160
|
+
`;
|
|
6161
|
+
if (includeMetrics) {
|
|
6162
|
+
const qualityId = sanitizeId("quality");
|
|
6163
|
+
const qualityLabel = `Quality: ${(thought.qualityMetrics.overallQuality * 100).toFixed(0)}%`;
|
|
6164
|
+
dot += ` ${qualityId} [label="${qualityLabel}", shape=diamond];
|
|
6165
|
+
`;
|
|
6166
|
+
}
|
|
6167
|
+
dot += ` ${currentId} -> ${recId} [style=bold, penwidth=2];
|
|
6168
|
+
`;
|
|
6169
|
+
thought.alternativeStrategies.forEach((_, index) => {
|
|
6170
|
+
const altId = sanitizeId(`alt_${index}`);
|
|
6171
|
+
dot += ` ${altId} -> ${recId} [style=dashed];
|
|
6172
|
+
`;
|
|
6173
|
+
});
|
|
6174
|
+
dot += "}\n";
|
|
6175
|
+
return dot;
|
|
6176
|
+
}
|
|
6177
|
+
function metaReasoningToASCII(thought) {
|
|
6178
|
+
let ascii = "Meta-Reasoning Analysis:\n";
|
|
6179
|
+
ascii += "========================\n\n";
|
|
6180
|
+
ascii += "CURRENT STRATEGY\n";
|
|
6181
|
+
ascii += "----------------\n";
|
|
6182
|
+
ascii += `Mode: ${thought.currentStrategy.mode}
|
|
6183
|
+
`;
|
|
6184
|
+
ascii += `Approach: ${thought.currentStrategy.approach}
|
|
6185
|
+
`;
|
|
6186
|
+
ascii += `Thoughts Spent: ${thought.currentStrategy.thoughtsSpent}
|
|
6187
|
+
`;
|
|
6188
|
+
if (thought.currentStrategy.progressIndicators.length > 0) {
|
|
6189
|
+
ascii += "Progress Indicators:\n";
|
|
6190
|
+
thought.currentStrategy.progressIndicators.forEach((ind, index) => {
|
|
6191
|
+
ascii += ` ${index + 1}. ${ind}
|
|
6192
|
+
`;
|
|
6193
|
+
});
|
|
6194
|
+
}
|
|
6195
|
+
ascii += "\n";
|
|
6196
|
+
ascii += "STRATEGY EVALUATION\n";
|
|
6197
|
+
ascii += "-------------------\n";
|
|
6198
|
+
ascii += `Effectiveness: ${(thought.strategyEvaluation.effectiveness * 100).toFixed(1)}%
|
|
6199
|
+
`;
|
|
6200
|
+
ascii += `Efficiency: ${(thought.strategyEvaluation.efficiency * 100).toFixed(1)}%
|
|
6201
|
+
`;
|
|
6202
|
+
ascii += `Confidence: ${(thought.strategyEvaluation.confidence * 100).toFixed(1)}%
|
|
6203
|
+
`;
|
|
6204
|
+
ascii += `Progress Rate: ${thought.strategyEvaluation.progressRate.toFixed(2)} insights/thought
|
|
6205
|
+
`;
|
|
6206
|
+
ascii += `Quality Score: ${(thought.strategyEvaluation.qualityScore * 100).toFixed(1)}%
|
|
6207
|
+
`;
|
|
6208
|
+
if (thought.strategyEvaluation.strengths.length > 0) {
|
|
6209
|
+
ascii += "Strengths:\n";
|
|
6210
|
+
thought.strategyEvaluation.strengths.forEach((s, index) => {
|
|
6211
|
+
ascii += ` + ${index + 1}. ${s}
|
|
6212
|
+
`;
|
|
6213
|
+
});
|
|
6214
|
+
}
|
|
6215
|
+
if (thought.strategyEvaluation.issues.length > 0) {
|
|
6216
|
+
ascii += "Issues:\n";
|
|
6217
|
+
thought.strategyEvaluation.issues.forEach((issue, index) => {
|
|
6218
|
+
ascii += ` - ${index + 1}. ${issue}
|
|
6219
|
+
`;
|
|
6220
|
+
});
|
|
6221
|
+
}
|
|
6222
|
+
ascii += "\n";
|
|
6223
|
+
if (thought.alternativeStrategies.length > 0) {
|
|
6224
|
+
ascii += "ALTERNATIVE STRATEGIES\n";
|
|
6225
|
+
ascii += "----------------------\n";
|
|
6226
|
+
thought.alternativeStrategies.forEach((alt, index) => {
|
|
6227
|
+
ascii += `[${index + 1}] ${alt.mode}
|
|
6228
|
+
`;
|
|
6229
|
+
ascii += ` Reasoning: ${alt.reasoning}
|
|
6230
|
+
`;
|
|
6231
|
+
ascii += ` Expected Benefit: ${alt.expectedBenefit}
|
|
6232
|
+
`;
|
|
6233
|
+
ascii += ` Switching Cost: ${(alt.switchingCost * 100).toFixed(0)}%
|
|
6234
|
+
`;
|
|
6235
|
+
ascii += ` Recommendation Score: ${(alt.recommendationScore * 100).toFixed(0)}%
|
|
6236
|
+
`;
|
|
6237
|
+
});
|
|
6238
|
+
ascii += "\n";
|
|
6239
|
+
}
|
|
6240
|
+
ascii += "RECOMMENDATION\n";
|
|
6241
|
+
ascii += "--------------\n";
|
|
6242
|
+
ascii += `Action: ${thought.recommendation.action}
|
|
6243
|
+
`;
|
|
6244
|
+
if (thought.recommendation.targetMode) {
|
|
6245
|
+
ascii += `Target Mode: ${thought.recommendation.targetMode}
|
|
6246
|
+
`;
|
|
6247
|
+
}
|
|
6248
|
+
ascii += `Justification: ${thought.recommendation.justification}
|
|
6249
|
+
`;
|
|
6250
|
+
ascii += `Confidence: ${(thought.recommendation.confidence * 100).toFixed(1)}%
|
|
6251
|
+
`;
|
|
6252
|
+
ascii += `Expected Improvement: ${thought.recommendation.expectedImprovement}
|
|
6253
|
+
`;
|
|
6254
|
+
ascii += "\n";
|
|
6255
|
+
ascii += "RESOURCE ALLOCATION\n";
|
|
6256
|
+
ascii += "-------------------\n";
|
|
6257
|
+
ascii += `Time Spent: ${thought.resourceAllocation.timeSpent}ms
|
|
6258
|
+
`;
|
|
6259
|
+
ascii += `Thoughts Remaining: ${thought.resourceAllocation.thoughtsRemaining}
|
|
6260
|
+
`;
|
|
6261
|
+
ascii += `Complexity: ${thought.resourceAllocation.complexityLevel}
|
|
6262
|
+
`;
|
|
6263
|
+
ascii += `Urgency: ${thought.resourceAllocation.urgency}
|
|
6264
|
+
`;
|
|
6265
|
+
ascii += `Recommendation: ${thought.resourceAllocation.recommendation}
|
|
6266
|
+
`;
|
|
6267
|
+
ascii += "\n";
|
|
6268
|
+
ascii += "QUALITY METRICS\n";
|
|
6269
|
+
ascii += "---------------\n";
|
|
6270
|
+
ascii += `Logical Consistency: ${(thought.qualityMetrics.logicalConsistency * 100).toFixed(1)}%
|
|
6271
|
+
`;
|
|
6272
|
+
ascii += `Evidence Quality: ${(thought.qualityMetrics.evidenceQuality * 100).toFixed(1)}%
|
|
6273
|
+
`;
|
|
6274
|
+
ascii += `Completeness: ${(thought.qualityMetrics.completeness * 100).toFixed(1)}%
|
|
6275
|
+
`;
|
|
6276
|
+
ascii += `Originality: ${(thought.qualityMetrics.originality * 100).toFixed(1)}%
|
|
6277
|
+
`;
|
|
6278
|
+
ascii += `Clarity: ${(thought.qualityMetrics.clarity * 100).toFixed(1)}%
|
|
6279
|
+
`;
|
|
6280
|
+
ascii += `Overall Quality: ${(thought.qualityMetrics.overallQuality * 100).toFixed(1)}%
|
|
6281
|
+
`;
|
|
6282
|
+
ascii += "\n";
|
|
6283
|
+
ascii += "SESSION CONTEXT\n";
|
|
6284
|
+
ascii += "---------------\n";
|
|
6285
|
+
ascii += `Session ID: ${thought.sessionContext.sessionId}
|
|
6286
|
+
`;
|
|
6287
|
+
ascii += `Total Thoughts: ${thought.sessionContext.totalThoughts}
|
|
6288
|
+
`;
|
|
6289
|
+
ascii += `Mode Switches: ${thought.sessionContext.modeSwitches}
|
|
6290
|
+
`;
|
|
6291
|
+
ascii += `Problem Type: ${thought.sessionContext.problemType}
|
|
6292
|
+
`;
|
|
6293
|
+
ascii += `Modes Used: ${thought.sessionContext.modesUsed.join(", ")}
|
|
6294
|
+
`;
|
|
6295
|
+
if (thought.sessionContext.historicalEffectiveness !== void 0) {
|
|
6296
|
+
ascii += `Historical Effectiveness: ${(thought.sessionContext.historicalEffectiveness * 100).toFixed(1)}%
|
|
6297
|
+
`;
|
|
6298
|
+
}
|
|
6299
|
+
return ascii;
|
|
6300
|
+
}
|
|
6301
|
+
var init_metareasoning = __esm({
|
|
6302
|
+
"src/export/visual/metareasoning.ts"() {
|
|
6303
|
+
init_esm_shims();
|
|
6304
|
+
init_utils();
|
|
6305
|
+
}
|
|
6306
|
+
});
|
|
6307
|
+
|
|
6308
|
+
// src/export/visual/index.ts
|
|
6309
|
+
var VisualExporter;
|
|
6310
|
+
var init_visual = __esm({
|
|
6311
|
+
"src/export/visual/index.ts"() {
|
|
6312
|
+
init_esm_shims();
|
|
6313
|
+
init_causal();
|
|
6314
|
+
init_temporal();
|
|
6315
|
+
init_game_theory();
|
|
6316
|
+
init_bayesian();
|
|
6317
|
+
init_sequential();
|
|
6318
|
+
init_shannon();
|
|
6319
|
+
init_abductive();
|
|
6320
|
+
init_counterfactual();
|
|
6321
|
+
init_analogical();
|
|
6322
|
+
init_evidential();
|
|
6323
|
+
init_first_principles();
|
|
6324
|
+
init_systems_thinking();
|
|
6325
|
+
init_scientific_method();
|
|
6326
|
+
init_optimization();
|
|
6327
|
+
init_formal_logic();
|
|
6328
|
+
init_mathematics();
|
|
6329
|
+
init_physics();
|
|
6330
|
+
init_hybrid();
|
|
6331
|
+
init_metareasoning();
|
|
6332
|
+
VisualExporter = class {
|
|
6333
|
+
exportCausalGraph(thought, options) {
|
|
6334
|
+
return exportCausalGraph(thought, options);
|
|
6335
|
+
}
|
|
6336
|
+
exportTemporalTimeline(thought, options) {
|
|
6337
|
+
return exportTemporalTimeline(thought, options);
|
|
6338
|
+
}
|
|
6339
|
+
exportGameTree(thought, options) {
|
|
6340
|
+
return exportGameTree(thought, options);
|
|
6341
|
+
}
|
|
6342
|
+
exportBayesianNetwork(thought, options) {
|
|
6343
|
+
return exportBayesianNetwork(thought, options);
|
|
6344
|
+
}
|
|
6345
|
+
exportSequentialDependencyGraph(thought, options) {
|
|
6346
|
+
return exportSequentialDependencyGraph(thought, options);
|
|
6347
|
+
}
|
|
6348
|
+
exportShannonStageFlow(thought, options) {
|
|
6349
|
+
return exportShannonStageFlow(thought, options);
|
|
6350
|
+
}
|
|
6351
|
+
exportAbductiveHypotheses(thought, options) {
|
|
6352
|
+
return exportAbductiveHypotheses(thought, options);
|
|
6353
|
+
}
|
|
6354
|
+
exportCounterfactualScenarios(thought, options) {
|
|
6355
|
+
return exportCounterfactualScenarios(thought, options);
|
|
6356
|
+
}
|
|
6357
|
+
exportAnalogicalMapping(thought, options) {
|
|
6358
|
+
return exportAnalogicalMapping(thought, options);
|
|
6359
|
+
}
|
|
6360
|
+
exportEvidentialBeliefs(thought, options) {
|
|
6361
|
+
return exportEvidentialBeliefs(thought, options);
|
|
6362
|
+
}
|
|
6363
|
+
exportFirstPrinciplesDerivation(thought, options) {
|
|
6364
|
+
return exportFirstPrinciplesDerivation(thought, options);
|
|
6365
|
+
}
|
|
6366
|
+
exportSystemsThinkingCausalLoops(thought, options) {
|
|
6367
|
+
return exportSystemsThinkingCausalLoops(thought, options);
|
|
6368
|
+
}
|
|
6369
|
+
exportScientificMethodExperiment(thought, options) {
|
|
6370
|
+
return exportScientificMethodExperiment(thought, options);
|
|
6371
|
+
}
|
|
6372
|
+
exportOptimizationSolution(thought, options) {
|
|
6373
|
+
return exportOptimizationSolution(thought, options);
|
|
6374
|
+
}
|
|
6375
|
+
exportFormalLogicProof(thought, options) {
|
|
6376
|
+
return exportFormalLogicProof(thought, options);
|
|
6377
|
+
}
|
|
6378
|
+
// Sprint 2: New visual export wrapper methods
|
|
6379
|
+
exportMathematicsDerivation(thought, options) {
|
|
6380
|
+
return exportMathematicsDerivation(thought, options);
|
|
6381
|
+
}
|
|
6382
|
+
exportPhysicsVisualization(thought, options) {
|
|
6383
|
+
return exportPhysicsVisualization(thought, options);
|
|
6384
|
+
}
|
|
6385
|
+
exportHybridOrchestration(thought, options) {
|
|
6386
|
+
return exportHybridOrchestration(thought, options);
|
|
6387
|
+
}
|
|
6388
|
+
exportMetaReasoningVisualization(thought, options) {
|
|
6389
|
+
return exportMetaReasoningVisualization(thought, options);
|
|
6390
|
+
}
|
|
6391
|
+
};
|
|
6392
|
+
}
|
|
6393
|
+
});
|
|
6394
|
+
|
|
6395
|
+
// src/services/ExportService.ts
|
|
6396
|
+
var ExportService;
|
|
6397
|
+
var init_ExportService = __esm({
|
|
6398
|
+
"src/services/ExportService.ts"() {
|
|
6399
|
+
init_esm_shims();
|
|
6400
|
+
init_types();
|
|
6401
|
+
init_visual();
|
|
6402
|
+
init_sanitization();
|
|
6403
|
+
init_logger();
|
|
6404
|
+
ExportService = class {
|
|
6405
|
+
visualExporter;
|
|
6406
|
+
logger;
|
|
6407
|
+
constructor(logger2) {
|
|
6408
|
+
this.visualExporter = new VisualExporter();
|
|
6409
|
+
this.logger = logger2 || createLogger({ minLevel: 1 /* INFO */, enableConsole: true });
|
|
6410
|
+
}
|
|
6411
|
+
/**
|
|
6412
|
+
* Export a session to the specified format
|
|
6413
|
+
*
|
|
6414
|
+
* Main export method that routes to format-specific exporters.
|
|
6415
|
+
* Handles both standard formats (JSON, Markdown, etc.) and visual
|
|
6416
|
+
* formats (Mermaid, DOT, ASCII).
|
|
6417
|
+
*
|
|
6418
|
+
* @param session - The session to export
|
|
6419
|
+
* @param format - The desired export format
|
|
6420
|
+
* @returns Formatted string in the requested format
|
|
6421
|
+
* @throws {Error} If session has no thoughts for visual exports
|
|
6422
|
+
*
|
|
6423
|
+
* @example
|
|
6424
|
+
* ```typescript
|
|
6425
|
+
* const service = new ExportService();
|
|
6426
|
+
* const exported = service.exportSession(session, 'markdown');
|
|
6427
|
+
* ```
|
|
6428
|
+
*/
|
|
6429
|
+
exportSession(session, format) {
|
|
6430
|
+
const startTime = Date.now();
|
|
6431
|
+
this.logger.debug("Export started", { sessionId: session.id, format, thoughtCount: session.thoughts.length });
|
|
6432
|
+
if (format === "mermaid" || format === "dot" || format === "ascii") {
|
|
6433
|
+
const result2 = this.exportVisual(session, format);
|
|
6434
|
+
this.logger.debug("Export completed", {
|
|
6435
|
+
sessionId: session.id,
|
|
6436
|
+
format,
|
|
6437
|
+
duration: Date.now() - startTime,
|
|
6438
|
+
outputSize: result2.length
|
|
6439
|
+
});
|
|
6440
|
+
return result2;
|
|
6441
|
+
}
|
|
6442
|
+
let result;
|
|
6443
|
+
switch (format) {
|
|
6444
|
+
case "json":
|
|
6445
|
+
result = this.exportToJSON(session);
|
|
6446
|
+
break;
|
|
6447
|
+
case "markdown":
|
|
6448
|
+
result = this.exportToMarkdown(session);
|
|
6449
|
+
break;
|
|
6450
|
+
case "latex":
|
|
6451
|
+
result = this.exportToLatex(session);
|
|
6452
|
+
break;
|
|
6453
|
+
case "html":
|
|
6454
|
+
result = this.exportToHTML(session);
|
|
6455
|
+
break;
|
|
6456
|
+
case "jupyter":
|
|
6457
|
+
result = this.exportToJupyter(session);
|
|
6458
|
+
break;
|
|
6459
|
+
default:
|
|
6460
|
+
result = this.exportToJSON(session);
|
|
6461
|
+
}
|
|
6462
|
+
this.logger.debug("Export completed", {
|
|
6463
|
+
sessionId: session.id,
|
|
6464
|
+
format,
|
|
6465
|
+
duration: Date.now() - startTime,
|
|
6466
|
+
outputSize: result.length
|
|
6467
|
+
});
|
|
6468
|
+
return result;
|
|
6469
|
+
}
|
|
6470
|
+
/**
|
|
6471
|
+
* Export session to visual format (Mermaid, DOT, ASCII)
|
|
5348
6472
|
*
|
|
5349
6473
|
* Uses VisualExporter to generate visual representations
|
|
5350
6474
|
* based on the session's thinking mode and thought structure.
|
|
@@ -5395,6 +6519,118 @@ var init_ExportService = __esm({
|
|
|
5395
6519
|
colorScheme: "default"
|
|
5396
6520
|
});
|
|
5397
6521
|
}
|
|
6522
|
+
if (lastThought.mode === "sequential" /* SEQUENTIAL */ && "buildUpon" in lastThought) {
|
|
6523
|
+
return this.visualExporter.exportSequentialDependencyGraph(lastThought, {
|
|
6524
|
+
format,
|
|
6525
|
+
colorScheme: "default",
|
|
6526
|
+
includeLabels: true,
|
|
6527
|
+
includeMetrics: true
|
|
6528
|
+
});
|
|
6529
|
+
}
|
|
6530
|
+
if (lastThought.mode === "shannon" /* SHANNON */ && "stage" in lastThought) {
|
|
6531
|
+
return this.visualExporter.exportShannonStageFlow(lastThought, {
|
|
6532
|
+
format,
|
|
6533
|
+
colorScheme: "default",
|
|
6534
|
+
includeLabels: true,
|
|
6535
|
+
includeMetrics: true
|
|
6536
|
+
});
|
|
6537
|
+
}
|
|
6538
|
+
if (lastThought.mode === "abductive" /* ABDUCTIVE */ && "hypotheses" in lastThought) {
|
|
6539
|
+
return this.visualExporter.exportAbductiveHypotheses(lastThought, {
|
|
6540
|
+
format,
|
|
6541
|
+
colorScheme: "default",
|
|
6542
|
+
includeLabels: true,
|
|
6543
|
+
includeMetrics: true
|
|
6544
|
+
});
|
|
6545
|
+
}
|
|
6546
|
+
if (lastThought.mode === "counterfactual" /* COUNTERFACTUAL */ && "scenarios" in lastThought) {
|
|
6547
|
+
return this.visualExporter.exportCounterfactualScenarios(lastThought, {
|
|
6548
|
+
format,
|
|
6549
|
+
colorScheme: "default",
|
|
6550
|
+
includeLabels: true,
|
|
6551
|
+
includeMetrics: true
|
|
6552
|
+
});
|
|
6553
|
+
}
|
|
6554
|
+
if (lastThought.mode === "analogical" /* ANALOGICAL */ && "sourceAnalogy" in lastThought) {
|
|
6555
|
+
return this.visualExporter.exportAnalogicalMapping(lastThought, {
|
|
6556
|
+
format,
|
|
6557
|
+
colorScheme: "default",
|
|
6558
|
+
includeLabels: true,
|
|
6559
|
+
includeMetrics: true
|
|
6560
|
+
});
|
|
6561
|
+
}
|
|
6562
|
+
if (lastThought.mode === "evidential" /* EVIDENTIAL */ && "frameOfDiscernment" in lastThought) {
|
|
6563
|
+
return this.visualExporter.exportEvidentialBeliefs(lastThought, {
|
|
6564
|
+
format,
|
|
6565
|
+
colorScheme: "default",
|
|
6566
|
+
includeLabels: true,
|
|
6567
|
+
includeMetrics: true
|
|
6568
|
+
});
|
|
6569
|
+
}
|
|
6570
|
+
if (lastThought.mode === "systemsthinking" /* SYSTEMSTHINKING */ && "systemComponents" in lastThought) {
|
|
6571
|
+
return this.visualExporter.exportSystemsThinkingCausalLoops(lastThought, {
|
|
6572
|
+
format,
|
|
6573
|
+
colorScheme: "default",
|
|
6574
|
+
includeLabels: true,
|
|
6575
|
+
includeMetrics: true
|
|
6576
|
+
});
|
|
6577
|
+
}
|
|
6578
|
+
if (lastThought.mode === "scientificmethod" /* SCIENTIFICMETHOD */ && "hypothesis" in lastThought) {
|
|
6579
|
+
return this.visualExporter.exportScientificMethodExperiment(lastThought, {
|
|
6580
|
+
format,
|
|
6581
|
+
colorScheme: "default",
|
|
6582
|
+
includeLabels: true,
|
|
6583
|
+
includeMetrics: true
|
|
6584
|
+
});
|
|
6585
|
+
}
|
|
6586
|
+
if (lastThought.mode === "optimization" /* OPTIMIZATION */ && "objectiveFunction" in lastThought) {
|
|
6587
|
+
return this.visualExporter.exportOptimizationSolution(lastThought, {
|
|
6588
|
+
format,
|
|
6589
|
+
colorScheme: "default",
|
|
6590
|
+
includeLabels: true,
|
|
6591
|
+
includeMetrics: true
|
|
6592
|
+
});
|
|
6593
|
+
}
|
|
6594
|
+
if (lastThought.mode === "formallogic" /* FORMALLOGIC */ && "premises" in lastThought) {
|
|
6595
|
+
return this.visualExporter.exportFormalLogicProof(lastThought, {
|
|
6596
|
+
format,
|
|
6597
|
+
colorScheme: "default",
|
|
6598
|
+
includeLabels: true,
|
|
6599
|
+
includeMetrics: true
|
|
6600
|
+
});
|
|
6601
|
+
}
|
|
6602
|
+
if (lastThought.mode === "mathematics" /* MATHEMATICS */ && "proofStrategy" in lastThought) {
|
|
6603
|
+
return this.visualExporter.exportMathematicsDerivation(lastThought, {
|
|
6604
|
+
format,
|
|
6605
|
+
colorScheme: "default",
|
|
6606
|
+
includeLabels: true,
|
|
6607
|
+
includeMetrics: true
|
|
6608
|
+
});
|
|
6609
|
+
}
|
|
6610
|
+
if (lastThought.mode === "physics" /* PHYSICS */ && "tensorProperties" in lastThought) {
|
|
6611
|
+
return this.visualExporter.exportPhysicsVisualization(lastThought, {
|
|
6612
|
+
format,
|
|
6613
|
+
colorScheme: "default",
|
|
6614
|
+
includeLabels: true,
|
|
6615
|
+
includeMetrics: true
|
|
6616
|
+
});
|
|
6617
|
+
}
|
|
6618
|
+
if (lastThought.mode === "hybrid" /* HYBRID */ && "primaryMode" in lastThought) {
|
|
6619
|
+
return this.visualExporter.exportHybridOrchestration(lastThought, {
|
|
6620
|
+
format,
|
|
6621
|
+
colorScheme: "default",
|
|
6622
|
+
includeLabels: true,
|
|
6623
|
+
includeMetrics: true
|
|
6624
|
+
});
|
|
6625
|
+
}
|
|
6626
|
+
if (lastThought.mode === "metareasoning" /* METAREASONING */ && "currentStrategy" in lastThought) {
|
|
6627
|
+
return this.visualExporter.exportMetaReasoningVisualization(lastThought, {
|
|
6628
|
+
format,
|
|
6629
|
+
colorScheme: "default",
|
|
6630
|
+
includeLabels: true,
|
|
6631
|
+
includeMetrics: true
|
|
6632
|
+
});
|
|
6633
|
+
}
|
|
5398
6634
|
const thoughts = session.thoughts.map(
|
|
5399
6635
|
(t, i) => `Thought ${i + 1} (${t.mode}):
|
|
5400
6636
|
${t.content}
|