@vib3code/sdk 2.0.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/CHANGELOG.md +118 -0
- package/DOCS/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +34 -0
- package/DOCS/CI_TESTING.md +38 -0
- package/DOCS/CLI_ONBOARDING.md +75 -0
- package/DOCS/CONTROL_REFERENCE.md +64 -0
- package/DOCS/DEV_TRACK_ANALYSIS.md +77 -0
- package/DOCS/DEV_TRACK_PLAN_2026-01-07.md +42 -0
- package/DOCS/DEV_TRACK_SESSION_2026-01-31.md +220 -0
- package/DOCS/ENV_SETUP.md +189 -0
- package/DOCS/EXPORT_FORMATS.md +417 -0
- package/DOCS/GPU_DISPOSAL_GUIDE.md +21 -0
- package/DOCS/LICENSING_TIERS.md +275 -0
- package/DOCS/MASTER_PLAN_2026-01-31.md +570 -0
- package/DOCS/OBS_SETUP_GUIDE.md +98 -0
- package/DOCS/PROJECT_SETUP.md +66 -0
- package/DOCS/RENDERER_LIFECYCLE.md +40 -0
- package/DOCS/REPO_MANIFEST.md +121 -0
- package/DOCS/SESSION_014_PLAN.md +195 -0
- package/DOCS/SESSION_LOG_2026-01-07.md +56 -0
- package/DOCS/STRATEGIC_BLUEPRINT_2026-01-07.md +72 -0
- package/DOCS/SYSTEM_AUDIT_2026-01-30.md +738 -0
- package/DOCS/SYSTEM_INVENTORY.md +520 -0
- package/DOCS/TELEMETRY_EXPORTS.md +34 -0
- package/DOCS/WEBGPU_STATUS.md +38 -0
- package/DOCS/XR_BENCHMARKS.md +608 -0
- package/LICENSE +21 -0
- package/README.md +426 -0
- package/docs/.nojekyll +0 -0
- package/docs/01-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/02-hyperspatial_ego_death.html +346 -0
- package/docs/03-post_cartesian_sublime.html +346 -0
- package/docs/04-crystalline_void_meditation.html +346 -0
- package/docs/05-quantum_decoherence_ballet.html +346 -0
- package/docs/06-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/07-hyperspatial_ego_death.html +346 -0
- package/docs/08-post_cartesian_sublime.html +346 -0
- package/docs/09-crystalline_void_meditation.html +346 -0
- package/docs/10-quantum_decoherence_ballet.html +346 -0
- package/docs/11-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/12-hyperspatial_ego_death.html +346 -0
- package/docs/13-post_cartesian_sublime.html +346 -0
- package/docs/index.html +794 -0
- package/docs/test-hub.html +441 -0
- package/docs/url-state.js +102 -0
- package/docs/vib3-exports/01-quantum-quantum-tetrahedron-lattice.html +489 -0
- package/docs/vib3-exports/02-quantum-quantum-hypersphere-matrix.html +489 -0
- package/docs/vib3-exports/03-quantum-quantum-hypertetra-fractal.html +489 -0
- package/docs/vib3-exports/04-faceted-faceted-crystal-structure.html +407 -0
- package/docs/vib3-exports/05-faceted-faceted-klein-bottle.html +407 -0
- package/docs/vib3-exports/06-faceted-faceted-hypertetra-torus.html +407 -0
- package/docs/vib3-exports/07-holographic-holographic-wave-field.html +457 -0
- package/docs/vib3-exports/08-holographic-holographic-hypersphere-sphere.html +457 -0
- package/docs/vib3-exports/09-holographic-holographic-hypertetra-crystal.html +457 -0
- package/docs/vib3-exports/index.html +238 -0
- package/docs/webgpu-live.html +702 -0
- package/package.json +367 -0
- package/src/advanced/AIPresetGenerator.js +777 -0
- package/src/advanced/MIDIController.js +703 -0
- package/src/advanced/OffscreenWorker.js +1051 -0
- package/src/advanced/WebGPUCompute.js +1051 -0
- package/src/advanced/WebXRRenderer.js +680 -0
- package/src/agent/cli/AgentCLI.js +615 -0
- package/src/agent/cli/index.js +14 -0
- package/src/agent/index.js +73 -0
- package/src/agent/mcp/MCPServer.js +950 -0
- package/src/agent/mcp/index.js +9 -0
- package/src/agent/mcp/tools.js +548 -0
- package/src/agent/telemetry/EventStream.js +669 -0
- package/src/agent/telemetry/Instrumentation.js +618 -0
- package/src/agent/telemetry/TelemetryExporters.js +427 -0
- package/src/agent/telemetry/TelemetryService.js +464 -0
- package/src/agent/telemetry/index.js +52 -0
- package/src/benchmarks/BenchmarkRunner.js +381 -0
- package/src/benchmarks/MetricsCollector.js +299 -0
- package/src/benchmarks/index.js +9 -0
- package/src/benchmarks/scenes.js +259 -0
- package/src/cli/index.js +675 -0
- package/src/config/ApiConfig.js +88 -0
- package/src/core/CanvasManager.js +217 -0
- package/src/core/ErrorReporter.js +117 -0
- package/src/core/ParameterMapper.js +333 -0
- package/src/core/Parameters.js +396 -0
- package/src/core/RendererContracts.js +200 -0
- package/src/core/UnifiedResourceManager.js +370 -0
- package/src/core/VIB3Engine.js +636 -0
- package/src/core/renderers/FacetedRendererAdapter.js +32 -0
- package/src/core/renderers/HolographicRendererAdapter.js +29 -0
- package/src/core/renderers/QuantumRendererAdapter.js +29 -0
- package/src/core/renderers/RendererLifecycleManager.js +63 -0
- package/src/creative/ColorPresetsSystem.js +980 -0
- package/src/creative/ParameterTimeline.js +1061 -0
- package/src/creative/PostProcessingPipeline.js +1113 -0
- package/src/creative/TransitionAnimator.js +683 -0
- package/src/export/CSSExporter.js +226 -0
- package/src/export/CardGeneratorBase.js +279 -0
- package/src/export/ExportManager.js +580 -0
- package/src/export/FacetedCardGenerator.js +279 -0
- package/src/export/HolographicCardGenerator.js +543 -0
- package/src/export/LottieExporter.js +552 -0
- package/src/export/QuantumCardGenerator.js +315 -0
- package/src/export/SVGExporter.js +519 -0
- package/src/export/ShaderExporter.js +903 -0
- package/src/export/TradingCardGenerator.js +3055 -0
- package/src/export/TradingCardManager.js +181 -0
- package/src/export/VIB3PackageExporter.js +559 -0
- package/src/export/index.js +14 -0
- package/src/export/systems/TradingCardSystemFaceted.js +494 -0
- package/src/export/systems/TradingCardSystemHolographic.js +452 -0
- package/src/export/systems/TradingCardSystemQuantum.js +411 -0
- package/src/faceted/FacetedSystem.js +963 -0
- package/src/features/CollectionManager.js +433 -0
- package/src/gallery/CollectionManager.js +240 -0
- package/src/gallery/GallerySystem.js +485 -0
- package/src/geometry/GeometryFactory.js +314 -0
- package/src/geometry/GeometryLibrary.js +72 -0
- package/src/geometry/buffers/BufferBuilder.js +338 -0
- package/src/geometry/buffers/index.js +18 -0
- package/src/geometry/generators/Crystal.js +420 -0
- package/src/geometry/generators/Fractal.js +298 -0
- package/src/geometry/generators/KleinBottle.js +197 -0
- package/src/geometry/generators/Sphere.js +192 -0
- package/src/geometry/generators/Tesseract.js +160 -0
- package/src/geometry/generators/Tetrahedron.js +225 -0
- package/src/geometry/generators/Torus.js +304 -0
- package/src/geometry/generators/Wave.js +341 -0
- package/src/geometry/index.js +142 -0
- package/src/geometry/warp/HypersphereCore.js +211 -0
- package/src/geometry/warp/HypertetraCore.js +386 -0
- package/src/geometry/warp/index.js +57 -0
- package/src/holograms/HolographicVisualizer.js +1073 -0
- package/src/holograms/RealHolographicSystem.js +966 -0
- package/src/holograms/variantRegistry.js +69 -0
- package/src/integrations/FigmaPlugin.js +854 -0
- package/src/integrations/OBSMode.js +754 -0
- package/src/integrations/ThreeJsPackage.js +660 -0
- package/src/integrations/TouchDesignerExport.js +552 -0
- package/src/integrations/frameworks/Vib3React.js +591 -0
- package/src/integrations/frameworks/Vib3Svelte.js +654 -0
- package/src/integrations/frameworks/Vib3Vue.js +628 -0
- package/src/llm/LLMParameterInterface.js +240 -0
- package/src/llm/LLMParameterUI.js +577 -0
- package/src/math/Mat4x4.js +708 -0
- package/src/math/Projection.js +341 -0
- package/src/math/Rotor4D.js +637 -0
- package/src/math/Vec4.js +476 -0
- package/src/math/constants.js +164 -0
- package/src/math/index.js +68 -0
- package/src/math/projections.js +54 -0
- package/src/math/rotations.js +196 -0
- package/src/quantum/QuantumEngine.js +906 -0
- package/src/quantum/QuantumVisualizer.js +1103 -0
- package/src/reactivity/ReactivityConfig.js +499 -0
- package/src/reactivity/ReactivityManager.js +586 -0
- package/src/reactivity/SpatialInputSystem.js +1783 -0
- package/src/reactivity/index.js +93 -0
- package/src/render/CommandBuffer.js +465 -0
- package/src/render/MultiCanvasBridge.js +340 -0
- package/src/render/RenderCommand.js +514 -0
- package/src/render/RenderResourceRegistry.js +523 -0
- package/src/render/RenderState.js +552 -0
- package/src/render/RenderTarget.js +512 -0
- package/src/render/ShaderLoader.js +253 -0
- package/src/render/ShaderProgram.js +599 -0
- package/src/render/UnifiedRenderBridge.js +496 -0
- package/src/render/backends/WebGLBackend.js +1108 -0
- package/src/render/backends/WebGPUBackend.js +1409 -0
- package/src/render/commands/CommandBufferExecutor.js +607 -0
- package/src/render/commands/RenderCommandBuffer.js +661 -0
- package/src/render/commands/index.js +17 -0
- package/src/render/index.js +367 -0
- package/src/scene/Disposable.js +498 -0
- package/src/scene/MemoryPool.js +618 -0
- package/src/scene/Node4D.js +697 -0
- package/src/scene/ResourceManager.js +599 -0
- package/src/scene/Scene4D.js +540 -0
- package/src/scene/index.js +98 -0
- package/src/schemas/error.schema.json +84 -0
- package/src/schemas/extension.schema.json +88 -0
- package/src/schemas/index.js +214 -0
- package/src/schemas/parameters.schema.json +142 -0
- package/src/schemas/tool-pack.schema.json +44 -0
- package/src/schemas/tool-response.schema.json +127 -0
- package/src/shaders/common/fullscreen.vert.glsl +5 -0
- package/src/shaders/common/fullscreen.vert.wgsl +17 -0
- package/src/shaders/common/geometry24.glsl +65 -0
- package/src/shaders/common/geometry24.wgsl +54 -0
- package/src/shaders/common/rotation4d.glsl +85 -0
- package/src/shaders/common/rotation4d.wgsl +86 -0
- package/src/shaders/common/uniforms.glsl +44 -0
- package/src/shaders/common/uniforms.wgsl +48 -0
- package/src/shaders/faceted/faceted.frag.glsl +129 -0
- package/src/shaders/faceted/faceted.frag.wgsl +164 -0
- package/src/shaders/holographic/holographic.frag.glsl +406 -0
- package/src/shaders/holographic/holographic.frag.wgsl +185 -0
- package/src/shaders/quantum/quantum.frag.glsl +513 -0
- package/src/shaders/quantum/quantum.frag.wgsl +361 -0
- package/src/testing/ParallelTestFramework.js +519 -0
- package/src/testing/__snapshots__/exportFormats.test.js.snap +24 -0
- package/src/testing/exportFormats.test.js +8 -0
- package/src/testing/projections.test.js +14 -0
- package/src/testing/rotations.test.js +37 -0
- package/src/ui/InteractivityMenu.js +516 -0
- package/src/ui/StatusManager.js +96 -0
- package/src/ui/adaptive/renderers/webgpu/BufferLayout.ts +252 -0
- package/src/ui/adaptive/renderers/webgpu/PolytopeInstanceBuffer.ts +144 -0
- package/src/ui/adaptive/renderers/webgpu/TripleBufferedUniform.ts +170 -0
- package/src/ui/adaptive/renderers/webgpu/WebGPURenderer.ts +735 -0
- package/src/ui/adaptive/renderers/webgpu/index.ts +112 -0
- package/src/variations/VariationManager.js +431 -0
- package/src/viewer/AudioReactivity.js +505 -0
- package/src/viewer/CardBending.js +481 -0
- package/src/viewer/GalleryUI.js +832 -0
- package/src/viewer/ReactivityManager.js +590 -0
- package/src/viewer/TradingCardExporter.js +600 -0
- package/src/viewer/ViewerPortal.js +374 -0
- package/src/viewer/index.js +12 -0
- package/src/wasm/WasmLoader.js +296 -0
- package/src/wasm/index.js +132 -0
- package/tools/agentic/mcpTools.js +88 -0
- package/tools/cli/agent-cli.js +92 -0
- package/tools/export/formats.js +24 -0
- package/tools/math/rotation-baseline.mjs +64 -0
- package/tools/shader-sync-verify.js +937 -0
- package/tools/telemetry/manifestPipeline.js +141 -0
- package/tools/telemetry/telemetryEvents.js +35 -0
- package/types/adaptive-sdk.d.ts +185 -0
- package/types/advanced/AIPresetGenerator.d.ts +81 -0
- package/types/advanced/MIDIController.d.ts +100 -0
- package/types/advanced/OffscreenWorker.d.ts +82 -0
- package/types/advanced/WebGPUCompute.d.ts +52 -0
- package/types/advanced/WebXRRenderer.d.ts +77 -0
- package/types/advanced/index.d.ts +46 -0
- package/types/core/ErrorReporter.d.ts +50 -0
- package/types/core/VIB3Engine.d.ts +204 -0
- package/types/creative/ColorPresetsSystem.d.ts +91 -0
- package/types/creative/ParameterTimeline.d.ts +74 -0
- package/types/creative/PostProcessingPipeline.d.ts +109 -0
- package/types/creative/TransitionAnimator.d.ts +71 -0
- package/types/creative/index.d.ts +35 -0
- package/types/integrations/FigmaPlugin.d.ts +46 -0
- package/types/integrations/OBSMode.d.ts +74 -0
- package/types/integrations/ThreeJsPackage.d.ts +62 -0
- package/types/integrations/TouchDesignerExport.d.ts +36 -0
- package/types/integrations/Vib3React.d.ts +74 -0
- package/types/integrations/Vib3Svelte.d.ts +63 -0
- package/types/integrations/Vib3Vue.d.ts +55 -0
- package/types/integrations/index.d.ts +52 -0
- package/types/reactivity/SpatialInputSystem.d.ts +173 -0
- package/types/reactivity/index.d.ts +394 -0
- package/types/render/CommandBuffer.d.ts +169 -0
- package/types/render/RenderCommand.d.ts +312 -0
- package/types/render/RenderState.d.ts +279 -0
- package/types/render/RenderTarget.d.ts +254 -0
- package/types/render/ShaderProgram.d.ts +277 -0
- package/types/render/UnifiedRenderBridge.d.ts +143 -0
- package/types/render/WebGLBackend.d.ts +168 -0
- package/types/render/WebGPUBackend.d.ts +186 -0
- package/types/render/index.d.ts +141 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM Module - VIB3+ SDK
|
|
3
|
+
*
|
|
4
|
+
* WebAssembly integration with automatic JavaScript fallback.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* import { init, getModule } from '@vib3code/sdk/wasm';
|
|
8
|
+
*
|
|
9
|
+
* // Initialize (loads WASM if available)
|
|
10
|
+
* await init();
|
|
11
|
+
*
|
|
12
|
+
* // Get the module (WASM or JS fallback)
|
|
13
|
+
* const vib3 = getModule();
|
|
14
|
+
*
|
|
15
|
+
* // Use math classes
|
|
16
|
+
* const v = new vib3.Vec4(1, 2, 3, 4);
|
|
17
|
+
* const r = vib3.Rotor4D.fromEuler6(0.1, 0.2, 0.3, 0.4, 0.5, 0.6);
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
// Loader functions
|
|
22
|
+
configure,
|
|
23
|
+
loadWasmModule,
|
|
24
|
+
init,
|
|
25
|
+
getModule,
|
|
26
|
+
getStatus,
|
|
27
|
+
reset,
|
|
28
|
+
|
|
29
|
+
// Feature detection
|
|
30
|
+
isWasmSupported,
|
|
31
|
+
isSimdSupported,
|
|
32
|
+
isWasmLoaded,
|
|
33
|
+
isFallbackActive,
|
|
34
|
+
|
|
35
|
+
// Fallback classes (always available)
|
|
36
|
+
Vec4Fallback,
|
|
37
|
+
Rotor4DFallback,
|
|
38
|
+
Mat4x4Fallback
|
|
39
|
+
} from './WasmLoader.js';
|
|
40
|
+
|
|
41
|
+
import WasmLoader from './WasmLoader.js';
|
|
42
|
+
export default WasmLoader;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Unified math API that automatically uses WASM or fallback
|
|
46
|
+
*
|
|
47
|
+
* This provides a consistent interface regardless of WASM availability.
|
|
48
|
+
*/
|
|
49
|
+
export class UnifiedMath {
|
|
50
|
+
static #module = null;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Initialize the unified API
|
|
54
|
+
* @returns {Promise<void>}
|
|
55
|
+
*/
|
|
56
|
+
static async init() {
|
|
57
|
+
const { init, getModule } = await import('./WasmLoader.js');
|
|
58
|
+
await init();
|
|
59
|
+
UnifiedMath.#module = getModule();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get the underlying module
|
|
64
|
+
*/
|
|
65
|
+
static get module() {
|
|
66
|
+
return UnifiedMath.#module;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create Vec4
|
|
71
|
+
*/
|
|
72
|
+
static vec4(x = 0, y = 0, z = 0, w = 0) {
|
|
73
|
+
const m = UnifiedMath.#module;
|
|
74
|
+
return m ? new m.Vec4(x, y, z, w) : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Create Rotor4D from plane angle
|
|
79
|
+
*/
|
|
80
|
+
static rotorFromPlane(plane, angle) {
|
|
81
|
+
const m = UnifiedMath.#module;
|
|
82
|
+
return m ? m.Rotor4D.fromPlaneAngle(plane, angle) : null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Create Rotor4D from 6 angles
|
|
87
|
+
*/
|
|
88
|
+
static rotorFromEuler6(xy, xz, yz, xw, yw, zw) {
|
|
89
|
+
const m = UnifiedMath.#module;
|
|
90
|
+
return m ? m.Rotor4D.fromEuler6(xy, xz, yz, xw, yw, zw) : null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create rotation matrix from 6 angles
|
|
95
|
+
*/
|
|
96
|
+
static matrixFromAngles(xy, xz, yz, xw, yw, zw) {
|
|
97
|
+
const m = UnifiedMath.#module;
|
|
98
|
+
return m ? m.Mat4x4.rotationFromAngles(xy, xz, yz, xw, yw, zw) : null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Project 4D point to 3D (perspective)
|
|
103
|
+
*/
|
|
104
|
+
static project(v, distance = 2.0) {
|
|
105
|
+
const m = UnifiedMath.#module;
|
|
106
|
+
return m ? m.projectPerspective(v, distance) : null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Project batch of 4D points (returns Float32Array)
|
|
111
|
+
*/
|
|
112
|
+
static projectBatch(points, distance = 2.0) {
|
|
113
|
+
const m = UnifiedMath.#module;
|
|
114
|
+
return m ? m.projectToFloatArray(points, distance) : null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Check if WASM is being used
|
|
119
|
+
*/
|
|
120
|
+
static get isWasm() {
|
|
121
|
+
const m = UnifiedMath.#module;
|
|
122
|
+
return m ? (m.isWasm?.() ?? true) : false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Check if SIMD is enabled
|
|
127
|
+
*/
|
|
128
|
+
static get hasSimd() {
|
|
129
|
+
const m = UnifiedMath.#module;
|
|
130
|
+
return m ? (m.hasSimd?.() ?? false) : false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createRotationMatrix4D } from '../../src/math/rotations.js';
|
|
2
|
+
import { buildTelemetryError } from '../telemetry/telemetryEvents.js';
|
|
3
|
+
|
|
4
|
+
const VALID_PLANES = ['XY', 'XZ', 'YZ', 'XW', 'YW', 'ZW'];
|
|
5
|
+
|
|
6
|
+
export const MCP_TOOL_DEFINITIONS = [
|
|
7
|
+
{
|
|
8
|
+
name: 'create_scene',
|
|
9
|
+
description: 'Create a 4D visualization scene with geometry and projection.',
|
|
10
|
+
parameters: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
required: ['geometryType', 'projection'],
|
|
13
|
+
properties: {
|
|
14
|
+
geometryType: { type: 'string' },
|
|
15
|
+
projection: { type: 'string', enum: ['stereographic', 'perspective', 'orthographic'] },
|
|
16
|
+
metadata: { type: 'object' },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'apply_rotation',
|
|
22
|
+
description: 'Apply a 4D rotation to a scene using a plane + angle.',
|
|
23
|
+
parameters: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
required: ['sceneId', 'plane', 'angle'],
|
|
26
|
+
properties: {
|
|
27
|
+
sceneId: { type: 'string' },
|
|
28
|
+
plane: { type: 'string', enum: VALID_PLANES },
|
|
29
|
+
angle: { type: 'number' },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'render_preview',
|
|
35
|
+
description: 'Render a preview frame for a scene.',
|
|
36
|
+
parameters: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
required: ['sceneId'],
|
|
39
|
+
properties: {
|
|
40
|
+
sceneId: { type: 'string' },
|
|
41
|
+
width: { type: 'number' },
|
|
42
|
+
height: { type: 'number' },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
export function invokeTool(toolName, payload) {
|
|
49
|
+
switch (toolName) {
|
|
50
|
+
case 'create_scene':
|
|
51
|
+
return {
|
|
52
|
+
sceneId: payload.sceneId || `scene-${Date.now()}`,
|
|
53
|
+
geometryType: payload.geometryType,
|
|
54
|
+
projection: payload.projection,
|
|
55
|
+
metadata: payload.metadata || {},
|
|
56
|
+
suggestedNextActions: ['apply_rotation', 'render_preview'],
|
|
57
|
+
};
|
|
58
|
+
case 'apply_rotation':
|
|
59
|
+
if (!VALID_PLANES.includes(payload.plane)) {
|
|
60
|
+
return buildTelemetryError({
|
|
61
|
+
code: 'INVALID_ROTATION_PLANE',
|
|
62
|
+
message: `Rotation plane '${payload.plane}' is not valid`,
|
|
63
|
+
suggestion: 'Use one of the six rotation planes.',
|
|
64
|
+
validOptions: VALID_PLANES,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
sceneId: payload.sceneId,
|
|
69
|
+
plane: payload.plane,
|
|
70
|
+
angle: payload.angle,
|
|
71
|
+
rotationMatrix: createRotationMatrix4D(payload.plane, payload.angle),
|
|
72
|
+
};
|
|
73
|
+
case 'render_preview':
|
|
74
|
+
return {
|
|
75
|
+
sceneId: payload.sceneId,
|
|
76
|
+
width: payload.width || 320,
|
|
77
|
+
height: payload.height || 180,
|
|
78
|
+
previewHint: 'Use TelemetryDirector.generatePreviewSprites for real rendering.',
|
|
79
|
+
};
|
|
80
|
+
default:
|
|
81
|
+
return buildTelemetryError({
|
|
82
|
+
code: 'UNKNOWN_TOOL',
|
|
83
|
+
message: `Tool '${toolName}' is not registered.`,
|
|
84
|
+
suggestion: 'Use one of the MCP_TOOL_DEFINITIONS entries.',
|
|
85
|
+
validOptions: MCP_TOOL_DEFINITIONS.map((tool) => tool.name),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { TelemetryDirector } from '../../js/core/telemetry-director.js';
|
|
4
|
+
import { buildTelemetryError, createTelemetrySpan, endTelemetrySpan } from '../telemetry/telemetryEvents.js';
|
|
5
|
+
|
|
6
|
+
function parseArgs(argv) {
|
|
7
|
+
const args = argv.slice(2);
|
|
8
|
+
const result = { command: args[0], flags: {}, positional: [] };
|
|
9
|
+
|
|
10
|
+
for (let i = 1; i < args.length; i += 1) {
|
|
11
|
+
const arg = args[i];
|
|
12
|
+
if (arg.startsWith('--')) {
|
|
13
|
+
const [key, value] = arg.replace(/^--/, '').split('=');
|
|
14
|
+
result.flags[key] = value ?? true;
|
|
15
|
+
} else {
|
|
16
|
+
result.positional.push(arg);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function readJson(filePath) {
|
|
24
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
25
|
+
return JSON.parse(raw);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function runTelemetryExport({ packPath, previewCount }) {
|
|
29
|
+
const pack = readJson(packPath);
|
|
30
|
+
const director = new TelemetryDirector();
|
|
31
|
+
return director.exportPack(pack, { previewCount });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function main() {
|
|
35
|
+
const { command, flags, positional } = parseArgs(process.argv);
|
|
36
|
+
const jsonOutput = Boolean(flags.json);
|
|
37
|
+
const nonInteractive = Boolean(flags['non-interactive']);
|
|
38
|
+
|
|
39
|
+
if (!command || command === '--help' || flags.help) {
|
|
40
|
+
console.log('Usage: node tools/cli/agent-cli.js telemetry:export <pack.json> [--json] [--non-interactive] [--preview-count=4]');
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (nonInteractive && !jsonOutput) {
|
|
45
|
+
console.error('Non-interactive mode requires --json output.');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (command === 'telemetry:export') {
|
|
50
|
+
const packPath = positional[0];
|
|
51
|
+
if (!packPath) {
|
|
52
|
+
console.error('Missing pack path for telemetry:export.');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const span = createTelemetrySpan('telemetry.export', { packPath, previewCount: flags['preview-count'] });
|
|
57
|
+
try {
|
|
58
|
+
const result = await runTelemetryExport({
|
|
59
|
+
packPath,
|
|
60
|
+
previewCount: Number(flags['preview-count']) || 4,
|
|
61
|
+
});
|
|
62
|
+
const completedSpan = endTelemetrySpan(span, 'ok');
|
|
63
|
+
|
|
64
|
+
if (jsonOutput) {
|
|
65
|
+
console.log(JSON.stringify({ ...result, span: completedSpan }, null, 2));
|
|
66
|
+
} else {
|
|
67
|
+
console.log(result.summary);
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const completedSpan = endTelemetrySpan(span, 'error');
|
|
72
|
+
const errorPayload = buildTelemetryError({
|
|
73
|
+
code: 'INVALID_PACK_JSON',
|
|
74
|
+
message: error.message || 'Failed to parse pack JSON.',
|
|
75
|
+
suggestion: 'Ensure the pack file is valid JSON with scenes or states.',
|
|
76
|
+
meta: { packPath },
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (jsonOutput) {
|
|
80
|
+
console.log(JSON.stringify({ ...errorPayload, span: completedSpan }, null, 2));
|
|
81
|
+
} else {
|
|
82
|
+
console.error(errorPayload.error.message);
|
|
83
|
+
}
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.error(`Unknown command: ${command}`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const EXPORT_FORMATS = [
|
|
2
|
+
{
|
|
3
|
+
id: 'svg-sprite',
|
|
4
|
+
name: 'SVG Sprite Sheet',
|
|
5
|
+
extension: '.svg',
|
|
6
|
+
description: 'Vector sprite sheet for web and design tooling.',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: 'lottie-json',
|
|
10
|
+
name: 'Lottie JSON',
|
|
11
|
+
extension: '.json',
|
|
12
|
+
description: 'Motion-ready JSON payload for Lottie renderers.',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'css-variables',
|
|
16
|
+
name: 'CSS Variables',
|
|
17
|
+
extension: '.css',
|
|
18
|
+
description: 'CSS custom properties for theming pipelines.',
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export function getExportFormat(id) {
|
|
23
|
+
return EXPORT_FORMATS.find((format) => format.id === id) || null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { Projection } from '../../src/math/Projection.js';
|
|
5
|
+
import { Rotor4D } from '../../src/math/Rotor4D.js';
|
|
6
|
+
import { Vec4 } from '../../src/math/Vec4.js';
|
|
7
|
+
|
|
8
|
+
const iterations = 4000;
|
|
9
|
+
const renormInterval = 25;
|
|
10
|
+
const step = Rotor4D.fromEuler6({ xy: 0.003, xw: 0.002, zw: -0.001 });
|
|
11
|
+
|
|
12
|
+
let rotorNoRenorm = Rotor4D.identity();
|
|
13
|
+
let rotorRenorm = Rotor4D.identity();
|
|
14
|
+
|
|
15
|
+
for (let i = 1; i <= iterations; i += 1) {
|
|
16
|
+
rotorNoRenorm = rotorNoRenorm.multiply(step);
|
|
17
|
+
rotorRenorm = rotorRenorm.multiply(step);
|
|
18
|
+
if (i % renormInterval === 0) {
|
|
19
|
+
rotorRenorm.normalizeInPlace();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const driftNoRenorm = Math.abs(rotorNoRenorm.norm() - 1);
|
|
24
|
+
const driftRenorm = Math.abs(rotorRenorm.norm() - 1);
|
|
25
|
+
|
|
26
|
+
let vector = new Vec4(0.2, -0.7, 1.1, 0.4);
|
|
27
|
+
const baselineLength = vector.length();
|
|
28
|
+
const stepRotor = Rotor4D.fromPlaneAngle('XW', 0.01);
|
|
29
|
+
|
|
30
|
+
for (let i = 1; i <= 2000; i += 1) {
|
|
31
|
+
vector = stepRotor.rotate(vector);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const vectorLengthDrift = Math.abs(vector.length() - baselineLength);
|
|
35
|
+
|
|
36
|
+
const perspectiveSample = Projection.perspective(new Vec4(1, 1, 1, 2), 2, { epsilon: 1e-4 });
|
|
37
|
+
const stereographicSample = Projection.stereographic(new Vec4(1, 0, 0, 1), { epsilon: 1e-4 });
|
|
38
|
+
|
|
39
|
+
const output = {
|
|
40
|
+
generated_at: new Date().toISOString(),
|
|
41
|
+
rotor_precision: {
|
|
42
|
+
iterations,
|
|
43
|
+
renorm_interval: renormInterval,
|
|
44
|
+
drift_without_renorm: driftNoRenorm,
|
|
45
|
+
drift_with_renorm: driftRenorm,
|
|
46
|
+
vector_length_drift: vectorLengthDrift,
|
|
47
|
+
},
|
|
48
|
+
projection_clamp: {
|
|
49
|
+
epsilon: 1e-4,
|
|
50
|
+
perspective_sample: {
|
|
51
|
+
x: perspectiveSample.x,
|
|
52
|
+
y: perspectiveSample.y,
|
|
53
|
+
z: perspectiveSample.z,
|
|
54
|
+
},
|
|
55
|
+
stereographic_sample: {
|
|
56
|
+
x: stereographicSample.x,
|
|
57
|
+
y: stereographicSample.y,
|
|
58
|
+
z: stereographicSample.z,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const outputPath = resolve('docs/src/math/rotation-baseline.json');
|
|
64
|
+
await writeFile(outputPath, `${JSON.stringify(output, null, 2)}\n`, 'utf8');
|