enya-agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +20 -0
- package/.github/workflows/ci.yml +70 -0
- package/.github/workflows/publish.yml +250 -0
- package/.gitmodules +3 -0
- package/Cargo.lock +3584 -0
- package/Cargo.toml +97 -0
- package/crates/enact/Cargo.toml +27 -0
- package/crates/enact/src/lib.rs +60 -0
- package/crates/enact-a2a/Cargo.toml +25 -0
- package/crates/enact-a2a/src/lib.rs +411 -0
- package/crates/enact-channels/Cargo.toml +64 -0
- package/crates/enact-channels/examples/README.md +80 -0
- package/crates/enact-channels/examples/channel_bot.rs +169 -0
- package/crates/enact-channels/examples/telegram-echo.rs +34 -0
- package/crates/enact-channels/examples/whatsapp-echo.rs +142 -0
- package/crates/enact-channels/src/config.rs +213 -0
- package/crates/enact-channels/src/lib.rs +25 -0
- package/crates/enact-channels/src/runtime.rs +237 -0
- package/crates/enact-channels/src/security/mod.rs +5 -0
- package/crates/enact-channels/src/security/pairing.rs +205 -0
- package/crates/enact-channels/src/teams.rs +601 -0
- package/crates/enact-channels/src/telegram.rs +2833 -0
- package/crates/enact-channels/src/traits.rs +200 -0
- package/crates/enact-channels/src/webhook.rs +262 -0
- package/crates/enact-channels/src/whatsapp.rs +310 -0
- package/crates/enact-cli/Cargo.toml +40 -0
- package/crates/enact-cli/src/commands/doctor.rs +62 -0
- package/crates/enact-cli/src/commands/mod.rs +3 -0
- package/crates/enact-cli/src/commands/run.rs +69 -0
- package/crates/enact-cli/src/commands/serve.rs +81 -0
- package/crates/enact-cli/src/config.rs +2 -0
- package/crates/enact-cli/src/main.rs +79 -0
- package/crates/enact-config/Cargo.toml +36 -0
- package/crates/enact-config/ENV_VAR_MAPPING.md +135 -0
- package/crates/enact-config/QUICK_REFERENCE.md +92 -0
- package/crates/enact-config/README.md +107 -0
- package/crates/enact-config/TESTING.md +161 -0
- package/crates/enact-config/examples/test-env-vars.rs +100 -0
- package/crates/enact-config/src/config.rs +399 -0
- package/crates/enact-config/src/encrypted_store.rs +211 -0
- package/crates/enact-config/src/lib.rs +298 -0
- package/crates/enact-config/src/secrets.rs +149 -0
- package/crates/enact-config/src/sync.rs +260 -0
- package/crates/enact-config/test-env-vars.sh +34 -0
- package/crates/enact-config/tests/README.md +99 -0
- package/crates/enact-config/tests/config_integration_test.rs +202 -0
- package/crates/enact-config/tests/security_test.rs +140 -0
- package/crates/enact-context/Cargo.toml +41 -0
- package/crates/enact-context/src/budget.rs +314 -0
- package/crates/enact-context/src/calibrator.rs +535 -0
- package/crates/enact-context/src/compactor.rs +392 -0
- package/crates/enact-context/src/condenser.rs +826 -0
- package/crates/enact-context/src/lib.rs +94 -0
- package/crates/enact-context/src/segment.rs +238 -0
- package/crates/enact-context/src/step_context.rs +645 -0
- package/crates/enact-context/src/token_counter.rs +148 -0
- package/crates/enact-context/src/window.rs +372 -0
- package/crates/enact-core/Cargo.toml +42 -0
- package/crates/enact-core/README.md +98 -0
- package/crates/enact-core/src/background/executor.rs +524 -0
- package/crates/enact-core/src/background/mod.rs +48 -0
- package/crates/enact-core/src/background/target_binding.rs +390 -0
- package/crates/enact-core/src/background/trigger.rs +511 -0
- package/crates/enact-core/src/callable/callable.rs +152 -0
- package/crates/enact-core/src/callable/composite.rs +817 -0
- package/crates/enact-core/src/callable/graph.rs +104 -0
- package/crates/enact-core/src/callable/llm.rs +211 -0
- package/crates/enact-core/src/callable/mod.rs +64 -0
- package/crates/enact-core/src/callable/registry.rs +206 -0
- package/crates/enact-core/src/context/execution_context.rs +757 -0
- package/crates/enact-core/src/context/invocation.rs +99 -0
- package/crates/enact-core/src/context/mod.rs +50 -0
- package/crates/enact-core/src/context/tenant.rs +175 -0
- package/crates/enact-core/src/context/trace.rs +127 -0
- package/crates/enact-core/src/flow/conditional.rs +293 -0
- package/crates/enact-core/src/flow/mod.rs +43 -0
- package/crates/enact-core/src/flow/parallel.rs +437 -0
- package/crates/enact-core/src/flow/repeat.rs +534 -0
- package/crates/enact-core/src/flow/sequential.rs +248 -0
- package/crates/enact-core/src/graph/checkpoint.rs +79 -0
- package/crates/enact-core/src/graph/checkpoint_store.rs +76 -0
- package/crates/enact-core/src/graph/compiled.rs +189 -0
- package/crates/enact-core/src/graph/edge.rs +59 -0
- package/crates/enact-core/src/graph/graph_schema.rs +218 -0
- package/crates/enact-core/src/graph/loader.rs +155 -0
- package/crates/enact-core/src/graph/mod.rs +18 -0
- package/crates/enact-core/src/graph/node/function.rs +49 -0
- package/crates/enact-core/src/graph/node/mod.rs +48 -0
- package/crates/enact-core/src/graph/schema.rs +62 -0
- package/crates/enact-core/src/inbox/message.rs +405 -0
- package/crates/enact-core/src/inbox/mod.rs +31 -0
- package/crates/enact-core/src/inbox/store.rs +355 -0
- package/crates/enact-core/src/kernel/artifact/filesystem.rs +546 -0
- package/crates/enact-core/src/kernel/artifact/metadata.rs +283 -0
- package/crates/enact-core/src/kernel/artifact/mod.rs +27 -0
- package/crates/enact-core/src/kernel/artifact/store.rs +427 -0
- package/crates/enact-core/src/kernel/enforcement.rs +1315 -0
- package/crates/enact-core/src/kernel/error.rs +1200 -0
- package/crates/enact-core/src/kernel/event.rs +1394 -0
- package/crates/enact-core/src/kernel/execution_model.rs +831 -0
- package/crates/enact-core/src/kernel/execution_state.rs +189 -0
- package/crates/enact-core/src/kernel/execution_strategy.rs +117 -0
- package/crates/enact-core/src/kernel/ids.rs +2086 -0
- package/crates/enact-core/src/kernel/interrupt.rs +125 -0
- package/crates/enact-core/src/kernel/kernel.rs +1283 -0
- package/crates/enact-core/src/kernel/mod.rs +205 -0
- package/crates/enact-core/src/kernel/persistence/event_store.rs +270 -0
- package/crates/enact-core/src/kernel/persistence/message_store.rs +908 -0
- package/crates/enact-core/src/kernel/persistence/mod.rs +102 -0
- package/crates/enact-core/src/kernel/persistence/state_store.rs +228 -0
- package/crates/enact-core/src/kernel/persistence/vector_store.rs +299 -0
- package/crates/enact-core/src/kernel/reducer.rs +808 -0
- package/crates/enact-core/src/kernel/replay.rs +153 -0
- package/crates/enact-core/src/lib.rs +413 -0
- package/crates/enact-core/src/memory/episodic.rs +0 -0
- package/crates/enact-core/src/memory/mod.rs +6 -0
- package/crates/enact-core/src/memory/semantic.rs +0 -0
- package/crates/enact-core/src/memory/trait.rs +0 -0
- package/crates/enact-core/src/memory/vector_db.rs +0 -0
- package/crates/enact-core/src/memory/working.rs +0 -0
- package/crates/enact-core/src/policy/execution_policy.rs +292 -0
- package/crates/enact-core/src/policy/filters.rs +458 -0
- package/crates/enact-core/src/policy/input_processor.rs +407 -0
- package/crates/enact-core/src/policy/long_running.rs +134 -0
- package/crates/enact-core/src/policy/mod.rs +193 -0
- package/crates/enact-core/src/policy/pii_input.rs +274 -0
- package/crates/enact-core/src/policy/tenant_policy.rs +453 -0
- package/crates/enact-core/src/policy/tool_policy.rs +407 -0
- package/crates/enact-core/src/providers/mod.rs +63 -0
- package/crates/enact-core/src/providers/trait.rs +292 -0
- package/crates/enact-core/src/runner/callbacks.rs +6 -0
- package/crates/enact-core/src/runner/execution_runner.rs +476 -0
- package/crates/enact-core/src/runner/loop.rs +117 -0
- package/crates/enact-core/src/runner/mod.rs +58 -0
- package/crates/enact-core/src/runner/protected_runner.rs +280 -0
- package/crates/enact-core/src/signal/inmemory.rs +231 -0
- package/crates/enact-core/src/signal/mod.rs +108 -0
- package/crates/enact-core/src/streaming/event_logger.rs +195 -0
- package/crates/enact-core/src/streaming/event_stream.rs +1423 -0
- package/crates/enact-core/src/streaming/mod.rs +108 -0
- package/crates/enact-core/src/streaming/pause_cancel.rs +0 -0
- package/crates/enact-core/src/streaming/protected_emitter.rs +173 -0
- package/crates/enact-core/src/streaming/protection/context.rs +136 -0
- package/crates/enact-core/src/streaming/protection/encryption.rs +289 -0
- package/crates/enact-core/src/streaming/protection/mod.rs +43 -0
- package/crates/enact-core/src/streaming/protection/pii_protection.rs +243 -0
- package/crates/enact-core/src/streaming/protection/processor.rs +166 -0
- package/crates/enact-core/src/streaming/sse.rs +0 -0
- package/crates/enact-core/src/telemetry/exporter.rs +0 -0
- package/crates/enact-core/src/telemetry/init.rs +0 -0
- package/crates/enact-core/src/telemetry/mod.rs +49 -0
- package/crates/enact-core/src/telemetry/spans.rs +245 -0
- package/crates/enact-core/src/tool/agent_tool.rs +177 -0
- package/crates/enact-core/src/tool/browser/mod.rs +0 -0
- package/crates/enact-core/src/tool/browser/webdriver.rs +0 -0
- package/crates/enact-core/src/tool/cost.rs +247 -0
- package/crates/enact-core/src/tool/discovery.rs +0 -0
- package/crates/enact-core/src/tool/dispatcher.rs +347 -0
- package/crates/enact-core/src/tool/filesystem.rs +231 -0
- package/crates/enact-core/src/tool/function.rs +99 -0
- package/crates/enact-core/src/tool/git.rs +162 -0
- package/crates/enact-core/src/tool/http.rs +214 -0
- package/crates/enact-core/src/tool/mcp/client.rs +0 -0
- package/crates/enact-core/src/tool/mcp/mod.rs +0 -0
- package/crates/enact-core/src/tool/mod.rs +51 -0
- package/crates/enact-core/src/tool/reasoning/debugging.rs +0 -0
- package/crates/enact-core/src/tool/reasoning/mcts.rs +0 -0
- package/crates/enact-core/src/tool/reasoning/mod.rs +0 -0
- package/crates/enact-core/src/tool/reasoning/sequential.rs +0 -0
- package/crates/enact-core/src/tool/sandbox/dagger.rs +0 -0
- package/crates/enact-core/src/tool/sandbox/mod.rs +0 -0
- package/crates/enact-core/src/tool/shell.rs +147 -0
- package/crates/enact-core/src/tool/trait.rs +33 -0
- package/crates/enact-core/src/tool/web_search.rs +277 -0
- package/crates/enact-core/src/util/config.rs +0 -0
- package/crates/enact-core/src/util/errors.rs +0 -0
- package/crates/enact-core/src/util/mod.rs +6 -0
- package/crates/enact-core/tests/airgapped_e2e_test.rs +291 -0
- package/crates/enact-core/tests/e2e_agentic_loop.rs +119 -0
- package/crates/enact-core/tests/e2e_test.rs +259 -0
- package/crates/enact-core/tests/graph_test.rs +130 -0
- package/crates/enact-core/tests/stream_event_id_validation.rs +435 -0
- package/crates/enact-cron/Cargo.toml +28 -0
- package/crates/enact-cron/src/lib.rs +44 -0
- package/crates/enact-cron/src/schedule.rs +156 -0
- package/crates/enact-cron/src/store.rs +589 -0
- package/crates/enact-cron/src/types.rs +148 -0
- package/crates/enact-gateway/Cargo.toml +31 -0
- package/crates/enact-gateway/README.md +30 -0
- package/crates/enact-gateway/examples/whatsapp-gateway-runner-mock.rs +59 -0
- package/crates/enact-gateway/examples/whatsapp-gateway.rs +42 -0
- package/crates/enact-gateway/src/lib.rs +582 -0
- package/crates/enact-mcp/Cargo.toml +24 -0
- package/crates/enact-mcp/src/lib.rs +178 -0
- package/crates/enact-memory/Cargo.toml +25 -0
- package/crates/enact-memory/src/backend.rs +20 -0
- package/crates/enact-memory/src/chunker.rs +230 -0
- package/crates/enact-memory/src/embeddings.rs +221 -0
- package/crates/enact-memory/src/lib.rs +67 -0
- package/crates/enact-memory/src/markdown.rs +127 -0
- package/crates/enact-memory/src/none.rs +61 -0
- package/crates/enact-memory/src/sqlite.rs +276 -0
- package/crates/enact-memory/src/traits.rs +65 -0
- package/crates/enact-memory/src/vector.rs +198 -0
- package/crates/enact-oauth/Cargo.toml +27 -0
- package/crates/enact-oauth/src/lib.rs +584 -0
- package/crates/enact-observability/Cargo.toml +22 -0
- package/crates/enact-observability/src/lib.rs +197 -0
- package/crates/enact-providers/Cargo.toml +33 -0
- package/crates/enact-providers/examples/hello-agent.rs +33 -0
- package/crates/enact-providers/src/anthropic.rs +182 -0
- package/crates/enact-providers/src/azure.rs +96 -0
- package/crates/enact-providers/src/bridge.rs +221 -0
- package/crates/enact-providers/src/gemini.rs +227 -0
- package/crates/enact-providers/src/http.rs +78 -0
- package/crates/enact-providers/src/lib.rs +53 -0
- package/crates/enact-providers/src/openai_compatible.rs +167 -0
- package/crates/enact-providers/src/openrouter.rs +33 -0
- package/crates/enact-runner/Cargo.toml +24 -0
- package/crates/enact-runner/README.md +76 -0
- package/crates/enact-runner/src/compaction.rs +225 -0
- package/crates/enact-runner/src/config.rs +118 -0
- package/crates/enact-runner/src/lib.rs +63 -0
- package/crates/enact-runner/src/loop_driver.rs +414 -0
- package/crates/enact-runner/src/parser.rs +421 -0
- package/crates/enact-runner/src/retry.rs +262 -0
- package/crates/enact-runner/tests/integration.rs +278 -0
- package/crates/enact-security/Cargo.toml +22 -0
- package/crates/enact-security/src/audit.rs +375 -0
- package/crates/enact-security/src/lib.rs +37 -0
- package/crates/enact-security/src/policy.rs +406 -0
- package/crates/enact-skills/Cargo.toml +25 -0
- package/crates/enact-skills/src/lib.rs +506 -0
- package/crates/enact-tools/Cargo.toml +22 -0
- package/crates/enact-tools/src/file_read.rs +166 -0
- package/crates/enact-tools/src/file_write.rs +216 -0
- package/crates/enact-tools/src/git_operations.rs +513 -0
- package/crates/enact-tools/src/http_request.rs +417 -0
- package/crates/enact-tools/src/lib.rs +104 -0
- package/crates/enact-tools/src/security.rs +227 -0
- package/crates/enact-tools/src/shell.rs +191 -0
- package/crates/enact-tools/src/traits.rs +159 -0
- package/docs/Makefile +74 -0
- package/docs/config.toml +62 -0
- package/docs/content/_index.md +174 -0
- package/docs/content/a2a/_index.md +431 -0
- package/docs/content/api/_index.md +323 -0
- package/docs/content/channels/_index.md +160 -0
- package/docs/content/channels/teams.md +205 -0
- package/docs/content/channels/telegram.md +182 -0
- package/docs/content/channels/webhook.md +423 -0
- package/docs/content/channels/whatsapp.md +240 -0
- package/docs/content/cli/_index.md +261 -0
- package/docs/content/concepts/_index.md +273 -0
- package/docs/content/configuration/_index.md +241 -0
- package/docs/content/cron/_index.md +248 -0
- package/docs/content/developers/_index.md +278 -0
- package/docs/content/getting-started/_index.md +180 -0
- package/docs/content/installation/_index.md +186 -0
- package/docs/content/installation/uninstall.md +101 -0
- package/docs/content/installation/updating.md +120 -0
- package/docs/content/mcp/_index.md +215 -0
- package/docs/content/memory/_index.md +163 -0
- package/docs/content/oauth/_index.md +515 -0
- package/docs/content/providers/_index.md +206 -0
- package/docs/content/roadmap/_index.md +199 -0
- package/docs/content/security/_index.md +219 -0
- package/docs/content/skills/_index.md +228 -0
- package/docs/content/tools/_index.md +485 -0
- package/docs/content/troubleshooting/_index.md +259 -0
- package/docs/content/yaml-schema/_index.md +294 -0
- package/docs/static/giallo-dark.css +91 -0
- package/docs/static/giallo-light.css +91 -0
- package/docs/themes/tanuki/.github/workflows/deploy.yml +44 -0
- package/docs/themes/tanuki/LICENSE +21 -0
- package/docs/themes/tanuki/README.md +166 -0
- package/docs/themes/tanuki/examples/blog/config.toml +58 -0
- package/docs/themes/tanuki/examples/blog/content/_index.md +4 -0
- package/docs/themes/tanuki/examples/blog/content/about.md +33 -0
- package/docs/themes/tanuki/examples/blog/content/blog/_index.md +7 -0
- package/docs/themes/tanuki/examples/blog/content/blog/api-design-best-practices.md +245 -0
- package/docs/themes/tanuki/examples/blog/content/blog/building-accessible-websites.md +147 -0
- package/docs/themes/tanuki/examples/blog/content/blog/css-grid-vs-flexbox.md +165 -0
- package/docs/themes/tanuki/examples/blog/content/blog/customizing-catppuccin-colors.md +137 -0
- package/docs/themes/tanuki/examples/blog/content/blog/dark-mode-best-practices.md +82 -0
- package/docs/themes/tanuki/examples/blog/content/blog/docker-essentials.md +301 -0
- package/docs/themes/tanuki/examples/blog/content/blog/getting-started-with-zola.md +129 -0
- package/docs/themes/tanuki/examples/blog/content/blog/git-workflow-for-content.md +112 -0
- package/docs/themes/tanuki/examples/blog/content/blog/introduction-to-webassembly.md +183 -0
- package/docs/themes/tanuki/examples/blog/content/blog/modern-javascript-features.md +234 -0
- package/docs/themes/tanuki/examples/blog/content/blog/testing-strategies.md +311 -0
- package/docs/themes/tanuki/examples/blog/content/blog/typography-for-developers.md +104 -0
- package/docs/themes/tanuki/examples/blog/content/blog/welcome-to-tanuki.md +67 -0
- package/docs/themes/tanuki/examples/blog/content/blog/why-static-sites.md +85 -0
- package/docs/themes/tanuki/examples/blog/content/projects.md +64 -0
- package/docs/themes/tanuki/examples/book/config.toml +17 -0
- package/docs/themes/tanuki/examples/book/content/_index.md +12 -0
- package/docs/themes/tanuki/examples/book/content/chapter-1.md +90 -0
- package/docs/themes/tanuki/examples/book/content/chapter-2.md +143 -0
- package/docs/themes/tanuki/examples/book/content/chapter-3.md +217 -0
- package/docs/themes/tanuki/examples/book/content/chapter-4.md +224 -0
- package/docs/themes/tanuki/examples/book/content/chapter-5.md +297 -0
- package/docs/themes/tanuki/examples/book/content/print.md +6 -0
- package/docs/themes/tanuki/examples/docs/config.toml +28 -0
- package/docs/themes/tanuki/examples/docs/content/_index.md +20 -0
- package/docs/themes/tanuki/examples/docs/content/components.md +156 -0
- package/docs/themes/tanuki/examples/docs/content/configuration.md +94 -0
- package/docs/themes/tanuki/examples/docs/content/customization.md +202 -0
- package/docs/themes/tanuki/examples/docs/content/deployment.md +204 -0
- package/docs/themes/tanuki/examples/docs/content/installation.md +59 -0
- package/docs/themes/tanuki/examples/docs/content/print.md +6 -0
- package/docs/themes/tanuki/examples/docs/static/img/tanuki-icon.avif +0 -0
- package/docs/themes/tanuki/examples/index.html +2104 -0
- package/docs/themes/tanuki/mise.toml +108 -0
- package/docs/themes/tanuki/sass/base/_catppuccin.scss +164 -0
- package/docs/themes/tanuki/sass/base/_fonts.scss +64 -0
- package/docs/themes/tanuki/sass/base/_reset.scss +152 -0
- package/docs/themes/tanuki/sass/base/_typography.scss +523 -0
- package/docs/themes/tanuki/sass/components/_buttons.scss +209 -0
- package/docs/themes/tanuki/sass/components/_code.scss +457 -0
- package/docs/themes/tanuki/sass/components/_landing.scss +633 -0
- package/docs/themes/tanuki/sass/components/_layout.scss +294 -0
- package/docs/themes/tanuki/sass/components/_navigation.scss +1200 -0
- package/docs/themes/tanuki/sass/components/_print.scss +237 -0
- package/docs/themes/tanuki/sass/components/_search.scss +224 -0
- package/docs/themes/tanuki/sass/components/_sidebar.scss +473 -0
- package/docs/themes/tanuki/sass/components/_theme-toggle.scss +186 -0
- package/docs/themes/tanuki/sass/modes/_blog.scss +366 -0
- package/docs/themes/tanuki/sass/modes/_product.scss +875 -0
- package/docs/themes/tanuki/sass/modes/_raskell.scss +1696 -0
- package/docs/themes/tanuki/sass/patterns/_buttons.scss +183 -0
- package/docs/themes/tanuki/sass/patterns/_cards.scss +144 -0
- package/docs/themes/tanuki/sass/patterns/_index.scss +9 -0
- package/docs/themes/tanuki/sass/patterns/_lists.scss +259 -0
- package/docs/themes/tanuki/sass/patterns/_sections.scss +243 -0
- package/docs/themes/tanuki/sass/style.scss +47 -0
- package/docs/themes/tanuki/sass/tokens/_colors.scss +139 -0
- package/docs/themes/tanuki/sass/tokens/_spacing.scss +100 -0
- package/docs/themes/tanuki/sass/tokens/_typography.scss +186 -0
- package/docs/themes/tanuki/screenshot.png +0 -0
- package/docs/themes/tanuki/sentinel.kdl +59 -0
- package/docs/themes/tanuki/static/elasticlunr.min.js +10 -0
- package/docs/themes/tanuki/static/fonts/GEIST-LICENSE.txt +92 -0
- package/docs/themes/tanuki/static/fonts/Geist-Variable.woff2 +0 -0
- package/docs/themes/tanuki/static/fonts/GeistMono-Variable.woff2 +0 -0
- package/docs/themes/tanuki/static/img/tanuki-icon.avif +0 -0
- package/docs/themes/tanuki/static/img/tanuki-icon.png +0 -0
- package/docs/themes/tanuki/static/js/anchors.js +18 -0
- package/docs/themes/tanuki/static/js/app.js +274 -0
- package/docs/themes/tanuki/static/js/code.js +394 -0
- package/docs/themes/tanuki/static/js/navigation.js +778 -0
- package/docs/themes/tanuki/static/js/scroll-to-top.js +33 -0
- package/docs/themes/tanuki/static/js/search-raskell.js +240 -0
- package/docs/themes/tanuki/static/js/search.js +215 -0
- package/docs/themes/tanuki/static/js/theme.js +169 -0
- package/docs/themes/tanuki/static/syntax-dark.css +151 -0
- package/docs/themes/tanuki/static/syntax-light.css +151 -0
- package/docs/themes/tanuki/static/wasm/sentinel_playground_wasm.js +486 -0
- package/docs/themes/tanuki/static/wasm/sentinel_playground_wasm_bg.wasm +0 -0
- package/docs/themes/tanuki/templates/404.html +52 -0
- package/docs/themes/tanuki/templates/base.html +428 -0
- package/docs/themes/tanuki/templates/blog.html +66 -0
- package/docs/themes/tanuki/templates/home.html +108 -0
- package/docs/themes/tanuki/templates/index.html +178 -0
- package/docs/themes/tanuki/templates/landing.html +168 -0
- package/docs/themes/tanuki/templates/macros/nav.html +128 -0
- package/docs/themes/tanuki/templates/macros/posts.html +101 -0
- package/docs/themes/tanuki/templates/macros/ui.html +159 -0
- package/docs/themes/tanuki/templates/page.html +135 -0
- package/docs/themes/tanuki/templates/partials/footer.html +38 -0
- package/docs/themes/tanuki/templates/partials/header.html +366 -0
- package/docs/themes/tanuki/templates/partials/nav-buttons.html +55 -0
- package/docs/themes/tanuki/templates/partials/nav-overlay.html +81 -0
- package/docs/themes/tanuki/templates/partials/page-toc-panel.html +43 -0
- package/docs/themes/tanuki/templates/partials/search.html +52 -0
- package/docs/themes/tanuki/templates/partials/sidebar.html +107 -0
- package/docs/themes/tanuki/templates/partials/theme-toggle.html +35 -0
- package/docs/themes/tanuki/templates/partials/toc-overlay.html +146 -0
- package/docs/themes/tanuki/templates/partials/version-picker.html +38 -0
- package/docs/themes/tanuki/templates/print.html +244 -0
- package/docs/themes/tanuki/templates/section.html +186 -0
- package/docs/themes/tanuki/templates/taxonomy_list.html +18 -0
- package/docs/themes/tanuki/templates/taxonomy_single.html +31 -0
- package/docs/themes/tanuki/theme.toml +58 -0
- package/examples/hello-agent.rs +55 -0
- package/package.json +36 -0
- package/proto/config.proto +60 -0
- package/proto/events.proto +0 -0
- package/proto/runtime.proto +215 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
+++
|
|
2
|
+
title = "Docker Essentials for Developers"
|
|
3
|
+
description = "Containers changed how we deploy software. Here's what every developer needs to know about Docker."
|
|
4
|
+
date = 2024-12-25
|
|
5
|
+
[taxonomies]
|
|
6
|
+
tags = ["docker", "devops", "containers"]
|
|
7
|
+
+++
|
|
8
|
+
|
|
9
|
+
# Docker Essentials for Developers
|
|
10
|
+
|
|
11
|
+
"Works on my machine" used to be a punchline. Docker makes it a guarantee.
|
|
12
|
+
|
|
13
|
+
## Core Concepts
|
|
14
|
+
|
|
15
|
+
**Image**: A read-only template with your application and dependencies.
|
|
16
|
+
|
|
17
|
+
**Container**: A running instance of an image.
|
|
18
|
+
|
|
19
|
+
**Dockerfile**: Instructions to build an image.
|
|
20
|
+
|
|
21
|
+
**Registry**: Storage for images (Docker Hub, GitHub Container Registry).
|
|
22
|
+
|
|
23
|
+
## Your First Dockerfile
|
|
24
|
+
|
|
25
|
+
For a Node.js application:
|
|
26
|
+
|
|
27
|
+
```dockerfile
|
|
28
|
+
# Start from a base image
|
|
29
|
+
FROM node:20-alpine
|
|
30
|
+
|
|
31
|
+
# Set working directory
|
|
32
|
+
WORKDIR /app
|
|
33
|
+
|
|
34
|
+
# Copy package files first (for caching)
|
|
35
|
+
COPY package*.json ./
|
|
36
|
+
|
|
37
|
+
# Install dependencies
|
|
38
|
+
RUN npm ci --only=production
|
|
39
|
+
|
|
40
|
+
# Copy application code
|
|
41
|
+
COPY . .
|
|
42
|
+
|
|
43
|
+
# Expose the port
|
|
44
|
+
EXPOSE 3000
|
|
45
|
+
|
|
46
|
+
# Run the application
|
|
47
|
+
CMD ["node", "server.js"]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Build and run:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
docker build -t myapp .
|
|
54
|
+
docker run -p 3000:3000 myapp
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Layer Caching
|
|
58
|
+
|
|
59
|
+
Docker caches layers. Order matters:
|
|
60
|
+
|
|
61
|
+
```dockerfile
|
|
62
|
+
# Bad: reinstalls deps on any code change
|
|
63
|
+
COPY . .
|
|
64
|
+
RUN npm install
|
|
65
|
+
|
|
66
|
+
# Good: deps only reinstall when package.json changes
|
|
67
|
+
COPY package*.json ./
|
|
68
|
+
RUN npm install
|
|
69
|
+
COPY . .
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Multi-Stage Builds
|
|
73
|
+
|
|
74
|
+
Keep production images small:
|
|
75
|
+
|
|
76
|
+
```dockerfile
|
|
77
|
+
# Build stage
|
|
78
|
+
FROM node:20 AS builder
|
|
79
|
+
WORKDIR /app
|
|
80
|
+
COPY package*.json ./
|
|
81
|
+
RUN npm ci
|
|
82
|
+
COPY . .
|
|
83
|
+
RUN npm run build
|
|
84
|
+
|
|
85
|
+
# Production stage
|
|
86
|
+
FROM node:20-alpine
|
|
87
|
+
WORKDIR /app
|
|
88
|
+
COPY --from=builder /app/dist ./dist
|
|
89
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
90
|
+
EXPOSE 3000
|
|
91
|
+
CMD ["node", "dist/server.js"]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Result: A fraction of the size.
|
|
95
|
+
|
|
96
|
+
## Docker Compose
|
|
97
|
+
|
|
98
|
+
Define multi-container applications:
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
# docker-compose.yml
|
|
102
|
+
services:
|
|
103
|
+
web:
|
|
104
|
+
build: .
|
|
105
|
+
ports:
|
|
106
|
+
- "3000:3000"
|
|
107
|
+
environment:
|
|
108
|
+
- DATABASE_URL=postgres://db:5432/myapp
|
|
109
|
+
depends_on:
|
|
110
|
+
- db
|
|
111
|
+
|
|
112
|
+
db:
|
|
113
|
+
image: postgres:16-alpine
|
|
114
|
+
environment:
|
|
115
|
+
- POSTGRES_DB=myapp
|
|
116
|
+
- POSTGRES_PASSWORD=secret
|
|
117
|
+
volumes:
|
|
118
|
+
- postgres_data:/var/lib/postgresql/data
|
|
119
|
+
|
|
120
|
+
volumes:
|
|
121
|
+
postgres_data:
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Run everything:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
docker compose up -d
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Essential Commands
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Images
|
|
134
|
+
docker build -t name:tag .
|
|
135
|
+
docker images
|
|
136
|
+
docker rmi image_name
|
|
137
|
+
|
|
138
|
+
# Containers
|
|
139
|
+
docker run -d -p 8080:80 nginx
|
|
140
|
+
docker ps # Running containers
|
|
141
|
+
docker ps -a # All containers
|
|
142
|
+
docker stop container_id
|
|
143
|
+
docker rm container_id
|
|
144
|
+
|
|
145
|
+
# Logs and debugging
|
|
146
|
+
docker logs container_id
|
|
147
|
+
docker logs -f container_id # Follow logs
|
|
148
|
+
docker exec -it container_id sh
|
|
149
|
+
|
|
150
|
+
# Cleanup
|
|
151
|
+
docker system prune # Remove unused data
|
|
152
|
+
docker system prune -a # Remove everything unused
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Volumes: Persistent Data
|
|
156
|
+
|
|
157
|
+
Data inside containers is ephemeral. Use volumes:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Named volume
|
|
161
|
+
docker run -v mydata:/app/data myapp
|
|
162
|
+
|
|
163
|
+
# Bind mount (development)
|
|
164
|
+
docker run -v $(pwd):/app myapp
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
In Compose:
|
|
168
|
+
|
|
169
|
+
```yaml
|
|
170
|
+
services:
|
|
171
|
+
app:
|
|
172
|
+
volumes:
|
|
173
|
+
- ./src:/app/src # Bind mount for hot reload
|
|
174
|
+
- node_modules:/app/node_modules # Named volume
|
|
175
|
+
|
|
176
|
+
volumes:
|
|
177
|
+
node_modules:
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Environment Variables
|
|
181
|
+
|
|
182
|
+
```dockerfile
|
|
183
|
+
# Default value in Dockerfile
|
|
184
|
+
ENV NODE_ENV=production
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Override at runtime:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
docker run -e NODE_ENV=development myapp
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Or use `.env` files with Compose:
|
|
194
|
+
|
|
195
|
+
```yaml
|
|
196
|
+
services:
|
|
197
|
+
app:
|
|
198
|
+
env_file:
|
|
199
|
+
- .env
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Health Checks
|
|
203
|
+
|
|
204
|
+
Let Docker know if your app is healthy:
|
|
205
|
+
|
|
206
|
+
```dockerfile
|
|
207
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
|
|
208
|
+
CMD curl -f http://localhost:3000/health || exit 1
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Security Best Practices
|
|
212
|
+
|
|
213
|
+
### Don't run as root
|
|
214
|
+
|
|
215
|
+
```dockerfile
|
|
216
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
217
|
+
USER appuser
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Use specific image tags
|
|
221
|
+
|
|
222
|
+
```dockerfile
|
|
223
|
+
# Bad: unpredictable
|
|
224
|
+
FROM node:latest
|
|
225
|
+
|
|
226
|
+
# Good: reproducible
|
|
227
|
+
FROM node:20.10-alpine3.18
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Don't store secrets in images
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Bad
|
|
234
|
+
ENV API_KEY=secret123
|
|
235
|
+
|
|
236
|
+
# Good: pass at runtime
|
|
237
|
+
docker run -e API_KEY=$API_KEY myapp
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## .dockerignore
|
|
241
|
+
|
|
242
|
+
Keep images lean:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
node_modules
|
|
246
|
+
.git
|
|
247
|
+
.env
|
|
248
|
+
*.md
|
|
249
|
+
Dockerfile
|
|
250
|
+
docker-compose.yml
|
|
251
|
+
.dockerignore
|
|
252
|
+
coverage
|
|
253
|
+
.nyc_output
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Development Workflow
|
|
257
|
+
|
|
258
|
+
```yaml
|
|
259
|
+
# docker-compose.dev.yml
|
|
260
|
+
services:
|
|
261
|
+
app:
|
|
262
|
+
build:
|
|
263
|
+
context: .
|
|
264
|
+
dockerfile: Dockerfile.dev
|
|
265
|
+
volumes:
|
|
266
|
+
- .:/app
|
|
267
|
+
- /app/node_modules
|
|
268
|
+
environment:
|
|
269
|
+
- NODE_ENV=development
|
|
270
|
+
command: npm run dev
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
docker compose -f docker-compose.dev.yml up
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Debugging Containers
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Shell into running container
|
|
281
|
+
docker exec -it container_id sh
|
|
282
|
+
|
|
283
|
+
# Inspect container details
|
|
284
|
+
docker inspect container_id
|
|
285
|
+
|
|
286
|
+
# View resource usage
|
|
287
|
+
docker stats
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Quick Reference
|
|
291
|
+
|
|
292
|
+
| Task | Command |
|
|
293
|
+
|------|---------|
|
|
294
|
+
| Build image | `docker build -t name .` |
|
|
295
|
+
| Run container | `docker run -d -p 8080:80 name` |
|
|
296
|
+
| View logs | `docker logs -f container` |
|
|
297
|
+
| Shell access | `docker exec -it container sh` |
|
|
298
|
+
| Stop all | `docker stop $(docker ps -q)` |
|
|
299
|
+
| Clean up | `docker system prune -a` |
|
|
300
|
+
|
|
301
|
+
Docker transforms "it works on my machine" into "it works everywhere."
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
+++
|
|
2
|
+
title = "Getting Started with Zola"
|
|
3
|
+
description = "A quick introduction to Zola, the fast static site generator that powers Tanuki."
|
|
4
|
+
date = 2024-12-26
|
|
5
|
+
[taxonomies]
|
|
6
|
+
tags = ["tutorial", "zola"]
|
|
7
|
+
+++
|
|
8
|
+
|
|
9
|
+
# Getting Started with Zola
|
|
10
|
+
|
|
11
|
+
Zola is a fast static site generator written in Rust. It's what powers the Tanuki theme, and it's a joy to work with.
|
|
12
|
+
|
|
13
|
+
## Why Zola?
|
|
14
|
+
|
|
15
|
+
There are many static site generators out there—Jekyll, Hugo, Eleventy, Next.js—so why choose Zola?
|
|
16
|
+
|
|
17
|
+
### Speed
|
|
18
|
+
|
|
19
|
+
Zola is incredibly fast. A typical site builds in milliseconds, not seconds. This makes development pleasant and deployments quick.
|
|
20
|
+
|
|
21
|
+
### Single Binary
|
|
22
|
+
|
|
23
|
+
Unlike Jekyll (Ruby) or Eleventy (Node.js), Zola is a single binary with no dependencies. Download it, run it, done.
|
|
24
|
+
|
|
25
|
+
### Built-in Features
|
|
26
|
+
|
|
27
|
+
Zola includes everything you need out of the box:
|
|
28
|
+
|
|
29
|
+
- Sass compilation
|
|
30
|
+
- Syntax highlighting
|
|
31
|
+
- Search index generation
|
|
32
|
+
- Image processing
|
|
33
|
+
- Shortcodes
|
|
34
|
+
- Taxonomies (tags, categories)
|
|
35
|
+
- Multilingual support
|
|
36
|
+
|
|
37
|
+
No plugins to install, no configuration rabbit holes.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
### macOS (Homebrew)
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
brew install zola
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Linux
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Snap
|
|
51
|
+
snap install zola --edge
|
|
52
|
+
|
|
53
|
+
# Or download from GitHub releases
|
|
54
|
+
wget https://github.com/getzola/zola/releases/download/v0.19.2/zola-v0.19.2-x86_64-unknown-linux-gnu.tar.gz
|
|
55
|
+
tar xzf zola-*.tar.gz
|
|
56
|
+
sudo mv zola /usr/local/bin/
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Windows
|
|
60
|
+
|
|
61
|
+
```powershell
|
|
62
|
+
# Scoop
|
|
63
|
+
scoop install zola
|
|
64
|
+
|
|
65
|
+
# Or Chocolatey
|
|
66
|
+
choco install zola
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Creating a New Site
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
zola init my-site
|
|
73
|
+
cd my-site
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Zola will ask a few questions about your site configuration. Answer them, and you'll have a basic structure:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
my-site/
|
|
80
|
+
├── config.toml
|
|
81
|
+
├── content/
|
|
82
|
+
├── sass/
|
|
83
|
+
├── static/
|
|
84
|
+
├── templates/
|
|
85
|
+
└── themes/
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Adding Content
|
|
89
|
+
|
|
90
|
+
Content goes in the `content/` directory as Markdown files:
|
|
91
|
+
|
|
92
|
+
```markdown
|
|
93
|
+
+++
|
|
94
|
+
title = "My First Post"
|
|
95
|
+
date = 2024-12-27
|
|
96
|
+
+++
|
|
97
|
+
|
|
98
|
+
# Hello, World!
|
|
99
|
+
|
|
100
|
+
This is my first post using Zola.
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The `+++` section is called front matter—it's TOML by default and contains metadata about your page.
|
|
104
|
+
|
|
105
|
+
## Development Server
|
|
106
|
+
|
|
107
|
+
Run the development server:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
zola serve
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Open http://127.0.0.1:1111 and you'll see your site. Changes trigger automatic rebuilds and browser refresh.
|
|
114
|
+
|
|
115
|
+
## Building for Production
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
zola build
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Your complete site will be in the `public/` directory, ready to deploy anywhere.
|
|
122
|
+
|
|
123
|
+
## Next Steps
|
|
124
|
+
|
|
125
|
+
- Read the [Zola documentation](https://www.getzola.org/documentation/)
|
|
126
|
+
- Explore the [Tanuki theme documentation](/docs/)
|
|
127
|
+
- Join the [Zola Discord](https://discord.gg/WN8n6xqp)
|
|
128
|
+
|
|
129
|
+
Happy building!
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
+++
|
|
2
|
+
title = "Git Workflow for Content Teams"
|
|
3
|
+
description = "How to use Git and pull requests to manage content on static sites, even if you're not a developer."
|
|
4
|
+
date = 2024-12-08
|
|
5
|
+
[taxonomies]
|
|
6
|
+
tags = ["git", "workflow", "static-sites"]
|
|
7
|
+
+++
|
|
8
|
+
|
|
9
|
+
# Git Workflow for Content Teams
|
|
10
|
+
|
|
11
|
+
Static sites store content as files in a Git repository. This unlocks powerful workflows for content teams.
|
|
12
|
+
|
|
13
|
+
## Why Git for Content?
|
|
14
|
+
|
|
15
|
+
Traditional CMS platforms have their own versioning, but Git offers:
|
|
16
|
+
|
|
17
|
+
- **Complete history**: Every change is tracked forever
|
|
18
|
+
- **Branching**: Work on drafts without affecting the live site
|
|
19
|
+
- **Review process**: Pull requests for editorial review
|
|
20
|
+
- **Rollback**: Instantly revert any change
|
|
21
|
+
- **Collaboration**: Multiple people can work simultaneously
|
|
22
|
+
|
|
23
|
+
## The Basic Workflow
|
|
24
|
+
|
|
25
|
+
### 1. Create a Branch
|
|
26
|
+
|
|
27
|
+
Never work directly on `main`. Create a branch for your changes:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
git checkout -b post/new-article-title
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 2. Make Your Changes
|
|
34
|
+
|
|
35
|
+
Edit or create Markdown files in the `content/` directory:
|
|
36
|
+
|
|
37
|
+
```markdown
|
|
38
|
+
+++
|
|
39
|
+
title = "My New Article"
|
|
40
|
+
date = 2024-12-08
|
|
41
|
+
+++
|
|
42
|
+
|
|
43
|
+
Article content goes here...
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 3. Commit Your Work
|
|
47
|
+
|
|
48
|
+
Save your changes with a descriptive message:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
git add content/my-new-article.md
|
|
52
|
+
git commit -m "Add article about Git workflows"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 4. Push and Create a Pull Request
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
git push origin post/new-article-title
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Then create a pull request on GitHub for review.
|
|
62
|
+
|
|
63
|
+
### 5. Review and Merge
|
|
64
|
+
|
|
65
|
+
Team members can:
|
|
66
|
+
- Comment on specific lines
|
|
67
|
+
- Suggest edits
|
|
68
|
+
- Preview the changes (with deploy previews)
|
|
69
|
+
- Approve and merge
|
|
70
|
+
|
|
71
|
+
## Deploy Previews
|
|
72
|
+
|
|
73
|
+
Services like Netlify and Vercel create preview URLs for every pull request. This lets editors see exactly how their changes will look before merging.
|
|
74
|
+
|
|
75
|
+
## Branch Naming Conventions
|
|
76
|
+
|
|
77
|
+
Use consistent prefixes:
|
|
78
|
+
|
|
79
|
+
- `post/` - New blog posts
|
|
80
|
+
- `docs/` - Documentation updates
|
|
81
|
+
- `fix/` - Corrections and typos
|
|
82
|
+
- `feature/` - New site features
|
|
83
|
+
|
|
84
|
+
## Handling Conflicts
|
|
85
|
+
|
|
86
|
+
If two people edit the same file:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git pull origin main
|
|
90
|
+
# Resolve conflicts in your editor
|
|
91
|
+
git add .
|
|
92
|
+
git commit -m "Resolve merge conflict"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Tips for Non-Developers
|
|
96
|
+
|
|
97
|
+
1. **Use GitHub's web editor** for simple changes
|
|
98
|
+
2. **Use a desktop app** like GitHub Desktop or VS Code
|
|
99
|
+
3. **Write good commit messages** describing what and why
|
|
100
|
+
4. **Don't fear branches** - they're cheap and easy to delete
|
|
101
|
+
5. **Ask for help** - Git has a learning curve
|
|
102
|
+
|
|
103
|
+
## Automating Quality Checks
|
|
104
|
+
|
|
105
|
+
Add CI checks to catch issues before merge:
|
|
106
|
+
|
|
107
|
+
- Spell checking
|
|
108
|
+
- Link validation
|
|
109
|
+
- Build verification
|
|
110
|
+
- Image optimization
|
|
111
|
+
|
|
112
|
+
Git transforms content management from a black box into a transparent, collaborative process.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
+++
|
|
2
|
+
title = "Introduction to WebAssembly"
|
|
3
|
+
description = "WebAssembly brings near-native performance to the browser. Here's what you need to know to get started."
|
|
4
|
+
date = 2024-12-18
|
|
5
|
+
[taxonomies]
|
|
6
|
+
tags = ["webassembly", "rust", "performance"]
|
|
7
|
+
+++
|
|
8
|
+
|
|
9
|
+
# Introduction to WebAssembly
|
|
10
|
+
|
|
11
|
+
WebAssembly (Wasm) is a binary instruction format that runs in browsers at near-native speed. It's not here to replace JavaScript—it's here to complement it.
|
|
12
|
+
|
|
13
|
+
## Why WebAssembly?
|
|
14
|
+
|
|
15
|
+
JavaScript is incredibly versatile, but some tasks need more performance:
|
|
16
|
+
|
|
17
|
+
- **Image/video processing**
|
|
18
|
+
- **Games and 3D graphics**
|
|
19
|
+
- **Compression/encryption**
|
|
20
|
+
- **Scientific computing**
|
|
21
|
+
- **CAD applications**
|
|
22
|
+
|
|
23
|
+
WebAssembly handles these without plugins or browser extensions.
|
|
24
|
+
|
|
25
|
+
## How It Works
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Source Code → Compiler → .wasm binary → Browser Runtime
|
|
29
|
+
(Rust, C++) (portable) (sandboxed)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The browser downloads the `.wasm` file and executes it in a secure sandbox alongside JavaScript.
|
|
33
|
+
|
|
34
|
+
## Your First WebAssembly (with Rust)
|
|
35
|
+
|
|
36
|
+
### 1. Set Up
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Install the Wasm target
|
|
40
|
+
rustup target add wasm32-unknown-unknown
|
|
41
|
+
|
|
42
|
+
# Install wasm-pack
|
|
43
|
+
cargo install wasm-pack
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Create a Project
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cargo new --lib hello-wasm
|
|
50
|
+
cd hello-wasm
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Configure Cargo.toml
|
|
54
|
+
|
|
55
|
+
```toml
|
|
56
|
+
[package]
|
|
57
|
+
name = "hello-wasm"
|
|
58
|
+
version = "0.1.0"
|
|
59
|
+
edition = "2021"
|
|
60
|
+
|
|
61
|
+
[lib]
|
|
62
|
+
crate-type = ["cdylib"]
|
|
63
|
+
|
|
64
|
+
[dependencies]
|
|
65
|
+
wasm-bindgen = "0.2"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 4. Write Rust Code
|
|
69
|
+
|
|
70
|
+
```rust
|
|
71
|
+
use wasm_bindgen::prelude::*;
|
|
72
|
+
|
|
73
|
+
#[wasm_bindgen]
|
|
74
|
+
pub fn greet(name: &str) -> String {
|
|
75
|
+
format!("Hello, {}!", name)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#[wasm_bindgen]
|
|
79
|
+
pub fn fibonacci(n: u32) -> u32 {
|
|
80
|
+
match n {
|
|
81
|
+
0 => 0,
|
|
82
|
+
1 => 1,
|
|
83
|
+
_ => fibonacci(n - 1) + fibonacci(n - 2),
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 5. Build
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
wasm-pack build --target web
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 6. Use in JavaScript
|
|
95
|
+
|
|
96
|
+
```html
|
|
97
|
+
<script type="module">
|
|
98
|
+
import init, { greet, fibonacci } from './pkg/hello_wasm.js';
|
|
99
|
+
|
|
100
|
+
async function main() {
|
|
101
|
+
await init();
|
|
102
|
+
console.log(greet("World"));
|
|
103
|
+
console.log(fibonacci(40)); // Much faster than JS
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
main();
|
|
107
|
+
</script>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Performance Comparison
|
|
111
|
+
|
|
112
|
+
Computing Fibonacci(45):
|
|
113
|
+
|
|
114
|
+
| Language | Time |
|
|
115
|
+
|----------|------|
|
|
116
|
+
| JavaScript | ~8 seconds |
|
|
117
|
+
| WebAssembly (Rust) | ~4 seconds |
|
|
118
|
+
| Native Rust | ~3 seconds |
|
|
119
|
+
|
|
120
|
+
For compute-heavy tasks, Wasm can be 2-10x faster than JavaScript.
|
|
121
|
+
|
|
122
|
+
## Real-World Use Cases
|
|
123
|
+
|
|
124
|
+
### Figma
|
|
125
|
+
The design tool uses WebAssembly for its rendering engine, enabling smooth performance with complex designs.
|
|
126
|
+
|
|
127
|
+
### Photoshop Web
|
|
128
|
+
Adobe ported significant portions of Photoshop to Wasm for the web version.
|
|
129
|
+
|
|
130
|
+
### Google Earth
|
|
131
|
+
Complex 3D rendering runs smoothly thanks to WebAssembly.
|
|
132
|
+
|
|
133
|
+
### SQLite in the Browser
|
|
134
|
+
The entire SQLite database engine compiled to Wasm.
|
|
135
|
+
|
|
136
|
+
## Interacting with the DOM
|
|
137
|
+
|
|
138
|
+
WebAssembly can't directly access the DOM—it must go through JavaScript:
|
|
139
|
+
|
|
140
|
+
```rust
|
|
141
|
+
use wasm_bindgen::prelude::*;
|
|
142
|
+
use web_sys::console;
|
|
143
|
+
|
|
144
|
+
#[wasm_bindgen(start)]
|
|
145
|
+
pub fn main() {
|
|
146
|
+
console::log_1(&"Hello from Wasm!".into());
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```toml
|
|
151
|
+
# Add to Cargo.toml
|
|
152
|
+
[dependencies.web-sys]
|
|
153
|
+
version = "0.3"
|
|
154
|
+
features = ["console"]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Memory Management
|
|
158
|
+
|
|
159
|
+
Wasm has its own linear memory that JavaScript can read:
|
|
160
|
+
|
|
161
|
+
```rust
|
|
162
|
+
#[wasm_bindgen]
|
|
163
|
+
pub fn process_image(data: &[u8]) -> Vec<u8> {
|
|
164
|
+
// Process and return new data
|
|
165
|
+
data.iter().map(|&x| 255 - x).collect()
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## When NOT to Use WebAssembly
|
|
170
|
+
|
|
171
|
+
- **Simple DOM manipulation**: JavaScript is faster to develop
|
|
172
|
+
- **Small utilities**: The Wasm overhead isn't worth it
|
|
173
|
+
- **I/O-bound tasks**: Network/file operations are limited by the browser
|
|
174
|
+
- **When bundle size matters**: Wasm adds payload
|
|
175
|
+
|
|
176
|
+
## The Future
|
|
177
|
+
|
|
178
|
+
- **WASI**: WebAssembly System Interface for running outside browsers
|
|
179
|
+
- **Component Model**: Better interoperability between Wasm modules
|
|
180
|
+
- **Garbage Collection**: Native GC support coming soon
|
|
181
|
+
- **Threads**: Shared memory and threading support
|
|
182
|
+
|
|
183
|
+
WebAssembly isn't just for browsers anymore—it's becoming a universal runtime.
|