@causyne/agent 1.20.122 → 1.20.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/causyne.js +38 -15
- package/docs/SECURITY_REVIEW.md +42 -6
- package/package.json +5 -5
- package/src/acp/agentCatalog.js +74 -50
- package/src/acp/agentCatalog.ts +82 -49
- package/src/acp/client.js +309 -86
- package/src/acp/client.ts +291 -84
- package/src/acp/protocol.js +147 -3
- package/src/acp/protocol.ts +162 -3
- package/src/acp/server.js +138 -39
- package/src/acp/server.ts +122 -41
- package/src/agent/errorClassifier.js +42 -6
- package/src/agent/errorClassifier.ts +44 -5
- package/src/agent/providerFailure.js +1 -1
- package/src/agent/providerFailure.ts +7 -1
- package/src/agent/toolArgValidator.js +38 -4
- package/src/agent/toolArgValidator.ts +39 -4
- package/src/agent/toolTurnIntegrity.js +28 -7
- package/src/agent/toolTurnIntegrity.ts +25 -6
- package/src/agent/workspaceBoundary.js +30 -4
- package/src/agent/workspaceBoundary.ts +32 -4
- package/src/agentLoop.js +598 -217
- package/src/agentLoop.ts +621 -215
- package/src/approvalPolicy.js +28 -1
- package/src/approvalPolicy.ts +28 -1
- package/src/auditLog.js +641 -48
- package/src/auditLog.ts +661 -0
- package/src/autoUpdate.js +32 -5
- package/src/autoUpdate.ts +27 -5
- package/src/backgroundTasks.js +328 -0
- package/src/backgroundTasks.ts +339 -0
- package/src/benchmarks/codingEval.js +558 -0
- package/src/benchmarks/codingEval.ts +628 -0
- package/src/benchmarks/planCache.js +115 -134
- package/src/benchmarks/planCache.ts +163 -0
- package/src/browser/browserRuntime.js +52 -0
- package/src/browser/browserRuntime.ts +55 -0
- package/src/browser/causyneBrowser.js +884 -10
- package/src/browser/causyneBrowser.ts +1042 -32
- package/src/browser/searchProviders.js +94 -6
- package/src/browser/searchProviders.ts +89 -6
- package/src/browser/urlPolicy.js +8 -1
- package/src/browser/urlPolicy.ts +7 -1
- package/src/browser/workspacePathSafety.js +6 -4
- package/src/browser/workspacePathSafety.ts +7 -4
- package/src/capabilities.js +18 -17
- package/src/capabilities.ts +38 -0
- package/src/checkpoints.js +1241 -1127
- package/src/checkpoints.ts +1377 -0
- package/src/cliMode.js +707 -755
- package/src/cliMode.ts +780 -0
- package/src/codebase/repoMap.js +656 -0
- package/src/codebase/repoMap.ts +664 -0
- package/src/commands.js +3651 -2514
- package/src/commands.ts +3985 -0
- package/src/compiledSkills.js +8052 -8054
- package/src/compiledSkills.ts +8078 -0
- package/src/config.js +103 -1
- package/src/config.ts +110 -1
- package/src/configVault.js +29 -2
- package/src/configVault.ts +26 -2
- package/src/contextManager.js +473 -557
- package/src/contextManager.ts +599 -0
- package/src/continuum/adapters/antigravity.js +8 -3
- package/src/continuum/adapters/antigravity.ts +8 -3
- package/src/continuum/sanitizer.js +23 -1
- package/src/continuum/sanitizer.ts +23 -1
- package/src/continuum/ui/continuumPicker.js +0 -2
- package/src/continuum/ui/continuumPicker.ts +0 -2
- package/src/continuum/ui/continuumPickerView.js +0 -2
- package/src/continuum/ui/continuumPickerView.ts +4 -20
- package/src/core/contextCompactor.js +88 -7
- package/src/core/contextCompactor.ts +87 -8
- package/src/creative/liveBridge.js +3 -2
- package/src/creative/liveBridge.ts +4 -2
- package/src/creative/studioScripts.js +1 -1
- package/src/creative/studioScripts.ts +1 -1
- package/src/decideTools.js +7 -2
- package/src/decideTools.ts +7 -2
- package/src/decisionPolicy.js +10 -2
- package/src/decisionPolicy.ts +10 -2
- package/src/designPalettes.js +72 -84
- package/src/designPalettes.ts +111 -0
- package/src/devMode.js +2 -2
- package/src/devMode.ts +6 -0
- package/src/diffReview.js +370 -0
- package/src/diffReview.ts +407 -0
- package/src/dynamicCatalogue.js +311 -11
- package/src/dynamicCatalogue.ts +331 -11
- package/src/embodimentSession.js +143 -154
- package/src/embodimentSession.ts +173 -0
- package/src/engines/installer.js +60 -29
- package/src/engines/installer.ts +73 -22
- package/src/enterprisePolicy.js +660 -0
- package/src/enterprisePolicy.ts +728 -0
- package/src/entrypoint.js +514 -268
- package/src/entrypoint.ts +607 -0
- package/src/gitSnapshot.js +417 -312
- package/src/gitSnapshot.ts +500 -0
- package/src/headlessCli.js +324 -13
- package/src/headlessCli.ts +321 -12
- package/src/hooks.js +247 -26
- package/src/hooks.ts +236 -26
- package/src/ignoreRules.js +297 -0
- package/src/ignoreRules.ts +308 -0
- package/src/implementationPlan.js +7 -6
- package/src/implementationPlan.ts +8 -6
- package/src/infra/atomicWriter.js +92 -19
- package/src/infra/atomicWriter.ts +108 -19
- package/src/launchIntent.js +13 -2
- package/src/launchIntent.ts +13 -2
- package/src/licensing/entitlements.js +553 -237
- package/src/licensing/entitlements.ts +590 -0
- package/src/licensing/policy.js +17 -1
- package/src/licensing/policy.ts +31 -0
- package/src/lsp/lspCatalog.js +398 -0
- package/src/lsp/lspCatalog.ts +452 -0
- package/src/lsp/lspClient.js +699 -0
- package/src/lsp/lspClient.ts +799 -0
- package/src/lsp/lspProtocol.js +121 -0
- package/src/lsp/lspProtocol.ts +140 -0
- package/src/mcp/mcpClient.js +69 -8
- package/src/mcp/mcpClient.ts +66 -9
- package/src/mcp/mcpRegistry.js +180 -7
- package/src/mcp/mcpRegistry.ts +171 -7
- package/src/mcp/mcpSecurity.js +6 -7
- package/src/mcp/mcpSecurity.ts +7 -6
- package/src/memory/episodicStore.js +2 -5
- package/src/memory/episodicStore.ts +2 -5
- package/src/memory.js +80 -32
- package/src/memory.ts +111 -0
- package/src/memoryManager.js +151 -143
- package/src/memoryManager.ts +182 -0
- package/src/modelCatalogue.js +172 -195
- package/src/modelCatalogue.ts +201 -0
- package/src/modelIds.js +8 -27
- package/src/modelIds.ts +33 -0
- package/src/modelVariants.js +600 -0
- package/src/modelVariants.ts +663 -0
- package/src/observer/evidence.js +5 -1
- package/src/observer/evidence.ts +5 -1
- package/src/osKeychain.js +17 -9
- package/src/osKeychain.ts +14 -9
- package/src/outputStore.js +210 -156
- package/src/outputStore.ts +321 -0
- package/src/planCache.js +3 -6
- package/src/planCache.ts +3 -6
- package/src/plugins/pluginManager.js +689 -461
- package/src/plugins/pluginManager.ts +807 -0
- package/src/plugins/pluginRunner.js +82 -37
- package/src/plugins/pluginRunner.ts +98 -0
- package/src/plugins/pluginSkills.js +47 -9
- package/src/plugins/pluginSkills.ts +46 -8
- package/src/pluginsFactory/discovery.js +0 -1
- package/src/pluginsFactory/discovery.ts +0 -1
- package/src/pluginsFactory/templates.js +17 -4
- package/src/pluginsFactory/templates.ts +17 -4
- package/src/prWorkflow.js +337 -0
- package/src/prWorkflow.ts +376 -0
- package/src/procSignal.js +1 -2
- package/src/procSignal.ts +1 -3
- package/src/projectInstructions.js +319 -0
- package/src/projectInstructions.ts +361 -0
- package/src/providers/acp.js +234 -49
- package/src/providers/acp.ts +240 -50
- package/src/providers/anthropic.js +152 -47
- package/src/providers/anthropic.ts +152 -45
- package/src/providers/antigravity.js +565 -354
- package/src/providers/antigravity.ts +555 -355
- package/src/providers/base.js +9 -2
- package/src/providers/base.ts +10 -2
- package/src/providers/byokHttp.js +127 -17
- package/src/providers/byokHttp.ts +175 -18
- package/src/providers/byokStream.js +162 -36
- package/src/providers/byokStream.ts +162 -55
- package/src/providers/dashscope-byok.js +29 -3
- package/src/providers/dashscope-byok.ts +30 -2
- package/src/providers/deepseek.js +12 -3
- package/src/providers/deepseek.ts +12 -3
- package/src/providers/factory.js +41 -0
- package/src/providers/factory.ts +42 -0
- package/src/providers/gemini.js +74 -22
- package/src/providers/gemini.ts +78 -26
- package/src/providers/moonshot.js +36 -3
- package/src/providers/moonshot.ts +32 -3
- package/src/providers/ollama.js +267 -21
- package/src/providers/ollama.ts +302 -29
- package/src/providers/openai-compatible.js +67 -11
- package/src/providers/openai-compatible.ts +78 -17
- package/src/providers/openai.js +25 -2
- package/src/providers/openai.ts +24 -2
- package/src/providers/openrouter.js +233 -66
- package/src/providers/openrouter.ts +226 -70
- package/src/providers/qwen-byok.js +29 -3
- package/src/providers/qwen-byok.ts +30 -2
- package/src/providers/wireNormalizer.js +66 -0
- package/src/providers/wireNormalizer.ts +64 -0
- package/src/providers/xai.js +10 -3
- package/src/providers/xai.ts +9 -3
- package/src/provisioning/capabilityConsent.js +29 -11
- package/src/provisioning/capabilityConsent.ts +42 -0
- package/src/provisioning/capabilityProvisioner.js +309 -197
- package/src/provisioning/capabilityProvisioner.ts +413 -0
- package/src/provisioning/capabilityTools.js +31 -17
- package/src/provisioning/capabilityTools.ts +43 -0
- package/src/provisioning/npmInstall.js +33 -5
- package/src/provisioning/npmInstall.ts +33 -5
- package/src/reporting.js +328 -326
- package/src/reporting.ts +482 -0
- package/src/sandbox.js +37 -0
- package/src/sandbox.ts +38 -0
- package/src/sessionJournal.js +24 -3
- package/src/sessionJournal.ts +18 -3
- package/src/sessionStore.js +1 -2
- package/src/sessionStore.ts +2 -0
- package/src/slopDetector.js +202 -265
- package/src/slopDetector.ts +279 -0
- package/src/smartToolsUse.js +10 -4
- package/src/smartToolsUse.ts +10 -4
- package/src/stallGuard.js +10 -3
- package/src/stallGuard.ts +9 -3
- package/src/taskBuffer.js +91 -40
- package/src/taskBuffer.ts +94 -0
- package/src/tokenTracker.js +78 -11
- package/src/tokenTracker.ts +69 -11
- package/src/toolPacks.js +5 -0
- package/src/toolPacks.ts +5 -0
- package/src/tools/applyPatch.js +610 -0
- package/src/tools/applyPatch.ts +661 -0
- package/src/tools/archive.js +135 -21
- package/src/tools/archive.ts +136 -21
- package/src/tools/astryxOracle.js +77 -72
- package/src/tools/astryxOracle.ts +95 -0
- package/src/tools/axSnapshot.js +127 -147
- package/src/tools/axSnapshot.ts +174 -0
- package/src/tools/backgroundTask.js +86 -0
- package/src/tools/backgroundTask.ts +121 -0
- package/src/tools/blenderAutomator.js +434 -390
- package/src/tools/blenderAutomator.ts +623 -0
- package/src/tools/checkSystemSpecs.js +54 -61
- package/src/tools/checkSystemSpecs.ts +73 -0
- package/src/tools/clipboard.js +42 -31
- package/src/tools/clipboard.ts +61 -0
- package/src/tools/codeSearchAst.js +359 -91
- package/src/tools/codeSearchAst.ts +399 -0
- package/src/tools/codeSearcher.js +179 -37
- package/src/tools/codeSearcher.ts +188 -33
- package/src/tools/codeTools.js +208 -245
- package/src/tools/codeTools.ts +271 -0
- package/src/tools/codebaseSearch.js +5 -0
- package/src/tools/codebaseSearch.ts +5 -0
- package/src/tools/desktopAct.js +185 -197
- package/src/tools/desktopAct.ts +257 -0
- package/src/tools/dynamicLoader.js +4 -40
- package/src/tools/dynamicLoader.ts +13 -0
- package/src/tools/executeProceduralMedia.js +117 -86
- package/src/tools/executeProceduralMedia.ts +135 -0
- package/src/tools/fileTracker.js +74 -0
- package/src/tools/fileTracker.ts +94 -0
- package/src/tools/fsDelete.js +57 -47
- package/src/tools/fsDelete.ts +80 -0
- package/src/tools/fsEdit.js +192 -74
- package/src/tools/fsEdit.ts +201 -72
- package/src/tools/fsMove.js +79 -52
- package/src/tools/fsMove.ts +108 -0
- package/src/tools/fsRead.js +54 -15
- package/src/tools/fsRead.ts +55 -15
- package/src/tools/fsSearch.js +5 -0
- package/src/tools/fsSearch.ts +5 -0
- package/src/tools/fsWrite.js +14 -6
- package/src/tools/fsWrite.ts +14 -6
- package/src/tools/gameAiBehaviorTree.js +74 -91
- package/src/tools/gameAiBehaviorTree.ts +219 -0
- package/src/tools/gameAnimationRig.js +128 -147
- package/src/tools/gameAnimationRig.ts +215 -0
- package/src/tools/gameAssetFetcher.js +403 -441
- package/src/tools/gameAssetFetcher.ts +477 -0
- package/src/tools/gameAssetHarvester.js +171 -200
- package/src/tools/gameAssetHarvester.ts +261 -0
- package/src/tools/gameAudioSynth.js +223 -259
- package/src/tools/gameAudioSynth.ts +255 -0
- package/src/tools/gameBuilder.js +100 -91
- package/src/tools/gameBuilder.ts +913 -0
- package/src/tools/gameCanvasAudit.js +138 -96
- package/src/tools/gameCanvasAudit.ts +157 -0
- package/src/tools/gameCinematicSequencer.js +93 -111
- package/src/tools/gameCinematicSequencer.ts +165 -0
- package/src/tools/gameDataForge.js +115 -118
- package/src/tools/gameDataForge.ts +151 -0
- package/src/tools/gameDialogueTreeGen.js +125 -156
- package/src/tools/gameDialogueTreeGen.ts +159 -0
- package/src/tools/gameEconomyBalancer.js +150 -153
- package/src/tools/gameEconomyBalancer.ts +186 -0
- package/src/tools/gameEntitySpawner.js +91 -108
- package/src/tools/gameEntitySpawner.ts +209 -0
- package/src/tools/gameLoreForge.js +125 -147
- package/src/tools/gameLoreForge.ts +162 -0
- package/src/tools/gameQuestArcBuilder.js +105 -144
- package/src/tools/gameQuestArcBuilder.ts +147 -0
- package/src/tools/gameSceneBuilder.js +143 -149
- package/src/tools/gameSceneBuilder.ts +196 -0
- package/src/tools/gameShaderForge.js +83 -101
- package/src/tools/gameShaderForge.ts +181 -0
- package/src/tools/gameTilemapGenerator.js +99 -129
- package/src/tools/gameTilemapGenerator.ts +158 -0
- package/src/tools/gameUiHudBuilder.js +109 -129
- package/src/tools/gameUiHudBuilder.ts +300 -0
- package/src/tools/gameVfxEmitterGen.js +86 -89
- package/src/tools/gameVfxEmitterGen.ts +133 -0
- package/src/tools/gameWebRuntimeInspector.js +153 -86
- package/src/tools/gameWebRuntimeInspector.ts +167 -0
- package/src/tools/generateMediaViaApi.js +53 -12
- package/src/tools/generateMediaViaApi.ts +52 -12
- package/src/tools/gitExec.js +133 -86
- package/src/tools/gitExec.ts +146 -0
- package/src/tools/gitWorktree.js +115 -0
- package/src/tools/gitWorktree.ts +150 -0
- package/src/tools/godotAutomator.js +417 -394
- package/src/tools/godotAutomator.ts +530 -0
- package/src/tools/lspCodeIntel.js +217 -0
- package/src/tools/lspCodeIntel.ts +260 -0
- package/src/tools/manageLocalAiDependencies.js +242 -206
- package/src/tools/manageLocalAiDependencies.ts +288 -0
- package/src/tools/multiEdit.js +16 -76
- package/src/tools/multiEdit.ts +20 -77
- package/src/tools/osSandbox.js +152 -15
- package/src/tools/osSandbox.ts +148 -15
- package/src/tools/palmierAutomator.js +147 -95
- package/src/tools/palmierAutomator.ts +171 -0
- package/src/tools/pdfReader.js +95 -104
- package/src/tools/pdfReader.ts +125 -0
- package/src/tools/persistentShell.js +267 -144
- package/src/tools/persistentShell.ts +314 -0
- package/src/tools/pluginManager.js +84 -72
- package/src/tools/pluginManager.ts +109 -0
- package/src/tools/printer.js +278 -296
- package/src/tools/printer.ts +326 -0
- package/src/tools/procTerm.js +96 -83
- package/src/tools/procTerm.ts +127 -0
- package/src/tools/processList.js +45 -48
- package/src/tools/processList.ts +73 -0
- package/src/tools/registry.js +298 -286
- package/src/tools/registry.ts +486 -0
- package/src/tools/repoMap.js +46 -0
- package/src/tools/repoMap.ts +66 -0
- package/src/tools/subagentOrchestrator.js +404 -348
- package/src/tools/subagentOrchestrator.ts +457 -0
- package/src/tools/sysRun.js +83 -26
- package/src/tools/sysRun.ts +80 -26
- package/src/tools/toolForge.js +84 -67
- package/src/tools/toolForge.ts +102 -0
- package/src/tools/toolPathSafety.js +262 -0
- package/src/tools/toolPathSafety.ts +308 -0
- package/src/tools/toolScanner.js +28 -0
- package/src/tools/toolScanner.ts +29 -0
- package/src/tools/toolSelfRepair.js +21 -6
- package/src/tools/toolSelfRepair.ts +26 -6
- package/src/tools/walkerSafety.ts +1 -0
- package/src/tools/webFetch.js +5 -2
- package/src/tools/webFetch.ts +5 -2
- package/src/toolsList.js +5 -0
- package/src/toolsList.ts +5 -0
- package/src/tui/ask.js +159 -168
- package/src/tui/ask.ts +259 -0
- package/src/tui/block.js +0 -1
- package/src/tui/block.ts +0 -1
- package/src/tui/chatRenderer.js +1193 -1441
- package/src/tui/chatRenderer.ts +1336 -0
- package/src/tui/clipboardImage.js +36 -12
- package/src/tui/clipboardImage.ts +39 -13
- package/src/tui/clipboardSync.js +34 -9
- package/src/tui/clipboardSync.ts +38 -9
- package/src/tui/codeProgress.js +0 -1
- package/src/tui/codeProgress.ts +0 -1
- package/src/tui/completion.js +395 -371
- package/src/tui/completion.ts +574 -0
- package/src/tui/composerControls.js +113 -19
- package/src/tui/composerControls.ts +124 -19
- package/src/tui/consoleGuard.js +27 -7
- package/src/tui/consoleGuard.ts +29 -7
- package/src/tui/dialogs.js +864 -717
- package/src/tui/dialogs.ts +984 -0
- package/src/tui/diff.js +205 -195
- package/src/tui/diff.ts +336 -0
- package/src/tui/history.js +143 -108
- package/src/tui/history.ts +167 -0
- package/src/tui/home.js +165 -161
- package/src/tui/home.ts +251 -0
- package/src/tui/invocation.js +58 -65
- package/src/tui/invocation.ts +117 -0
- package/src/tui/keys.js +437 -420
- package/src/tui/keys.ts +597 -0
- package/src/tui/lineEditor.js +477 -432
- package/src/tui/lineEditor.ts +542 -0
- package/src/tui/messageActionPlacement.js +0 -1
- package/src/tui/messageActionPlacement.ts +0 -1
- package/src/tui/messageInteraction.js +0 -2
- package/src/tui/messageInteraction.ts +0 -2
- package/src/tui/modelPicker.js +0 -3
- package/src/tui/modelPicker.ts +3 -6
- package/src/tui/observerPicker.js +0 -2
- package/src/tui/observerPicker.ts +0 -2
- package/src/tui/overlay.js +0 -1
- package/src/tui/overlay.ts +0 -1
- package/src/tui/prompt.js +1816 -2151
- package/src/tui/prompt.ts +1870 -0
- package/src/tui/runningLight.js +0 -1
- package/src/tui/runningLight.ts +0 -1
- package/src/tui/selectList.js +365 -337
- package/src/tui/selectList.ts +441 -0
- package/src/tui/sessionPicker.js +0 -1
- package/src/tui/sessionPicker.ts +0 -1
- package/src/tui/sessionPickerView.js +0 -2
- package/src/tui/sessionPickerView.ts +4 -21
- package/src/tui/sessionSidebar.js +3 -1
- package/src/tui/sessionSidebar.ts +4 -1
- package/src/tui/setup.js +17 -5
- package/src/tui/setup.ts +19 -5
- package/src/tui/skillAuthoring.js +0 -2
- package/src/tui/skillAuthoring.ts +0 -3
- package/src/tui/stageSurface.js +829 -909
- package/src/tui/stageSurface.ts +1003 -0
- package/src/tui/statusLine.js +7 -4
- package/src/tui/statusLine.ts +7 -3
- package/src/tui/terminalInputFramer.js +82 -69
- package/src/tui/terminalInputFramer.ts +116 -0
- package/src/tui/text.js +25 -10
- package/src/tui/text.ts +24 -10
- package/src/tui/textLayout.js +0 -1
- package/src/tui/textLayout.ts +0 -1
- package/src/tui/theme.js +245 -250
- package/src/tui/theme.ts +441 -0
- package/src/tui/thinkingBox.js +0 -1
- package/src/tui/thinkingBox.ts +0 -1
- package/src/tui/transcript.js +239 -216
- package/src/tui/transcript.ts +324 -0
- package/src/tui/turnRail.js +53 -54
- package/src/tui/turnRail.ts +51 -49
- package/src/tui/usageCard.js +0 -2
- package/src/tui/usageCard.ts +0 -2
- package/src/tui/workspaceSwitch.js +4 -2
- package/src/tui/workspaceSwitch.ts +5 -2
- package/src/types/contracts.ts +4 -1
- package/src/utils/browserOpen.js +107 -0
- package/src/utils/browserOpen.ts +129 -0
- package/src/utils/cli_ui.js +0 -0
- package/src/utils/cli_ui.ts +158 -0
- package/src/utils/winSpawn.js +248 -0
- package/src/utils/winSpawn.ts +275 -0
- package/src/verification/boundedExplorer.js +138 -107
- package/src/verification/boundedExplorer.ts +154 -0
- package/src/verification/byokSmokeProbe.js +193 -0
- package/src/verification/byokSmokeProbe.ts +234 -0
- package/src/verification/cliProbe.js +144 -110
- package/src/verification/cliProbe.ts +170 -0
- package/src/verification/featureMap.js +105 -75
- package/src/verification/featureMap.ts +124 -0
- package/src/verification/interactivePty.js +195 -100
- package/src/verification/interactivePty.ts +333 -0
- package/src/verification/propertyProbe.js +109 -101
- package/src/verification/propertyProbe.ts +159 -0
- package/src/verification/ptyProbe.js +168 -73
- package/src/verification/ptyProbe.ts +254 -0
- package/src/verification/skillCatalog.js +25 -25
- package/src/verification/skillCatalog.ts +66 -0
- package/src/verification/statechart.js +140 -127
- package/src/verification/statechart.ts +196 -0
- package/src/verification/uiRuntime.js +80 -49
- package/src/verification/uiRuntime.ts +88 -0
- package/src/version.js +37 -32
- package/src/version.ts +45 -0
- package/src/web/guiLauncher.js +89 -0
- package/src/web/guiLauncher.ts +119 -0
- package/src/web/skybridgeBrowserBridge.js +256 -0
- package/src/web/skybridgeBrowserBridge.ts +285 -0
- package/src/web/skybridgeBrowserMcp.js +730 -0
- package/src/web/skybridgeBrowserMcp.ts +813 -0
- package/src/web/skybridgeClientScript.js +3951 -0
- package/src/web/skybridgeClientScript.ts +3952 -0
- package/src/web/skybridgeServer.js +2622 -0
- package/src/web/skybridgeServer.ts +2787 -0
- package/src/web/skybridgeStyles.js +827 -0
- package/src/web/skybridgeStyles.ts +828 -0
- package/src/web/skybridgeUi.js +472 -0
- package/src/web/skybridgeUi.ts +485 -0
- package/src/worktreeManager.js +511 -0
- package/src/worktreeManager.ts +546 -0
- package/src/zeroCostFailover.js +168 -0
- package/src/zeroCostFailover.ts +198 -0
- package/src/zeroCostRouting.js +391 -0
- package/src/zeroCostRouting.ts +437 -0
- package/src/agentLoop.d.ts +0 -65
- package/src/auditLog.d.ts +0 -3
- package/src/checkpoints.d.ts +0 -4
- package/src/compiledSkills.d.ts +0 -5
- package/src/contextManager.d.ts +0 -14
- package/src/designPalettes.d.ts +0 -2
- package/src/devMode.d.ts +0 -1
- package/src/embodimentSession.d.ts +0 -2
- package/src/licensing/entitlements.d.ts +0 -14
- package/src/memory.d.ts +0 -13
- package/src/memoryManager.d.ts +0 -1
- package/src/modelCatalogue.d.ts +0 -6
- package/src/modelIds.d.ts +0 -2
- package/src/outputStore.d.ts +0 -4
- package/src/plugins/pluginManager.d.ts +0 -7
- package/src/providers/antigravity.d.ts +0 -19
- package/src/provisioning/capabilityProvisioner.d.ts +0 -12
- package/src/slopDetector.d.ts +0 -3
- package/src/taskBuffer.d.ts +0 -1
- package/src/tools/desktopAct.d.ts +0 -10
- package/src/tools/registry.d.ts +0 -5
- package/src/tui/chatRenderer.d.ts +0 -27
- package/src/tui/diff.d.ts +0 -3
- package/src/utils/cli_ui.d.ts +0 -19
- package/src/utils/paths.d.ts +0 -3
- package/src/verification/skillCatalog.d.ts +0 -1
- package/src/version.d.ts +0 -1
|
@@ -0,0 +1,913 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import fsSync from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {
|
|
5
|
+
assertSafeWorkspaceOutput,
|
|
6
|
+
atomicWriteFileSafe,
|
|
7
|
+
escapeHtmlText,
|
|
8
|
+
escapeJsString,
|
|
9
|
+
getErrorMessage,
|
|
10
|
+
resolveScopedPath,
|
|
11
|
+
resolveToolWorkspaceRoots,
|
|
12
|
+
safeFilenameStrict,
|
|
13
|
+
sanitizeToolError,
|
|
14
|
+
type ToolWorkspaceContext
|
|
15
|
+
} from './toolPathSafety.js';
|
|
16
|
+
|
|
17
|
+
const MAX_CUSTOM_HTML_CHARS = 2 * 1024 * 1024;
|
|
18
|
+
|
|
19
|
+
function getWorkspaceTempDir(sandbox?: ToolWorkspaceContext): string {
|
|
20
|
+
const baseDir = resolveToolWorkspaceRoots(sandbox).primaryRoot || process.cwd();
|
|
21
|
+
const tmpDir = path.join(baseDir, '.tmp_causyne_3d');
|
|
22
|
+
if (!fsSync.existsSync(tmpDir)) {
|
|
23
|
+
fsSync.mkdirSync(tmpDir, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
return tmpDir;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// -----------------------------------------------------------------------------
|
|
29
|
+
// Benchmark Template 1: 3D Space Defense (Three.js WebGL + Web Audio + Joysticks)
|
|
30
|
+
// -----------------------------------------------------------------------------
|
|
31
|
+
function getSpaceDefense3dTemplate(title: string, _includeAudio = true): string {
|
|
32
|
+
return `<!DOCTYPE html>
|
|
33
|
+
<html lang="en">
|
|
34
|
+
<head>
|
|
35
|
+
<meta charset="UTF-8">
|
|
36
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
37
|
+
<title>${escapeHtmlText(title, 120)} — Causyne Sovereign Edge Game</title>
|
|
38
|
+
<style>
|
|
39
|
+
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
|
|
40
|
+
body { background: #000; overflow: hidden; font-family: 'Outfit', sans-serif; }
|
|
41
|
+
#canvas-container { width: 100vw; height: 100vh; display: block; }
|
|
42
|
+
#hud {
|
|
43
|
+
position: absolute; top: 20px; left: 20px; right: 20px;
|
|
44
|
+
display: flex; justify-content: space-between; align-items: center; pointer-events: none;
|
|
45
|
+
color: #fff; text-shadow: 0 0 10px rgba(0, 255, 204, 0.8);
|
|
46
|
+
}
|
|
47
|
+
.hud-box {
|
|
48
|
+
background: rgba(10, 15, 25, 0.6); border: 1px solid rgba(0, 255, 204, 0.4);
|
|
49
|
+
padding: 10px 20px; border-radius: 8px; backdrop-filter: blur(10px); pointer-events: auto;
|
|
50
|
+
}
|
|
51
|
+
.hud-score { font-size: 24px; font-weight: 800; color: #00ffcc; }
|
|
52
|
+
.hud-health { font-size: 18px; color: #ff3366; }
|
|
53
|
+
#mute-btn {
|
|
54
|
+
background: rgba(10, 15, 25, 0.8); border: 1px solid #00ffcc; color: #fff;
|
|
55
|
+
padding: 8px 14px; border-radius: 20px; font-size: 18px; cursor: pointer; pointer-events: auto;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Mobile Controls Overlay */
|
|
59
|
+
#mobile-controls {
|
|
60
|
+
position: absolute; bottom: 30px; left: 30px; right: 30px;
|
|
61
|
+
display: flex; justify-content: space-between; align-items: flex-end;
|
|
62
|
+
pointer-events: none;
|
|
63
|
+
}
|
|
64
|
+
.touch-pad {
|
|
65
|
+
width: 120px; height: 120px; background: rgba(255, 255, 255, 0.1);
|
|
66
|
+
border: 2px solid rgba(0, 255, 204, 0.4); border-radius: 50%;
|
|
67
|
+
position: relative; pointer-events: auto; touch-action: none;
|
|
68
|
+
}
|
|
69
|
+
.touch-knob {
|
|
70
|
+
width: 50px; height: 50px; background: rgba(0, 255, 204, 0.8);
|
|
71
|
+
border-radius: 50%; position: absolute; top: 35px; left: 35px;
|
|
72
|
+
box-shadow: 0 0 15px #00ffcc; transition: transform 0.05s ease;
|
|
73
|
+
}
|
|
74
|
+
.btn-fire {
|
|
75
|
+
width: 90px; height: 90px; background: rgba(255, 51, 102, 0.8);
|
|
76
|
+
border: 2px solid #fff; border-radius: 50%; font-weight: bold; color: #fff;
|
|
77
|
+
display: flex; align-items: center; justify-content: center; font-size: 18px;
|
|
78
|
+
pointer-events: auto; box-shadow: 0 0 20px rgba(255, 51, 102, 0.8);
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
}
|
|
81
|
+
.btn-fire:active { transform: scale(0.95); background: #ff0044; }
|
|
82
|
+
#game-over {
|
|
83
|
+
position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;
|
|
84
|
+
background: rgba(0, 0, 0, 0.85); display: none; flex-direction: column;
|
|
85
|
+
align-items: center; justify-content: center; color: #fff; z-index: 100;
|
|
86
|
+
}
|
|
87
|
+
#game-over h1 { font-size: 48px; color: #ff3366; margin-bottom: 20px; }
|
|
88
|
+
.restart-btn {
|
|
89
|
+
padding: 15px 40px; background: #00ffcc; color: #000; font-weight: 800;
|
|
90
|
+
border: none; border-radius: 30px; font-size: 20px; cursor: pointer;
|
|
91
|
+
box-shadow: 0 0 25px rgba(0, 255, 204, 0.8);
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
94
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
|
95
|
+
</head>
|
|
96
|
+
<body>
|
|
97
|
+
<div id="canvas-container"></div>
|
|
98
|
+
<div id="hud">
|
|
99
|
+
<div class="hud-box"><span class="hud-score" id="score">SCORE: 0</span></div>
|
|
100
|
+
<button id="mute-btn" title="Toggle Audio">🔊</button>
|
|
101
|
+
<div class="hud-box"><span class="hud-health" id="health">SHIELD: 100%</span></div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div id="mobile-controls">
|
|
105
|
+
<div class="touch-pad" id="joystick">
|
|
106
|
+
<div class="touch-knob" id="knob"></div>
|
|
107
|
+
</div>
|
|
108
|
+
<div class="btn-fire" id="fire-btn">FIRE</div>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<div id="game-over">
|
|
112
|
+
<h1>MISSION TERMINATED</h1>
|
|
113
|
+
<p style="font-size: 22px; margin-bottom: 30px;">Final Sovereign Score: <span id="final-score" style="color: #00ffcc;">0</span></p>
|
|
114
|
+
<button class="restart-btn" onclick="location.reload()">RE-INITIALIZE</button>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<script>
|
|
118
|
+
// ── Sovereign Web Audio API Synthesizer ──
|
|
119
|
+
class SovereignAudioEngine {
|
|
120
|
+
constructor() {
|
|
121
|
+
this.ctx = null;
|
|
122
|
+
this.muted = false;
|
|
123
|
+
this.bgmTimer = null;
|
|
124
|
+
}
|
|
125
|
+
init() {
|
|
126
|
+
if (!this.ctx) {
|
|
127
|
+
const AudioCtx = window.AudioContext || window.webkitAudioContext;
|
|
128
|
+
if (AudioCtx) this.ctx = new AudioCtx();
|
|
129
|
+
}
|
|
130
|
+
if (this.ctx && this.ctx.state === 'suspended') {
|
|
131
|
+
this.ctx.resume();
|
|
132
|
+
}
|
|
133
|
+
if (!this.bgmTimer && !this.muted) {
|
|
134
|
+
this.startBGM();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
toggleMute() {
|
|
138
|
+
this.muted = !this.muted;
|
|
139
|
+
const btn = document.getElementById('mute-btn');
|
|
140
|
+
if (btn) btn.innerText = this.muted ? '🔇' : '🔊';
|
|
141
|
+
if (this.muted && this.bgmTimer) {
|
|
142
|
+
clearInterval(this.bgmTimer);
|
|
143
|
+
this.bgmTimer = null;
|
|
144
|
+
} else if (!this.muted) {
|
|
145
|
+
this.startBGM();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
playSFX(type) {
|
|
149
|
+
if (this.muted || !this.ctx) return;
|
|
150
|
+
try {
|
|
151
|
+
const osc = this.ctx.createOscillator();
|
|
152
|
+
const gain = this.ctx.createGain();
|
|
153
|
+
osc.connect(gain);
|
|
154
|
+
gain.connect(this.ctx.destination);
|
|
155
|
+
const now = this.ctx.currentTime;
|
|
156
|
+
|
|
157
|
+
if (type === 'laser') {
|
|
158
|
+
osc.type = 'sawtooth';
|
|
159
|
+
osc.frequency.setValueAtTime(800, now);
|
|
160
|
+
osc.frequency.exponentialRampToValueAtTime(120, now + 0.18);
|
|
161
|
+
gain.gain.setValueAtTime(0.25, now);
|
|
162
|
+
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.18);
|
|
163
|
+
osc.start(now);
|
|
164
|
+
osc.stop(now + 0.18);
|
|
165
|
+
} else if (type === 'explosion') {
|
|
166
|
+
const bufferSize = this.ctx.sampleRate * 0.5;
|
|
167
|
+
const buffer = this.ctx.createBuffer(1, bufferSize, this.ctx.sampleRate);
|
|
168
|
+
const data = buffer.getChannelData(0);
|
|
169
|
+
for (let i = 0; i < bufferSize; i++) data[i] = Math.random() * 2 - 1;
|
|
170
|
+
const noise = this.ctx.createBufferSource();
|
|
171
|
+
noise.buffer = buffer;
|
|
172
|
+
const filter = this.ctx.createBiquadFilter();
|
|
173
|
+
filter.type = 'lowpass';
|
|
174
|
+
filter.frequency.setValueAtTime(400, now);
|
|
175
|
+
filter.frequency.linearRampToValueAtTime(60, now + 0.5);
|
|
176
|
+
noise.connect(filter);
|
|
177
|
+
filter.connect(gain);
|
|
178
|
+
gain.gain.setValueAtTime(0.4, now);
|
|
179
|
+
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.5);
|
|
180
|
+
noise.start(now);
|
|
181
|
+
}
|
|
182
|
+
} catch (e) {}
|
|
183
|
+
}
|
|
184
|
+
startBGM() {
|
|
185
|
+
if (this.muted || !this.ctx || this.bgmTimer) return;
|
|
186
|
+
const notes = [130.81, 164.81, 196.00, 233.08]; // C3, E3, G3, Bb3 Synthwave Arp
|
|
187
|
+
let idx = 0;
|
|
188
|
+
this.bgmTimer = setInterval(() => {
|
|
189
|
+
if (this.muted || !this.ctx) return;
|
|
190
|
+
try {
|
|
191
|
+
const osc = this.ctx.createOscillator();
|
|
192
|
+
const gain = this.ctx.createGain();
|
|
193
|
+
osc.type = 'triangle';
|
|
194
|
+
osc.frequency.value = notes[idx % notes.length];
|
|
195
|
+
idx++;
|
|
196
|
+
osc.connect(gain);
|
|
197
|
+
gain.connect(this.ctx.destination);
|
|
198
|
+
const now = this.ctx.currentTime;
|
|
199
|
+
gain.gain.setValueAtTime(0.06, now);
|
|
200
|
+
gain.gain.exponentialRampToValueAtTime(0.005, now + 0.16);
|
|
201
|
+
osc.start(now);
|
|
202
|
+
osc.stop(now + 0.16);
|
|
203
|
+
} catch (e) {}
|
|
204
|
+
}, 180);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const audio = new SovereignAudioEngine();
|
|
208
|
+
document.getElementById('mute-btn').addEventListener('click', () => audio.toggleMute());
|
|
209
|
+
window.addEventListener('pointerdown', () => audio.init(), { once: true });
|
|
210
|
+
window.addEventListener('keydown', () => audio.init(), { once: true });
|
|
211
|
+
|
|
212
|
+
// Scene, Camera, Renderer
|
|
213
|
+
const container = document.getElementById('canvas-container');
|
|
214
|
+
const scene = new THREE.Scene();
|
|
215
|
+
scene.fog = new THREE.FogExp2(0x050811, 0.015);
|
|
216
|
+
|
|
217
|
+
const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000);
|
|
218
|
+
camera.position.set(0, 4, 12);
|
|
219
|
+
camera.lookAt(0, 0, -10);
|
|
220
|
+
|
|
221
|
+
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
|
|
222
|
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
223
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
224
|
+
renderer.shadowMap.enabled = true;
|
|
225
|
+
container.appendChild(renderer.domElement);
|
|
226
|
+
|
|
227
|
+
// Lighting
|
|
228
|
+
const ambLight = new THREE.AmbientLight(0x223344, 1.5);
|
|
229
|
+
scene.add(ambLight);
|
|
230
|
+
|
|
231
|
+
const dirLight = new THREE.DirectionalLight(0x00ffcc, 2.0);
|
|
232
|
+
dirLight.position.set(10, 20, 10);
|
|
233
|
+
scene.add(dirLight);
|
|
234
|
+
|
|
235
|
+
// Player Ship Rig (Cyberpunk Jet)
|
|
236
|
+
const shipGroup = new THREE.Group();
|
|
237
|
+
const bodyGeo = new THREE.ConeGeometry(0.8, 2.5, 4);
|
|
238
|
+
bodyGeo.rotateX(Math.PI / 2);
|
|
239
|
+
const bodyMat = new THREE.MeshStandardMaterial({ color: 0x00ffcc, metalness: 0.8, roughness: 0.2, wireframe: false });
|
|
240
|
+
const shipBody = new THREE.Mesh(bodyGeo, bodyMat);
|
|
241
|
+
shipGroup.add(shipBody);
|
|
242
|
+
|
|
243
|
+
const wingGeo = new THREE.BoxGeometry(3.0, 0.1, 0.8);
|
|
244
|
+
const wingMat = new THREE.MeshStandardMaterial({ color: 0x112233, metalness: 0.9 });
|
|
245
|
+
const shipWings = new THREE.Mesh(wingGeo, wingMat);
|
|
246
|
+
shipWings.position.set(0, -0.2, 0.5);
|
|
247
|
+
shipGroup.add(shipWings);
|
|
248
|
+
scene.add(shipGroup);
|
|
249
|
+
shipGroup.position.set(0, 0, 0);
|
|
250
|
+
|
|
251
|
+
// Grid Tunnel Environment
|
|
252
|
+
const gridHelper = new THREE.GridHelper(200, 50, 0x00ffcc, 0x112233);
|
|
253
|
+
gridHelper.position.y = -3;
|
|
254
|
+
scene.add(gridHelper);
|
|
255
|
+
|
|
256
|
+
// Game State & Arrays
|
|
257
|
+
let score = 0;
|
|
258
|
+
let health = 100;
|
|
259
|
+
let isGameOver = false;
|
|
260
|
+
const lasers = [];
|
|
261
|
+
const enemies = [];
|
|
262
|
+
const particles = [];
|
|
263
|
+
|
|
264
|
+
// Controls State
|
|
265
|
+
const keys = { Left: false, Right: false, Up: false, Down: false, Space: false };
|
|
266
|
+
let joyX = 0, joyY = 0;
|
|
267
|
+
|
|
268
|
+
window.addEventListener('keydown', (e) => {
|
|
269
|
+
if (e.code === 'ArrowLeft' || e.code === 'KeyA') keys.Left = true;
|
|
270
|
+
if (e.code === 'ArrowRight' || e.code === 'KeyD') keys.Right = true;
|
|
271
|
+
if (e.code === 'ArrowUp' || e.code === 'KeyW') keys.Up = true;
|
|
272
|
+
if (e.code === 'ArrowDown' || e.code === 'KeyS') keys.Down = true;
|
|
273
|
+
if (e.code === 'Space') { keys.Space = true; fireLaser(); }
|
|
274
|
+
});
|
|
275
|
+
window.addEventListener('keyup', (e) => {
|
|
276
|
+
if (e.code === 'ArrowLeft' || e.code === 'KeyA') keys.Left = false;
|
|
277
|
+
if (e.code === 'ArrowRight' || e.code === 'KeyD') keys.Right = false;
|
|
278
|
+
if (e.code === 'ArrowUp' || e.code === 'KeyW') keys.Up = false;
|
|
279
|
+
if (e.code === 'ArrowDown' || e.code === 'KeyS') keys.Down = false;
|
|
280
|
+
if (e.code === 'Space') keys.Space = false;
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const joystick = document.getElementById('joystick');
|
|
284
|
+
const knob = document.getElementById('knob');
|
|
285
|
+
joystick.addEventListener('pointermove', (e) => {
|
|
286
|
+
if (e.buttons !== 1) return;
|
|
287
|
+
const rect = joystick.getBoundingClientRect();
|
|
288
|
+
const cx = rect.left + rect.width / 2;
|
|
289
|
+
const cy = rect.top + rect.height / 2;
|
|
290
|
+
let dx = e.clientX - cx;
|
|
291
|
+
let dy = e.clientY - cy;
|
|
292
|
+
const dist = Math.min(35, Math.hypot(dx, dy));
|
|
293
|
+
const angle = Math.atan2(dy, dx);
|
|
294
|
+
knob.style.transform = \`translate(\${Math.cos(angle)*dist}px, \${Math.sin(angle)*dist}px)\`;
|
|
295
|
+
joyX = (Math.cos(angle) * dist) / 35;
|
|
296
|
+
joyY = (Math.sin(angle) * dist) / 35;
|
|
297
|
+
});
|
|
298
|
+
joystick.addEventListener('pointerup', () => {
|
|
299
|
+
knob.style.transform = 'translate(0, 0)';
|
|
300
|
+
joyX = 0; joyY = 0;
|
|
301
|
+
});
|
|
302
|
+
document.getElementById('fire-btn').addEventListener('pointerdown', fireLaser);
|
|
303
|
+
|
|
304
|
+
function fireLaser() {
|
|
305
|
+
if (isGameOver) return;
|
|
306
|
+
audio.init();
|
|
307
|
+
audio.playSFX('laser');
|
|
308
|
+
const laserGeo = new THREE.CylinderGeometry(0.1, 0.1, 1.5, 8);
|
|
309
|
+
laserGeo.rotateX(Math.PI / 2);
|
|
310
|
+
const laserMat = new THREE.MeshBasicMaterial({ color: 0xff3366 });
|
|
311
|
+
const laser = new THREE.Mesh(laserGeo, laserMat);
|
|
312
|
+
laser.position.copy(shipGroup.position);
|
|
313
|
+
laser.position.z -= 1.5;
|
|
314
|
+
scene.add(laser);
|
|
315
|
+
lasers.push(laser);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function spawnEnemy() {
|
|
319
|
+
if (isGameOver) return;
|
|
320
|
+
const geo = new THREE.DodecahedronGeometry(1.2, 0);
|
|
321
|
+
const mat = new THREE.MeshStandardMaterial({ color: 0xff3366, roughness: 0.4, metalness: 0.6 });
|
|
322
|
+
const enemy = new THREE.Mesh(geo, mat);
|
|
323
|
+
enemy.position.set((Math.random() - 0.5) * 20, (Math.random() - 0.5) * 10, -60);
|
|
324
|
+
scene.add(enemy);
|
|
325
|
+
enemies.push(enemy);
|
|
326
|
+
}
|
|
327
|
+
setInterval(spawnEnemy, 1200);
|
|
328
|
+
|
|
329
|
+
function spawnExplosion(pos, colorHex) {
|
|
330
|
+
for (let i = 0; i < 12; i++) {
|
|
331
|
+
const pGeo = new THREE.SphereGeometry(0.2, 4, 4);
|
|
332
|
+
const pMat = new THREE.MeshBasicMaterial({ color: colorHex });
|
|
333
|
+
const p = new THREE.Mesh(pGeo, pMat);
|
|
334
|
+
p.position.copy(pos);
|
|
335
|
+
p.userData = {
|
|
336
|
+
vx: (Math.random() - 0.5) * 0.8,
|
|
337
|
+
vy: (Math.random() - 0.5) * 0.8,
|
|
338
|
+
vz: (Math.random() - 0.5) * 0.8,
|
|
339
|
+
life: 1.0
|
|
340
|
+
};
|
|
341
|
+
scene.add(p);
|
|
342
|
+
particles.push(p);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function animate() {
|
|
347
|
+
if (isGameOver) return;
|
|
348
|
+
requestAnimationFrame(animate);
|
|
349
|
+
|
|
350
|
+
let vx = (joyX + (keys.Right ? 1 : 0) - (keys.Left ? 1 : 0)) * 0.35;
|
|
351
|
+
let vy = (-joyY + (keys.Up ? 1 : 0) - (keys.Down ? 1 : 0)) * 0.35;
|
|
352
|
+
shipGroup.position.x = Math.max(-12, Math.min(12, shipGroup.position.x + vx));
|
|
353
|
+
shipGroup.position.y = Math.max(-2, Math.min(8, shipGroup.position.y + vy));
|
|
354
|
+
shipGroup.rotation.z = -vx * 1.5;
|
|
355
|
+
shipGroup.rotation.x = vy * 0.5;
|
|
356
|
+
|
|
357
|
+
gridHelper.position.z = (gridHelper.position.z + 0.4) % 4;
|
|
358
|
+
|
|
359
|
+
for (let i = lasers.length - 1; i >= 0; i--) {
|
|
360
|
+
lasers[i].position.z -= 1.8;
|
|
361
|
+
if (lasers[i].position.z < -80) {
|
|
362
|
+
scene.remove(lasers[i]);
|
|
363
|
+
lasers.splice(i, 1);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
for (let i = enemies.length - 1; i >= 0; i--) {
|
|
368
|
+
const en = enemies[i];
|
|
369
|
+
en.position.z += 0.45;
|
|
370
|
+
en.rotation.x += 0.02;
|
|
371
|
+
en.rotation.y += 0.03;
|
|
372
|
+
|
|
373
|
+
if (en.position.distanceTo(shipGroup.position) < 2.0) {
|
|
374
|
+
audio.playSFX('explosion');
|
|
375
|
+
spawnExplosion(en.position, 0xff3366);
|
|
376
|
+
scene.remove(en);
|
|
377
|
+
enemies.splice(i, 1);
|
|
378
|
+
health -= 25;
|
|
379
|
+
document.getElementById('health').innerText = \`SHIELD: \${Math.max(0, health)}%\`;
|
|
380
|
+
if (health <= 0) triggerGameOver();
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
let enemyDestroyed = false;
|
|
385
|
+
for (let j = lasers.length - 1; j >= 0; j--) {
|
|
386
|
+
if (en.position.distanceTo(lasers[j].position) < 1.8) {
|
|
387
|
+
audio.playSFX('explosion');
|
|
388
|
+
spawnExplosion(en.position, 0x00ffcc);
|
|
389
|
+
scene.remove(en);
|
|
390
|
+
scene.remove(lasers[j]);
|
|
391
|
+
enemies.splice(i, 1);
|
|
392
|
+
lasers.splice(j, 1);
|
|
393
|
+
score += 100;
|
|
394
|
+
document.getElementById('score').innerText = \`SCORE: \${score}\`;
|
|
395
|
+
enemyDestroyed = true;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (enemyDestroyed) continue;
|
|
400
|
+
|
|
401
|
+
if (en && en.position.z > 15) {
|
|
402
|
+
scene.remove(en);
|
|
403
|
+
enemies.splice(i, 1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
for (let i = particles.length - 1; i >= 0; i--) {
|
|
408
|
+
const p = particles[i];
|
|
409
|
+
p.position.x += p.userData.vx;
|
|
410
|
+
p.position.y += p.userData.vy;
|
|
411
|
+
p.position.z += p.userData.vz;
|
|
412
|
+
p.userData.life -= 0.04;
|
|
413
|
+
p.scale.setScalar(p.userData.life);
|
|
414
|
+
if (p.userData.life <= 0) {
|
|
415
|
+
scene.remove(p);
|
|
416
|
+
particles.splice(i, 1);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
renderer.render(scene, camera);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function triggerGameOver() {
|
|
424
|
+
isGameOver = true;
|
|
425
|
+
document.getElementById('final-score').innerText = score;
|
|
426
|
+
document.getElementById('game-over').style.display = 'flex';
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
window.addEventListener('resize', () => {
|
|
430
|
+
camera.aspect = window.innerWidth / window.innerHeight;
|
|
431
|
+
camera.updateProjectionMatrix();
|
|
432
|
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
animate();
|
|
436
|
+
</script>
|
|
437
|
+
</body>
|
|
438
|
+
</html>`;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// -----------------------------------------------------------------------------
|
|
442
|
+
// Benchmark Template 2: 2D Cyberpunk Platformer (Canvas 2D + Web Audio)
|
|
443
|
+
// -----------------------------------------------------------------------------
|
|
444
|
+
function getArcadePlatformer2dTemplate(title: string, _includeAudio = true): string {
|
|
445
|
+
return `<!DOCTYPE html>
|
|
446
|
+
<html lang="en">
|
|
447
|
+
<head>
|
|
448
|
+
<meta charset="UTF-8">
|
|
449
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
450
|
+
<title>${escapeHtmlText(title, 120)} — Causyne 2D Arcade Engine</title>
|
|
451
|
+
<style>
|
|
452
|
+
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
|
|
453
|
+
body { background: #080a12; overflow: hidden; font-family: 'JetBrains Mono', monospace; display: flex; align-items: center; justify-content: center; height: 100vh; }
|
|
454
|
+
canvas { background: #0d1220; border: 2px solid #00ffcc; box-shadow: 0 0 30px rgba(0, 255, 204, 0.3); max-width: 100vw; max-height: 100vh; }
|
|
455
|
+
#hud { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; pointer-events: none; }
|
|
456
|
+
#mute-btn {
|
|
457
|
+
background: rgba(10, 15, 25, 0.8); border: 1px solid #00ffcc; color: #fff;
|
|
458
|
+
padding: 8px 14px; border-radius: 20px; font-size: 18px; cursor: pointer; pointer-events: auto;
|
|
459
|
+
}
|
|
460
|
+
#mobile-controls {
|
|
461
|
+
position: absolute; bottom: 20px; left: 20px; right: 20px;
|
|
462
|
+
display: flex; justify-content: space-between; pointer-events: none;
|
|
463
|
+
}
|
|
464
|
+
.btn-group { display: flex; gap: 15px; pointer-events: auto; }
|
|
465
|
+
.touch-btn {
|
|
466
|
+
width: 70px; height: 70px; background: rgba(0, 255, 204, 0.2);
|
|
467
|
+
border: 2px solid #00ffcc; border-radius: 12px; color: #fff; font-size: 24px;
|
|
468
|
+
font-weight: bold; display: flex; align-items: center; justify-content: center;
|
|
469
|
+
}
|
|
470
|
+
.touch-btn:active { background: #00ffcc; color: #000; }
|
|
471
|
+
</style>
|
|
472
|
+
</head>
|
|
473
|
+
<body>
|
|
474
|
+
<div id="hud">
|
|
475
|
+
<span style="color: #fff; font-size: 24px; font-weight: bold;"></span>
|
|
476
|
+
<button id="mute-btn" title="Toggle Audio">🔊</button>
|
|
477
|
+
</div>
|
|
478
|
+
<canvas id="gameCanvas" width="960" height="540"></canvas>
|
|
479
|
+
|
|
480
|
+
<div id="mobile-controls">
|
|
481
|
+
<div class="btn-group">
|
|
482
|
+
<div class="touch-btn" id="btn-left">◀</div>
|
|
483
|
+
<div class="touch-btn" id="btn-right">▶</div>
|
|
484
|
+
</div>
|
|
485
|
+
<div class="btn-group">
|
|
486
|
+
<div class="touch-btn" id="btn-jump" style="background: rgba(255, 51, 102, 0.2); border-color: #ff3366;">▲</div>
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
|
|
490
|
+
<script>
|
|
491
|
+
// ── Sovereign Web Audio API Synthesizer ──
|
|
492
|
+
class SovereignAudioEngine {
|
|
493
|
+
constructor() {
|
|
494
|
+
this.ctx = null;
|
|
495
|
+
this.muted = false;
|
|
496
|
+
this.bgmTimer = null;
|
|
497
|
+
}
|
|
498
|
+
init() {
|
|
499
|
+
if (!this.ctx) {
|
|
500
|
+
const AudioCtx = window.AudioContext || window.webkitAudioContext;
|
|
501
|
+
if (AudioCtx) this.ctx = new AudioCtx();
|
|
502
|
+
}
|
|
503
|
+
if (this.ctx && this.ctx.state === 'suspended') {
|
|
504
|
+
this.ctx.resume();
|
|
505
|
+
}
|
|
506
|
+
if (!this.bgmTimer && !this.muted) {
|
|
507
|
+
this.startBGM();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
toggleMute() {
|
|
511
|
+
this.muted = !this.muted;
|
|
512
|
+
const btn = document.getElementById('mute-btn');
|
|
513
|
+
if (btn) btn.innerText = this.muted ? '🔇' : '🔊';
|
|
514
|
+
if (this.muted && this.bgmTimer) {
|
|
515
|
+
clearInterval(this.bgmTimer);
|
|
516
|
+
this.bgmTimer = null;
|
|
517
|
+
} else if (!this.muted) {
|
|
518
|
+
this.startBGM();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
playSFX(type) {
|
|
522
|
+
if (this.muted || !this.ctx) return;
|
|
523
|
+
try {
|
|
524
|
+
const osc = this.ctx.createOscillator();
|
|
525
|
+
const gain = this.ctx.createGain();
|
|
526
|
+
osc.connect(gain);
|
|
527
|
+
gain.connect(this.ctx.destination);
|
|
528
|
+
const now = this.ctx.currentTime;
|
|
529
|
+
|
|
530
|
+
if (type === 'jump') {
|
|
531
|
+
osc.type = 'square';
|
|
532
|
+
osc.frequency.setValueAtTime(260, now);
|
|
533
|
+
osc.frequency.linearRampToValueAtTime(560, now + 0.15);
|
|
534
|
+
gain.gain.setValueAtTime(0.2, now);
|
|
535
|
+
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.15);
|
|
536
|
+
osc.start(now);
|
|
537
|
+
osc.stop(now + 0.15);
|
|
538
|
+
} else if (type === 'coin') {
|
|
539
|
+
osc.type = 'sine';
|
|
540
|
+
osc.frequency.setValueAtTime(1200, now);
|
|
541
|
+
osc.frequency.setValueAtTime(1800, now + 0.08);
|
|
542
|
+
gain.gain.setValueAtTime(0.25, now);
|
|
543
|
+
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.28);
|
|
544
|
+
osc.start(now);
|
|
545
|
+
osc.stop(now + 0.28);
|
|
546
|
+
}
|
|
547
|
+
} catch (e) {}
|
|
548
|
+
}
|
|
549
|
+
startBGM() {
|
|
550
|
+
if (this.muted || !this.ctx || this.bgmTimer) return;
|
|
551
|
+
const notes = [164.81, 196.00, 220.00, 261.63]; // E3, G3, A3, C4 Arp
|
|
552
|
+
let idx = 0;
|
|
553
|
+
this.bgmTimer = setInterval(() => {
|
|
554
|
+
if (this.muted || !this.ctx) return;
|
|
555
|
+
try {
|
|
556
|
+
const osc = this.ctx.createOscillator();
|
|
557
|
+
const gain = this.ctx.createGain();
|
|
558
|
+
osc.type = 'triangle';
|
|
559
|
+
osc.frequency.value = notes[idx % notes.length];
|
|
560
|
+
idx++;
|
|
561
|
+
osc.connect(gain);
|
|
562
|
+
gain.connect(this.ctx.destination);
|
|
563
|
+
const now = this.ctx.currentTime;
|
|
564
|
+
gain.gain.setValueAtTime(0.06, now);
|
|
565
|
+
gain.gain.exponentialRampToValueAtTime(0.005, now + 0.16);
|
|
566
|
+
osc.start(now);
|
|
567
|
+
osc.stop(now + 0.16);
|
|
568
|
+
} catch (e) {}
|
|
569
|
+
}, 180);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const audio = new SovereignAudioEngine();
|
|
573
|
+
document.getElementById('mute-btn').addEventListener('click', () => audio.toggleMute());
|
|
574
|
+
window.addEventListener('pointerdown', () => audio.init(), { once: true });
|
|
575
|
+
window.addEventListener('keydown', () => audio.init(), { once: true });
|
|
576
|
+
|
|
577
|
+
const canvas = document.getElementById('gameCanvas');
|
|
578
|
+
const ctx = canvas.getContext('2d');
|
|
579
|
+
|
|
580
|
+
const player = {
|
|
581
|
+
x: 100, y: 300, w: 36, h: 48, vx: 0, vy: 0, speed: 6, jump: -14,
|
|
582
|
+
grounded: false, color: '#00ffcc'
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
const gravity = 0.65;
|
|
586
|
+
const keys = { left: false, right: false, up: false };
|
|
587
|
+
|
|
588
|
+
const platforms = [
|
|
589
|
+
{ x: 0, y: 500, w: 960, h: 40, color: '#1a243a' },
|
|
590
|
+
{ x: 180, y: 380, w: 200, h: 20, color: '#00ffcc' },
|
|
591
|
+
{ x: 450, y: 280, w: 180, h: 20, color: '#ff3366' },
|
|
592
|
+
{ x: 700, y: 180, w: 200, h: 20, color: '#00ffcc' }
|
|
593
|
+
];
|
|
594
|
+
|
|
595
|
+
const coins = [
|
|
596
|
+
{ x: 260, y: 340, r: 12, collected: false },
|
|
597
|
+
{ x: 530, y: 240, r: 12, collected: false },
|
|
598
|
+
{ x: 780, y: 140, r: 12, collected: false }
|
|
599
|
+
];
|
|
600
|
+
let score = 0;
|
|
601
|
+
|
|
602
|
+
window.addEventListener('keydown', (e) => {
|
|
603
|
+
if (e.code === 'ArrowLeft' || e.code === 'KeyA') keys.left = true;
|
|
604
|
+
if (e.code === 'ArrowRight' || e.code === 'KeyD') keys.right = true;
|
|
605
|
+
if ((e.code === 'ArrowUp' || e.code === 'Space') && player.grounded) {
|
|
606
|
+
player.vy = player.jump; player.grounded = false;
|
|
607
|
+
audio.init(); audio.playSFX('jump');
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
window.addEventListener('keyup', (e) => {
|
|
611
|
+
if (e.code === 'ArrowLeft' || e.code === 'KeyA') keys.left = false;
|
|
612
|
+
if (e.code === 'ArrowRight' || e.code === 'KeyD') keys.right = false;
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
document.getElementById('btn-left').addEventListener('pointerdown', () => keys.left = true);
|
|
616
|
+
document.getElementById('btn-left').addEventListener('pointerup', () => keys.left = false);
|
|
617
|
+
document.getElementById('btn-right').addEventListener('pointerdown', () => keys.right = true);
|
|
618
|
+
document.getElementById('btn-right').addEventListener('pointerup', () => keys.right = false);
|
|
619
|
+
document.getElementById('btn-jump').addEventListener('pointerdown', () => {
|
|
620
|
+
if (player.grounded) {
|
|
621
|
+
player.vy = player.jump; player.grounded = false;
|
|
622
|
+
audio.init(); audio.playSFX('jump');
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
function update() {
|
|
627
|
+
if (keys.left) player.vx = -player.speed;
|
|
628
|
+
else if (keys.right) player.vx = player.speed;
|
|
629
|
+
else player.vx *= 0.8;
|
|
630
|
+
|
|
631
|
+
player.x += player.vx;
|
|
632
|
+
player.vy += gravity;
|
|
633
|
+
player.y += player.vy;
|
|
634
|
+
player.grounded = false;
|
|
635
|
+
|
|
636
|
+
for (const p of platforms) {
|
|
637
|
+
if (player.x < p.x + p.w && player.x + player.w > p.x &&
|
|
638
|
+
player.y + player.h > p.y && player.y + player.h < p.y + p.h + player.vy) {
|
|
639
|
+
player.y = p.y - player.h;
|
|
640
|
+
player.vy = 0;
|
|
641
|
+
player.grounded = true;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
for (const c of coins) {
|
|
646
|
+
if (!c.collected && Math.hypot(player.x + player.w/2 - c.x, player.y + player.h/2 - c.y) < c.r + 18) {
|
|
647
|
+
c.collected = true;
|
|
648
|
+
score += 100;
|
|
649
|
+
audio.playSFX('coin');
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (player.x < 0) player.x = 0;
|
|
654
|
+
if (player.x + player.w > canvas.width) player.x = canvas.width - player.w;
|
|
655
|
+
if (player.y > canvas.height) { player.x = 100; player.y = 300; player.vy = 0; }
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function draw() {
|
|
659
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
660
|
+
|
|
661
|
+
for (const p of platforms) {
|
|
662
|
+
ctx.fillStyle = p.color;
|
|
663
|
+
ctx.fillRect(p.x, p.y, p.w, p.h);
|
|
664
|
+
ctx.shadowColor = p.color;
|
|
665
|
+
ctx.shadowBlur = 10;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
for (const c of coins) {
|
|
669
|
+
if (!c.collected) {
|
|
670
|
+
ctx.beginPath();
|
|
671
|
+
ctx.arc(c.x, c.y, c.r, 0, Math.PI * 2);
|
|
672
|
+
ctx.fillStyle = '#ffcc00';
|
|
673
|
+
ctx.fill();
|
|
674
|
+
ctx.shadowColor = '#ffcc00';
|
|
675
|
+
ctx.shadowBlur = 15;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
ctx.fillStyle = player.color;
|
|
680
|
+
ctx.fillRect(player.x, player.y, player.w, player.h);
|
|
681
|
+
ctx.shadowColor = player.color;
|
|
682
|
+
ctx.shadowBlur = 20;
|
|
683
|
+
|
|
684
|
+
ctx.shadowBlur = 0;
|
|
685
|
+
ctx.fillStyle = '#fff';
|
|
686
|
+
ctx.font = 'bold 24px JetBrains Mono';
|
|
687
|
+
ctx.fillText(\`SCORE: \${score}\`, 20, 40);
|
|
688
|
+
|
|
689
|
+
requestAnimationFrame(() => { update(); draw(); });
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
draw();
|
|
693
|
+
</script>
|
|
694
|
+
</body>
|
|
695
|
+
</html>`;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// -----------------------------------------------------------------------------
|
|
699
|
+
// Benchmark Template 3: 3D Cyberpunk Highway Racer (Three.js + Web Audio)
|
|
700
|
+
// -----------------------------------------------------------------------------
|
|
701
|
+
function getCyberpunkRacer3dTemplate(title: string, _includeAudio = true): string {
|
|
702
|
+
return `<!DOCTYPE html>
|
|
703
|
+
<html lang="en">
|
|
704
|
+
<head>
|
|
705
|
+
<meta charset="UTF-8">
|
|
706
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
707
|
+
<title>${escapeHtmlText(title, 120)} — Cyberpunk Racer 3D</title>
|
|
708
|
+
<style>
|
|
709
|
+
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
|
|
710
|
+
body { background: #03050c; overflow: hidden; font-family: 'Outfit', sans-serif; }
|
|
711
|
+
#canvas-container { width: 100vw; height: 100vh; display: block; }
|
|
712
|
+
#hud {
|
|
713
|
+
position: absolute; top: 20px; left: 20px; right: 20px;
|
|
714
|
+
display: flex; justify-content: space-between; align-items: center; pointer-events: none;
|
|
715
|
+
color: #fff; text-shadow: 0 0 10px #00ffcc;
|
|
716
|
+
}
|
|
717
|
+
.hud-box {
|
|
718
|
+
background: rgba(10, 15, 25, 0.7); border: 1px solid #00ffcc;
|
|
719
|
+
padding: 12px 24px; border-radius: 8px; backdrop-filter: blur(10px); pointer-events: auto;
|
|
720
|
+
}
|
|
721
|
+
.speed-val { font-size: 28px; font-weight: 800; color: #ff0055; }
|
|
722
|
+
</style>
|
|
723
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
|
724
|
+
</head>
|
|
725
|
+
<body>
|
|
726
|
+
<div id="canvas-container"></div>
|
|
727
|
+
<div id="hud">
|
|
728
|
+
<div class="hud-box"><span class="speed-val" id="speed-hud">SPEED: 0 MPH</span></div>
|
|
729
|
+
<div class="hud-box"><span id="score-hud" style="font-size: 24px; font-weight: bold; color: #00ffcc;">DISTANCE: 0 M</span></div>
|
|
730
|
+
</div>
|
|
731
|
+
<script>
|
|
732
|
+
const container = document.getElementById('canvas-container');
|
|
733
|
+
const scene = new THREE.Scene();
|
|
734
|
+
scene.fog = new THREE.FogExp2(0x050814, 0.02);
|
|
735
|
+
const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000);
|
|
736
|
+
camera.position.set(0, 4, 10);
|
|
737
|
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
|
738
|
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
739
|
+
container.appendChild(renderer.domElement);
|
|
740
|
+
|
|
741
|
+
const ambLight = new THREE.AmbientLight(0x223344, 2.0);
|
|
742
|
+
scene.add(ambLight);
|
|
743
|
+
const dirLight = new THREE.DirectionalLight(0x00ffcc, 1.5);
|
|
744
|
+
dirLight.position.set(10, 20, 10);
|
|
745
|
+
scene.add(dirLight);
|
|
746
|
+
|
|
747
|
+
// Road
|
|
748
|
+
const roadGeo = new THREE.PlaneGeometry(16, 600, 10, 100);
|
|
749
|
+
roadGeo.rotateX(-Math.PI / 2);
|
|
750
|
+
const roadMat = new THREE.MeshStandardMaterial({ color: 0x0f1422, roughness: 0.8 });
|
|
751
|
+
const road = new THREE.Mesh(roadGeo, roadMat);
|
|
752
|
+
scene.add(road);
|
|
753
|
+
|
|
754
|
+
// Car
|
|
755
|
+
const carGeo = new THREE.BoxGeometry(2.0, 0.8, 4.0);
|
|
756
|
+
const carMat = new THREE.MeshStandardMaterial({ color: 0xff0055, metalness: 0.9, roughness: 0.1 });
|
|
757
|
+
const car = new THREE.Mesh(carGeo, carMat);
|
|
758
|
+
car.position.set(0, 0.5, 3);
|
|
759
|
+
scene.add(car);
|
|
760
|
+
|
|
761
|
+
let speed = 0, targetSpeed = 120, distance = 0;
|
|
762
|
+
const keys = { Left: false, Right: false, Up: false, Down: false };
|
|
763
|
+
window.addEventListener('keydown', e => { if(e.code==='ArrowLeft'||e.code==='KeyA') keys.Left=true; if(e.code==='ArrowRight'||e.code==='KeyD') keys.Right=true; if(e.code==='ArrowUp'||e.code==='KeyW') keys.Up=true; });
|
|
764
|
+
window.addEventListener('keyup', e => { if(e.code==='ArrowLeft'||e.code==='KeyA') keys.Left=false; if(e.code==='ArrowRight'||e.code==='KeyD') keys.Right=false; if(e.code==='ArrowUp'||e.code==='KeyW') keys.Up=false; });
|
|
765
|
+
|
|
766
|
+
function animate() {
|
|
767
|
+
requestAnimationFrame(animate);
|
|
768
|
+
if (keys.Up) speed = Math.min(220, speed + 1.5); else speed = Math.max(30, speed - 0.5);
|
|
769
|
+
if (keys.Left) car.position.x = Math.max(-6, car.position.x - 0.25);
|
|
770
|
+
if (keys.Right) car.position.x = Math.min(6, car.position.x + 0.25);
|
|
771
|
+
car.rotation.z = (car.position.x * -0.05);
|
|
772
|
+
distance += speed * 0.05;
|
|
773
|
+
document.getElementById('speed-hud').innerText = \`SPEED: \${Math.round(speed)} MPH\`;
|
|
774
|
+
document.getElementById('score-hud').innerText = \`DISTANCE: \${Math.round(distance)} M\`;
|
|
775
|
+
renderer.render(scene, camera);
|
|
776
|
+
}
|
|
777
|
+
animate();
|
|
778
|
+
</script>
|
|
779
|
+
</body>
|
|
780
|
+
</html>`;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// -----------------------------------------------------------------------------
|
|
784
|
+
// Benchmark Template 4: 2D Top-Down RPG (Canvas 2D + Web Audio)
|
|
785
|
+
// -----------------------------------------------------------------------------
|
|
786
|
+
function getTopdownRpg2dTemplate(title: string, _includeAudio = true): string {
|
|
787
|
+
return `<!DOCTYPE html>
|
|
788
|
+
<html lang="en">
|
|
789
|
+
<head>
|
|
790
|
+
<meta charset="UTF-8">
|
|
791
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
792
|
+
<title>${escapeHtmlText(title, 120)} — Topdown RPG 2D</title>
|
|
793
|
+
<style>
|
|
794
|
+
body { margin: 0; background: #11141a; display: flex; align-items: center; justify-content: center; height: 100vh; font-family: sans-serif; color: #fff; }
|
|
795
|
+
canvas { background: #1b2233; border: 2px solid #3a86ff; box-shadow: 0 0 20px rgba(58,134,255,0.4); }
|
|
796
|
+
</style>
|
|
797
|
+
</head>
|
|
798
|
+
<body>
|
|
799
|
+
<canvas id="rpgCanvas" width="800" height="600"></canvas>
|
|
800
|
+
<script>
|
|
801
|
+
const canvas = document.getElementById('rpgCanvas');
|
|
802
|
+
const ctx = canvas.getContext('2d');
|
|
803
|
+
const hero = { x: 400, y: 300, r: 18, speed: 4, color: '#3a86ff' };
|
|
804
|
+
const keys = {};
|
|
805
|
+
window.addEventListener('keydown', e => keys[e.code] = true);
|
|
806
|
+
window.addEventListener('keyup', e => keys[e.code] = false);
|
|
807
|
+
|
|
808
|
+
function loop() {
|
|
809
|
+
if (keys['KeyW'] || keys['ArrowUp']) hero.y -= hero.speed;
|
|
810
|
+
if (keys['KeyS'] || keys['ArrowDown']) hero.y += hero.speed;
|
|
811
|
+
if (keys['KeyA'] || keys['ArrowLeft']) hero.x -= hero.speed;
|
|
812
|
+
if (keys['KeyD'] || keys['ArrowRight']) hero.x += hero.speed;
|
|
813
|
+
hero.x = Math.max(hero.r, Math.min(canvas.width - hero.r, hero.x));
|
|
814
|
+
hero.y = Math.max(hero.r, Math.min(canvas.height - hero.r, hero.y));
|
|
815
|
+
|
|
816
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
817
|
+
ctx.fillStyle = '#1e293b';
|
|
818
|
+
for(let x=0; x<canvas.width; x+=40) {
|
|
819
|
+
for(let y=0; y<canvas.height; y+=40) {
|
|
820
|
+
ctx.strokeRect(x, y, 40, 40);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
ctx.beginPath();
|
|
824
|
+
ctx.arc(hero.x, hero.y, hero.r, 0, Math.PI * 2);
|
|
825
|
+
ctx.fillStyle = hero.color;
|
|
826
|
+
ctx.fill();
|
|
827
|
+
ctx.shadowColor = hero.color;
|
|
828
|
+
ctx.shadowBlur = 15;
|
|
829
|
+
ctx.font = 'bold 20px sans-serif';
|
|
830
|
+
ctx.fillText(${escapeJsString(title, 120)}, 20, 35);
|
|
831
|
+
requestAnimationFrame(loop);
|
|
832
|
+
}
|
|
833
|
+
loop();
|
|
834
|
+
</script>
|
|
835
|
+
</body>
|
|
836
|
+
</html>`;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
export const gameBuilder = {
|
|
840
|
+
schema: {
|
|
841
|
+
name: 'game.build_html5',
|
|
842
|
+
description: 'Instant Sovereign HTML5 Game Engine Builder (`100% offline edge ready`). Generates complete, browser-playable 3D WebGL (Three.js) or 2D Arcade (Canvas 2D) games with procedural sound effects (`SFX`), looping background music (`BGM`), mobile touch controls, and WASD controls directly inside local workspace buffers (`space_defense_3d`, `arcade_platformer_2d`, `cyberpunk_racer_3d`, `topdown_rpg_2d`, `custom`).',
|
|
843
|
+
parameters: {
|
|
844
|
+
type: 'object',
|
|
845
|
+
properties: {
|
|
846
|
+
title: { type: 'string', description: 'Title of the game (`Sovereign Space Defense`, `Cyberpunk Racer 3D`).' },
|
|
847
|
+
engine: { type: 'string', enum: ['threejs', 'canvas2d'], description: 'Game engine selection: `threejs` (3D WebGL) or `canvas2d` (2D Arcade Physics).' },
|
|
848
|
+
template: {
|
|
849
|
+
type: 'string',
|
|
850
|
+
enum: ['space_defense_3d', 'arcade_platformer_2d', 'cyberpunk_racer_3d', 'topdown_rpg_2d', 'custom'],
|
|
851
|
+
description: 'Preset benchmark template (`space_defense_3d`, `arcade_platformer_2d`, `cyberpunk_racer_3d`, `topdown_rpg_2d`) or `custom` for custom script.'
|
|
852
|
+
},
|
|
853
|
+
audio: { type: 'boolean', description: 'Whether to embed the SovereignAudioEngine for procedural SFX & Synthwave BGM (default: true).' },
|
|
854
|
+
customScript: { type: 'string', description: 'Complete custom HTML/JS code if `template` is `custom`.' },
|
|
855
|
+
outputDir: { type: 'string', description: 'Target output directory. Defaults to `.tmp_causyne_3d` in current workspace.' },
|
|
856
|
+
filename: { type: 'string', description: 'Name of HTML file to write (default: `game.html`).' }
|
|
857
|
+
},
|
|
858
|
+
required: ['title', 'engine']
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
|
|
862
|
+
async execute(args: { title?: string | undefined; engine?: string | undefined; template?: string | undefined; audio?: boolean | undefined; customScript?: string | undefined; outputDir?: string | undefined; filename?: string | undefined } = {}, sandbox?: ToolWorkspaceContext): Promise<{ success: boolean; output?: string | undefined; error?: string | undefined }> {
|
|
863
|
+
try {
|
|
864
|
+
const { title = 'Untitled Game', engine = 'canvas2d', template, audio = true, customScript, outputDir, filename = 'game.html' } = args || {};
|
|
865
|
+
const safeName = safeFilenameStrict(filename, 128);
|
|
866
|
+
if (!safeName) {
|
|
867
|
+
return { success: false, error: 'filename must be a plain file name without path separators or reserved device names.' };
|
|
868
|
+
}
|
|
869
|
+
const targetDir = outputDir
|
|
870
|
+
? resolveScopedPath(outputDir, sandbox)
|
|
871
|
+
: getWorkspaceTempDir(sandbox);
|
|
872
|
+
if (!fsSync.existsSync(targetDir)) {
|
|
873
|
+
await fs.mkdir(targetDir, { recursive: true });
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
let htmlContent = '';
|
|
877
|
+
if (template === 'custom' && customScript) {
|
|
878
|
+
if (customScript.length > MAX_CUSTOM_HTML_CHARS) {
|
|
879
|
+
return { success: false, error: `customScript exceeds maximum size of ${MAX_CUSTOM_HTML_CHARS} characters.` };
|
|
880
|
+
}
|
|
881
|
+
htmlContent = customScript;
|
|
882
|
+
} else if (template === 'cyberpunk_racer_3d') {
|
|
883
|
+
htmlContent = getCyberpunkRacer3dTemplate(title, audio);
|
|
884
|
+
} else if (template === 'topdown_rpg_2d') {
|
|
885
|
+
htmlContent = getTopdownRpg2dTemplate(title, audio);
|
|
886
|
+
} else if (engine === 'threejs' || template === 'space_defense_3d') {
|
|
887
|
+
htmlContent = getSpaceDefense3dTemplate(title, audio);
|
|
888
|
+
} else {
|
|
889
|
+
htmlContent = getArcadePlatformer2dTemplate(title, audio);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
const filePath = await assertSafeWorkspaceOutput(path.join(targetDir, safeName), sandbox, { scopeRoot: targetDir });
|
|
893
|
+
await atomicWriteFileSafe(filePath, htmlContent);
|
|
894
|
+
|
|
895
|
+
return {
|
|
896
|
+
success: true,
|
|
897
|
+
output: JSON.stringify({
|
|
898
|
+
engine: engine === 'threejs' ? 'Three.js (3D WebGL + Web Audio)' : 'Canvas 2D Arcade Engine (+ Web Audio)',
|
|
899
|
+
template: template || (engine === 'threejs' ? 'space_defense_3d' : 'arcade_platformer_2d'),
|
|
900
|
+
title: title,
|
|
901
|
+
audio_enabled: audio,
|
|
902
|
+
output_file: filePath,
|
|
903
|
+
size_bytes: Buffer.byteLength(htmlContent, 'utf8'),
|
|
904
|
+
ready_to_play: true,
|
|
905
|
+
instructions: `Open ${filePath} directly in Google Chrome or via browser_act to play instantly across Desktop and Mobile.`
|
|
906
|
+
}, null, 2)
|
|
907
|
+
};
|
|
908
|
+
} catch (e: unknown) {
|
|
909
|
+
return { success: false, error: sanitizeToolError(e) };
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
|