synabun 1.3.0 → 2.0.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +197 -662
- package/LICENSE-COMMERCIAL.md +33 -0
- package/NOTICE +17 -0
- package/README.md +175 -853
- package/THIRD-PARTY-LICENSES.md +131 -0
- package/benchmarks/browser-live-results.json +79 -0
- package/benchmarks/browser-v2-results.json +258 -0
- package/benchmarks/fixtures/browser/README.md +57 -0
- package/benchmarks/fixtures/browser/page-state.json +132 -0
- package/benchmarks/fixtures/browser/social.json +92 -0
- package/benchmarks/fixtures/browser/target.json +319 -0
- package/benchmarks/fixtures/desktop/README.md +58 -0
- package/benchmarks/fixtures/desktop/abstention.json +59 -0
- package/benchmarks/fixtures/desktop/adversarial.json +22 -0
- package/benchmarks/fixtures/desktop/forbidden.json +93 -0
- package/benchmarks/fixtures/desktop/generate.mjs +1023 -0
- package/benchmarks/fixtures/desktop/target.json +136 -0
- package/bin/synabun.js +30 -0
- package/docs/browser-v2.md +109 -0
- package/docs/hook-integrity.md +89 -0
- package/docs/judgments.md +182 -0
- package/docs/style-guide.md +246 -0
- package/docs/whatsapp.md +325 -0
- package/hooks/claude-code/post-plan.mjs +613 -391
- package/hooks/claude-code/post-remember.mjs +246 -122
- package/hooks/claude-code/pre-compact.mjs +171 -110
- package/hooks/claude-code/pre-task.mjs +133 -0
- package/hooks/claude-code/pre-websearch.mjs +15 -4
- package/hooks/claude-code/prompt-origin.mjs +94 -0
- package/hooks/claude-code/prompt-submit.mjs +1244 -861
- package/hooks/claude-code/session-start.mjs +114 -156
- package/hooks/claude-code/shared.mjs +1228 -368
- package/hooks/claude-code/state.mjs +167 -0
- package/hooks/claude-code/stop.mjs +515 -140
- package/hooks/claude-code/subagent-start.mjs +154 -0
- package/hooks/claude-code/subagent-stop.mjs +102 -0
- package/hooks/claude-code/task-gate.mjs +150 -0
- package/lib/claude-hooks.js +84 -0
- package/lib/claude-usage-audit.js +141 -0
- package/lib/client-config-repair.js +144 -0
- package/lib/data-home-migration.js +498 -0
- package/lib/first-launch-protection.js +240 -0
- package/lib/paths.d.ts +21 -0
- package/lib/paths.js +103 -0
- package/mcp-server/dist/config.d.ts +22 -0
- package/mcp-server/dist/config.d.ts.map +1 -0
- package/mcp-server/dist/config.js +109 -0
- package/mcp-server/dist/config.js.map +1 -0
- package/mcp-server/dist/http.d.ts +30 -0
- package/mcp-server/dist/http.d.ts.map +1 -0
- package/mcp-server/dist/http.js +276 -0
- package/mcp-server/dist/http.js.map +1 -0
- package/mcp-server/dist/index.d.ts +48 -0
- package/mcp-server/dist/index.d.ts.map +1 -0
- package/mcp-server/dist/index.js +538 -0
- package/mcp-server/dist/index.js.map +1 -0
- package/mcp-server/dist/preload-http.d.ts +3 -0
- package/mcp-server/dist/preload-http.d.ts.map +1 -0
- package/mcp-server/dist/preload-http.js +28 -0
- package/mcp-server/dist/preload-http.js.map +1 -0
- package/mcp-server/dist/preload.d.ts +3 -0
- package/mcp-server/dist/preload.d.ts.map +1 -0
- package/mcp-server/dist/preload.js +32 -0
- package/mcp-server/dist/preload.js.map +1 -0
- package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.d.ts +19 -0
- package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.d.ts.map +1 -0
- package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.js +403 -0
- package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.js.map +1 -0
- package/mcp-server/dist/scripts/setup-embeddings.d.ts +3 -0
- package/mcp-server/dist/scripts/setup-embeddings.d.ts.map +1 -0
- package/mcp-server/dist/scripts/setup-embeddings.js +15 -0
- package/mcp-server/dist/scripts/setup-embeddings.js.map +1 -0
- package/mcp-server/dist/services/assistant-judgments.d.ts +79 -0
- package/mcp-server/dist/services/assistant-judgments.d.ts.map +1 -0
- package/mcp-server/dist/services/assistant-judgments.js +128 -0
- package/mcp-server/dist/services/assistant-judgments.js.map +1 -0
- package/mcp-server/dist/services/browser-assist-gate.d.ts +314 -0
- package/mcp-server/dist/services/browser-assist-gate.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-assist-gate.js +344 -0
- package/mcp-server/dist/services/browser-assist-gate.js.map +1 -0
- package/mcp-server/dist/services/browser-assist.d.ts +104 -0
- package/mcp-server/dist/services/browser-assist.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-assist.js +282 -0
- package/mcp-server/dist/services/browser-assist.js.map +1 -0
- package/mcp-server/dist/services/browser-bench.d.ts +772 -0
- package/mcp-server/dist/services/browser-bench.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-bench.js +424 -0
- package/mcp-server/dist/services/browser-bench.js.map +1 -0
- package/mcp-server/dist/services/browser-judgments.d.ts +196 -0
- package/mcp-server/dist/services/browser-judgments.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-judgments.js +363 -0
- package/mcp-server/dist/services/browser-judgments.js.map +1 -0
- package/mcp-server/dist/services/browser-risk.d.ts +166 -0
- package/mcp-server/dist/services/browser-risk.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-risk.js +458 -0
- package/mcp-server/dist/services/browser-risk.js.map +1 -0
- package/mcp-server/dist/services/categories.d.ts +61 -0
- package/mcp-server/dist/services/categories.d.ts.map +1 -0
- package/mcp-server/dist/services/categories.js +377 -0
- package/mcp-server/dist/services/categories.js.map +1 -0
- package/mcp-server/dist/services/codex-config-heal.d.ts +49 -0
- package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -0
- package/mcp-server/dist/services/codex-config-heal.js +346 -0
- package/mcp-server/dist/services/codex-config-heal.js.map +1 -0
- package/mcp-server/dist/services/desktop-assist-gate.d.ts +198 -0
- package/mcp-server/dist/services/desktop-assist-gate.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-assist-gate.js +202 -0
- package/mcp-server/dist/services/desktop-assist-gate.js.map +1 -0
- package/mcp-server/dist/services/desktop-assist.d.ts +104 -0
- package/mcp-server/dist/services/desktop-assist.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-assist.js +266 -0
- package/mcp-server/dist/services/desktop-assist.js.map +1 -0
- package/mcp-server/dist/services/desktop-bench.d.ts +553 -0
- package/mcp-server/dist/services/desktop-bench.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-bench.js +311 -0
- package/mcp-server/dist/services/desktop-bench.js.map +1 -0
- package/mcp-server/dist/services/desktop-client.d.ts +23 -0
- package/mcp-server/dist/services/desktop-client.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-client.js +79 -0
- package/mcp-server/dist/services/desktop-client.js.map +1 -0
- package/mcp-server/dist/services/desktop-judgments.d.ts +125 -0
- package/mcp-server/dist/services/desktop-judgments.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-judgments.js +177 -0
- package/mcp-server/dist/services/desktop-judgments.js.map +1 -0
- package/mcp-server/dist/services/desktop-risk.d.ts +283 -0
- package/mcp-server/dist/services/desktop-risk.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-risk.js +605 -0
- package/mcp-server/dist/services/desktop-risk.js.map +1 -0
- package/mcp-server/dist/services/discord.d.ts +112 -0
- package/mcp-server/dist/services/discord.d.ts.map +1 -0
- package/mcp-server/dist/services/discord.js +477 -0
- package/mcp-server/dist/services/discord.js.map +1 -0
- package/mcp-server/dist/services/edit-stale.d.ts +81 -0
- package/mcp-server/dist/services/edit-stale.d.ts.map +1 -0
- package/mcp-server/dist/services/edit-stale.js +358 -0
- package/mcp-server/dist/services/edit-stale.js.map +1 -0
- package/mcp-server/dist/services/embedding-service.d.ts +16 -0
- package/mcp-server/dist/services/embedding-service.d.ts.map +1 -0
- package/mcp-server/dist/services/embedding-service.js +126 -0
- package/mcp-server/dist/services/embedding-service.js.map +1 -0
- package/mcp-server/dist/services/embedding-worker.d.ts +2 -0
- package/mcp-server/dist/services/embedding-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/embedding-worker.js +52 -0
- package/mcp-server/dist/services/embedding-worker.js.map +1 -0
- package/mcp-server/dist/services/fb-regions.d.ts +71 -0
- package/mcp-server/dist/services/fb-regions.d.ts.map +1 -0
- package/mcp-server/dist/services/fb-regions.js +211 -0
- package/mcp-server/dist/services/fb-regions.js.map +1 -0
- package/mcp-server/dist/services/file-checksums.d.ts +22 -0
- package/mcp-server/dist/services/file-checksums.d.ts.map +1 -0
- package/mcp-server/dist/services/file-checksums.js +55 -0
- package/mcp-server/dist/services/file-checksums.js.map +1 -0
- package/mcp-server/dist/services/file-excerpt.d.ts +24 -0
- package/mcp-server/dist/services/file-excerpt.d.ts.map +1 -0
- package/mcp-server/dist/services/file-excerpt.js +65 -0
- package/mcp-server/dist/services/file-excerpt.js.map +1 -0
- package/mcp-server/dist/services/identity.d.ts +124 -0
- package/mcp-server/dist/services/identity.d.ts.map +1 -0
- package/mcp-server/dist/services/identity.js +241 -0
- package/mcp-server/dist/services/identity.js.map +1 -0
- package/mcp-server/dist/services/local-embeddings.d.ts +2 -0
- package/mcp-server/dist/services/local-embeddings.d.ts.map +1 -0
- package/mcp-server/dist/services/local-embeddings.js +3 -0
- package/mcp-server/dist/services/local-embeddings.js.map +1 -0
- package/mcp-server/dist/services/memory-client.d.ts +4 -0
- package/mcp-server/dist/services/memory-client.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-client.js +27 -0
- package/mcp-server/dist/services/memory-client.js.map +1 -0
- package/mcp-server/dist/services/memory-judge-backfill.d.ts +135 -0
- package/mcp-server/dist/services/memory-judge-backfill.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-judge-backfill.js +510 -0
- package/mcp-server/dist/services/memory-judge-backfill.js.map +1 -0
- package/mcp-server/dist/services/memory-judgments.d.ts +362 -0
- package/mcp-server/dist/services/memory-judgments.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-judgments.js +674 -0
- package/mcp-server/dist/services/memory-judgments.js.map +1 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts +108 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-maintenance.js +403 -0
- package/mcp-server/dist/services/memory-maintenance.js.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts +66 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.js +412 -0
- package/mcp-server/dist/services/memory-retrieval.js.map +1 -0
- package/mcp-server/dist/services/memory-schema.d.ts +16 -0
- package/mcp-server/dist/services/memory-schema.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-schema.js +282 -0
- package/mcp-server/dist/services/memory-schema.js.map +1 -0
- package/mcp-server/dist/services/memory-sessions.d.ts +24 -0
- package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-sessions.js +110 -0
- package/mcp-server/dist/services/memory-sessions.js.map +1 -0
- package/mcp-server/dist/services/memory-triage.d.ts +60 -0
- package/mcp-server/dist/services/memory-triage.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-triage.js +189 -0
- package/mcp-server/dist/services/memory-triage.js.map +1 -0
- package/mcp-server/dist/services/memory-verification.d.ts +24 -0
- package/mcp-server/dist/services/memory-verification.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-verification.js +92 -0
- package/mcp-server/dist/services/memory-verification.js.map +1 -0
- package/mcp-server/dist/services/memory-writer.d.ts +26 -0
- package/mcp-server/dist/services/memory-writer.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-writer.js +126 -0
- package/mcp-server/dist/services/memory-writer.js.map +1 -0
- package/mcp-server/dist/services/neural-interface.d.ts +439 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -0
- package/mcp-server/dist/services/neural-interface.js +1135 -0
- package/mcp-server/dist/services/neural-interface.js.map +1 -0
- package/mcp-server/dist/services/profiles.d.ts +120 -0
- package/mcp-server/dist/services/profiles.d.ts.map +1 -0
- package/mcp-server/dist/services/profiles.js +387 -0
- package/mcp-server/dist/services/profiles.js.map +1 -0
- package/mcp-server/dist/services/secret-gate.d.ts +29 -0
- package/mcp-server/dist/services/secret-gate.d.ts.map +1 -0
- package/mcp-server/dist/services/secret-gate.js +43 -0
- package/mcp-server/dist/services/secret-gate.js.map +1 -0
- package/mcp-server/dist/services/server-instructions.d.ts +10 -0
- package/mcp-server/dist/services/server-instructions.d.ts.map +1 -0
- package/mcp-server/dist/services/server-instructions.js +101 -0
- package/mcp-server/dist/services/server-instructions.js.map +1 -0
- package/mcp-server/dist/services/sqlite.d.ts +235 -0
- package/mcp-server/dist/services/sqlite.d.ts.map +1 -0
- package/mcp-server/dist/services/sqlite.js +1185 -0
- package/mcp-server/dist/services/sqlite.js.map +1 -0
- package/mcp-server/dist/services/typesafe-bench.d.ts +99 -0
- package/mcp-server/dist/services/typesafe-bench.d.ts.map +1 -0
- package/mcp-server/dist/services/typesafe-bench.js +218 -0
- package/mcp-server/dist/services/typesafe-bench.js.map +1 -0
- package/mcp-server/dist/services/typesafe-config.d.ts +342 -0
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -0
- package/mcp-server/dist/services/typesafe-config.js +746 -0
- package/mcp-server/dist/services/typesafe-config.js.map +1 -0
- package/mcp-server/dist/services/typesafe.d.ts +213 -0
- package/mcp-server/dist/services/typesafe.d.ts.map +1 -0
- package/mcp-server/dist/services/typesafe.js +330 -0
- package/mcp-server/dist/services/typesafe.js.map +1 -0
- package/mcp-server/dist/services/vector-cache.d.ts +68 -0
- package/mcp-server/dist/services/vector-cache.d.ts.map +1 -0
- package/mcp-server/dist/services/vector-cache.js +271 -0
- package/mcp-server/dist/services/vector-cache.js.map +1 -0
- package/mcp-server/dist/services/whiteboard-geometry.d.ts +305 -0
- package/mcp-server/dist/services/whiteboard-geometry.d.ts.map +1 -0
- package/mcp-server/dist/services/whiteboard-geometry.js +666 -0
- package/mcp-server/dist/services/whiteboard-geometry.js.map +1 -0
- package/mcp-server/dist/tools/agents.d.ts +212 -0
- package/mcp-server/dist/tools/agents.d.ts.map +1 -0
- package/mcp-server/dist/tools/agents.js +407 -0
- package/mcp-server/dist/tools/agents.js.map +1 -0
- package/mcp-server/dist/tools/bluesky.d.ts +39 -0
- package/mcp-server/dist/tools/bluesky.d.ts.map +1 -0
- package/mcp-server/dist/tools/bluesky.js +1144 -0
- package/mcp-server/dist/tools/bluesky.js.map +1 -0
- package/mcp-server/dist/tools/browser-advanced.d.ts +58 -0
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-advanced.js +106 -0
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -0
- package/mcp-server/dist/tools/browser-batch.d.ts +99 -0
- package/mcp-server/dist/tools/browser-batch.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-batch.js +187 -0
- package/mcp-server/dist/tools/browser-batch.js.map +1 -0
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts +21 -0
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-cheatsheet.js +144 -0
- package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -0
- package/mcp-server/dist/tools/browser-interact.d.ts +239 -0
- package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-interact.js +300 -0
- package/mcp-server/dist/tools/browser-interact.js.map +1 -0
- package/mcp-server/dist/tools/browser-navigate.d.ts +90 -0
- package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-navigate.js +142 -0
- package/mcp-server/dist/tools/browser-navigate.js.map +1 -0
- package/mcp-server/dist/tools/browser-observe.d.ts +561 -0
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-observe.js +2009 -0
- package/mcp-server/dist/tools/browser-observe.js.map +1 -0
- package/mcp-server/dist/tools/browser.d.ts +34 -0
- package/mcp-server/dist/tools/browser.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser.js +112 -0
- package/mcp-server/dist/tools/browser.js.map +1 -0
- package/mcp-server/dist/tools/card-tools.d.ts +82 -0
- package/mcp-server/dist/tools/card-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/card-tools.js +137 -0
- package/mcp-server/dist/tools/card-tools.js.map +1 -0
- package/mcp-server/dist/tools/card.d.ts +8 -0
- package/mcp-server/dist/tools/card.d.ts.map +1 -0
- package/mcp-server/dist/tools/card.js +16 -0
- package/mcp-server/dist/tools/card.js.map +1 -0
- package/mcp-server/dist/tools/category.d.ts +32 -0
- package/mcp-server/dist/tools/category.d.ts.map +1 -0
- package/mcp-server/dist/tools/category.js +290 -0
- package/mcp-server/dist/tools/category.js.map +1 -0
- package/mcp-server/dist/tools/choice.d.ts +160 -0
- package/mcp-server/dist/tools/choice.d.ts.map +1 -0
- package/mcp-server/dist/tools/choice.js +80 -0
- package/mcp-server/dist/tools/choice.js.map +1 -0
- package/mcp-server/dist/tools/computer.d.ts +71 -0
- package/mcp-server/dist/tools/computer.d.ts.map +1 -0
- package/mcp-server/dist/tools/computer.js +174 -0
- package/mcp-server/dist/tools/computer.js.map +1 -0
- package/mcp-server/dist/tools/discord-channel.d.ts +44 -0
- package/mcp-server/dist/tools/discord-channel.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-channel.js +236 -0
- package/mcp-server/dist/tools/discord-channel.js.map +1 -0
- package/mcp-server/dist/tools/discord-guild.d.ts +20 -0
- package/mcp-server/dist/tools/discord-guild.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-guild.js +138 -0
- package/mcp-server/dist/tools/discord-guild.js.map +1 -0
- package/mcp-server/dist/tools/discord-member.d.ts +26 -0
- package/mcp-server/dist/tools/discord-member.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-member.js +122 -0
- package/mcp-server/dist/tools/discord-member.js.map +1 -0
- package/mcp-server/dist/tools/discord-message.d.ts +36 -0
- package/mcp-server/dist/tools/discord-message.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-message.js +184 -0
- package/mcp-server/dist/tools/discord-message.js.map +1 -0
- package/mcp-server/dist/tools/discord-onboarding.d.ts +32 -0
- package/mcp-server/dist/tools/discord-onboarding.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-onboarding.js +179 -0
- package/mcp-server/dist/tools/discord-onboarding.js.map +1 -0
- package/mcp-server/dist/tools/discord-role.d.ts +34 -0
- package/mcp-server/dist/tools/discord-role.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-role.js +178 -0
- package/mcp-server/dist/tools/discord-role.js.map +1 -0
- package/mcp-server/dist/tools/discord-thread.d.ts +28 -0
- package/mcp-server/dist/tools/discord-thread.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-thread.js +88 -0
- package/mcp-server/dist/tools/discord-thread.js.map +1 -0
- package/mcp-server/dist/tools/discord-webhook.d.ts +32 -0
- package/mcp-server/dist/tools/discord-webhook.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-webhook.js +154 -0
- package/mcp-server/dist/tools/discord-webhook.js.map +1 -0
- package/mcp-server/dist/tools/discord.d.ts +7 -0
- package/mcp-server/dist/tools/discord.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord.js +25 -0
- package/mcp-server/dist/tools/discord.js.map +1 -0
- package/mcp-server/dist/tools/fb-groups.d.ts +98 -0
- package/mcp-server/dist/tools/fb-groups.d.ts.map +1 -0
- package/mcp-server/dist/tools/fb-groups.js +369 -0
- package/mcp-server/dist/tools/fb-groups.js.map +1 -0
- package/mcp-server/dist/tools/forget.d.ts +14 -0
- package/mcp-server/dist/tools/forget.d.ts.map +1 -0
- package/mcp-server/dist/tools/forget.js +26 -0
- package/mcp-server/dist/tools/forget.js.map +1 -0
- package/mcp-server/dist/tools/git-tools.d.ts +24 -0
- package/mcp-server/dist/tools/git-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/git-tools.js +107 -0
- package/mcp-server/dist/tools/git-tools.js.map +1 -0
- package/mcp-server/dist/tools/git.d.ts +7 -0
- package/mcp-server/dist/tools/git.d.ts.map +1 -0
- package/mcp-server/dist/tools/git.js +11 -0
- package/mcp-server/dist/tools/git.js.map +1 -0
- package/mcp-server/dist/tools/gsc/experience.d.ts +135 -0
- package/mcp-server/dist/tools/gsc/experience.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/experience.js +351 -0
- package/mcp-server/dist/tools/gsc/experience.js.map +1 -0
- package/mcp-server/dist/tools/gsc/helpers.d.ts +78 -0
- package/mcp-server/dist/tools/gsc/helpers.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/helpers.js +258 -0
- package/mcp-server/dist/tools/gsc/helpers.js.map +1 -0
- package/mcp-server/dist/tools/gsc/indexing.d.ts +121 -0
- package/mcp-server/dist/tools/gsc/indexing.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/indexing.js +357 -0
- package/mcp-server/dist/tools/gsc/indexing.js.map +1 -0
- package/mcp-server/dist/tools/gsc/inspect.d.ts +78 -0
- package/mcp-server/dist/tools/gsc/inspect.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/inspect.js +321 -0
- package/mcp-server/dist/tools/gsc/inspect.js.map +1 -0
- package/mcp-server/dist/tools/gsc/navigate.d.ts +44 -0
- package/mcp-server/dist/tools/gsc/navigate.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/navigate.js +197 -0
- package/mcp-server/dist/tools/gsc/navigate.js.map +1 -0
- package/mcp-server/dist/tools/gsc/performance.d.ts +84 -0
- package/mcp-server/dist/tools/gsc/performance.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/performance.js +274 -0
- package/mcp-server/dist/tools/gsc/performance.js.map +1 -0
- package/mcp-server/dist/tools/gsc/settings.d.ts +153 -0
- package/mcp-server/dist/tools/gsc/settings.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/settings.js +425 -0
- package/mcp-server/dist/tools/gsc/settings.js.map +1 -0
- package/mcp-server/dist/tools/gsc.d.ts +7 -0
- package/mcp-server/dist/tools/gsc.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc.js +51 -0
- package/mcp-server/dist/tools/gsc.js.map +1 -0
- package/mcp-server/dist/tools/image-tools.d.ts +24 -0
- package/mcp-server/dist/tools/image-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/image-tools.js +80 -0
- package/mcp-server/dist/tools/image-tools.js.map +1 -0
- package/mcp-server/dist/tools/image.d.ts +10 -0
- package/mcp-server/dist/tools/image.d.ts.map +1 -0
- package/mcp-server/dist/tools/image.js +14 -0
- package/mcp-server/dist/tools/image.js.map +1 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.d.ts +97 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.js +228 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.js.map +1 -0
- package/mcp-server/dist/tools/leonardo.d.ts +13 -0
- package/mcp-server/dist/tools/leonardo.d.ts.map +1 -0
- package/mcp-server/dist/tools/leonardo.js +21 -0
- package/mcp-server/dist/tools/leonardo.js.map +1 -0
- package/mcp-server/dist/tools/loop.d.ts +30 -0
- package/mcp-server/dist/tools/loop.d.ts.map +1 -0
- package/mcp-server/dist/tools/loop.js +401 -0
- package/mcp-server/dist/tools/loop.js.map +1 -0
- package/mcp-server/dist/tools/memories.d.ts +56 -0
- package/mcp-server/dist/tools/memories.d.ts.map +1 -0
- package/mcp-server/dist/tools/memories.js +171 -0
- package/mcp-server/dist/tools/memories.js.map +1 -0
- package/mcp-server/dist/tools/morelogin.d.ts +24 -0
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -0
- package/mcp-server/dist/tools/morelogin.js +79 -0
- package/mcp-server/dist/tools/morelogin.js.map +1 -0
- package/mcp-server/dist/tools/profile.d.ts +17 -0
- package/mcp-server/dist/tools/profile.d.ts.map +1 -0
- package/mcp-server/dist/tools/profile.js +114 -0
- package/mcp-server/dist/tools/profile.js.map +1 -0
- package/mcp-server/dist/tools/recall.d.ts +71 -0
- package/mcp-server/dist/tools/recall.d.ts.map +1 -0
- package/mcp-server/dist/tools/recall.js +147 -0
- package/mcp-server/dist/tools/recall.js.map +1 -0
- package/mcp-server/dist/tools/reflect.d.ts +56 -0
- package/mcp-server/dist/tools/reflect.d.ts.map +1 -0
- package/mcp-server/dist/tools/reflect.js +157 -0
- package/mcp-server/dist/tools/reflect.js.map +1 -0
- package/mcp-server/dist/tools/remember.d.ts +62 -0
- package/mcp-server/dist/tools/remember.d.ts.map +1 -0
- package/mcp-server/dist/tools/remember.js +201 -0
- package/mcp-server/dist/tools/remember.js.map +1 -0
- package/mcp-server/dist/tools/response.d.ts +23 -0
- package/mcp-server/dist/tools/response.d.ts.map +1 -0
- package/mcp-server/dist/tools/response.js +24 -0
- package/mcp-server/dist/tools/response.js.map +1 -0
- package/mcp-server/dist/tools/restore.d.ts +14 -0
- package/mcp-server/dist/tools/restore.d.ts.map +1 -0
- package/mcp-server/dist/tools/restore.js +23 -0
- package/mcp-server/dist/tools/restore.js.map +1 -0
- package/mcp-server/dist/tools/style-guide-tools.d.ts +51 -0
- package/mcp-server/dist/tools/style-guide-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/style-guide-tools.js +231 -0
- package/mcp-server/dist/tools/style-guide-tools.js.map +1 -0
- package/mcp-server/dist/tools/style-guide.d.ts +8 -0
- package/mcp-server/dist/tools/style-guide.d.ts.map +1 -0
- package/mcp-server/dist/tools/style-guide.js +12 -0
- package/mcp-server/dist/tools/style-guide.js.map +1 -0
- package/mcp-server/dist/tools/sync.d.ts +20 -0
- package/mcp-server/dist/tools/sync.d.ts.map +1 -0
- package/mcp-server/dist/tools/sync.js +156 -0
- package/mcp-server/dist/tools/sync.js.map +1 -0
- package/mcp-server/dist/tools/tictactoe-tools.d.ts +18 -0
- package/mcp-server/dist/tools/tictactoe-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/tictactoe-tools.js +78 -0
- package/mcp-server/dist/tools/tictactoe-tools.js.map +1 -0
- package/mcp-server/dist/tools/tictactoe.d.ts +7 -0
- package/mcp-server/dist/tools/tictactoe.d.ts.map +1 -0
- package/mcp-server/dist/tools/tictactoe.js +11 -0
- package/mcp-server/dist/tools/tictactoe.js.map +1 -0
- package/mcp-server/dist/tools/utils.d.ts +19 -0
- package/mcp-server/dist/tools/utils.d.ts.map +1 -0
- package/mcp-server/dist/tools/utils.js +54 -0
- package/mcp-server/dist/tools/utils.js.map +1 -0
- package/mcp-server/dist/tools/whiteboard-format.d.ts +88 -0
- package/mcp-server/dist/tools/whiteboard-format.d.ts.map +1 -0
- package/mcp-server/dist/tools/whiteboard-format.js +337 -0
- package/mcp-server/dist/tools/whiteboard-format.js.map +1 -0
- package/mcp-server/dist/tools/whiteboard-tools.d.ts +326 -0
- package/mcp-server/dist/tools/whiteboard-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/whiteboard-tools.js +222 -0
- package/mcp-server/dist/tools/whiteboard-tools.js.map +1 -0
- package/mcp-server/dist/tools/whiteboard.d.ts +8 -0
- package/mcp-server/dist/tools/whiteboard.d.ts.map +1 -0
- package/mcp-server/dist/tools/whiteboard.js +16 -0
- package/mcp-server/dist/tools/whiteboard.js.map +1 -0
- package/mcp-server/dist/tools/youtube/analytics.d.ts +46 -0
- package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/analytics.js +83 -0
- package/mcp-server/dist/tools/youtube/analytics.js.map +1 -0
- package/mcp-server/dist/tools/youtube/dedup.d.ts +35 -0
- package/mcp-server/dist/tools/youtube/dedup.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/dedup.js +56 -0
- package/mcp-server/dist/tools/youtube/dedup.js.map +1 -0
- package/mcp-server/dist/tools/youtube/download.d.ts +31 -0
- package/mcp-server/dist/tools/youtube/download.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/download.js +30 -0
- package/mcp-server/dist/tools/youtube/download.js.map +1 -0
- package/mcp-server/dist/tools/youtube/helpers.d.ts +66 -0
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/helpers.js +143 -0
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -0
- package/mcp-server/dist/tools/youtube/media.d.ts +43 -0
- package/mcp-server/dist/tools/youtube/media.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/media.js +97 -0
- package/mcp-server/dist/tools/youtube/media.js.map +1 -0
- package/mcp-server/dist/tools/youtube/metadata.d.ts +33 -0
- package/mcp-server/dist/tools/youtube/metadata.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/metadata.js +106 -0
- package/mcp-server/dist/tools/youtube/metadata.js.map +1 -0
- package/mcp-server/dist/tools/youtube/navigate.d.ts +30 -0
- package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/navigate.js +71 -0
- package/mcp-server/dist/tools/youtube/navigate.js.map +1 -0
- package/mcp-server/dist/tools/youtube/playlist.d.ts +29 -0
- package/mcp-server/dist/tools/youtube/playlist.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/playlist.js +128 -0
- package/mcp-server/dist/tools/youtube/playlist.js.map +1 -0
- package/mcp-server/dist/tools/youtube/schedule.d.ts +31 -0
- package/mcp-server/dist/tools/youtube/schedule.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/schedule.js +147 -0
- package/mcp-server/dist/tools/youtube/schedule.js.map +1 -0
- package/mcp-server/dist/tools/youtube/source.d.ts +36 -0
- package/mcp-server/dist/tools/youtube/source.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/source.js +85 -0
- package/mcp-server/dist/tools/youtube/source.js.map +1 -0
- package/mcp-server/dist/tools/youtube/upload.d.ts +53 -0
- package/mcp-server/dist/tools/youtube/upload.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/upload.js +255 -0
- package/mcp-server/dist/tools/youtube/upload.js.map +1 -0
- package/mcp-server/dist/tools/youtube.d.ts +12 -0
- package/mcp-server/dist/tools/youtube.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube.js +38 -0
- package/mcp-server/dist/tools/youtube.js.map +1 -0
- package/mcp-server/dist/tui.d.ts +3 -0
- package/mcp-server/dist/tui.d.ts.map +1 -0
- package/mcp-server/dist/tui.js +806 -0
- package/mcp-server/dist/tui.js.map +1 -0
- package/mcp-server/dist/types.d.ts +77 -0
- package/mcp-server/dist/types.d.ts.map +1 -0
- package/mcp-server/dist/types.js +2 -0
- package/mcp-server/dist/types.js.map +1 -0
- package/mcp-server/package-lock.json +4798 -0
- package/mcp-server/package.json +55 -38
- package/mcp-server/run.mjs +12 -2
- package/mcp-server/src/config.ts +48 -3
- package/mcp-server/src/http.ts +296 -93
- package/mcp-server/src/index.ts +546 -203
- package/mcp-server/src/preload-http.ts +19 -18
- package/mcp-server/src/preload.ts +19 -18
- package/mcp-server/src/scripts/setup-embeddings.ts +9 -0
- package/mcp-server/src/services/assistant-judgments.ts +157 -0
- package/mcp-server/src/services/browser-assist-gate.ts +383 -0
- package/mcp-server/src/services/browser-assist.ts +267 -0
- package/mcp-server/src/services/browser-bench.ts +477 -0
- package/mcp-server/src/services/browser-judgments.ts +414 -0
- package/mcp-server/src/services/browser-risk.ts +484 -0
- package/mcp-server/src/services/categories.ts +36 -19
- package/mcp-server/src/services/codex-config-heal.ts +403 -0
- package/mcp-server/src/services/desktop-assist-gate.ts +251 -0
- package/mcp-server/src/services/desktop-assist.ts +308 -0
- package/mcp-server/src/services/desktop-bench.ts +372 -0
- package/mcp-server/src/services/desktop-client.ts +76 -0
- package/mcp-server/src/services/desktop-judgments.ts +218 -0
- package/mcp-server/src/services/desktop-risk.ts +743 -0
- package/mcp-server/src/services/edit-stale.ts +299 -0
- package/mcp-server/src/services/embedding-service.ts +108 -0
- package/mcp-server/src/services/embedding-worker.ts +46 -0
- package/mcp-server/src/services/fb-regions.ts +221 -0
- package/mcp-server/src/services/file-checksums.ts +26 -9
- package/mcp-server/src/services/file-excerpt.ts +59 -0
- package/mcp-server/src/services/identity.ts +291 -0
- package/mcp-server/src/services/local-embeddings.ts +2 -77
- package/mcp-server/src/services/memory-client.ts +23 -0
- package/mcp-server/src/services/memory-judge-backfill.ts +462 -0
- package/mcp-server/src/services/memory-judgments.ts +901 -0
- package/mcp-server/src/services/memory-maintenance.ts +360 -0
- package/mcp-server/src/services/memory-retrieval.ts +349 -0
- package/mcp-server/src/services/memory-schema.ts +280 -0
- package/mcp-server/src/services/memory-sessions.ts +87 -0
- package/mcp-server/src/services/memory-triage.ts +182 -0
- package/mcp-server/src/services/memory-verification.ts +68 -0
- package/mcp-server/src/services/memory-writer.ts +125 -0
- package/mcp-server/src/services/neural-interface.ts +1217 -73
- package/mcp-server/src/services/profiles.ts +428 -0
- package/mcp-server/src/services/secret-gate.ts +52 -0
- package/mcp-server/src/services/server-instructions.ts +122 -0
- package/mcp-server/src/services/sqlite.ts +1456 -823
- package/mcp-server/src/services/typesafe-bench.ts +247 -0
- package/mcp-server/src/services/typesafe-config.ts +790 -0
- package/mcp-server/src/services/typesafe.ts +390 -0
- package/mcp-server/src/services/vector-cache.ts +255 -0
- package/mcp-server/src/services/whiteboard-geometry.ts +711 -0
- package/mcp-server/src/tools/agents.ts +539 -0
- package/mcp-server/src/tools/bluesky.ts +1186 -0
- package/mcp-server/src/tools/browser-advanced.ts +15 -6
- package/mcp-server/src/tools/browser-batch.ts +178 -0
- package/mcp-server/src/tools/browser-cheatsheet.ts +155 -0
- package/mcp-server/src/tools/browser-interact.ts +362 -255
- package/mcp-server/src/tools/browser-navigate.ts +164 -77
- package/mcp-server/src/tools/browser-observe.ts +2222 -1330
- package/mcp-server/src/tools/browser.ts +181 -107
- package/mcp-server/src/tools/card.ts +7 -5
- package/mcp-server/src/tools/choice.ts +103 -0
- package/mcp-server/src/tools/computer.ts +190 -0
- package/mcp-server/src/tools/discord.ts +10 -23
- package/mcp-server/src/tools/fb-groups.ts +387 -0
- package/mcp-server/src/tools/forget.ts +1 -1
- package/mcp-server/src/tools/git.ts +3 -1
- package/mcp-server/src/tools/gsc/experience.ts +440 -0
- package/mcp-server/src/tools/gsc/helpers.ts +288 -0
- package/mcp-server/src/tools/gsc/indexing.ts +495 -0
- package/mcp-server/src/tools/gsc/inspect.ts +391 -0
- package/mcp-server/src/tools/gsc/navigate.ts +236 -0
- package/mcp-server/src/tools/gsc/performance.ts +352 -0
- package/mcp-server/src/tools/gsc/settings.ts +564 -0
- package/mcp-server/src/tools/gsc.ts +95 -0
- package/mcp-server/src/tools/image.ts +3 -1
- package/mcp-server/src/tools/leonardo-browser-tools.ts +47 -37
- package/mcp-server/src/tools/leonardo.ts +7 -5
- package/mcp-server/src/tools/loop.ts +118 -25
- package/mcp-server/src/tools/memories.ts +65 -5
- package/mcp-server/src/tools/morelogin.ts +81 -0
- package/mcp-server/src/tools/profile.ts +122 -0
- package/mcp-server/src/tools/recall.ts +105 -261
- package/mcp-server/src/tools/reflect.ts +171 -145
- package/mcp-server/src/tools/remember.ts +223 -115
- package/mcp-server/src/tools/style-guide-tools.ts +250 -0
- package/mcp-server/src/tools/style-guide.ts +16 -0
- package/mcp-server/src/tools/sync.ts +66 -9
- package/mcp-server/src/tools/tictactoe.ts +3 -1
- package/mcp-server/src/tools/utils.ts +22 -0
- package/mcp-server/src/tools/whiteboard-format.ts +394 -0
- package/mcp-server/src/tools/whiteboard-tools.ts +191 -183
- package/mcp-server/src/tools/whiteboard.ts +7 -5
- package/mcp-server/src/tools/youtube/analytics.ts +106 -0
- package/mcp-server/src/tools/youtube/dedup.ts +57 -0
- package/mcp-server/src/tools/youtube/download.ts +41 -0
- package/mcp-server/src/tools/youtube/helpers.ts +183 -0
- package/mcp-server/src/tools/youtube/media.ts +109 -0
- package/mcp-server/src/tools/youtube/metadata.ts +112 -0
- package/mcp-server/src/tools/youtube/navigate.ts +81 -0
- package/mcp-server/src/tools/youtube/playlist.ts +134 -0
- package/mcp-server/src/tools/youtube/schedule.ts +158 -0
- package/mcp-server/src/tools/youtube/source.ts +101 -0
- package/mcp-server/src/tools/youtube/upload.ts +296 -0
- package/mcp-server/src/tools/youtube.ts +47 -0
- package/mcp-server/src/tui.ts +8 -9
- package/neural-interface/games/TicTacToe/1.svg +1 -0
- package/neural-interface/games/TicTacToe/2.svg +1 -0
- package/neural-interface/games/TicTacToe/3.svg +1 -0
- package/neural-interface/games/TicTacToe/4.svg +1 -0
- package/neural-interface/games/TicTacToe/5.svg +1 -0
- package/neural-interface/games/TicTacToe/6.svg +1 -0
- package/neural-interface/games/TicTacToe/7.svg +1 -0
- package/neural-interface/games/TicTacToe/8.svg +1 -0
- package/neural-interface/games/TicTacToe/9.svg +1 -0
- package/neural-interface/games/TicTacToe/Board.svg +1 -0
- package/neural-interface/games/TicTacToe/Circle.svg +1 -0
- package/neural-interface/games/TicTacToe/Cross.svg +1 -0
- package/neural-interface/i18n/en.json +6983 -0
- package/neural-interface/i18n/pt-BR.json +6987 -0
- package/neural-interface/lib/assistant-api.js +1005 -0
- package/neural-interface/lib/assistant-attachments.js +121 -0
- package/neural-interface/lib/assistant-brains/claude.js +207 -0
- package/neural-interface/lib/assistant-brains/codex-browser-policy-hook.mjs +43 -0
- package/neural-interface/lib/assistant-brains/codex-route-gate-hook.mjs +56 -0
- package/neural-interface/lib/assistant-brains/codex.js +213 -0
- package/neural-interface/lib/assistant-brains/opencode-browser-policy.js +47 -0
- package/neural-interface/lib/assistant-brains/opencode-route-gate.js +62 -0
- package/neural-interface/lib/assistant-brains/opencode.js +320 -0
- package/neural-interface/lib/assistant-budget.js +318 -0
- package/neural-interface/lib/assistant-catalog.js +731 -0
- package/neural-interface/lib/assistant-clarify.js +664 -0
- package/neural-interface/lib/assistant-config.js +232 -0
- package/neural-interface/lib/assistant-dispatch.js +2744 -0
- package/neural-interface/lib/assistant-envelope.js +579 -0
- package/neural-interface/lib/assistant-evidence.js +236 -0
- package/neural-interface/lib/assistant-hidden-models.js +272 -0
- package/neural-interface/lib/assistant-jev.js +117 -0
- package/neural-interface/lib/assistant-judgments.js +111 -0
- package/neural-interface/lib/assistant-media.js +335 -0
- package/neural-interface/lib/assistant-memory.js +398 -0
- package/neural-interface/lib/assistant-persona.js +444 -0
- package/neural-interface/lib/assistant-plan-permissions.js +448 -0
- package/neural-interface/lib/assistant-playbooks/design.md +87 -0
- package/neural-interface/lib/assistant-playbooks.js +72 -0
- package/neural-interface/lib/assistant-pricing.js +159 -0
- package/neural-interface/lib/assistant-route-gate-codex.js +163 -0
- package/neural-interface/lib/assistant-route-gate.js +212 -0
- package/neural-interface/lib/assistant-router.js +1324 -0
- package/neural-interface/lib/assistant-runtime.js +3337 -0
- package/neural-interface/lib/assistant-task-prompt.js +472 -0
- package/neural-interface/lib/assistant-usage.js +1688 -0
- package/neural-interface/lib/augmented-path.js +50 -0
- package/neural-interface/lib/automation-storage-migration.js +54 -0
- package/neural-interface/lib/backup-service.js +851 -0
- package/neural-interface/lib/backup-zip-reader.js +262 -0
- package/neural-interface/lib/browser-assist-api.js +41 -0
- package/neural-interface/lib/browser-console.js +176 -0
- package/neural-interface/lib/browser-execution.js +241 -0
- package/neural-interface/lib/browser-extraction.js +191 -0
- package/neural-interface/lib/browser-screenshot.js +399 -0
- package/neural-interface/lib/browser-semantic-context.js +639 -0
- package/neural-interface/lib/browser-snapshots.js +192 -0
- package/neural-interface/lib/browser-tab-recovery.js +119 -0
- package/neural-interface/lib/browser-targets.js +70 -0
- package/neural-interface/lib/browser-tool-policy.js +926 -0
- package/neural-interface/lib/claude-accounts.js +230 -0
- package/neural-interface/lib/claude-agent-bridge.js +3296 -0
- package/neural-interface/lib/claude-bypass-policy.js +99 -0
- package/neural-interface/lib/claude-history.js +429 -0
- package/neural-interface/lib/claude-model-catalog.js +483 -0
- package/neural-interface/lib/claude-panel-requests.js +165 -0
- package/neural-interface/lib/claude-panel-session.js +272 -0
- package/neural-interface/lib/claude-permission-rules.js +153 -0
- package/neural-interface/lib/claude-session-cleanup.js +71 -0
- package/neural-interface/lib/claude-session-list.js +82 -0
- package/neural-interface/lib/claude-session-ops.js +140 -0
- package/neural-interface/lib/claude-settings-view.js +51 -0
- package/neural-interface/lib/claude-skin-connect.js +79 -0
- package/neural-interface/lib/claude-stall-policy.js +7 -0
- package/neural-interface/lib/claude-temporary.js +435 -0
- package/neural-interface/lib/cli-update-planner.js +312 -0
- package/neural-interface/lib/codex-capabilities.d.ts +41 -0
- package/neural-interface/lib/codex-capabilities.js +148 -0
- package/neural-interface/lib/codex-collaboration-mode.js +17 -0
- package/neural-interface/lib/codex-compat-rpc.js +241 -0
- package/neural-interface/lib/codex-mcp-approvals.js +56 -0
- package/neural-interface/lib/codex-mcp-apps.js +47 -0
- package/neural-interface/lib/codex-model-context.js +202 -0
- package/neural-interface/lib/codex-plan-store.js +71 -0
- package/neural-interface/lib/codex-request-journal.js +242 -0
- package/neural-interface/lib/codex-runtime-path.js +213 -0
- package/neural-interface/lib/codex-session-catalog.js +231 -0
- package/neural-interface/lib/codex-session-settings.js +46 -0
- package/neural-interface/lib/codex-sidepanel-permissions.js +110 -0
- package/neural-interface/lib/codex-thread-history.js +165 -0
- package/neural-interface/lib/codex-user-verification.js +34 -0
- package/neural-interface/lib/codex-writer-lifecycle.js +152 -0
- package/neural-interface/lib/confined-fs.js +256 -0
- package/neural-interface/lib/db.js +922 -0
- package/neural-interface/lib/design-md.js +9 -0
- package/neural-interface/lib/desktop/api.js +92 -0
- package/neural-interface/lib/desktop/audit.js +62 -0
- package/neural-interface/lib/desktop/build.js +423 -0
- package/neural-interface/lib/desktop/config.js +606 -0
- package/neural-interface/lib/desktop/coords.js +76 -0
- package/neural-interface/lib/desktop/fake-helper.js +1192 -0
- package/neural-interface/lib/desktop/frames.js +77 -0
- package/neural-interface/lib/desktop/grants.js +84 -0
- package/neural-interface/lib/desktop/guards.js +170 -0
- package/neural-interface/lib/desktop/helper/SynabunDesktop.swift +3056 -0
- package/neural-interface/lib/desktop/lease.js +51 -0
- package/neural-interface/lib/desktop/manager.js +545 -0
- package/neural-interface/lib/desktop/press-contexts.js +103 -0
- package/neural-interface/lib/desktop/protocol.js +495 -0
- package/neural-interface/lib/desktop/service.js +1202 -0
- package/neural-interface/lib/effort-levels.js +148 -0
- package/neural-interface/lib/event-loop-monitor.js +67 -0
- package/neural-interface/lib/exec-loop-command.js +209 -0
- package/neural-interface/lib/folder-picker.ps1 +77 -0
- package/neural-interface/lib/http-guards.js +287 -0
- package/neural-interface/lib/jsonl-lines.js +94 -0
- package/neural-interface/lib/loop-logger.js +127 -0
- package/neural-interface/lib/mcp-client-config.js +133 -0
- package/neural-interface/lib/mcp-installer.js +487 -0
- package/neural-interface/lib/mcp-profile-refresh-coordinator.js +78 -0
- package/neural-interface/lib/mcp-profile-servers.js +120 -0
- package/neural-interface/lib/memo-cache.js +84 -0
- package/neural-interface/lib/memory-api.js +758 -0
- package/neural-interface/lib/memory-map-api.js +1150 -0
- package/neural-interface/lib/memory-map-layout.js +872 -0
- package/neural-interface/lib/memory-map-worker.js +165 -0
- package/neural-interface/lib/memory-session-capture.js +81 -0
- package/neural-interface/lib/memory-timers.js +62 -0
- package/neural-interface/lib/morelogin.js +301 -0
- package/neural-interface/lib/native-binary-runtime.js +650 -0
- package/neural-interface/lib/native-loop-goal.js +33 -0
- package/neural-interface/lib/native-loop-providers.js +1016 -0
- package/neural-interface/lib/native-loop-runtime.js +747 -0
- package/neural-interface/lib/opencode-hidden-models.js +113 -0
- package/neural-interface/lib/opencode-history.js +253 -0
- package/neural-interface/lib/opencode-runtime-config.js +58 -0
- package/neural-interface/lib/opencode-v2-client.js +486 -0
- package/neural-interface/lib/opencode-v2-ws-requests.js +955 -0
- package/neural-interface/lib/path-confine.js +213 -0
- package/neural-interface/lib/plugin-installer.js +264 -0
- package/neural-interface/lib/project-storage.js +766 -0
- package/neural-interface/lib/pty-host/core.js +603 -0
- package/neural-interface/lib/pty-host/flow.js +43 -0
- package/neural-interface/lib/pty-host/host.js +47 -0
- package/neural-interface/lib/pty-host/manager.js +360 -0
- package/neural-interface/lib/pty-host/protocol.js +81 -0
- package/neural-interface/lib/pty-host/snapshot.js +133 -0
- package/neural-interface/lib/remote-policy.js +582 -0
- package/neural-interface/lib/rulesets/api.js +175 -0
- package/neural-interface/lib/rulesets/fs-safe.js +245 -0
- package/neural-interface/lib/rulesets/installer.js +1453 -0
- package/neural-interface/lib/rulesets/json-edit.js +186 -0
- package/neural-interface/lib/rulesets/lock.js +170 -0
- package/neural-interface/lib/rulesets/managed-text.js +314 -0
- package/neural-interface/lib/rulesets/normalise.js +24 -0
- package/neural-interface/lib/rulesets/render.js +84 -0
- package/neural-interface/lib/schedule-launch-intent.js +40 -0
- package/neural-interface/lib/session-cache-builder.js +524 -0
- package/neural-interface/lib/session-chunker.js +344 -0
- package/neural-interface/lib/session-indexer.js +327 -0
- package/neural-interface/lib/session-title-generator.js +227 -0
- package/neural-interface/lib/skill-prompt-bridge.js +11 -0
- package/neural-interface/lib/style-guide/api.js +375 -0
- package/neural-interface/lib/style-guide/color.js +352 -0
- package/neural-interface/lib/style-guide/export-css.js +99 -0
- package/neural-interface/lib/style-guide/export-dtcg.js +209 -0
- package/neural-interface/lib/style-guide/export-tailwind.js +102 -0
- package/neural-interface/lib/style-guide/fonts.json +227 -0
- package/neural-interface/lib/style-guide/import.js +1268 -0
- package/neural-interface/lib/style-guide/pointers.js +103 -0
- package/neural-interface/lib/style-guide/presets.js +232 -0
- package/neural-interface/lib/style-guide/render-design-md.js +319 -0
- package/neural-interface/lib/style-guide/schema.js +848 -0
- package/neural-interface/lib/style-guide/security.js +43 -0
- package/neural-interface/lib/style-guide/store.js +491 -0
- package/neural-interface/lib/style-guide/summary.js +106 -0
- package/neural-interface/lib/style-guide/tokens.js +170 -0
- package/neural-interface/lib/synabun-update-plan.js +305 -0
- package/neural-interface/lib/synabun-version.js +179 -0
- package/neural-interface/lib/system-restore.js +99 -0
- package/neural-interface/lib/terminal-env.js +86 -0
- package/neural-interface/lib/ui-blob-store.js +106 -0
- package/neural-interface/lib/vector-cache.js +2 -0
- package/neural-interface/lib/virtual-socket.js +60 -0
- package/neural-interface/lib/whatsapp/api.js +146 -0
- package/neural-interface/lib/whatsapp/auth-store.js +389 -0
- package/neural-interface/lib/whatsapp/baileys-adapter.js +457 -0
- package/neural-interface/lib/whatsapp/brain.js +128 -0
- package/neural-interface/lib/whatsapp/bridge.js +1499 -0
- package/neural-interface/lib/whatsapp/cards.js +519 -0
- package/neural-interface/lib/whatsapp/commands.js +92 -0
- package/neural-interface/lib/whatsapp/config.js +291 -0
- package/neural-interface/lib/whatsapp/connector/entry.mjs +25 -0
- package/neural-interface/lib/whatsapp/connector/manifest.json +6 -0
- package/neural-interface/lib/whatsapp/connector/npm-shrinkwrap.json +717 -0
- package/neural-interface/lib/whatsapp/connector/package.json +8 -0
- package/neural-interface/lib/whatsapp/fake-baileys.js +444 -0
- package/neural-interface/lib/whatsapp/format.js +552 -0
- package/neural-interface/lib/whatsapp/host-core.js +1225 -0
- package/neural-interface/lib/whatsapp/host.js +119 -0
- package/neural-interface/lib/whatsapp/identity.js +288 -0
- package/neural-interface/lib/whatsapp/inbound.js +149 -0
- package/neural-interface/lib/whatsapp/installer.js +562 -0
- package/neural-interface/lib/whatsapp/manager.js +638 -0
- package/neural-interface/lib/whatsapp/paths.js +81 -0
- package/neural-interface/lib/whatsapp/protocol.js +327 -0
- package/neural-interface/lib/whatsapp/qr-svg.js +57 -0
- package/neural-interface/lib/whatsapp/redact.js +130 -0
- package/neural-interface/lib/whatsapp/service.js +1305 -0
- package/neural-interface/lib/whatsapp/vendor/qrcodegen.js +848 -0
- package/neural-interface/package-lock.json +4682 -0
- package/neural-interface/package.json +58 -27
- package/neural-interface/public/apple-touch-icon.png +0 -0
- package/neural-interface/public/category-logos/synabun.png +0 -0
- package/neural-interface/public/claude.svg +1 -0
- package/neural-interface/public/favicon-16x16.png +0 -0
- package/neural-interface/public/favicon-32x32.png +0 -0
- package/neural-interface/public/icon-192.png +0 -0
- package/neural-interface/public/icon-512.png +0 -0
- package/neural-interface/public/index.html +32 -182
- package/neural-interface/public/index2d.html +2 -2
- package/neural-interface/public/logo-synabun.png +0 -0
- package/neural-interface/public/logoHD.png +0 -0
- package/neural-interface/public/mcp.svg +4 -0
- package/neural-interface/public/offline.html +335 -299
- package/neural-interface/public/onboarding.html +692 -155
- package/neural-interface/public/opencode-logo-dark-square.svg +1 -0
- package/neural-interface/public/shared/agent-runtime-options.js +596 -0
- package/neural-interface/public/shared/api.js +339 -28
- package/neural-interface/public/shared/assistant/asst-accounts.js +318 -0
- package/neural-interface/public/shared/assistant/asst-agents-dock.js +296 -0
- package/neural-interface/public/shared/assistant/asst-api.js +270 -0
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +744 -0
- package/neural-interface/public/shared/assistant/asst-budget.js +333 -0
- package/neural-interface/public/shared/assistant/asst-composer.js +656 -0
- package/neural-interface/public/shared/assistant/asst-computer.js +803 -0
- package/neural-interface/public/shared/assistant/asst-control.js +1018 -0
- package/neural-interface/public/shared/assistant/asst-hosts.js +262 -0
- package/neural-interface/public/shared/assistant/asst-mascot.js +311 -0
- package/neural-interface/public/shared/assistant/asst-menu.js +375 -0
- package/neural-interface/public/shared/assistant/asst-panel.js +1845 -0
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +589 -0
- package/neural-interface/public/shared/assistant/asst-render.js +3296 -0
- package/neural-interface/public/shared/assistant/asst-route.js +1653 -0
- package/neural-interface/public/shared/assistant/asst-roving.js +75 -0
- package/neural-interface/public/shared/assistant/asst-sanitize.js +117 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel-styles.js +488 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +675 -0
- package/neural-interface/public/shared/assistant/asst-slash.js +258 -0
- package/neural-interface/public/shared/assistant/asst-state.js +727 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +1684 -0
- package/neural-interface/public/shared/assistant/asst-tool-kinds.js +1017 -0
- package/neural-interface/public/shared/assistant/asst-usage.js +444 -0
- package/neural-interface/public/shared/assistant/asst-ws.js +175 -0
- package/neural-interface/public/shared/automation-context.js +75 -0
- package/neural-interface/public/shared/blob-store.js +99 -0
- package/neural-interface/public/shared/cdx/cdx-capabilities.js +118 -0
- package/neural-interface/public/shared/cdx/cdx-cards.js +37 -0
- package/neural-interface/public/shared/cdx/cdx-commands.js +171 -0
- package/neural-interface/public/shared/cdx/cdx-context-menu.js +402 -0
- package/neural-interface/public/shared/cdx/cdx-context-model.js +220 -0
- package/neural-interface/public/shared/cdx/cdx-features.js +408 -0
- package/neural-interface/public/shared/cdx/cdx-icons.js +89 -0
- package/neural-interface/public/shared/cdx/cdx-mcp-app-host.js +414 -0
- package/neural-interface/public/shared/cdx/cdx-mcp-app-proxy.html +6 -0
- package/neural-interface/public/shared/cdx/cdx-mcp-app-proxy.js +56 -0
- package/neural-interface/public/shared/cdx/cdx-mcp-app.js +178 -0
- package/neural-interface/public/shared/cdx/cdx-model-catalog.js +120 -0
- package/neural-interface/public/shared/cdx/cdx-output-model.js +261 -0
- package/neural-interface/public/shared/cdx/cdx-output.js +382 -0
- package/neural-interface/public/shared/cdx/cdx-panel.js +1372 -0
- package/neural-interface/public/shared/cdx/cdx-plan.js +266 -0
- package/neural-interface/public/shared/cdx/cdx-protocol.js +682 -0
- package/neural-interface/public/shared/cdx/cdx-render.js +3381 -0
- package/neural-interface/public/shared/cdx/cdx-requests.js +1136 -0
- package/neural-interface/public/shared/cdx/cdx-styles.js +3251 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +7992 -0
- package/neural-interface/public/shared/cdx/cdx-ws.js +363 -0
- package/neural-interface/public/shared/cli-status.js +169 -0
- package/neural-interface/public/shared/constants.js +22 -5
- package/neural-interface/public/shared/cp/cp-agents.js +186 -0
- package/neural-interface/public/shared/cp/cp-bash.js +252 -0
- package/neural-interface/public/shared/cp/cp-compose.js +159 -0
- package/neural-interface/public/shared/cp/cp-context-menu.js +309 -0
- package/neural-interface/public/shared/cp/cp-context-model.js +157 -0
- package/neural-interface/public/shared/cp/cp-context-window.js +80 -0
- package/neural-interface/public/shared/cp/cp-ctx.js +11 -0
- package/neural-interface/public/shared/cp/cp-diff.js +255 -0
- package/neural-interface/public/shared/cp/cp-event-rows.js +637 -0
- package/neural-interface/public/shared/cp/cp-events.js +846 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +104 -0
- package/neural-interface/public/shared/cp/cp-permission-model.js +905 -0
- package/neural-interface/public/shared/cp/cp-permissions.js +626 -0
- package/neural-interface/public/shared/cp/cp-rehydrate.js +113 -0
- package/neural-interface/public/shared/cp/cp-restore.js +224 -0
- package/neural-interface/public/shared/cp/cp-session-model.js +338 -0
- package/neural-interface/public/shared/cp/cp-session-settings.js +254 -0
- package/neural-interface/public/shared/cp/cp-sessions.js +227 -0
- package/neural-interface/public/shared/cp/cp-statusline.js +153 -0
- package/neural-interface/public/shared/cp/cp-styles.js +349 -0
- package/neural-interface/public/shared/cp/cp-tasks-model.js +282 -0
- package/neural-interface/public/shared/cp/cp-tasks.js +107 -0
- package/neural-interface/public/shared/cp/cp-temporary-view.js +56 -0
- package/neural-interface/public/shared/cp/cp-temporary.js +231 -0
- package/neural-interface/public/shared/cp/cp-tool-cards.js +326 -0
- package/neural-interface/public/shared/cp/cp-tool-results.js +618 -0
- package/neural-interface/public/shared/cp/cp-usage-model.js +124 -0
- package/neural-interface/public/shared/graph-activity.js +68 -0
- package/neural-interface/public/shared/html-shell.js +107 -12
- package/neural-interface/public/shared/i18n.js +132 -34
- package/neural-interface/public/shared/node-positions-store.js +44 -0
- package/neural-interface/public/shared/ocp-hidden-models.js +116 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-approvals.js +355 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-autoaccept-button.js +35 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +72 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-binding.js +280 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-caps.js +67 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-changes-logic.js +179 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-changes.js +164 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +725 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-compact-button.js +75 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-composer-logic.js +1204 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-confirm-logic.js +117 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-confirm.js +59 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-context-gauge.js +252 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-context-menu.js +478 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-context-model.js +179 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +233 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +30 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1065 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-mention-hints.js +182 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +655 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +2636 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-plan.js +601 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-profile-inheritance.js +78 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +649 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-providers.js +35 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +357 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render-logic.js +189 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +1869 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-select.js +42 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +117 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +1714 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +468 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-widgets.js +63 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +366 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-settings-link.js +19 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-slash-hints.js +343 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +746 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-status-logic.js +347 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-status.js +338 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +3543 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-subagents-logic.js +482 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +351 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +168 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +315 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +545 -0
- package/neural-interface/public/shared/provider-icons.js +30 -0
- package/neural-interface/public/shared/session-title.js +100 -0
- package/neural-interface/public/shared/settings/settings-ia.js +389 -0
- package/neural-interface/public/shared/settings/settings-kit.js +234 -0
- package/neural-interface/public/shared/settings/settings-search.js +463 -0
- package/neural-interface/public/shared/settings/settings-shell.js +570 -0
- package/neural-interface/public/shared/state.js +5 -0
- package/neural-interface/public/shared/storage.js +50 -7
- package/neural-interface/public/shared/styleguide/sg-agents.js +42 -0
- package/neural-interface/public/shared/styleguide/sg-brand.js +4 -0
- package/neural-interface/public/shared/styleguide/sg-color-client.js +388 -0
- package/neural-interface/public/shared/styleguide/sg-colors.js +148 -0
- package/neural-interface/public/shared/styleguide/sg-components.js +35 -0
- package/neural-interface/public/shared/styleguide/sg-history.js +41 -0
- package/neural-interface/public/shared/styleguide/sg-icons-logo.js +38 -0
- package/neural-interface/public/shared/styleguide/sg-imagery.js +4 -0
- package/neural-interface/public/shared/styleguide/sg-import-export.js +47 -0
- package/neural-interface/public/shared/styleguide/sg-kit.js +281 -0
- package/neural-interface/public/shared/styleguide/sg-labels.js +318 -0
- package/neural-interface/public/shared/styleguide/sg-layout.js +4 -0
- package/neural-interface/public/shared/styleguide/sg-motion.js +5 -0
- package/neural-interface/public/shared/styleguide/sg-panel.js +229 -0
- package/neural-interface/public/shared/styleguide/sg-preview.js +138 -0
- package/neural-interface/public/shared/styleguide/sg-rules.js +9 -0
- package/neural-interface/public/shared/styleguide/sg-shape.js +24 -0
- package/neural-interface/public/shared/styleguide/sg-state.js +132 -0
- package/neural-interface/public/shared/styleguide/sg-typography.js +124 -0
- package/neural-interface/public/shared/styles.css +7883 -1155
- package/neural-interface/public/shared/synabun-mascot.js +1625 -0
- package/neural-interface/public/shared/synabun-ticker.js +376 -0
- package/neural-interface/public/shared/term-renderer.js +343 -0
- package/neural-interface/public/shared/ui-assistant-panel.js +10 -0
- package/neural-interface/public/shared/ui-assistant.js +77 -0
- package/neural-interface/public/shared/ui-automation-studio.js +5105 -3573
- package/neural-interface/public/shared/ui-claude-panel.js +11685 -6333
- package/neural-interface/public/shared/ui-codex-panel.js +12 -0
- package/neural-interface/public/shared/ui-cost-widget.js +55 -34
- package/neural-interface/public/shared/ui-detail.js +77 -14
- package/neural-interface/public/shared/ui-explorer.js +360 -181
- package/neural-interface/public/shared/ui-file-explorer.js +485 -107
- package/neural-interface/public/shared/ui-help.js +2 -2
- package/neural-interface/public/shared/ui-image-gallery.js +45 -21
- package/neural-interface/public/shared/ui-judgments.js +1346 -0
- package/neural-interface/public/shared/ui-keybinds.js +3 -2
- package/neural-interface/public/shared/ui-link.js +105 -51
- package/neural-interface/public/shared/ui-loading.js +4 -4
- package/neural-interface/public/shared/ui-memory-maintenance.js +111 -0
- package/neural-interface/public/shared/ui-menubar.js +89 -4
- package/neural-interface/public/shared/ui-native-loop-router-state.js +94 -0
- package/neural-interface/public/shared/ui-native-loop-router.js +493 -0
- package/neural-interface/public/shared/ui-native-window-id.js +7 -0
- package/neural-interface/public/shared/ui-navbar.js +357 -222
- package/neural-interface/public/shared/ui-notifications.js +58 -12
- package/neural-interface/public/shared/ui-opencode-panel-v2.js +17 -0
- package/neural-interface/public/shared/ui-panels.js +15 -7
- package/neural-interface/public/shared/ui-resume.js +823 -653
- package/neural-interface/public/shared/ui-schedule-queue.js +172 -0
- package/neural-interface/public/shared/ui-schedules-studio.js +1882 -0
- package/neural-interface/public/shared/ui-scroll-follow.js +194 -0
- package/neural-interface/public/shared/ui-sessions.js +789 -34
- package/neural-interface/public/shared/ui-settings.js +5793 -2190
- package/neural-interface/public/shared/ui-sidepanel-layout.js +109 -0
- package/neural-interface/public/shared/ui-sidepanel-runtime.js +19 -0
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +40 -0
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +221 -0
- package/neural-interface/public/shared/ui-sidepanel-state.js +131 -0
- package/neural-interface/public/shared/ui-sidepanel-tray.js +547 -0
- package/neural-interface/public/shared/ui-sidepanel-windows.js +387 -0
- package/neural-interface/public/shared/ui-skills.js +18 -32
- package/neural-interface/public/shared/ui-styleguide.js +35 -0
- package/neural-interface/public/shared/ui-sync.js +87 -0
- package/neural-interface/public/shared/ui-terminal.js +7877 -6385
- package/neural-interface/public/shared/ui-tool-updates.js +292 -0
- package/neural-interface/public/shared/ui-tooltip.js +156 -15
- package/neural-interface/public/shared/ui-tutorial-draw.js +119 -683
- package/neural-interface/public/shared/ui-tutorial-layout.js +135 -0
- package/neural-interface/public/shared/ui-tutorial-steps.js +59 -2209
- package/neural-interface/public/shared/ui-tutorial.css +102 -0
- package/neural-interface/public/shared/ui-tutorial.js +557 -1076
- package/neural-interface/public/shared/ui-update.js +420 -68
- package/neural-interface/public/shared/ui-whatsapp.js +941 -0
- package/neural-interface/public/shared/ui-whiteboard.js +1076 -233
- package/neural-interface/public/shared/ui-workspaces.js +2 -1
- package/neural-interface/public/shared/utils.js +58 -0
- package/neural-interface/public/shared/vterm-buffer.js +15 -5
- package/neural-interface/public/shared/whatsapp/wa-phone.js +65 -0
- package/neural-interface/public/shared/whatsapp/wa-view.js +411 -0
- package/neural-interface/public/sidepanel-session.html +18 -0
- package/neural-interface/public/sw.js +8 -2
- package/neural-interface/public/synabun.png +0 -0
- package/neural-interface/public/variant/2d/graph.js +1707 -1635
- package/neural-interface/public/variant/2d/lasso.js +2 -1
- package/neural-interface/public/variant/2d/layout.js +595 -594
- package/neural-interface/public/variant/2d/main.js +556 -521
- package/neural-interface/public/variant/2d/settings-gfx.js +18 -24
- package/neural-interface/public/variant/3d/main.js +516 -500
- package/neural-interface/public/variant/3d/map-controls.js +144 -0
- package/neural-interface/public/variant/3d/map-data.js +251 -0
- package/neural-interface/public/variant/3d/map-labels.js +241 -0
- package/neural-interface/public/variant/3d/map-pick.js +90 -0
- package/neural-interface/public/variant/3d/map-renderer.js +521 -0
- package/neural-interface/public/variant/3d/map-shaders.js +158 -0
- package/neural-interface/public/variant/3d/map-view.js +618 -0
- package/neural-interface/public/vendor/three/manifest.json +3 -0
- package/neural-interface/public/vendor/three/three-0.169.0.min.js +3844 -0
- package/neural-interface/public/vendor/xterm/manifest.json +3 -0
- package/neural-interface/public/vendor/xterm/xterm-6.0.0.css +285 -0
- package/neural-interface/public/vendor/xterm/xterm-6.0.0.min.js +192 -0
- package/neural-interface/scripts/build-vendor.mjs +64 -0
- package/neural-interface/scripts/codex-protocol-fixture.mjs +83 -0
- package/neural-interface/scripts/rebuild-pty.js +37 -23
- package/neural-interface/scripts/vendor-three-entry.js +24 -0
- package/neural-interface/scripts/vendor-xterm-entry.js +8 -0
- package/neural-interface/server.js +33948 -15000
- package/neural-interface/skins/default/skin.css +90 -0
- package/neural-interface/skins/default/skin.json +8 -0
- package/neural-interface/templates/rulesets/README.md +9 -0
- package/neural-interface/templates/rulesets/claude.md +3 -0
- package/neural-interface/templates/rulesets/codex.md +2 -0
- package/neural-interface/templates/rulesets/coexistence.md +6 -0
- package/neural-interface/templates/rulesets/core.md +26 -0
- package/neural-interface/templates/rulesets/cursor.md +2 -0
- package/neural-interface/templates/rulesets/gemini.md +2 -0
- package/neural-interface/templates/rulesets/legacy-hashes.json +227 -0
- package/neural-interface/templates/rulesets/manifest.json +12 -0
- package/neural-interface/templates/rulesets/opencode.md +2 -0
- package/package.json +119 -53
- package/postinstall.js +125 -26
- package/preuninstall.js +187 -0
- package/scripts/audit-claude-hook-usage.mjs +12 -0
- package/scripts/audit-memory-duplicates.mjs +44 -0
- package/scripts/measure-claude-hook-overhead.mjs +77 -0
- package/scripts/recover-user-config.mjs +254 -0
- package/scripts/restore-data-home-from-backup.mjs +239 -0
- package/setup.js +804 -260
- package/skills/leonardo/SKILL.md +19 -10
- package/skills/leonardo/modules/image-prompter.md +18 -12
- package/skills/leonardo/modules/video-prompter.md +19 -13
- package/skills/synabun/SKILL.md +209 -185
- package/skills/synabun/icon.png +0 -0
- package/skills/synabun/modules/audit.md +380 -374
- package/skills/synabun/modules/changelog.md +15 -6
- package/skills/synabun/modules/idea.md +148 -144
- package/skills/synabun/modules/memorize.md +13 -4
- package/skills/synabun/modules/schedule.md +198 -0
- package/skills/synabun/synabunicon.png +0 -0
- package/updater.cmd +31 -0
- package/updater.mjs +382 -0
- package/updater.sh +29 -0
- package/hooks/claude-code/test-user-learning.mjs +0 -531
- package/neural-interface/public/claude-chat.css +0 -878
- package/neural-interface/public/claude-chat.html +0 -92
- package/neural-interface/public/claude-chat.js +0 -1168
- package/neural-interface/public/index-legacy.html +0 -14677
- package/neural-interface/public/index2d-legacy.html +0 -8193
- package/neural-interface/public/shared/html-term-renderer.js +0 -1022
- package/neural-interface/public/variant/3d/background.js +0 -884
- package/neural-interface/public/variant/3d/camera.js +0 -661
- package/neural-interface/public/variant/3d/gfx.js +0 -116
- package/neural-interface/public/variant/3d/graph.js +0 -2399
- package/neural-interface/public/variant/3d/settings-gfx.js +0 -228
- package/neural-interface/templates/CLAUDE-template.md +0 -211
|
@@ -0,0 +1,1625 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun mascot — pill eyes and a smile, rig v2
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
// The onboarding character (onboarding.html initEyesSVG / updateEyesSVG): the
|
|
5
|
+
// same 280×140 geometry and blink timing, as a module any page can mount, now
|
|
6
|
+
// a small rig that acts out what the Assistant is doing. Every pose is a pure
|
|
7
|
+
// function of time (poseFrame) over a few parameters per eye, the mouth and
|
|
8
|
+
// the face, plus one prop drawn in the face's own pill geometry. Rigs draw
|
|
9
|
+
// from the shared ticker (shared/synabun-ticker.js): 30 fps while a pose
|
|
10
|
+
// loops, 60 fps for blends and reactions, no frames at all while still. One
|
|
11
|
+
// pointermove listener and one IntersectionObserver serve every rig, and only
|
|
12
|
+
// one rig at a time plays a pose loop (the one posed most recently); the
|
|
13
|
+
// others hold their pose's still frame. Under prefers-reduced-motion every
|
|
14
|
+
// pose is its still frame and changes are instant. A rig tears itself down
|
|
15
|
+
// once its SVG leaves the document.
|
|
16
|
+
//
|
|
17
|
+
// v1 callers are unchanged: createMascot(container, opts) → { el, destroy,
|
|
18
|
+
// look, blink }, idle, blinking every 3-7 s and following the cursor.
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @module synabun-mascot
|
|
22
|
+
*
|
|
23
|
+
* ## Mount
|
|
24
|
+
* `createMascot(container?, opts?)` appends the SVG to `container` (or returns
|
|
25
|
+
* it unattached as `el` when the first argument is the options object).
|
|
26
|
+
* Options: `width` (128), `height` (64), `className` ('synabun-mascot'),
|
|
27
|
+
* `pose` ('idle'), `poseOptions`, `active` (true unless `false`), and the v1
|
|
28
|
+
* `rangeX` / `rangeY`, which can only widen the v2 cursor travel (±20 × ±12
|
|
29
|
+
* viewBox units).
|
|
30
|
+
*
|
|
31
|
+
* ## Instance
|
|
32
|
+
* - `el` — the `<svg>`.
|
|
33
|
+
* - `setPose(name, opts?)` — blends from the current frame over 160 ms
|
|
34
|
+
* (cubic-bezier(.2,0,.38,.9)). Names: `MASCOT_POSES`; unknown → 'idle'.
|
|
35
|
+
* `opts.count` 1-3 (subagent minis), `opts.mode` 'recall' | 'remember'
|
|
36
|
+
* (memory), `opts.ticks` 0-3 (plan), `opts.then` a pose to blend to once a
|
|
37
|
+
* one-shot (success, error, blocked) has played and held. The same pose with
|
|
38
|
+
* a new count or ticks keeps its loop running.
|
|
39
|
+
* - `react(name)` — `MASCOT_REACTIONS`: hop (spring, at most one per 600 ms),
|
|
40
|
+
* wince, nod, pop (plan: pops the newest tick; ticks the next box too
|
|
41
|
+
* unless setPose passed `ticks`), startle, pulse, click
|
|
42
|
+
* (computer: a ripple). While one plays the SVG carries `syna-react-<name>`,
|
|
43
|
+
* removed when it ends and on `animationend`.
|
|
44
|
+
* - `look(x, y)` — gaze in [-1, 1] on both axes. Idle: a cursor that moved in
|
|
45
|
+
* the last 2.5 s wins. watch / computer / runs / wait / blocked follow it.
|
|
46
|
+
* - `blink()` — one blink.
|
|
47
|
+
* - `setActive(bool)` — false unsubscribes and shows the pose's still frame
|
|
48
|
+
* (no loops, no tracking); true resumes.
|
|
49
|
+
* - `pose` — the current pose name (also the SVG's `data-pose`); `fps` — the
|
|
50
|
+
* rate it draws at now (0 = still).
|
|
51
|
+
* - `destroy()` — releases everything; idempotent.
|
|
52
|
+
*
|
|
53
|
+
* ## Pure helpers (Node-safe)
|
|
54
|
+
* - `poseFrame(name, t, opts?)` → `{ eyes: [{dx,dy,sx,sy,rot} ×2],
|
|
55
|
+
* mouth: {w,c,dx,dy,rot,op}, face: {dx,dy,rot,op}, prop: {name, …} }`,
|
|
56
|
+
* `t` in ms since the pose began; opts: look {x,y}, range {x,y}, count,
|
|
57
|
+
* mode, ticks, still. Deterministic; unknown names fall back to idle.
|
|
58
|
+
* - `stillFrame(name, opts?)` — the frame reduced motion shows.
|
|
59
|
+
* - `reactionFrame(frame, name, p)` — a reaction `p` (0-1) of the way in.
|
|
60
|
+
* - `mouthPath(mouth)` — the mouth's `d`.
|
|
61
|
+
* - `paintMascot(svg, frame)` — draw a frame on any `mascotSvg()`. A still
|
|
62
|
+
* frame (`stillFrame`, or a rig that is not looping) draws its prop at
|
|
63
|
+
* ≥ .7 opacity with strokes of ≥ 1.5 CSS px, so it reads at 28×14.
|
|
64
|
+
* - `mascotCameoSvg()` — two 3×7 px pill eyes (`syna-cameo` /
|
|
65
|
+
* `syna-cameo-eye`) for running pills, leaning −12° like the two-pill mark
|
|
66
|
+
* (never a pause glyph); the host's CSS animates them.
|
|
67
|
+
* - `mascotPropSvg(kind, { width, height })` + `paintMascotProp(svg, kind)`
|
|
68
|
+
* — a kind's prop alone, framed to its own box: the ledger's row glyphs.
|
|
69
|
+
* - v1: `mascotSvg`, `mascotRefs`, `poseMascot`, `blinkAmount`, `MASCOT_VIEWBOX`.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
import {
|
|
73
|
+
isReducedMotion, lastInputAt, now as tickerNow, onKey, onPointer, onReducedMotionChange,
|
|
74
|
+
pointerPosition, requestFrames, subscribe,
|
|
75
|
+
} from './synabun-ticker.js';
|
|
76
|
+
|
|
77
|
+
export const MASCOT_VIEWBOX = '0 0 280 140';
|
|
78
|
+
|
|
79
|
+
/** One pose per tool kind (shared with the activity rack's kind ids). */
|
|
80
|
+
export const MASCOT_KINDS = Object.freeze(['shell', 'read', 'edit', 'search', 'web', 'subagent', 'plan', 'memory', 'runs', 'computer', 'think', 'mcp']);
|
|
81
|
+
export const MASCOT_STATES = Object.freeze(['idle', 'sleep', 'watch', 'wait', 'success', 'error', 'blocked', 'offline']);
|
|
82
|
+
export const MASCOT_POSES = Object.freeze([...MASCOT_KINDS, ...MASCOT_STATES]);
|
|
83
|
+
export const MASCOT_REACTIONS = Object.freeze(['hop', 'wince', 'nod', 'pop', 'startle', 'pulse', 'click']);
|
|
84
|
+
|
|
85
|
+
/** The character's SVG. Colour comes from `currentColor` (the mouth at 25 %). */
|
|
86
|
+
export function mascotSvg({ width = 280, height = 140, className = '' } = {}) {
|
|
87
|
+
return `<svg${className ? ` class="${className}"` : ''} viewBox="${MASCOT_VIEWBOX}" width="${width}" height="${height}" style="overflow:visible" aria-hidden="true" focusable="false">`
|
|
88
|
+
+ '<g class="syna-face">'
|
|
89
|
+
+ '<g class="syna-eye"><g class="syna-lid"><rect x="80" y="24" width="38" height="72" rx="19" fill="currentColor"/></g></g>'
|
|
90
|
+
+ '<g class="syna-eye"><g class="syna-lid"><rect x="162" y="24" width="38" height="72" rx="19" fill="currentColor"/></g></g>'
|
|
91
|
+
+ '<path class="syna-mouth" d="M118,116 Q140,130 162,116" fill="none" stroke="currentColor" stroke-opacity=".25" stroke-width="2.5" stroke-linecap="round"/>'
|
|
92
|
+
+ '<g class="syna-props"></g>'
|
|
93
|
+
+ '</g></svg>';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function mascotRefs(root) {
|
|
97
|
+
return {
|
|
98
|
+
lids: root.querySelectorAll('.syna-lid'),
|
|
99
|
+
mouth: root.querySelector('.syna-mouth'),
|
|
100
|
+
face: root.querySelector('.syna-face'),
|
|
101
|
+
props: root.querySelector('.syna-props'),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* v1 pose: look in [-1, 1] on both axes, blink in [0, 1] (1 = shut).
|
|
107
|
+
* Travel is in viewBox units; onboarding's full-page character uses 4 × 3.
|
|
108
|
+
*/
|
|
109
|
+
export function poseMascot(refs, lookX, lookY, blink, now, { rangeX = 4, rangeY = 3 } = {}) {
|
|
110
|
+
const moveX = lookX * rangeX;
|
|
111
|
+
const moveY = lookY * rangeY;
|
|
112
|
+
const cy = 60;
|
|
113
|
+
const vScale = Math.max(0.06, 1 - blink * 0.94);
|
|
114
|
+
refs.lids.forEach((lid) => {
|
|
115
|
+
lid.setAttribute('transform', `translate(${moveX},${moveY}) translate(0,${cy}) scale(1,${vScale}) translate(0,${-cy})`);
|
|
116
|
+
});
|
|
117
|
+
// The mouth follows at half the travel, with a slow wobble.
|
|
118
|
+
const t = (now || 0) * 0.001;
|
|
119
|
+
refs.mouth?.setAttribute('transform', `translate(${moveX * 0.5 + Math.sin(t * 0.7) * 1.2},${moveY * 0.5 + Math.cos(t * 1.1) * 0.8})`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Lid closure `elapsed` ms into a blink: 90 ms closing, 60 ms shut, 130 ms opening. */
|
|
123
|
+
export function blinkAmount(elapsed) {
|
|
124
|
+
if (!(elapsed >= 0)) return 0;
|
|
125
|
+
if (elapsed < 90) return elapsed / 90;
|
|
126
|
+
if (elapsed < 150) return 1;
|
|
127
|
+
if (elapsed < 280) return 1 - (elapsed - 150) / 130;
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Two 3×7 px pill eyes for a running pill; the host's CSS moves them. The
|
|
133
|
+
* pair leans −12° like the two-pill mark (the right eye sits higher), so it
|
|
134
|
+
* never reads as a pause glyph. The eyes stay untransformed for the CSS glance.
|
|
135
|
+
*/
|
|
136
|
+
export function mascotCameoSvg({ className = '' } = {}) {
|
|
137
|
+
return `<svg class="syna-cameo${className ? ` ${className}` : ''}" viewBox="0 0 10 7" width="10" height="7" style="overflow:visible" aria-hidden="true" focusable="false">`
|
|
138
|
+
+ '<g class="syna-cameo-pair" transform="rotate(-12 5 3.5)">'
|
|
139
|
+
+ '<rect class="syna-cameo-eye" x="0" y="0" width="3" height="7" rx="1.5" fill="currentColor"/>'
|
|
140
|
+
+ '<rect class="syna-cameo-eye" x="7" y="0" width="3" height="7" rx="1.5" fill="currentColor"/>'
|
|
141
|
+
+ '</g></svg>';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Each prop's own box in face units, to draw it alone (a ledger row's glyph, a suggestion's). */
|
|
145
|
+
const PROP_BOX = Object.freeze({
|
|
146
|
+
shell: [144, 116, 42, 26], // the last keycap and the caret
|
|
147
|
+
read: [65, 20, 150, 88],
|
|
148
|
+
edit: [188, 93, 56, 44],
|
|
149
|
+
search: [215, 31, 48, 46],
|
|
150
|
+
web: [216, 10, 44, 40],
|
|
151
|
+
subagent: [216, 38, 68, 44],
|
|
152
|
+
plan: [14, 17, 50, 67],
|
|
153
|
+
memory: [210, 2, 48, 48],
|
|
154
|
+
runs: [211, 16, 46, 46],
|
|
155
|
+
computer: [219, 60, 30, 38],
|
|
156
|
+
think: [202, -2, 52, 42],
|
|
157
|
+
mcp: [16, 68, 42, 72],
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* A kind's prop alone, framed to its own box: the glyph a ledger row shows
|
|
162
|
+
* so rows differ at a squint. Paint it with paintMascotProp. '' for a kind
|
|
163
|
+
* without a prop.
|
|
164
|
+
*/
|
|
165
|
+
export function mascotPropSvg(kind, { width = 24, height = 16, className = '' } = {}) {
|
|
166
|
+
const box = PROP_BOX[kind];
|
|
167
|
+
if (!box) return '';
|
|
168
|
+
return `<svg class="syna-prop-glyph${className ? ` ${className}` : ''}" viewBox="${box.join(' ')}" width="${width}" height="${height}" preserveAspectRatio="xMidYMid meet" aria-hidden="true" focusable="false">`
|
|
169
|
+
+ '<g class="syna-face"><g class="syna-props"></g></g></svg>';
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ── Math ──
|
|
173
|
+
|
|
174
|
+
const TAU = Math.PI * 2;
|
|
175
|
+
const clamp = (v, lo, hi) => (v < lo ? lo : v > hi ? hi : v);
|
|
176
|
+
const clamp01 = v => clamp(v, 0, 1);
|
|
177
|
+
const unit = v => clamp(Number(v) || 0, -1, 1);
|
|
178
|
+
const lerp = (a, b, p) => a + (b - a) * p;
|
|
179
|
+
const mod = (a, n) => ((a % n) + n) % n;
|
|
180
|
+
const smooth = p => p * p * (3 - 2 * p);
|
|
181
|
+
const easeOut = p => 1 - (1 - p) ** 3;
|
|
182
|
+
const intIn = (v, lo, hi, fallback) => {
|
|
183
|
+
const n = Math.round(Number(v));
|
|
184
|
+
return v != null && Number.isFinite(n) ? clamp(n, lo, hi) : fallback;
|
|
185
|
+
};
|
|
186
|
+
/** 0 → 1 → 0 across [start, start + dur). */
|
|
187
|
+
const bump = (t, start, dur) => {
|
|
188
|
+
const p = (t - start) / dur;
|
|
189
|
+
return p > 0 && p < 1 ? Math.sin(Math.PI * p) : 0;
|
|
190
|
+
};
|
|
191
|
+
/** A blink stretched over `dur` ms (the patient poses blink slowly). */
|
|
192
|
+
const blinkOver = (elapsed, dur) => blinkAmount(elapsed * 280 / dur);
|
|
193
|
+
/** Attribute number: two decimals, never "-0". */
|
|
194
|
+
const n = (v) => {
|
|
195
|
+
const r = Math.round(v * 100) / 100;
|
|
196
|
+
return String(r === 0 ? 0 : r);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
function cubicBezier(x1, y1, x2, y2) {
|
|
200
|
+
const cx = 3 * x1;
|
|
201
|
+
const bx = 3 * (x2 - x1) - cx;
|
|
202
|
+
const ax = 1 - cx - bx;
|
|
203
|
+
const cy = 3 * y1;
|
|
204
|
+
const by = 3 * (y2 - y1) - cy;
|
|
205
|
+
const ay = 1 - cy - by;
|
|
206
|
+
const X = s => ((ax * s + bx) * s + cx) * s;
|
|
207
|
+
const Y = s => ((ay * s + by) * s + cy) * s;
|
|
208
|
+
const dX = s => (3 * ax * s + 2 * bx) * s + cx;
|
|
209
|
+
return (x) => {
|
|
210
|
+
if (!(x > 0)) return 0;
|
|
211
|
+
if (x >= 1) return 1;
|
|
212
|
+
let s = x;
|
|
213
|
+
for (let i = 0; i < 8; i += 1) {
|
|
214
|
+
const err = X(s) - x;
|
|
215
|
+
if (Math.abs(err) < 1e-6) return Y(s);
|
|
216
|
+
const d = dX(s);
|
|
217
|
+
if (Math.abs(d) < 1e-6) break;
|
|
218
|
+
s -= err / d;
|
|
219
|
+
if (s < 0 || s > 1) break;
|
|
220
|
+
}
|
|
221
|
+
let lo = 0;
|
|
222
|
+
let hi = 1;
|
|
223
|
+
s = x;
|
|
224
|
+
for (let i = 0; i < 30; i += 1) {
|
|
225
|
+
const v = X(s);
|
|
226
|
+
if (Math.abs(v - x) < 1e-6) break;
|
|
227
|
+
if (v < x) lo = s; else hi = s;
|
|
228
|
+
s = (lo + hi) / 2;
|
|
229
|
+
}
|
|
230
|
+
return Y(s);
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** --asst-ease-standard: every blend. */
|
|
235
|
+
const easeStandard = cubicBezier(0.2, 0, 0.38, 0.9);
|
|
236
|
+
/** --asst-ease-spring, linear(0, 0.35 9%, 0.78 21%, 1.03 40%, 0.99 60%, 1): hops and snaps. */
|
|
237
|
+
const SPRING = [[0, 0], [0.09, 0.35], [0.21, 0.78], [0.4, 1.03], [0.6, 0.99], [1, 1]];
|
|
238
|
+
function springEase(p) {
|
|
239
|
+
if (!(p > 0)) return 0;
|
|
240
|
+
if (p >= 1) return 1;
|
|
241
|
+
for (let i = 1; i < SPRING.length; i += 1) {
|
|
242
|
+
const [x1, y1] = SPRING[i];
|
|
243
|
+
if (p <= x1) {
|
|
244
|
+
const [x0, y0] = SPRING[i - 1];
|
|
245
|
+
return y0 + (y1 - y0) * (p - x0) / (x1 - x0);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return 1;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ── Frames ──
|
|
252
|
+
|
|
253
|
+
const EYE_CX = [99, 181];
|
|
254
|
+
const EYE_CY = 60;
|
|
255
|
+
const RANGE = { x: 20, y: 12 }; // cursor travel, viewBox units
|
|
256
|
+
const ZERO = Object.freeze({ x: 0, y: 0 });
|
|
257
|
+
|
|
258
|
+
const eye = (dx = 0, dy = 0, sx = 1, sy = 1, rot = 0) => ({ dx, dy, sx, sy, rot });
|
|
259
|
+
const mouth = (w = 44, c = 14, dx = 0, dy = 0, rot = 0, op = 0.25) => ({ w, c, dx, dy, rot, op });
|
|
260
|
+
const blankFrame = () => ({ eyes: [eye(), eye()], mouth: mouth(), face: { dx: 0, dy: 0, rot: 0, op: 1 }, prop: { name: null } });
|
|
261
|
+
|
|
262
|
+
/** Gaze: both eyes travel, the mouth follows at `mouthK`, the far eye foreshortens. */
|
|
263
|
+
function gaze(f, look, range, mouthK = 0.5) {
|
|
264
|
+
const x = look.x * range.x;
|
|
265
|
+
const y = look.y * range.y;
|
|
266
|
+
for (const e of f.eyes) { e.dx += x; e.dy += y; }
|
|
267
|
+
f.mouth.dx += x * mouthK;
|
|
268
|
+
f.mouth.dy += y * mouthK;
|
|
269
|
+
f.eyes[1].sx *= 1 - 0.06 * clamp01(look.x);
|
|
270
|
+
f.eyes[0].sx *= 1 - 0.06 * clamp01(-look.x);
|
|
271
|
+
return f;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** The runs / wait poses: patient half-lids, a slow blink every 6 s, the gaze on look(). */
|
|
275
|
+
function patientPose(prop) {
|
|
276
|
+
return {
|
|
277
|
+
motion: 'blink',
|
|
278
|
+
look: 150,
|
|
279
|
+
frame(t, o) {
|
|
280
|
+
const f = blankFrame();
|
|
281
|
+
const c = o.still ? 0 : mod(t, 6000);
|
|
282
|
+
const k = 1 - 0.94 * (c >= 5520 ? blinkOver(c - 5520, 480) : 0);
|
|
283
|
+
f.eyes = [eye(0, 3, 1, 0.42 * k, 0), eye(0, 3, 1, 0.5 * k, 0)];
|
|
284
|
+
f.mouth = mouth(26, 3, 0, 0, 0, 0.25);
|
|
285
|
+
gaze(f, o.look, { x: o.range.x * 0.6, y: o.range.y * 0.6 });
|
|
286
|
+
f.prop = { name: prop };
|
|
287
|
+
return f;
|
|
288
|
+
},
|
|
289
|
+
/** ms until the pose moves again; 0 while it blinks. */
|
|
290
|
+
idleFor(t) {
|
|
291
|
+
const c = mod(t, 6000);
|
|
292
|
+
return c < 5520 ? 5520 - c : 0;
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const KEY_BEATS = [0, 420, 700, 1380, 1760]; // five irregular keystrokes per 2.48 s
|
|
298
|
+
const KEY_ORDER = [0, 2, 1, 2, 0];
|
|
299
|
+
const READ_STOPS = [-9, -3, 3, 9];
|
|
300
|
+
const SEARCH_POINTS = [[-9, -4], [7, -6], [10, 3], [-3, 5], [-10, 1], [4, -2]];
|
|
301
|
+
// Mini eye-pairs [x, y, scale] per count, right of the face (face coordinates;
|
|
302
|
+
// the parent steps 20 units left to make room).
|
|
303
|
+
const MINIS = [
|
|
304
|
+
[[250, 60, 0.5]],
|
|
305
|
+
[[246, 40, 0.42], [256, 94, 0.34]],
|
|
306
|
+
[[242, 28, 0.36], [262, 68, 0.3], [242, 106, 0.28]],
|
|
307
|
+
];
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* motion: 'loop' (30 fps while it leads), 'blink' (still between slow blinks),
|
|
311
|
+
* 'once' (plays `settle` ms, then still; `hold` before opts.then), 'still'.
|
|
312
|
+
* blinks: random blinks every 3-7 s. tracks: follows the cursor.
|
|
313
|
+
* look: follows look(), easing with this time constant (ms).
|
|
314
|
+
*/
|
|
315
|
+
const POSES = {
|
|
316
|
+
// ── States ──
|
|
317
|
+
idle: {
|
|
318
|
+
motion: 'still', blinks: true, tracks: true,
|
|
319
|
+
frame(t, o) {
|
|
320
|
+
return gaze(blankFrame(), o.look, o.range);
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
sleep: {
|
|
324
|
+
motion: 'loop',
|
|
325
|
+
frame(t, o) {
|
|
326
|
+
const f = blankFrame();
|
|
327
|
+
const b = o.still ? 0 : Math.sin(TAU * t / 6000);
|
|
328
|
+
const sy = 0.1 + 0.02 * b;
|
|
329
|
+
f.eyes = [eye(-1, 9, 1.04, sy, 0), eye(1, 9, 1.04, sy * 0.92, 0)];
|
|
330
|
+
f.mouth = mouth(22, 3, 0, 1, 0, 0.2);
|
|
331
|
+
f.face.dy = b;
|
|
332
|
+
return f;
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
watch: {
|
|
336
|
+
motion: 'still', blinks: true, look: 47,
|
|
337
|
+
frame(t, o) {
|
|
338
|
+
const f = blankFrame();
|
|
339
|
+
f.eyes = [eye(0, 10, 1, 1.05, 0), eye(0, 10, 1, 1.02, 0)];
|
|
340
|
+
f.mouth = mouth(24, 6, 0, 1, 0, 0.25);
|
|
341
|
+
return gaze(f, { x: o.look.x, y: 0 }, { x: o.range.x * 0.8, y: 0 });
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
wait: patientPose(null),
|
|
345
|
+
success: {
|
|
346
|
+
motion: 'once', settle: 900, hold: 1200,
|
|
347
|
+
frame(t, o) {
|
|
348
|
+
const f = blankFrame();
|
|
349
|
+
const tt = o.still ? 900 : t;
|
|
350
|
+
const happy = tt >= 290; // the eyes turn happy while the lids are shut
|
|
351
|
+
const k = 1 - 0.94 * (tt < 480 ? blinkAmount(tt - 200) : 0);
|
|
352
|
+
const lift = easeOut(clamp01(tt / 200));
|
|
353
|
+
const tilt = 8 * easeOut(clamp01((tt - 290) / 300));
|
|
354
|
+
const sy = happy ? 0.3 : lerp(1, 1.06, lift);
|
|
355
|
+
const dy = happy ? -4 : -3 * lift;
|
|
356
|
+
f.eyes = [eye(0, dy, 1.06, sy * k, -tilt), eye(0, dy, 1.06, sy * k, tilt)];
|
|
357
|
+
const smile = easeOut(clamp01(tt / 300));
|
|
358
|
+
f.mouth = mouth(lerp(44, 58, smile), lerp(14, 22, smile), 0, -smile, 0, lerp(0.25, 0.4, smile));
|
|
359
|
+
f.face.dy = -2.5 * bump(tt, 480, 360);
|
|
360
|
+
return f;
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
error: {
|
|
364
|
+
motion: 'once', settle: 120, hold: 1800,
|
|
365
|
+
frame(t, o) {
|
|
366
|
+
const f = blankFrame();
|
|
367
|
+
const e = o.still ? 1 : easeOut(clamp01(t / 120));
|
|
368
|
+
f.face.dy = 2 * e;
|
|
369
|
+
f.eyes = [eye(1.5 * e, 2 * e, 0.96, lerp(1, 0.8, e), 12 * e), eye(-1.5 * e, 2 * e, 0.96, lerp(1, 0.74, e), -12 * e)];
|
|
370
|
+
f.mouth = mouth(lerp(44, 34, e), lerp(14, -10, e), 0, 2 * e, 0, lerp(0.25, 0.32, e));
|
|
371
|
+
return f;
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
blocked: { // two pulses, then still; the eyes stay on what it waits for (look())
|
|
375
|
+
motion: 'once', settle: 1200, look: 47,
|
|
376
|
+
frame(t, o) {
|
|
377
|
+
const f = blankFrame();
|
|
378
|
+
const g = 1 + 0.05 * (o.still || t >= 1200 ? 0 : Math.sin(Math.PI * mod(t, 600) / 600));
|
|
379
|
+
f.eyes = [eye(0, -2, 1.02 * g, 1.1 * g, 0), eye(0, -2, 1.02 * g, 1.14 * g, 0)];
|
|
380
|
+
f.mouth = mouth(20, 0, 0, 1, 0, 0.3);
|
|
381
|
+
return gaze(f, o.look, { x: o.range.x * 0.6, y: o.range.y * 0.6 });
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
offline: {
|
|
385
|
+
motion: 'still',
|
|
386
|
+
frame() {
|
|
387
|
+
const f = blankFrame();
|
|
388
|
+
f.eyes = [eye(0, 5, 1, 0.42, 0), eye(0, 5, 1, 0.46, 0)];
|
|
389
|
+
f.mouth = mouth(30, 0, 0, 1, 0, 0.25);
|
|
390
|
+
f.face.op = 0.5;
|
|
391
|
+
return f;
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
// ── Kinds ──
|
|
396
|
+
shell: {
|
|
397
|
+
motion: 'loop', blinks: true,
|
|
398
|
+
frame(t, o) {
|
|
399
|
+
const f = blankFrame();
|
|
400
|
+
f.eyes = [eye(-1, 10, 1, 0.58, 3), eye(1, 10, 1, 0.62, -3)];
|
|
401
|
+
f.mouth = mouth(30, 1.5, 0, 0, 0, 0.25);
|
|
402
|
+
let nod = 0;
|
|
403
|
+
let key = -1;
|
|
404
|
+
if (!o.still) {
|
|
405
|
+
const c = mod(t, 2480);
|
|
406
|
+
KEY_BEATS.forEach((beat, i) => {
|
|
407
|
+
const b = bump(c, beat, 110);
|
|
408
|
+
if (b > 0) { nod = b; key = KEY_ORDER[i]; }
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
f.face.dy = 1.6 * nod;
|
|
412
|
+
// The keys stay put while the head nods over them.
|
|
413
|
+
f.prop = { name: 'shell', key, press: nod, caret: o.still || mod(t, 1060) < 530 ? 1 : 0, dy: -f.face.dy };
|
|
414
|
+
return f;
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
read: {
|
|
418
|
+
motion: 'loop',
|
|
419
|
+
frame(t, o) {
|
|
420
|
+
const f = blankFrame();
|
|
421
|
+
let x = READ_STOPS[1];
|
|
422
|
+
let b = 0;
|
|
423
|
+
if (!o.still) {
|
|
424
|
+
const c = mod(t, 1800);
|
|
425
|
+
if (c < 1540) {
|
|
426
|
+
const i = Math.min(3, Math.floor(c / 385));
|
|
427
|
+
x = i === 0 ? READ_STOPS[0] : lerp(READ_STOPS[i - 1], READ_STOPS[i], easeOut(clamp01((c - i * 385) / 70)));
|
|
428
|
+
} else {
|
|
429
|
+
// Carriage return: back to the start of the line with a blink.
|
|
430
|
+
x = lerp(READ_STOPS[3], READ_STOPS[0], smooth((c - 1540) / 260));
|
|
431
|
+
b = blinkOver(c - 1540, 260);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
const k = 1 - 0.94 * b;
|
|
435
|
+
f.eyes = [eye(x - 0.6, 4.5, 1, 0.86 * k, 0), eye(x + 0.6, 4, 1, 0.9 * k, 0)];
|
|
436
|
+
f.mouth = mouth(30, 7, x * 0.25, 0, 0, 0.25);
|
|
437
|
+
f.prop = { name: 'read' };
|
|
438
|
+
return f;
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
edit: {
|
|
442
|
+
motion: 'loop', blinks: true,
|
|
443
|
+
frame(t, o) {
|
|
444
|
+
const f = blankFrame();
|
|
445
|
+
const draw = o.still ? 0.6 : mod(t, 2520) / 2520;
|
|
446
|
+
const follow = (draw - 0.5) * 4; // the eyes ride the pencil
|
|
447
|
+
f.face.rot = -4;
|
|
448
|
+
f.eyes = [eye(5 + follow, 9, 1, 0.5, -3), eye(5 + follow, 9, 1, 0.9, 0)];
|
|
449
|
+
f.mouth = mouth(26, 6, 8, -1, -10, 0.25);
|
|
450
|
+
f.prop = { name: 'edit', draw, jig: o.still ? 0 : 1.2 * Math.sin(TAU * t / 420) };
|
|
451
|
+
return f;
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
search: {
|
|
455
|
+
motion: 'loop', blinks: true,
|
|
456
|
+
frame(t, o) {
|
|
457
|
+
const f = blankFrame();
|
|
458
|
+
let x = 2;
|
|
459
|
+
let y = -1;
|
|
460
|
+
if (!o.still) {
|
|
461
|
+
// Saccades: a 150 ms jump, a 270 ms hold, six points.
|
|
462
|
+
const c = mod(t, 2520);
|
|
463
|
+
const i = Math.floor(c / 420);
|
|
464
|
+
const e = easeStandard(clamp01((c - i * 420) / 150));
|
|
465
|
+
const [x0, y0] = SEARCH_POINTS[(i + 5) % 6];
|
|
466
|
+
const [x1, y1] = SEARCH_POINTS[i];
|
|
467
|
+
x = lerp(x0, x1, e);
|
|
468
|
+
y = lerp(y0, y1, e);
|
|
469
|
+
}
|
|
470
|
+
f.eyes = [eye(x, y, 0.94, 1.06, 0), eye(x, y, 0.94, 1.1, 0)];
|
|
471
|
+
f.mouth = mouth(16, 1, x * 0.4, 1 + y * 0.3, 0, 0.25);
|
|
472
|
+
const a = o.still ? 0 : TAU * t / 1400;
|
|
473
|
+
f.prop = { name: 'search', x: x * 0.5 + 1.3 * Math.cos(a), y: y * 0.5 + 1.3 * Math.sin(a) };
|
|
474
|
+
return f;
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
web: {
|
|
478
|
+
motion: 'loop', blinks: true,
|
|
479
|
+
frame(t, o) {
|
|
480
|
+
const f = blankFrame();
|
|
481
|
+
f.eyes = [eye(9, -3, 0.97, 0.92, 0), eye(9, -3, 1.02, 0.98, 0)];
|
|
482
|
+
f.mouth = mouth(26, 6, 5, -1, -3, 0.25);
|
|
483
|
+
f.prop = { name: 'web', spin: o.still ? 0.2 : mod(t, 2600) / 2600 };
|
|
484
|
+
return f;
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
subagent: {
|
|
488
|
+
motion: 'loop', blinks: true,
|
|
489
|
+
frame(t, o) {
|
|
490
|
+
const f = blankFrame();
|
|
491
|
+
f.face.dx = -20;
|
|
492
|
+
// Every 6 s the parent checks on its minis: 250 ms there, 700 ms, 300 ms back.
|
|
493
|
+
const c = o.still ? -1 : mod(t, 6000);
|
|
494
|
+
const g = c < 0 ? 0 : c < 250 ? easeStandard(c / 250) : c < 950 ? 1 : c < 1250 ? 1 - easeStandard((c - 950) / 300) : 0;
|
|
495
|
+
f.eyes = [eye(2 + 12 * g, 2 * g, 0.97, 0.96, 0), eye(2 + 12 * g, 2 * g, 1.03 - 0.05 * g, 1, 0)];
|
|
496
|
+
f.mouth = mouth(32, 10, 2 + 4 * g, 0, 0, 0.25);
|
|
497
|
+
const minis = MINIS[o.count - 1].map(([x, y, s], i) => ({
|
|
498
|
+
x,
|
|
499
|
+
y: y + (o.still ? 0 : 1.6 * Math.sin(TAU * (t / 1700 + i * 0.37))),
|
|
500
|
+
s,
|
|
501
|
+
sy: 1 - 0.94 * (o.still ? 0 : blinkAmount(mod(t + i * 1500, 4600) - 4300)),
|
|
502
|
+
look: -g,
|
|
503
|
+
op: 1,
|
|
504
|
+
}));
|
|
505
|
+
f.prop = { name: 'subagent', count: o.count, minis };
|
|
506
|
+
return f;
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
plan: {
|
|
510
|
+
motion: 'still', blinks: true,
|
|
511
|
+
frame(t, o) {
|
|
512
|
+
const f = blankFrame();
|
|
513
|
+
f.eyes = [eye(-8, -5, 1.02, 0.9, 0), eye(-8, -5, 0.97, 0.86, 2)];
|
|
514
|
+
f.mouth = mouth(30, 4, -3, 0, 0, 0.25);
|
|
515
|
+
f.prop = { name: 'plan', ticks: o.ticks, pop: 1 };
|
|
516
|
+
return f;
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
memory: {
|
|
520
|
+
motion: 'loop', blinks: true,
|
|
521
|
+
frame(t, o) {
|
|
522
|
+
const f = blankFrame();
|
|
523
|
+
f.eyes = [eye(4, -7, 1, 0.5, 0), eye(4, -7, 1, 0.58, 0)];
|
|
524
|
+
f.mouth = mouth(26, 4, 2, 0, 0, 0.25);
|
|
525
|
+
let gap;
|
|
526
|
+
let ring = 0;
|
|
527
|
+
let ringOp = 0;
|
|
528
|
+
let nod = 0;
|
|
529
|
+
if (o.mode === 'remember') {
|
|
530
|
+
// Snap together (200 ms spring), nod, drift apart for the next one.
|
|
531
|
+
const c = o.still ? 400 : mod(t, 1600);
|
|
532
|
+
gap = c < 200 ? 7 * (1 - springEase(c / 200)) : 7 * smooth(clamp01((c - 520) / 1080));
|
|
533
|
+
nod = o.still ? 0 : bump(c, 140, 260);
|
|
534
|
+
} else if (o.still) {
|
|
535
|
+
gap = 5;
|
|
536
|
+
} else {
|
|
537
|
+
// Recall: a sonar ring out of the mark while its pills slide apart.
|
|
538
|
+
const c = mod(t, 1400);
|
|
539
|
+
gap = c < 700 ? lerp(1, 7, easeOut(c / 700)) : lerp(7, 1, smooth((c - 700) / 700));
|
|
540
|
+
if (c < 700) { ring = 46 * easeOut(c / 700); ringOp = 0.5 * (1 - c / 700); }
|
|
541
|
+
}
|
|
542
|
+
f.face.dy = 2 * nod;
|
|
543
|
+
f.prop = { name: 'memory', gap, ring, ringOp };
|
|
544
|
+
return f;
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
runs: patientPose('runs'),
|
|
548
|
+
computer: {
|
|
549
|
+
motion: 'still', blinks: true, look: 47,
|
|
550
|
+
frame(t, o) {
|
|
551
|
+
const f = blankFrame();
|
|
552
|
+
f.eyes[0].sy = 0.95;
|
|
553
|
+
gaze(f, o.look, { x: 16, y: 10 }, 0.45);
|
|
554
|
+
f.prop = { name: 'computer', x: o.look.x, y: o.look.y, ripple: 0 };
|
|
555
|
+
return f;
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
think: {
|
|
559
|
+
motion: 'loop', blinks: true,
|
|
560
|
+
frame(t, o) {
|
|
561
|
+
const f = blankFrame();
|
|
562
|
+
// A slow figure-8 up and to the right.
|
|
563
|
+
const a = o.still ? Math.PI / 2 : TAU * t / 4800;
|
|
564
|
+
const x = 6 + 6 * Math.sin(a);
|
|
565
|
+
const y = -6 + 4 * Math.sin(2 * a);
|
|
566
|
+
f.eyes = [eye(x, y, 1, 0.88, 0), eye(x, y, 1, 0.8, -2)];
|
|
567
|
+
f.mouth = mouth(20, 0, -10, 1, -5, 0.25);
|
|
568
|
+
f.prop = { name: 'think', phase: o.still ? 0.9 : mod(t, 1200) / 1200 };
|
|
569
|
+
return f;
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
mcp: {
|
|
573
|
+
motion: 'loop', blinks: true,
|
|
574
|
+
frame(t, o) {
|
|
575
|
+
const f = blankFrame();
|
|
576
|
+
const c = o.still ? -1 : mod(t, 1200);
|
|
577
|
+
const g = c < 0 ? 0 : c < 120 ? easeStandard(c / 120) : c < 420 ? 1 : c < 560 ? 1 - easeStandard((c - 420) / 140) : 0;
|
|
578
|
+
f.eyes = [eye(-9 * g, 5 * g, 1 + 0.03 * g, 1, 0), eye(-9 * g, 5 * g, 1 - 0.04 * g, 0.97, 0)];
|
|
579
|
+
f.mouth = mouth(34, 9, -3 * g, 0, 0, 0.25);
|
|
580
|
+
f.prop = { name: 'mcp', nudge: g };
|
|
581
|
+
return f;
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
function poseOptions(opts) {
|
|
587
|
+
const o = opts && typeof opts === 'object' ? opts : {};
|
|
588
|
+
const look = o.look ? { x: unit(o.look.x), y: unit(o.look.y) } : { x: 0, y: 0 };
|
|
589
|
+
const range = {
|
|
590
|
+
x: Number(o.range?.x) > 0 ? Number(o.range.x) : RANGE.x,
|
|
591
|
+
y: Number(o.range?.y) > 0 ? Number(o.range.y) : RANGE.y,
|
|
592
|
+
};
|
|
593
|
+
return {
|
|
594
|
+
look,
|
|
595
|
+
range,
|
|
596
|
+
count: intIn(o.count, 1, 3, 1),
|
|
597
|
+
mode: o.mode === 'remember' ? 'remember' : 'recall',
|
|
598
|
+
ticks: intIn(o.ticks, 0, 3, 1),
|
|
599
|
+
still: !!o.still,
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* The pose `name` at `t` ms after it began. Pure and deterministic; unknown
|
|
605
|
+
* names fall back to idle. `opts.still` gives the still frame.
|
|
606
|
+
*/
|
|
607
|
+
export function poseFrame(name, t = 0, opts = {}) {
|
|
608
|
+
const def = POSES[name] || POSES.idle;
|
|
609
|
+
const time = Number.isFinite(t) && t > 0 ? t : 0;
|
|
610
|
+
const o = poseOptions(opts);
|
|
611
|
+
const frame = def.frame(time, o);
|
|
612
|
+
return o.still ? markStill(frame) : frame; // the painter makes a still's prop legible at a glance
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** Flag a frame as still (not enumerable: a still frame's geometry compares equal to a settled one). */
|
|
616
|
+
function markStill(frame) {
|
|
617
|
+
Object.defineProperty(frame, 'still', { value: true, enumerable: false, configurable: true });
|
|
618
|
+
return frame;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/** The frame a pose holds under reduced motion, off screen or inactive. */
|
|
622
|
+
export function stillFrame(name, opts = {}) {
|
|
623
|
+
return poseFrame(name, 0, { ...opts, still: true });
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/** The mouth's quadratic stroke: `w` wide, control `c` below the corners. */
|
|
627
|
+
export function mouthPath(m) {
|
|
628
|
+
const hw = m.w / 2;
|
|
629
|
+
const cx = 140 + m.dx;
|
|
630
|
+
const cy = 116 + m.dy;
|
|
631
|
+
const a = (m.rot * Math.PI) / 180;
|
|
632
|
+
const cos = Math.cos(a);
|
|
633
|
+
const sin = Math.sin(a);
|
|
634
|
+
const pt = (x, y) => `${n(cx + x * cos - y * sin)},${n(cy + x * sin + y * cos)}`;
|
|
635
|
+
return `M${pt(-hw, 0)} Q${pt(0, m.c)} ${pt(hw, 0)}`;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function cloneFrame(f) {
|
|
639
|
+
const out = {
|
|
640
|
+
eyes: [{ ...f.eyes[0] }, { ...f.eyes[1] }],
|
|
641
|
+
mouth: { ...f.mouth },
|
|
642
|
+
face: { ...f.face },
|
|
643
|
+
prop: f.prop?.minis ? { ...f.prop, minis: f.prop.minis.map(m => ({ ...m })) } : { ...f.prop },
|
|
644
|
+
...(f.propFrom !== undefined ? { propFrom: f.propFrom, propMix: f.propMix } : {}),
|
|
645
|
+
};
|
|
646
|
+
return f.still ? markStill(out) : out;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function mixFrames(a, b, p) {
|
|
650
|
+
const m = (x, y) => x + (y - x) * p;
|
|
651
|
+
const eyeMix = (e, g) => ({ dx: m(e.dx, g.dx), dy: m(e.dy, g.dy), sx: m(e.sx, g.sx), sy: m(e.sy, g.sy), rot: m(e.rot, g.rot) });
|
|
652
|
+
const out = {
|
|
653
|
+
eyes: [eyeMix(a.eyes[0], b.eyes[0]), eyeMix(a.eyes[1], b.eyes[1])],
|
|
654
|
+
mouth: { w: m(a.mouth.w, b.mouth.w), c: m(a.mouth.c, b.mouth.c), dx: m(a.mouth.dx, b.mouth.dx), dy: m(a.mouth.dy, b.mouth.dy), rot: m(a.mouth.rot, b.mouth.rot), op: m(a.mouth.op, b.mouth.op) },
|
|
655
|
+
face: { dx: m(a.face.dx, b.face.dx), dy: m(a.face.dy, b.face.dy), rot: m(a.face.rot, b.face.rot), op: m(a.face.op, b.face.op) },
|
|
656
|
+
prop: b.prop,
|
|
657
|
+
propFrom: a.prop,
|
|
658
|
+
propMix: p,
|
|
659
|
+
};
|
|
660
|
+
return b.still ? markStill(out) : out; // blending into a still: its prop is already legible
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/** Two frames that draw the same face and prop (a blend between them would be wasted frames). */
|
|
664
|
+
function sameFrame(a, b) {
|
|
665
|
+
const nums = f => [...f.eyes.flatMap(e => [e.dx, e.dy, e.sx, e.sy, e.rot]), f.mouth.w, f.mouth.c, f.mouth.dx, f.mouth.dy, f.mouth.rot, f.mouth.op, f.face.dx, f.face.dy, f.face.rot, f.face.op];
|
|
666
|
+
const x = nums(a);
|
|
667
|
+
const y = nums(b);
|
|
668
|
+
return (a.prop?.name || null) === (b.prop?.name || null) && x.every((v, i) => Math.abs(v - y[i]) < 1e-3);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// ── Reactions ──
|
|
672
|
+
|
|
673
|
+
const REACTIONS = { hop: 300, wince: 240, nod: 260, pop: 220, startle: 220, pulse: 600, click: 300, wiggle: 360, split: 420 };
|
|
674
|
+
|
|
675
|
+
/** `frame` with reaction `name` `p` (0-1) of the way through. Pure. */
|
|
676
|
+
export function reactionFrame(frame, name, p) {
|
|
677
|
+
const f = cloneFrame(frame);
|
|
678
|
+
const q = clamp01(Number(p) || 0);
|
|
679
|
+
const b = bump(q, 0, 1);
|
|
680
|
+
switch (name) {
|
|
681
|
+
case 'hop': {
|
|
682
|
+
// 90 ms up (stretching), then a spring landing that dips a touch below rest (squashing).
|
|
683
|
+
const up = q < 0.3 ? easeOut(q / 0.3) : 1 - springEase((q - 0.3) / 0.7);
|
|
684
|
+
const rise = bump(q, 0, 0.3);
|
|
685
|
+
const land = bump(q, 0.45, 0.35);
|
|
686
|
+
f.face.dy -= 12 * up;
|
|
687
|
+
for (const e of f.eyes) {
|
|
688
|
+
e.sy *= (1 + 0.06 * rise) * (1 - 0.12 * land);
|
|
689
|
+
e.sx *= (1 - 0.03 * rise) * (1 + 0.06 * land);
|
|
690
|
+
}
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
case 'wince':
|
|
694
|
+
for (const e of f.eyes) e.sy *= 1 - 0.45 * b; // lids to about .55
|
|
695
|
+
f.mouth.c = lerp(f.mouth.c, -Math.abs(f.mouth.c) - 4, b);
|
|
696
|
+
f.face.dy += 1.5 * b;
|
|
697
|
+
break;
|
|
698
|
+
case 'nod':
|
|
699
|
+
f.face.dy += 3 * b;
|
|
700
|
+
break;
|
|
701
|
+
case 'pop':
|
|
702
|
+
if (f.prop.name === 'plan') f.prop.pop = q;
|
|
703
|
+
else for (const e of f.eyes) { e.sy *= 1 + 0.08 * b; e.sx *= 1 + 0.04 * b; }
|
|
704
|
+
break;
|
|
705
|
+
case 'startle':
|
|
706
|
+
for (const e of f.eyes) { e.sy *= 1 + 0.15 * b; e.sx *= 1 + 0.03 * b; }
|
|
707
|
+
f.face.dy -= 2 * b;
|
|
708
|
+
break;
|
|
709
|
+
case 'pulse': {
|
|
710
|
+
const g = 1 + 0.06 * Math.sin(Math.PI * q);
|
|
711
|
+
for (const e of f.eyes) { e.sx *= g; e.sy *= g; }
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
714
|
+
case 'click': {
|
|
715
|
+
const k = 1 - 0.94 * blinkAmount(q * 280);
|
|
716
|
+
for (const e of f.eyes) e.sy *= k;
|
|
717
|
+
if (f.prop.name === 'computer') f.prop.ripple = q;
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
case 'wiggle': // the idle fidget: a small head wobble that dies out
|
|
721
|
+
f.face.rot += 3 * Math.sin(TAU * 2 * q) * (1 - q);
|
|
722
|
+
break;
|
|
723
|
+
case 'split': { // the eyes part, tilting away, and spring back into one face
|
|
724
|
+
const apart = q < 0.3 ? easeOut(q / 0.3) : 1 - springEase((q - 0.3) / 0.7);
|
|
725
|
+
f.eyes[0].dx -= 16 * apart;
|
|
726
|
+
f.eyes[1].dx += 16 * apart;
|
|
727
|
+
f.eyes[0].rot -= 12 * apart;
|
|
728
|
+
f.eyes[1].rot += 12 * apart;
|
|
729
|
+
for (const e of f.eyes) e.sy *= 1 - 0.1 * clamp01(apart);
|
|
730
|
+
f.mouth.op *= 1 - 0.6 * clamp01(apart);
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
default:
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
return f;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// ── Props: small, currentColor, in the face's pill geometry ──
|
|
740
|
+
|
|
741
|
+
const PROPS = {
|
|
742
|
+
shell: { // three keycaps and a block caret under the chin
|
|
743
|
+
markup: () => [0, 1, 2].map(i => `<rect class="syna-key" x="${100 + i * 24}" y="127" width="20" height="9" rx="4.5" fill="currentColor" fill-opacity=".4"/>`).join('')
|
|
744
|
+
+ '<rect class="syna-caret" x="174" y="125" width="7" height="12" rx="2" fill="currentColor" fill-opacity=".75"/>',
|
|
745
|
+
refs: g => ({ keys: Array.from(g.querySelectorAll('.syna-key')), caret: g.querySelector('.syna-caret') }),
|
|
746
|
+
update(r, p, put) {
|
|
747
|
+
r.keys.forEach((k, i) => {
|
|
748
|
+
const on = i === p.key ? p.press : 0;
|
|
749
|
+
put(k, 'transform', on ? `translate(0,${n(2 * on)})` : null);
|
|
750
|
+
put(k, 'fill-opacity', n(0.4 + 0.35 * on));
|
|
751
|
+
});
|
|
752
|
+
put(r.caret, 'fill-opacity', p.caret ? '.75' : '.12');
|
|
753
|
+
},
|
|
754
|
+
},
|
|
755
|
+
read: { // two thin reading rings round the eyes
|
|
756
|
+
markup: () => '<g fill="none" stroke="currentColor" stroke-opacity=".5" stroke-width="4"><rect x="69" y="24" width="60" height="80" rx="30"/><rect x="151" y="24" width="60" height="80" rx="30"/><path d="M129,58 Q140,50 151,58" stroke-linecap="round"/></g>',
|
|
757
|
+
refs: () => ({}),
|
|
758
|
+
update() {},
|
|
759
|
+
},
|
|
760
|
+
edit: { // a pencil drawing a stroke
|
|
761
|
+
markup: () => '<path class="syna-ink" d="M192,130 q5.5,-3 11,0 t11,0 t11,0 t11,0" pathLength="1" fill="none" stroke="currentColor" stroke-opacity=".45" stroke-width="3" stroke-linecap="round" stroke-dasharray="1 1" stroke-dashoffset="1"/>'
|
|
762
|
+
+ '<g class="syna-pencil" fill="currentColor" fill-opacity=".75"><rect x="-4" y="-34" width="8" height="25" rx="4"/><path d="M-3.6,-10 L0,-1 L3.6,-10 Z"/></g>',
|
|
763
|
+
refs: g => ({ ink: g.querySelector('.syna-ink'), pencil: g.querySelector('.syna-pencil') }),
|
|
764
|
+
update(r, p, put) {
|
|
765
|
+
const fade = p.draw > 0.85 ? (1 - p.draw) / 0.15 : 1;
|
|
766
|
+
put(r.ink, 'stroke-dashoffset', n(1 - p.draw));
|
|
767
|
+
put(r.ink, 'stroke-opacity', n(0.45 * fade));
|
|
768
|
+
put(r.pencil, 'transform', `translate(${n(192 + 44 * p.draw)},${n(129 + p.jig)}) rotate(35)`);
|
|
769
|
+
},
|
|
770
|
+
},
|
|
771
|
+
search: { // a magnifier on a small orbit
|
|
772
|
+
markup: () => '<g class="syna-glass"><circle cx="232" cy="50" r="12" fill="none" stroke="currentColor" stroke-opacity=".6" stroke-width="5"/><rect x="244.5" y="58" width="7" height="16" rx="3.5" transform="rotate(-45 248 66)" fill="currentColor" fill-opacity=".6"/></g>',
|
|
773
|
+
refs: g => ({ glass: g.querySelector('.syna-glass') }),
|
|
774
|
+
update(r, p, put) {
|
|
775
|
+
put(r.glass, 'transform', `translate(${n(p.x)},${n(p.y)})`);
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
web: { // a globe whose meridian turns
|
|
779
|
+
markup: () => '<g fill="none" stroke="currentColor" stroke-width="3.5"><circle cx="238" cy="30" r="16" stroke-opacity=".55"/><ellipse cx="238" cy="30" rx="16" ry="5.5" stroke-opacity=".28"/><path class="syna-meridian" d="M238,14 L238,46" stroke-opacity=".55"/></g>',
|
|
780
|
+
refs: g => ({ meridian: g.querySelector('.syna-meridian') }),
|
|
781
|
+
update(r, p, put) {
|
|
782
|
+
const a = TAU * p.spin;
|
|
783
|
+
const bulge = 16 * Math.sin(a);
|
|
784
|
+
put(r.meridian, 'd', Math.abs(bulge) < 0.6 ? 'M238,14 L238,46' : `M238,14 A${n(Math.abs(bulge))},16 0 0 ${bulge > 0 ? 1 : 0} 238,46`);
|
|
785
|
+
put(r.meridian, 'stroke-opacity', Math.cos(a) >= 0 ? '.55' : '.18');
|
|
786
|
+
},
|
|
787
|
+
},
|
|
788
|
+
subagent: { // 1-3 mini eye-pairs, one <use> each
|
|
789
|
+
markup: uid => `<defs><g id="${uid}-pair"><rect x="-60" y="-36" width="38" height="72" rx="19" fill="currentColor"/><rect x="22" y="-36" width="38" height="72" rx="19" fill="currentColor"/></g></defs>`
|
|
790
|
+
+ [0, 1, 2].map(() => `<use class="syna-mini" href="#${uid}-pair" fill-opacity=".78" display="none"/>`).join(''),
|
|
791
|
+
refs: g => ({ minis: Array.from(g.querySelectorAll('.syna-mini')) }),
|
|
792
|
+
update(r, p, put) {
|
|
793
|
+
r.minis.forEach((u, i) => {
|
|
794
|
+
const m = p.minis?.[i];
|
|
795
|
+
if (!m) { put(u, 'display', 'none'); return; }
|
|
796
|
+
put(u, 'display', null);
|
|
797
|
+
put(u, 'transform', `translate(${n(m.x + 3 * m.look)},${n(m.y)}) scale(${n(m.s)},${n(m.s * Math.max(0.04, m.sy))})`);
|
|
798
|
+
put(u, 'opacity', m.op < 0.999 ? n(m.op) : null);
|
|
799
|
+
});
|
|
800
|
+
},
|
|
801
|
+
},
|
|
802
|
+
plan: { // a clipboard with three rows; ticked rows pop in
|
|
803
|
+
markup: () => '<rect x="20" y="26" width="38" height="52" rx="8" fill="none" stroke="currentColor" stroke-opacity=".5" stroke-width="3.5"/>'
|
|
804
|
+
+ '<rect x="31" y="21" width="16" height="9" rx="4.5" fill="currentColor" fill-opacity=".6"/>'
|
|
805
|
+
+ [0, 1, 2].map((i) => {
|
|
806
|
+
const y = 40 + i * 12;
|
|
807
|
+
return `<g class="syna-check"><circle cx="30" cy="${y}" r="3.6" fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-opacity=".5" stroke-width="2.2"/>`
|
|
808
|
+
+ `<path d="M27.7,${y} l1.7,1.9 l3.3,-3.9" fill="none" stroke="currentColor" stroke-opacity=".85" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" display="none"/></g>`
|
|
809
|
+
+ `<rect x="37" y="${y - 1.5}" width="15" height="3" rx="1.5" fill="currentColor" fill-opacity=".35"/>`;
|
|
810
|
+
}).join(''),
|
|
811
|
+
refs: g => ({ rows: Array.from(g.querySelectorAll('.syna-check')).map(check => ({ check, box: check.firstElementChild, tick: check.lastElementChild })) }),
|
|
812
|
+
update(r, p, put) {
|
|
813
|
+
r.rows.forEach((row, i) => {
|
|
814
|
+
const on = i < p.ticks;
|
|
815
|
+
const y = 40 + i * 12;
|
|
816
|
+
put(row.tick, 'display', on ? null : 'none');
|
|
817
|
+
put(row.box, 'fill-opacity', on ? '.25' : '0');
|
|
818
|
+
const popping = on && i === p.ticks - 1 && p.pop < 1;
|
|
819
|
+
const s = popping ? 0.6 + 0.4 * springEase(p.pop) : 1;
|
|
820
|
+
put(row.check, 'transform', s !== 1 ? `translate(30,${y}) scale(${n(s)}) translate(-30,${-y})` : null);
|
|
821
|
+
put(row.tick, 'stroke-opacity', popping ? n(0.85 * clamp01(p.pop * 3)) : '.85');
|
|
822
|
+
});
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
memory: { // the two-pill SynaBun mark and a sonar ring
|
|
826
|
+
markup: () => '<circle class="syna-sonar" cx="234" cy="26" r="1" fill="none" stroke="currentColor" stroke-width="3" stroke-opacity="0" display="none"/>'
|
|
827
|
+
+ '<g class="syna-pill-a"><rect x="-13.2" y="-6" width="26.4" height="12" rx="6" transform="rotate(-12)" fill="currentColor" fill-opacity=".72"/></g>'
|
|
828
|
+
+ '<g class="syna-pill-b"><rect x="-13.2" y="-6" width="26.4" height="12" rx="6" transform="rotate(-12)" fill="currentColor" fill-opacity=".72"/></g>',
|
|
829
|
+
refs: g => ({ ring: g.querySelector('.syna-sonar'), a: g.querySelector('.syna-pill-a'), b: g.querySelector('.syna-pill-b') }),
|
|
830
|
+
update(r, p, put) {
|
|
831
|
+
const h = p.gap / 2; // along the mark's diagonal
|
|
832
|
+
put(r.a, 'transform', `translate(${n(238.2 + 0.447 * h)},${n(17.6 - 0.894 * h)})`);
|
|
833
|
+
put(r.b, 'transform', `translate(${n(229.8 - 0.447 * h)},${n(34.4 + 0.894 * h)})`);
|
|
834
|
+
const on = p.ring > 0.5 && p.ringOp > 0.01;
|
|
835
|
+
put(r.ring, 'display', on ? null : 'none');
|
|
836
|
+
if (on) { put(r.ring, 'r', n(p.ring)); put(r.ring, 'stroke-opacity', n(p.ringOp)); }
|
|
837
|
+
},
|
|
838
|
+
},
|
|
839
|
+
runs: { // a radar dish listening
|
|
840
|
+
markup: () => '<g fill="none" stroke="currentColor" stroke-linecap="round">'
|
|
841
|
+
+ '<path d="M222,30 A20,20 0 0 0 242,50" stroke-opacity=".6" stroke-width="4"/>'
|
|
842
|
+
+ '<path d="M228,44 L236,36 M228,44 L223,55 M217,55 L229,55" stroke-opacity=".5" stroke-width="3"/>'
|
|
843
|
+
+ '<path d="M237.4,28.1 A8,8 0 0 1 243.9,34.6" stroke-opacity=".45" stroke-width="3"/>'
|
|
844
|
+
+ '<path d="M238.4,22.2 A14,14 0 0 1 249.8,33.6" stroke-opacity=".3" stroke-width="3"/></g>',
|
|
845
|
+
refs: () => ({}),
|
|
846
|
+
update() {},
|
|
847
|
+
},
|
|
848
|
+
computer: { // a cursor arrow and its click ripple
|
|
849
|
+
markup: () => '<circle class="syna-ripple" r="4" fill="none" stroke="currentColor" stroke-width="2.5" stroke-opacity="0" display="none"/>'
|
|
850
|
+
+ '<path class="syna-cursor" d="M0,0 L0,22 L5.5,17 L9.5,25.5 L13.5,23.8 L9.6,15.4 L16.5,15.4 Z" fill="currentColor" fill-opacity=".85" stroke="currentColor" stroke-opacity=".85" stroke-width="1.5" stroke-linejoin="round"/>',
|
|
851
|
+
refs: g => ({ ripple: g.querySelector('.syna-ripple'), cursor: g.querySelector('.syna-cursor') }),
|
|
852
|
+
update(r, p, put) {
|
|
853
|
+
const x = 226 + 30 * p.x;
|
|
854
|
+
const y = 66 + 40 * p.y;
|
|
855
|
+
put(r.cursor, 'transform', `translate(${n(x)},${n(y)})`);
|
|
856
|
+
const on = p.ripple > 0 && p.ripple < 1;
|
|
857
|
+
put(r.ripple, 'display', on ? null : 'none');
|
|
858
|
+
if (on) {
|
|
859
|
+
put(r.ripple, 'cx', n(x));
|
|
860
|
+
put(r.ripple, 'cy', n(y));
|
|
861
|
+
put(r.ripple, 'r', n(3 + 13 * easeOut(p.ripple)));
|
|
862
|
+
put(r.ripple, 'stroke-opacity', n(0.6 * (1 - p.ripple)));
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
},
|
|
866
|
+
think: { // three thought dots, lit in turn
|
|
867
|
+
markup: () => '<circle cx="210" cy="32" r="3.5" fill="currentColor"/><circle cx="224" cy="20" r="5" fill="currentColor"/><circle cx="243" cy="9" r="6.5" fill="currentColor"/>',
|
|
868
|
+
refs: g => ({ dots: Array.from(g.querySelectorAll('circle')) }),
|
|
869
|
+
update(r, p, put) {
|
|
870
|
+
r.dots.forEach((dot, i) => {
|
|
871
|
+
const q = (p.phase - i * 0.22) / 0.5;
|
|
872
|
+
put(dot, 'fill-opacity', n(0.25 + 0.55 * (q > 0 && q < 1 ? Math.sin(Math.PI * q) : 0)));
|
|
873
|
+
});
|
|
874
|
+
},
|
|
875
|
+
},
|
|
876
|
+
mcp: { // a two-prong plug on its cord
|
|
877
|
+
markup: () => '<path d="M41,106 C41,120 30,122 22,134" fill="none" stroke="currentColor" stroke-opacity=".4" stroke-width="3" stroke-linecap="round"/>'
|
|
878
|
+
+ '<g class="syna-plug" fill="currentColor" fill-opacity=".65"><rect x="30" y="86" width="22" height="20" rx="7"/><rect x="34" y="74" width="4.5" height="14" rx="2.25"/><rect x="43.5" y="74" width="4.5" height="14" rx="2.25"/></g>',
|
|
879
|
+
refs: g => ({ plug: g.querySelector('.syna-plug') }),
|
|
880
|
+
update(r, p, put) {
|
|
881
|
+
put(r.plug, 'transform', p.nudge ? `translate(${n(2 * p.nudge)},${n(-1.5 * p.nudge)})` : null);
|
|
882
|
+
},
|
|
883
|
+
},
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
// ── Painter: frame → attributes, each written only when it changed ──
|
|
887
|
+
|
|
888
|
+
let uidSeq = 0;
|
|
889
|
+
const nextUid = () => `syna-m${(uidSeq += 1).toString(36)}`;
|
|
890
|
+
|
|
891
|
+
function lidTransform(e, i) {
|
|
892
|
+
const cx = EYE_CX[i];
|
|
893
|
+
return `translate(${n(e.dx)},${n(e.dy)}) translate(${cx},${EYE_CY}) rotate(${n(e.rot)}) scale(${n(e.sx)},${n(Math.max(0.04, e.sy))}) translate(${-cx},${-EYE_CY})`;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// A still frame's prop reads at a glance: every visible part at least this
|
|
897
|
+
// opaque, every stroke at least this many CSS px wide (the live loop keeps
|
|
898
|
+
// the drawn values; a still has no motion to carry a faint prop).
|
|
899
|
+
const STILL_PROP_OPACITY = 0.7;
|
|
900
|
+
const STILL_STROKE_PX = 1.5;
|
|
901
|
+
const OPACITY_ATTRS = ['fill-opacity', 'stroke-opacity'];
|
|
902
|
+
|
|
903
|
+
function createPainter(svg, uid) {
|
|
904
|
+
const refs = mascotRefs(svg);
|
|
905
|
+
const lids = Array.from(refs.lids).slice(0, 2);
|
|
906
|
+
const written = new WeakMap();
|
|
907
|
+
const built = new Map();
|
|
908
|
+
const put = (el, attr, value) => {
|
|
909
|
+
if (!el) return;
|
|
910
|
+
let seen = written.get(el);
|
|
911
|
+
if (!seen) { seen = {}; written.set(el, seen); }
|
|
912
|
+
if (seen[attr] === value) return;
|
|
913
|
+
seen[attr] = value;
|
|
914
|
+
if (value == null) el.removeAttribute(attr);
|
|
915
|
+
else el.setAttribute(attr, value);
|
|
916
|
+
};
|
|
917
|
+
/** CSS px per face unit: the SVG's box over its viewBox (xMidYMid meet: the tighter axis). */
|
|
918
|
+
const unitPx = () => {
|
|
919
|
+
const w = Number(svg.getAttribute?.('width'));
|
|
920
|
+
const h = Number(svg.getAttribute?.('height'));
|
|
921
|
+
const box = String(svg.getAttribute?.('viewBox') || '').split(/[\s,]+/).map(Number);
|
|
922
|
+
if (!(w > 0 && box[2] > 0)) return 1;
|
|
923
|
+
return h > 0 && box[3] > 0 ? Math.min(w / box[2], h / box[3]) : w / box[2];
|
|
924
|
+
};
|
|
925
|
+
const propEntry = (name) => {
|
|
926
|
+
let entry = built.get(name);
|
|
927
|
+
if (entry || !refs.props || !PROPS[name]) return entry || null;
|
|
928
|
+
refs.props.insertAdjacentHTML('beforeend', `<g class="syna-prop" data-prop="${name}" display="none">${PROPS[name].markup(uid)}</g>`);
|
|
929
|
+
const g = refs.props.lastElementChild;
|
|
930
|
+
// The drawn attributes as the markup has them: a live frame goes back to these before its update.
|
|
931
|
+
const base = [];
|
|
932
|
+
for (const el of g.querySelectorAll('[fill-opacity], [stroke-opacity], [stroke-width]')) {
|
|
933
|
+
for (const attr of [...OPACITY_ATTRS, 'stroke-width']) if (el.hasAttribute(attr)) base.push({ el, attr, value: el.getAttribute(attr) });
|
|
934
|
+
}
|
|
935
|
+
entry = { g, r: PROPS[name].refs(g), base };
|
|
936
|
+
built.set(name, entry);
|
|
937
|
+
return entry;
|
|
938
|
+
};
|
|
939
|
+
/** Raise a still's prop: visible parts to STILL_PROP_OPACITY, strokes to STILL_STROKE_PX. */
|
|
940
|
+
const legible = (entry) => {
|
|
941
|
+
const minStroke = STILL_STROKE_PX / unitPx();
|
|
942
|
+
for (const el of entry.g.querySelectorAll('[fill-opacity], [stroke-opacity], [stroke-width]')) {
|
|
943
|
+
for (const attr of OPACITY_ATTRS) {
|
|
944
|
+
// A fill under a stroke is a background (a ticked box): raising it would drown what is drawn on it.
|
|
945
|
+
if (attr === 'fill-opacity' && (el.getAttribute('stroke') || 'none') !== 'none') continue;
|
|
946
|
+
const v = Number(el.getAttribute(attr));
|
|
947
|
+
if (el.hasAttribute(attr) && v > 0.05 && v < STILL_PROP_OPACITY) put(el, attr, String(STILL_PROP_OPACITY));
|
|
948
|
+
}
|
|
949
|
+
const w = Number(el.getAttribute('stroke-width'));
|
|
950
|
+
if (el.hasAttribute('stroke-width') && w > 0 && w < minStroke) put(el, 'stroke-width', n(minStroke));
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
function paint(f) {
|
|
954
|
+
if (refs.face) {
|
|
955
|
+
put(refs.face, 'transform', `translate(${n(f.face.dx)},${n(f.face.dy)}) rotate(${n(f.face.rot)} 140 70)`);
|
|
956
|
+
put(refs.face, 'opacity', f.face.op < 0.999 ? n(f.face.op) : null);
|
|
957
|
+
}
|
|
958
|
+
lids.forEach((lid, i) => put(lid, 'transform', lidTransform(f.eyes[i], i)));
|
|
959
|
+
put(refs.mouth, 'd', mouthPath(f.mouth));
|
|
960
|
+
put(refs.mouth, 'stroke-opacity', n(f.mouth.op));
|
|
961
|
+
const cur = f.prop?.name || null;
|
|
962
|
+
const prev = f.propFrom?.name || null;
|
|
963
|
+
const mix = prev !== cur && f.propMix != null ? clamp01(f.propMix) : 1;
|
|
964
|
+
if (cur) propEntry(cur);
|
|
965
|
+
for (const [name, entry] of built) {
|
|
966
|
+
let op = 0;
|
|
967
|
+
let p = null;
|
|
968
|
+
if (name === cur) { op = mix; p = f.prop; } else if (name === prev) { op = 1 - mix; p = f.propFrom; }
|
|
969
|
+
if (op <= 0.001) { put(entry.g, 'display', 'none'); continue; }
|
|
970
|
+
put(entry.g, 'display', null);
|
|
971
|
+
put(entry.g, 'opacity', op < 0.999 ? n(op) : null);
|
|
972
|
+
put(entry.g, 'transform', p.dx || p.dy ? `translate(${n(p.dx || 0)},${n(p.dy || 0)})` : null);
|
|
973
|
+
if (!f.still) for (const b of entry.base) put(b.el, b.attr, b.value); // live: the drawn values
|
|
974
|
+
PROPS[name].update(entry.r, p, put);
|
|
975
|
+
if (f.still) legible(entry);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return { paint };
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/** Paint the prop of `kind` in its still state on an SVG from mascotPropSvg(); no face transform. */
|
|
982
|
+
export function paintMascotProp(svg, kind) {
|
|
983
|
+
if (!svg || !PROP_BOX[kind]) return;
|
|
984
|
+
const frame = stillFrame(kind);
|
|
985
|
+
paintMascot(svg, markStill({ ...frame, face: { dx: 0, dy: 0, rot: 0, op: 1 }, prop: { ...frame.prop, dx: 0, dy: 0 } }));
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
const painters = new WeakMap();
|
|
989
|
+
|
|
990
|
+
/** Draw `frame` (poseFrame / stillFrame) on an SVG from mascotSvg(); no rig needed. */
|
|
991
|
+
export function paintMascot(svg, frame) {
|
|
992
|
+
let painter = painters.get(svg);
|
|
993
|
+
if (!painter) { painter = createPainter(svg, nextUid()); painters.set(svg, painter); }
|
|
994
|
+
painter.paint(frame);
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
// ── Shared runtime: one observer, one motion listener, one lead ──
|
|
998
|
+
|
|
999
|
+
const rigs = new Set();
|
|
1000
|
+
let leadRig = null;
|
|
1001
|
+
let promoteSeq = 0;
|
|
1002
|
+
let stopMotionWatch = null;
|
|
1003
|
+
let io = null;
|
|
1004
|
+
const ioRigs = new WeakMap();
|
|
1005
|
+
|
|
1006
|
+
/** Only one rig plays a pose loop: the most recently posed one that wants to. */
|
|
1007
|
+
function elect() {
|
|
1008
|
+
let best = null;
|
|
1009
|
+
for (const rig of rigs) if (rig.wantsLead() && (!best || rig.promotedAt() > best.promotedAt())) best = rig;
|
|
1010
|
+
if (best === leadRig) return;
|
|
1011
|
+
const prev = leadRig;
|
|
1012
|
+
leadRig = best;
|
|
1013
|
+
prev?.leadChanged();
|
|
1014
|
+
best?.leadChanged();
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function observe(el, rig) {
|
|
1018
|
+
if (typeof IntersectionObserver !== 'function') return;
|
|
1019
|
+
try {
|
|
1020
|
+
io ||= new IntersectionObserver((entries) => {
|
|
1021
|
+
for (const entry of entries) ioRigs.get(entry.target)?.visibilityChanged(entry.isIntersecting);
|
|
1022
|
+
});
|
|
1023
|
+
ioRigs.set(el, rig);
|
|
1024
|
+
io.observe(el);
|
|
1025
|
+
} catch { /* no observer: the rig counts as on screen */ }
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
function unobserve(el) {
|
|
1029
|
+
ioRigs.delete(el);
|
|
1030
|
+
try { io?.unobserve(el); } catch { /* already gone */ }
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
function register(rig) {
|
|
1034
|
+
rigs.add(rig);
|
|
1035
|
+
stopMotionWatch ||= onReducedMotionChange(() => {
|
|
1036
|
+
for (const r of Array.from(rigs)) r.motionChanged();
|
|
1037
|
+
elect();
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function unregister(rig) {
|
|
1042
|
+
rigs.delete(rig);
|
|
1043
|
+
if (leadRig === rig) { leadRig = null; elect(); }
|
|
1044
|
+
if (!rigs.size && stopMotionWatch) { stopMotionWatch(); stopMotionWatch = null; }
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
const BLEND_MS = 160;
|
|
1048
|
+
const AIM_K = 140; // px: the cursor distance at which the eyes travel half way
|
|
1049
|
+
const GLANCES = [[-0.8, -0.35], [0.85, -0.25], [0.45, 0.6], [-0.5, 0.55], [0.1, -0.7]];
|
|
1050
|
+
const TRACK_TAU = 200; // the v1 lerp of .08 per 60 Hz frame
|
|
1051
|
+
const SETTLE_UNITS = 0.25; // gaze closer than this (viewBox units, a tenth of a pixel at 120 px) has arrived
|
|
1052
|
+
const rand = (lo, hi) => lo + Math.random() * (hi - lo);
|
|
1053
|
+
|
|
1054
|
+
/** Internal: live rigs registered right now (tests check that still faces are not rigs). */
|
|
1055
|
+
export const __mascot = { rigs: () => rigs.size };
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Mount a live character. `createMascot(container, opts)` appends it (v1);
|
|
1059
|
+
* `createMascot(opts)` returns it unattached as `el`. See the module header.
|
|
1060
|
+
*/
|
|
1061
|
+
export function createMascot(container, options) {
|
|
1062
|
+
let host = container;
|
|
1063
|
+
let opts = options;
|
|
1064
|
+
if (!host || typeof host.insertAdjacentHTML !== 'function') {
|
|
1065
|
+
opts = host && typeof host === 'object' ? host : options;
|
|
1066
|
+
host = null;
|
|
1067
|
+
}
|
|
1068
|
+
const {
|
|
1069
|
+
width = 128, height = 64, rangeX, rangeY, className = 'synabun-mascot',
|
|
1070
|
+
pose: firstPose = 'idle', poseOptions: firstOptions, active: startActive,
|
|
1071
|
+
} = opts || {};
|
|
1072
|
+
const markup = mascotSvg({ width, height, className });
|
|
1073
|
+
let svg;
|
|
1074
|
+
if (host) {
|
|
1075
|
+
host.insertAdjacentHTML('beforeend', markup);
|
|
1076
|
+
svg = host.lastElementChild;
|
|
1077
|
+
} else {
|
|
1078
|
+
const holder = document.createElement('div');
|
|
1079
|
+
holder.innerHTML = markup;
|
|
1080
|
+
svg = holder.firstElementChild;
|
|
1081
|
+
svg.remove();
|
|
1082
|
+
}
|
|
1083
|
+
const painter = createPainter(svg, nextUid());
|
|
1084
|
+
painters.set(svg, painter); // paintMascot() on a live rig's SVG reuses its props
|
|
1085
|
+
const range = { x: Math.max(RANGE.x, Number(rangeX) || 0), y: Math.max(RANGE.y, Number(rangeY) || 0) };
|
|
1086
|
+
|
|
1087
|
+
let destroyed = false;
|
|
1088
|
+
let active = startActive !== false;
|
|
1089
|
+
let visible = true;
|
|
1090
|
+
let seenConnected = svg.isConnected;
|
|
1091
|
+
let promotedAt = (promoteSeq += 1);
|
|
1092
|
+
let clock = 0; // rig time in ms: the ticker's dt while drawing, real time while still
|
|
1093
|
+
let frozenAt = tickerNow(); // while not drawing: when the clock was last brought up to date; -1 while drawing
|
|
1094
|
+
let pose = { name: 'idle', raw: {}, start: 0, then: null };
|
|
1095
|
+
let settled = false; // a one-shot's opts.then has fired
|
|
1096
|
+
let blend = null; // { from, start, dur }
|
|
1097
|
+
let lastFrame = null; // the last frame before blinks and reactions
|
|
1098
|
+
let drawn = false; // has drawn a live frame (a never-drawn rig has nothing to blend from)
|
|
1099
|
+
let look = { x: 0, y: 0 }; // eased gaze
|
|
1100
|
+
let track = { x: 0, y: 0 }; // idle: where the cursor (or look()) points
|
|
1101
|
+
let hostLook = { x: 0, y: 0 };
|
|
1102
|
+
let pointerAt = -Infinity;
|
|
1103
|
+
let aim = null; // a pointer position to aim at on the next frame
|
|
1104
|
+
let glance = null; // idle: { x, y, until }
|
|
1105
|
+
let blinkStart = -1;
|
|
1106
|
+
let nextBlinkAt = Infinity;
|
|
1107
|
+
let nextGlanceAt = Infinity;
|
|
1108
|
+
let nextFidgetAt = Infinity;
|
|
1109
|
+
let lastHopAt = -Infinity;
|
|
1110
|
+
let ticks = 1;
|
|
1111
|
+
let miniBorn = [];
|
|
1112
|
+
const reactions = [];
|
|
1113
|
+
const tempClasses = new Set();
|
|
1114
|
+
let unsubscribeFrames = null;
|
|
1115
|
+
let fps = 0;
|
|
1116
|
+
let stopPointer = null;
|
|
1117
|
+
let stopKey = null;
|
|
1118
|
+
let wakeTimer = 0;
|
|
1119
|
+
|
|
1120
|
+
const def = () => POSES[pose.name];
|
|
1121
|
+
const animating = () => !destroyed && active && visible && !isReducedMotion();
|
|
1122
|
+
const isLead = () => leadRig === rig;
|
|
1123
|
+
const poseTime = () => clock - pose.start;
|
|
1124
|
+
|
|
1125
|
+
function wantsLead() {
|
|
1126
|
+
if (!animating()) return false;
|
|
1127
|
+
const { motion, settle } = def();
|
|
1128
|
+
if (motion === 'loop' || motion === 'blink') return true;
|
|
1129
|
+
return motion === 'once' && poseTime() < settle;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/** Where the eyes are headed for this pose. */
|
|
1133
|
+
function gazeTarget() {
|
|
1134
|
+
const d = def();
|
|
1135
|
+
if (d.tracks) return glance || track;
|
|
1136
|
+
if (d.look) return hostLook;
|
|
1137
|
+
return ZERO;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* A drawing rig's clock moves with the ticker (its dt is clamped after a
|
|
1142
|
+
* freeze, so nothing jumps). A still rig has nothing on screen to jump: its
|
|
1143
|
+
* clock follows real time, so a pose's timeline (the 6 s blink, a hold)
|
|
1144
|
+
* stays on schedule.
|
|
1145
|
+
*/
|
|
1146
|
+
function syncClock() {
|
|
1147
|
+
if (frozenAt < 0) return;
|
|
1148
|
+
const t = tickerNow();
|
|
1149
|
+
clock += Math.max(0, t - frozenAt);
|
|
1150
|
+
frozenAt = t;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function setRate(next) {
|
|
1154
|
+
if (next === fps) return;
|
|
1155
|
+
if (next <= 0) {
|
|
1156
|
+
unsubscribeFrames?.();
|
|
1157
|
+
unsubscribeFrames = null;
|
|
1158
|
+
fps = 0;
|
|
1159
|
+
frozenAt = tickerNow();
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
if (unsubscribeFrames) unsubscribeFrames.setFps(next);
|
|
1163
|
+
else {
|
|
1164
|
+
syncClock();
|
|
1165
|
+
frozenAt = -1;
|
|
1166
|
+
unsubscribeFrames = subscribe(onFrame, { fps: next });
|
|
1167
|
+
}
|
|
1168
|
+
fps = next;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
const ensureRate = (min) => { if (fps < min) setRate(min); };
|
|
1172
|
+
|
|
1173
|
+
const gazes = () => !!(def().tracks || def().look);
|
|
1174
|
+
|
|
1175
|
+
/** Still travelling: more than SETTLE_UNITS from the target on either axis. */
|
|
1176
|
+
const far = to => Math.abs(to.x - look.x) * range.x > SETTLE_UNITS || Math.abs(to.y - look.y) * range.y > SETTLE_UNITS;
|
|
1177
|
+
|
|
1178
|
+
function easing() {
|
|
1179
|
+
return gazes() && far(gazeTarget());
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
function miniPopping() {
|
|
1183
|
+
return miniBorn.some(at => at >= 0 && clock - at < 220);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
function nextRate() {
|
|
1187
|
+
if (!animating()) return 0;
|
|
1188
|
+
if (blend || blinkStart >= 0 || reactions.length || aim || easing() || miniPopping()) return 60;
|
|
1189
|
+
if (!isLead()) return 0;
|
|
1190
|
+
const d = def();
|
|
1191
|
+
const t = poseTime();
|
|
1192
|
+
if (d.motion === 'loop') return 30;
|
|
1193
|
+
if (d.motion === 'blink') return d.idleFor(t) > 0 ? 0 : 30;
|
|
1194
|
+
if (d.motion === 'once') return t < d.settle ? 60 : 0;
|
|
1195
|
+
return 0;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
function clearWake() {
|
|
1199
|
+
if (wakeTimer) clearTimeout(wakeTimer);
|
|
1200
|
+
wakeTimer = 0;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/** Still: sleep until the next thing this pose does on its own. */
|
|
1204
|
+
function armWake() {
|
|
1205
|
+
clearWake();
|
|
1206
|
+
if (!animating()) return;
|
|
1207
|
+
syncClock();
|
|
1208
|
+
const d = def();
|
|
1209
|
+
const at0 = tickerNow();
|
|
1210
|
+
let at = Infinity;
|
|
1211
|
+
if (d.blinks && (d.motion === 'still' || isLead())) at = Math.min(at, nextBlinkAt);
|
|
1212
|
+
if (d.tracks) at = Math.min(at, nextGlanceAt, nextFidgetAt, glance ? glance.until : Infinity);
|
|
1213
|
+
if (d.motion === 'blink' && isLead()) at = Math.min(at, at0 + d.idleFor(poseTime()));
|
|
1214
|
+
if (d.motion === 'once' && pose.then && !settled) at = Math.min(at, at0 + Math.max(0, d.settle + (d.hold || 0) - poseTime()));
|
|
1215
|
+
if (!Number.isFinite(at)) return;
|
|
1216
|
+
wakeTimer = setTimeout(() => {
|
|
1217
|
+
wakeTimer = 0;
|
|
1218
|
+
if (!animating()) return;
|
|
1219
|
+
syncClock();
|
|
1220
|
+
handleDue();
|
|
1221
|
+
refresh();
|
|
1222
|
+
}, Math.max(16, at - at0));
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
function startBlink() {
|
|
1226
|
+
syncClock();
|
|
1227
|
+
blinkStart = clock;
|
|
1228
|
+
ensureRate(60);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
/** Arm the idle life (blink, glance, fidget) that is unset or went stale while parked. */
|
|
1232
|
+
function scheduleIdle() {
|
|
1233
|
+
const t = tickerNow();
|
|
1234
|
+
const stale = at => !Number.isFinite(at) || at <= t;
|
|
1235
|
+
if (stale(nextBlinkAt)) nextBlinkAt = t + rand(3000, 7000);
|
|
1236
|
+
if (def().tracks) {
|
|
1237
|
+
if (stale(nextGlanceAt)) nextGlanceAt = t + rand(9000, 15000);
|
|
1238
|
+
if (stale(nextFidgetAt)) nextFidgetAt = t + rand(45000, 75000);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/** Blinks, glances, fidgets and one-shot hand-offs that came due. */
|
|
1243
|
+
function handleDue() {
|
|
1244
|
+
const d = def();
|
|
1245
|
+
const t = tickerNow();
|
|
1246
|
+
if (d.blinks && (d.motion === 'still' || isLead()) && t >= nextBlinkAt) {
|
|
1247
|
+
nextBlinkAt = t + rand(3000, 7000);
|
|
1248
|
+
startBlink();
|
|
1249
|
+
}
|
|
1250
|
+
if (d.tracks) {
|
|
1251
|
+
if (glance && t >= glance.until) glance = null;
|
|
1252
|
+
if (t >= nextGlanceAt) {
|
|
1253
|
+
// Only while the cursor is still and no other rig is busy.
|
|
1254
|
+
if (t - pointerAt < 2500 || leadRig) nextGlanceAt = t + 3000;
|
|
1255
|
+
else {
|
|
1256
|
+
const [x, y] = GLANCES[Math.floor(Math.random() * GLANCES.length)];
|
|
1257
|
+
glance = { x, y, until: t + rand(700, 1000) };
|
|
1258
|
+
nextGlanceAt = t + rand(9000, 15000);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
if (t >= nextFidgetAt) {
|
|
1262
|
+
const quietFor = t - Math.max(lastInputAt(), pointerAt);
|
|
1263
|
+
if (quietFor < 20000) nextFidgetAt = t + (20000 - quietFor) + rand(0, 5000);
|
|
1264
|
+
else if (leadRig) nextFidgetAt = t + 10000;
|
|
1265
|
+
else {
|
|
1266
|
+
nextFidgetAt = t + rand(45000, 75000);
|
|
1267
|
+
startReaction(Math.random() < 0.5 ? 'hop' : 'wiggle');
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
if (d.motion === 'once' && pose.then && !settled && poseTime() >= d.settle + (d.hold || 0)) {
|
|
1272
|
+
settled = true;
|
|
1273
|
+
setPose(pose.then);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
function clearTempClasses() {
|
|
1278
|
+
for (const cls of tempClasses) svg.classList.remove(cls);
|
|
1279
|
+
tempClasses.clear();
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
function onAnimationEnd(e) {
|
|
1283
|
+
if (e.target === svg) clearTempClasses();
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
function startReaction(name) {
|
|
1287
|
+
syncClock();
|
|
1288
|
+
const at = tickerNow();
|
|
1289
|
+
if (name === 'hop') {
|
|
1290
|
+
if (at - lastHopAt < 600) return false;
|
|
1291
|
+
lastHopAt = at;
|
|
1292
|
+
}
|
|
1293
|
+
const i = reactions.findIndex(r => r.name === name);
|
|
1294
|
+
if (i >= 0) reactions.splice(i, 1);
|
|
1295
|
+
reactions.push({ name, start: clock, dur: REACTIONS[name] });
|
|
1296
|
+
const cls = `syna-react-${name}`;
|
|
1297
|
+
svg.classList.add(cls);
|
|
1298
|
+
tempClasses.add(cls);
|
|
1299
|
+
requestFrames(REACTIONS[name]);
|
|
1300
|
+
ensureRate(60);
|
|
1301
|
+
return true;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
/** The pose frame this rig would draw now, before blends and overlays. */
|
|
1305
|
+
function frameNow() {
|
|
1306
|
+
const loopOn = isLead() && def().motion !== 'still';
|
|
1307
|
+
return poseFrame(pose.name, poseTime(), { ...pose.raw, look, range, ticks, still: !loopOn });
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/** Ease from what is on screen to what comes next, unless they already match. */
|
|
1311
|
+
function blendIn() {
|
|
1312
|
+
const from = lastFrame || stillFrameNow();
|
|
1313
|
+
blend = sameFrame(from, frameNow()) ? null : { from, start: clock, dur: BLEND_MS };
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function stillFrameNow() {
|
|
1317
|
+
const d = def();
|
|
1318
|
+
return poseFrame(pose.name, 0, { ...pose.raw, look: d.look ? hostLook : ZERO, range, ticks, still: true });
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/** Not animating: the pose's still frame, nothing pending. */
|
|
1322
|
+
function paintStill() {
|
|
1323
|
+
blend = null;
|
|
1324
|
+
blinkStart = -1;
|
|
1325
|
+
glance = null;
|
|
1326
|
+
aim = null;
|
|
1327
|
+
reactions.length = 0;
|
|
1328
|
+
miniBorn = [];
|
|
1329
|
+
clearTempClasses();
|
|
1330
|
+
look = def().look ? { ...hostLook } : { x: 0, y: 0 };
|
|
1331
|
+
lastFrame = stillFrameNow();
|
|
1332
|
+
painter.paint(lastFrame);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
function compose() {
|
|
1336
|
+
let f = frameNow();
|
|
1337
|
+
if (f.prop.name === 'subagent') {
|
|
1338
|
+
f.prop.minis.forEach((m, i) => {
|
|
1339
|
+
const age = miniBorn[i] >= 0 ? clock - miniBorn[i] : Infinity;
|
|
1340
|
+
if (age < 220) { m.s *= 0.6 + 0.4 * springEase(age / 220); m.op = clamp01(age / 120); }
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
if (blend) {
|
|
1344
|
+
const p = (clock - blend.start) / blend.dur;
|
|
1345
|
+
if (p >= 1) blend = null;
|
|
1346
|
+
else f = mixFrames(blend.from, f, easeStandard(clamp01(p)));
|
|
1347
|
+
}
|
|
1348
|
+
lastFrame = f;
|
|
1349
|
+
if (blinkStart >= 0) {
|
|
1350
|
+
const e = clock - blinkStart;
|
|
1351
|
+
if (e >= 280) blinkStart = -1;
|
|
1352
|
+
else {
|
|
1353
|
+
f = cloneFrame(f);
|
|
1354
|
+
const k = 1 - 0.94 * blinkAmount(e);
|
|
1355
|
+
for (const eyeF of f.eyes) eyeF.sy *= k;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
for (let i = reactions.length - 1; i >= 0; i -= 1) {
|
|
1359
|
+
const r = reactions[i];
|
|
1360
|
+
const p = (clock - r.start) / r.dur;
|
|
1361
|
+
if (p >= 1) {
|
|
1362
|
+
reactions.splice(i, 1);
|
|
1363
|
+
svg.classList.remove(`syna-react-${r.name}`);
|
|
1364
|
+
tempClasses.delete(`syna-react-${r.name}`);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
for (const r of reactions) f = reactionFrame(f, r.name, (clock - r.start) / r.dur);
|
|
1368
|
+
return f;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
function easeLook(dt) {
|
|
1372
|
+
if (!gazes()) { look = { x: 0, y: 0 }; return; }
|
|
1373
|
+
const to = gazeTarget();
|
|
1374
|
+
const tau = def().look || TRACK_TAU;
|
|
1375
|
+
const k = 1 - Math.exp(-dt / tau);
|
|
1376
|
+
look = { x: look.x + (to.x - look.x) * k, y: look.y + (to.y - look.y) * k };
|
|
1377
|
+
if (!far(to)) look = { x: to.x, y: to.y };
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
function aimAt(p) {
|
|
1381
|
+
const r = svg.getBoundingClientRect();
|
|
1382
|
+
if (!r.width) return;
|
|
1383
|
+
const vx = p.x - (r.left + r.width / 2);
|
|
1384
|
+
const vy = p.y - (r.top + r.height / 2);
|
|
1385
|
+
const d = Math.hypot(vx, vy);
|
|
1386
|
+
if (d < 1) { track = { x: 0, y: 0 }; return; }
|
|
1387
|
+
const m = (d / (d + AIM_K)) * 1.25;
|
|
1388
|
+
track = { x: unit((vx / d) * m), y: unit((vy / d) * m) };
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
function onFrame(_now, dt) {
|
|
1392
|
+
if (destroyed) return;
|
|
1393
|
+
if (!svg.isConnected) {
|
|
1394
|
+
if (seenConnected) { destroy(); return; }
|
|
1395
|
+
setRate(0); // built before it was attached: wait for the observer
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1398
|
+
seenConnected = true;
|
|
1399
|
+
clock += dt;
|
|
1400
|
+
handleDue();
|
|
1401
|
+
if (aim) { aimAt(aim); aim = null; }
|
|
1402
|
+
easeLook(dt);
|
|
1403
|
+
const wasLead = isLead();
|
|
1404
|
+
painter.paint(compose());
|
|
1405
|
+
drawn = true;
|
|
1406
|
+
if (wasLead && def().motion === 'once' && poseTime() >= def().settle) elect();
|
|
1407
|
+
const rate = nextRate();
|
|
1408
|
+
setRate(rate);
|
|
1409
|
+
if (!rate) armWake();
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
function listenInputs(anim) {
|
|
1413
|
+
const d = def();
|
|
1414
|
+
const wantPointer = anim && (d.tracks || pose.name === 'sleep');
|
|
1415
|
+
const wantKey = anim && (d.tracks || pose.name === 'sleep');
|
|
1416
|
+
if (wantPointer && !stopPointer) stopPointer = onPointer(onPointerMove);
|
|
1417
|
+
if (!wantPointer && stopPointer) { stopPointer(); stopPointer = null; }
|
|
1418
|
+
if (wantKey && !stopKey) stopKey = onKey(onKeyDown);
|
|
1419
|
+
if (!wantKey && stopKey) { stopKey(); stopKey = null; }
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
/** Reconcile subscriptions with the state: frames, inputs, the wake timer. */
|
|
1423
|
+
function refresh() {
|
|
1424
|
+
if (destroyed) return;
|
|
1425
|
+
syncClock();
|
|
1426
|
+
const anim = animating();
|
|
1427
|
+
listenInputs(anim);
|
|
1428
|
+
if (!anim) {
|
|
1429
|
+
setRate(0);
|
|
1430
|
+
clearWake();
|
|
1431
|
+
paintStill();
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
const rate = nextRate();
|
|
1435
|
+
setRate(rate);
|
|
1436
|
+
if (!rate) {
|
|
1437
|
+
painter.paint(compose());
|
|
1438
|
+
armWake();
|
|
1439
|
+
} else clearWake();
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/** Coming back to life (active, on screen, motion allowed): ease out of the still frame. */
|
|
1443
|
+
function revive() {
|
|
1444
|
+
syncClock();
|
|
1445
|
+
if (!animating()) return;
|
|
1446
|
+
blendIn();
|
|
1447
|
+
if (def().tracks) {
|
|
1448
|
+
const p = pointerPosition();
|
|
1449
|
+
if (p) aim = p;
|
|
1450
|
+
}
|
|
1451
|
+
scheduleIdle();
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
function onPointerMove(x, y) {
|
|
1455
|
+
if (destroyed) return;
|
|
1456
|
+
pointerAt = tickerNow();
|
|
1457
|
+
if (pose.name === 'sleep') { setPose('idle'); return; }
|
|
1458
|
+
if (!def().tracks || !animating()) return;
|
|
1459
|
+
glance = null;
|
|
1460
|
+
aim = { x, y };
|
|
1461
|
+
ensureRate(60);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function onKeyDown() {
|
|
1465
|
+
if (!destroyed && pose.name === 'sleep') setPose('idle');
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// ── Public API ──
|
|
1469
|
+
|
|
1470
|
+
function setPose(name, options2) {
|
|
1471
|
+
if (destroyed) return api;
|
|
1472
|
+
const next = POSES[name] ? name : 'idle';
|
|
1473
|
+
const raw = options2 && typeof options2 === 'object' ? { ...options2 } : {};
|
|
1474
|
+
const same = next === pose.name;
|
|
1475
|
+
const keys = new Set([...Object.keys(raw), ...Object.keys(pose.raw)]);
|
|
1476
|
+
const changed = [...keys].filter(k => raw[k] !== pose.raw[k]);
|
|
1477
|
+
if (same && !changed.length) return api;
|
|
1478
|
+
syncClock();
|
|
1479
|
+
if (same && changed.every(k => k === 'count' || k === 'ticks')) {
|
|
1480
|
+
// Same pose, new numbers: the loop keeps its phase; a new mini pops in.
|
|
1481
|
+
const before = intIn(pose.raw.count, 1, 3, 1);
|
|
1482
|
+
const after = intIn(raw.count, 1, 3, 1);
|
|
1483
|
+
for (let i = before; i < after; i += 1) miniBorn[i] = clock;
|
|
1484
|
+
if (raw.ticks != null) ticks = intIn(raw.ticks, 0, 3, ticks);
|
|
1485
|
+
pose.raw = raw;
|
|
1486
|
+
} else {
|
|
1487
|
+
pose = { name: next, raw, start: clock, then: raw.then && POSES[raw.then] ? raw.then : null };
|
|
1488
|
+
svg.setAttribute('data-pose', next);
|
|
1489
|
+
settled = false;
|
|
1490
|
+
miniBorn = [];
|
|
1491
|
+
ticks = intIn(raw.ticks, 0, 3, 1);
|
|
1492
|
+
glance = null;
|
|
1493
|
+
blendIn();
|
|
1494
|
+
if (def().tracks) {
|
|
1495
|
+
const p = pointerPosition();
|
|
1496
|
+
if (p && tickerNow() - p.at < 2500) aim = p;
|
|
1497
|
+
}
|
|
1498
|
+
scheduleIdle();
|
|
1499
|
+
}
|
|
1500
|
+
promotedAt = (promoteSeq += 1);
|
|
1501
|
+
if (animating()) requestFrames(BLEND_MS);
|
|
1502
|
+
elect();
|
|
1503
|
+
refresh();
|
|
1504
|
+
return api;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
function react(name) {
|
|
1508
|
+
if (destroyed || !Object.hasOwn(REACTIONS, name)) return api;
|
|
1509
|
+
// pop on the plan ticks the next box, unless the host counts the ticks itself (opts.ticks).
|
|
1510
|
+
if (name === 'pop' && pose.name === 'plan' && pose.raw.ticks == null) ticks = ticks >= 3 ? 1 : ticks + 1;
|
|
1511
|
+
if (!animating()) { paintStill(); return api; }
|
|
1512
|
+
startReaction(name);
|
|
1513
|
+
return api;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/** Point the eyes ([-1, 1] both axes); in idle a cursor that moved in the last 2.5 s wins. */
|
|
1517
|
+
function lookAt(x, y) {
|
|
1518
|
+
hostLook = { x: unit(x), y: unit(y) };
|
|
1519
|
+
if (destroyed) return;
|
|
1520
|
+
const d = def();
|
|
1521
|
+
if (d.tracks) {
|
|
1522
|
+
if (!animating() || tickerNow() - pointerAt < 2500) return;
|
|
1523
|
+
track = { ...hostLook };
|
|
1524
|
+
glance = null;
|
|
1525
|
+
} else if (!d.look) return;
|
|
1526
|
+
if (!animating()) { paintStill(); return; }
|
|
1527
|
+
syncClock();
|
|
1528
|
+
ensureRate(60);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
function blink() {
|
|
1532
|
+
if (destroyed || !animating()) return;
|
|
1533
|
+
startBlink();
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
function setActive(on) {
|
|
1537
|
+
const next = !!on;
|
|
1538
|
+
if (destroyed || next === active) return api;
|
|
1539
|
+
active = next;
|
|
1540
|
+
if (active) { promotedAt = (promoteSeq += 1); revive(); }
|
|
1541
|
+
elect();
|
|
1542
|
+
refresh();
|
|
1543
|
+
return api;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
function destroy() {
|
|
1547
|
+
if (destroyed) return;
|
|
1548
|
+
destroyed = true;
|
|
1549
|
+
setRate(0);
|
|
1550
|
+
clearWake();
|
|
1551
|
+
stopPointer?.();
|
|
1552
|
+
stopPointer = null;
|
|
1553
|
+
stopKey?.();
|
|
1554
|
+
stopKey = null;
|
|
1555
|
+
unobserve(svg);
|
|
1556
|
+
svg.removeEventListener('animationend', onAnimationEnd);
|
|
1557
|
+
clearTempClasses();
|
|
1558
|
+
reactions.length = 0;
|
|
1559
|
+
unregister(rig);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
const rig = {
|
|
1563
|
+
promotedAt: () => promotedAt,
|
|
1564
|
+
wantsLead,
|
|
1565
|
+
leadChanged() {
|
|
1566
|
+
if (destroyed) return;
|
|
1567
|
+
// Gaining or losing the loop swaps the still frame for the live one: blend
|
|
1568
|
+
// when they differ (a patient pose between blinks, a settled one-shot: no).
|
|
1569
|
+
if (drawn && animating()) {
|
|
1570
|
+
syncClock();
|
|
1571
|
+
blendIn();
|
|
1572
|
+
}
|
|
1573
|
+
refresh();
|
|
1574
|
+
},
|
|
1575
|
+
visibilityChanged(inView) {
|
|
1576
|
+
if (destroyed) return;
|
|
1577
|
+
if (svg.isConnected) seenConnected = true;
|
|
1578
|
+
else if (seenConnected) { destroy(); return; }
|
|
1579
|
+
const was = visible;
|
|
1580
|
+
visible = inView;
|
|
1581
|
+
if (visible && !was) revive();
|
|
1582
|
+
elect();
|
|
1583
|
+
refresh(); // also wakes a rig that was built before it was attached
|
|
1584
|
+
},
|
|
1585
|
+
motionChanged() {
|
|
1586
|
+
if (destroyed) return;
|
|
1587
|
+
if (animating()) revive();
|
|
1588
|
+
refresh();
|
|
1589
|
+
},
|
|
1590
|
+
};
|
|
1591
|
+
|
|
1592
|
+
const api = {
|
|
1593
|
+
el: svg,
|
|
1594
|
+
destroy,
|
|
1595
|
+
look: lookAt,
|
|
1596
|
+
blink,
|
|
1597
|
+
setPose,
|
|
1598
|
+
react,
|
|
1599
|
+
setActive,
|
|
1600
|
+
/** The current pose name. */
|
|
1601
|
+
get pose() { return pose.name; },
|
|
1602
|
+
/** The frame rate this rig asks of the ticker right now (0 = still). */
|
|
1603
|
+
get fps() { return fps; },
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
pose = { name: POSES[firstPose] ? firstPose : 'idle', raw: firstOptions && typeof firstOptions === 'object' ? { ...firstOptions } : {}, start: 0, then: null };
|
|
1607
|
+
pose.then = pose.raw.then && POSES[pose.raw.then] ? pose.raw.then : null;
|
|
1608
|
+
svg.setAttribute('data-pose', pose.name);
|
|
1609
|
+
ticks = intIn(pose.raw.ticks, 0, 3, 1);
|
|
1610
|
+
register(rig);
|
|
1611
|
+
svg.addEventListener('animationend', onAnimationEnd);
|
|
1612
|
+
lastFrame = stillFrameNow();
|
|
1613
|
+
painter.paint(lastFrame);
|
|
1614
|
+
observe(svg, rig);
|
|
1615
|
+
if (animating()) {
|
|
1616
|
+
scheduleIdle();
|
|
1617
|
+
if (def().tracks) {
|
|
1618
|
+
const p = pointerPosition();
|
|
1619
|
+
if (p) aim = p;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
elect();
|
|
1623
|
+
refresh();
|
|
1624
|
+
return api;
|
|
1625
|
+
}
|