hyacinth-ai 0.9.6
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/LICENSE +21 -0
- package/README.md +205 -0
- package/commands.json +25 -0
- package/dist/agents/builtins.d.ts +8 -0
- package/dist/agents/builtins.js +50 -0
- package/dist/agents/config-loader.d.ts +15 -0
- package/dist/agents/config-loader.js +75 -0
- package/dist/agents/delegate-tool.d.ts +109 -0
- package/dist/agents/delegate-tool.js +407 -0
- package/dist/agents/index.d.ts +5 -0
- package/dist/agents/index.js +5 -0
- package/dist/agents/registry.d.ts +2 -0
- package/dist/agents/registry.js +2 -0
- package/dist/bypass/agents/companion/index.d.ts +57 -0
- package/dist/bypass/agents/companion/index.js +487 -0
- package/dist/bypass/agents/orchestrator/index.d.ts +17 -0
- package/dist/bypass/agents/orchestrator/index.js +414 -0
- package/dist/bypass/agents/orchestrator.d.ts +16 -0
- package/dist/bypass/agents/orchestrator.js +377 -0
- package/dist/bypass/agents/world-engine/agent.d.ts +41 -0
- package/dist/bypass/agents/world-engine/agent.js +385 -0
- package/dist/bypass/agents/world-engine/index.d.ts +52 -0
- package/dist/bypass/agents/world-engine/index.js +198 -0
- package/dist/bypass/agents/world-engine/sim.d.ts +14 -0
- package/dist/bypass/agents/world-engine/sim.js +120 -0
- package/dist/bypass/agents/world-engine/store.d.ts +110 -0
- package/dist/bypass/agents/world-engine/store.js +519 -0
- package/dist/bypass/agents/world-engine/ticker.d.ts +37 -0
- package/dist/bypass/agents/world-engine/ticker.js +214 -0
- package/dist/bypass/agents/world-engine/tools.d.ts +6 -0
- package/dist/bypass/agents/world-engine/tools.js +380 -0
- package/dist/bypass/agents/world-engine/types.d.ts +202 -0
- package/dist/bypass/agents/world-engine/types.js +56 -0
- package/dist/bypass/agents/world-engine.d.ts +20 -0
- package/dist/bypass/agents/world-engine.js +63 -0
- package/dist/bypass/base.d.ts +48 -0
- package/dist/bypass/base.js +126 -0
- package/dist/bypass/index.d.ts +5 -0
- package/dist/bypass/index.js +6 -0
- package/dist/bypass/manager.d.ts +41 -0
- package/dist/bypass/manager.js +179 -0
- package/dist/bypass/types.d.ts +63 -0
- package/dist/bypass/types.js +14 -0
- package/dist/channels/auto-detect.d.ts +25 -0
- package/dist/channels/auto-detect.js +77 -0
- package/dist/channels/builtin/http-webhook.d.ts +25 -0
- package/dist/channels/builtin/http-webhook.js +287 -0
- package/dist/channels/builtin/tui-channel.d.ts +33 -0
- package/dist/channels/builtin/tui-channel.js +61 -0
- package/dist/channels/builtin/tui-ws-session.d.ts +16 -0
- package/dist/channels/builtin/tui-ws-session.js +90 -0
- package/dist/channels/builtin/webui-output-handler.d.ts +30 -0
- package/dist/channels/builtin/webui-output-handler.js +93 -0
- package/dist/channels/index.d.ts +5 -0
- package/dist/channels/index.js +3 -0
- package/dist/channels/interface.d.ts +148 -0
- package/dist/channels/interface.js +15 -0
- package/dist/channels/manager.d.ts +43 -0
- package/dist/channels/manager.js +156 -0
- package/dist/channels/message-queue.d.ts +36 -0
- package/dist/channels/message-queue.js +91 -0
- package/dist/channels/plugins/clawbot/clawbot-auth.d.ts +50 -0
- package/dist/channels/plugins/clawbot/clawbot-auth.js +235 -0
- package/dist/channels/plugins/clawbot/clawbot-channel.d.ts +76 -0
- package/dist/channels/plugins/clawbot/clawbot-channel.js +566 -0
- package/dist/channels/plugins/clawbot/clawbot-client.d.ts +180 -0
- package/dist/channels/plugins/clawbot/clawbot-client.js +312 -0
- package/dist/channels/plugins/clawbot/clawbot-config.d.ts +30 -0
- package/dist/channels/plugins/clawbot/clawbot-config.js +28 -0
- package/dist/channels/plugins/clawbot/clawbot-message-queue.d.ts +27 -0
- package/dist/channels/plugins/clawbot/clawbot-message-queue.js +114 -0
- package/dist/channels/plugins/clawbot/clawbot-session.d.ts +10 -0
- package/dist/channels/plugins/clawbot/clawbot-session.js +26 -0
- package/dist/channels/plugins/clawbot/index.d.ts +17 -0
- package/dist/channels/plugins/clawbot/index.js +58 -0
- package/dist/channels/plugins/feishu/feishu-channel.d.ts +57 -0
- package/dist/channels/plugins/feishu/feishu-channel.js +602 -0
- package/dist/channels/plugins/feishu/feishu-client.d.ts +23 -0
- package/dist/channels/plugins/feishu/feishu-client.js +86 -0
- package/dist/channels/plugins/feishu/feishu-config.d.ts +53 -0
- package/dist/channels/plugins/feishu/feishu-config.js +35 -0
- package/dist/channels/plugins/feishu/feishu-event.d.ts +102 -0
- package/dist/channels/plugins/feishu/feishu-event.js +257 -0
- package/dist/channels/plugins/feishu/feishu-log-suppressor.d.ts +7 -0
- package/dist/channels/plugins/feishu/feishu-log-suppressor.js +34 -0
- package/dist/channels/plugins/feishu/feishu-message-queue.d.ts +27 -0
- package/dist/channels/plugins/feishu/feishu-message-queue.js +112 -0
- package/dist/channels/plugins/feishu/feishu-send.d.ts +44 -0
- package/dist/channels/plugins/feishu/feishu-send.js +232 -0
- package/dist/channels/plugins/feishu/feishu-session.d.ts +44 -0
- package/dist/channels/plugins/feishu/feishu-session.js +84 -0
- package/dist/channels/plugins/feishu/feishu-streaming.d.ts +49 -0
- package/dist/channels/plugins/feishu/feishu-streaming.js +185 -0
- package/dist/channels/plugins/feishu/feishu-transport.d.ts +29 -0
- package/dist/channels/plugins/feishu/feishu-transport.js +99 -0
- package/dist/channels/plugins/feishu/index.d.ts +22 -0
- package/dist/channels/plugins/feishu/index.js +68 -0
- package/dist/cli/doctor.d.ts +20 -0
- package/dist/cli/doctor.js +317 -0
- package/dist/context/cache-strategy.d.ts +76 -0
- package/dist/context/cache-strategy.js +123 -0
- package/dist/context/composer.d.ts +77 -0
- package/dist/context/composer.js +318 -0
- package/dist/context/compressor.d.ts +218 -0
- package/dist/context/compressor.js +909 -0
- package/dist/context/index.d.ts +14 -0
- package/dist/context/index.js +8 -0
- package/dist/context/interface.d.ts +33 -0
- package/dist/context/interface.js +2 -0
- package/dist/context/manifest-defaults.d.ts +51 -0
- package/dist/context/manifest-defaults.js +133 -0
- package/dist/context/manifest-loader.d.ts +16 -0
- package/dist/context/manifest-loader.js +103 -0
- package/dist/context/manifest-types.d.ts +26 -0
- package/dist/context/manifest-types.js +2 -0
- package/dist/context/precision/analyzer.d.ts +31 -0
- package/dist/context/precision/analyzer.js +131 -0
- package/dist/context/precision/companion.d.ts +27 -0
- package/dist/context/precision/companion.js +144 -0
- package/dist/context/precision/default.d.ts +14 -0
- package/dist/context/precision/default.js +17 -0
- package/dist/context/precision/index.d.ts +9 -0
- package/dist/context/precision/index.js +7 -0
- package/dist/context/precision/keyword-pool.d.ts +27 -0
- package/dist/context/precision/keyword-pool.js +66 -0
- package/dist/context/precision/strategy.d.ts +18 -0
- package/dist/context/precision/strategy.js +51 -0
- package/dist/context/precision/summary-store.d.ts +18 -0
- package/dist/context/precision/summary-store.js +67 -0
- package/dist/context/precision/types.d.ts +23 -0
- package/dist/context/precision/types.js +2 -0
- package/dist/context/profiles.d.ts +45 -0
- package/dist/context/profiles.js +92 -0
- package/dist/context/prompt-builder.d.ts +76 -0
- package/dist/context/prompt-builder.js +133 -0
- package/dist/context/retriever.d.ts +44 -0
- package/dist/context/retriever.js +203 -0
- package/dist/context/router.d.ts +122 -0
- package/dist/context/router.js +291 -0
- package/dist/context/section-resolver.d.ts +38 -0
- package/dist/context/section-resolver.js +398 -0
- package/dist/context/tokenizer.d.ts +23 -0
- package/dist/context/tokenizer.js +78 -0
- package/dist/dependency/analyzer.d.ts +33 -0
- package/dist/dependency/analyzer.js +242 -0
- package/dist/dependency/data-flow-tracker.d.ts +12 -0
- package/dist/dependency/data-flow-tracker.js +97 -0
- package/dist/dependency/function-parser.d.ts +34 -0
- package/dist/dependency/function-parser.js +295 -0
- package/dist/dependency/index.d.ts +14 -0
- package/dist/dependency/index.js +20 -0
- package/dist/dependency/parser.d.ts +10 -0
- package/dist/dependency/parser.js +93 -0
- package/dist/dependency/types.d.ts +57 -0
- package/dist/dependency/types.js +2 -0
- package/dist/env/env-collector.d.ts +45 -0
- package/dist/env/env-collector.js +221 -0
- package/dist/env/index.d.ts +3 -0
- package/dist/env/index.js +2 -0
- package/dist/event-store.d.ts +27 -0
- package/dist/event-store.js +71 -0
- package/dist/evolution/git-manager.d.ts +46 -0
- package/dist/evolution/git-manager.js +276 -0
- package/dist/evolution/index.d.ts +3 -0
- package/dist/evolution/index.js +2 -0
- package/dist/flow/bootstrap-flow.d.ts +19 -0
- package/dist/flow/bootstrap-flow.js +72 -0
- package/dist/flow/flow-registry.d.ts +12 -0
- package/dist/flow/flow-registry.js +74 -0
- package/dist/flow/flow-tools.d.ts +8 -0
- package/dist/flow/flow-tools.js +106 -0
- package/dist/flow/index.d.ts +6 -0
- package/dist/flow/index.js +8 -0
- package/dist/flow/todo-flow.d.ts +25 -0
- package/dist/flow/todo-flow.js +107 -0
- package/dist/flow/types.d.ts +78 -0
- package/dist/flow/types.js +12 -0
- package/dist/flows/bootstrap.d.ts +18 -0
- package/dist/flows/bootstrap.js +119 -0
- package/dist/flows/index.d.ts +6 -0
- package/dist/flows/index.js +11 -0
- package/dist/flows/todo.d.ts +26 -0
- package/dist/flows/todo.js +174 -0
- package/dist/flows/tools.d.ts +8 -0
- package/dist/flows/tools.js +119 -0
- package/dist/flows/types.d.ts +27 -0
- package/dist/flows/types.js +10 -0
- package/dist/gateway/cli.d.ts +5 -0
- package/dist/gateway/cli.js +1027 -0
- package/dist/gateway/factory.d.ts +80 -0
- package/dist/gateway/factory.js +832 -0
- package/dist/gateway/guardian.d.ts +8 -0
- package/dist/gateway/guardian.js +30 -0
- package/dist/gateway/index.d.ts +3 -0
- package/dist/gateway/index.js +3 -0
- package/dist/gateway/server.d.ts +17 -0
- package/dist/gateway/server.js +96 -0
- package/dist/gateway/tui.d.ts +16 -0
- package/dist/gateway/tui.js +3273 -0
- package/dist/hot-reload/agent-watcher.d.ts +24 -0
- package/dist/hot-reload/agent-watcher.js +175 -0
- package/dist/hot-reload/bundle-watcher.d.ts +12 -0
- package/dist/hot-reload/bundle-watcher.js +35 -0
- package/dist/hot-reload/channel-watcher.d.ts +19 -0
- package/dist/hot-reload/channel-watcher.js +54 -0
- package/dist/hot-reload/command-watcher.d.ts +14 -0
- package/dist/hot-reload/command-watcher.js +54 -0
- package/dist/hot-reload/config-watcher.d.ts +20 -0
- package/dist/hot-reload/config-watcher.js +58 -0
- package/dist/hot-reload/index.d.ts +12 -0
- package/dist/hot-reload/index.js +12 -0
- package/dist/hot-reload/manager.d.ts +58 -0
- package/dist/hot-reload/manager.js +243 -0
- package/dist/hot-reload/manifest-watcher.d.ts +9 -0
- package/dist/hot-reload/manifest-watcher.js +42 -0
- package/dist/hot-reload/mcp-watcher.d.ts +18 -0
- package/dist/hot-reload/mcp-watcher.js +64 -0
- package/dist/hot-reload/model-catalog-watcher.d.ts +18 -0
- package/dist/hot-reload/model-catalog-watcher.js +62 -0
- package/dist/hot-reload/plugin-watcher.d.ts +20 -0
- package/dist/hot-reload/plugin-watcher.js +56 -0
- package/dist/hot-reload/prompt-watcher.d.ts +6 -0
- package/dist/hot-reload/prompt-watcher.js +38 -0
- package/dist/hot-reload/provider-watcher.d.ts +16 -0
- package/dist/hot-reload/provider-watcher.js +45 -0
- package/dist/hot-reload/skill-watcher.d.ts +19 -0
- package/dist/hot-reload/skill-watcher.js +82 -0
- package/dist/hot-reload/tool-watcher.d.ts +16 -0
- package/dist/hot-reload/tool-watcher.js +168 -0
- package/dist/hot-reload/workflow-watcher.d.ts +19 -0
- package/dist/hot-reload/workflow-watcher.js +84 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/knowledge/fts5-retriever.d.ts +30 -0
- package/dist/knowledge/fts5-retriever.js +223 -0
- package/dist/knowledge/index.d.ts +11 -0
- package/dist/knowledge/index.js +14 -0
- package/dist/knowledge/indexer.d.ts +41 -0
- package/dist/knowledge/indexer.js +186 -0
- package/dist/knowledge/query-preprocessor.d.ts +13 -0
- package/dist/knowledge/query-preprocessor.js +63 -0
- package/dist/knowledge/retriever.d.ts +45 -0
- package/dist/knowledge/retriever.js +9 -0
- package/dist/knowledge/store.d.ts +27 -0
- package/dist/knowledge/store.js +61 -0
- package/dist/knowledge/structured-store.d.ts +78 -0
- package/dist/knowledge/structured-store.js +280 -0
- package/dist/knowledge/structured-tools.d.ts +12 -0
- package/dist/knowledge/structured-tools.js +151 -0
- package/dist/knowledge/tools.d.ts +20 -0
- package/dist/knowledge/tools.js +238 -0
- package/dist/knowledge/watcher.d.ts +28 -0
- package/dist/knowledge/watcher.js +113 -0
- package/dist/lifecycle/index.d.ts +12 -0
- package/dist/lifecycle/index.js +14 -0
- package/dist/lifecycle/interface.d.ts +94 -0
- package/dist/lifecycle/interface.js +2 -0
- package/dist/lifecycle/local-model.d.ts +62 -0
- package/dist/lifecycle/local-model.js +331 -0
- package/dist/lifecycle/manager.d.ts +70 -0
- package/dist/lifecycle/manager.js +374 -0
- package/dist/lifecycle/supervisor.d.ts +89 -0
- package/dist/lifecycle/supervisor.js +277 -0
- package/dist/lifecycle-integration-test.d.ts +2 -0
- package/dist/lifecycle-integration-test.js +72 -0
- package/dist/local-model/download-manager.d.ts +59 -0
- package/dist/local-model/download-manager.js +517 -0
- package/dist/local-model/index.d.ts +109 -0
- package/dist/local-model/index.js +233 -0
- package/dist/local-model/llamacpp-provider.d.ts +95 -0
- package/dist/local-model/llamacpp-provider.js +379 -0
- package/dist/local-model/model-bridge.d.ts +48 -0
- package/dist/local-model/model-bridge.js +256 -0
- package/dist/local-model/model-registry.d.ts +47 -0
- package/dist/local-model/model-registry.js +188 -0
- package/dist/local-model/types.d.ts +49 -0
- package/dist/local-model/types.js +2 -0
- package/dist/logging/index.d.ts +3 -0
- package/dist/logging/index.js +3 -0
- package/dist/logging/logger.d.ts +56 -0
- package/dist/logging/logger.js +94 -0
- package/dist/machine/flows/bootstrap.d.ts +18 -0
- package/dist/machine/flows/bootstrap.js +119 -0
- package/dist/machine/flows/index.d.ts +6 -0
- package/dist/machine/flows/index.js +11 -0
- package/dist/machine/flows/spec.d.ts +17 -0
- package/dist/machine/flows/spec.js +176 -0
- package/dist/machine/flows/todo.d.ts +26 -0
- package/dist/machine/flows/todo.js +175 -0
- package/dist/machine/flows/tools.d.ts +8 -0
- package/dist/machine/flows/tools.js +119 -0
- package/dist/machine/flows/types.d.ts +33 -0
- package/dist/machine/flows/types.js +10 -0
- package/dist/machine/index.d.ts +8 -0
- package/dist/machine/index.js +9 -0
- package/dist/machine/registry.d.ts +34 -0
- package/dist/machine/registry.js +98 -0
- package/dist/machine/runner.d.ts +41 -0
- package/dist/machine/runner.js +177 -0
- package/dist/machine/types.d.ts +121 -0
- package/dist/machine/types.js +9 -0
- package/dist/mcp/bridge.d.ts +33 -0
- package/dist/mcp/bridge.js +99 -0
- package/dist/mcp/client.d.ts +37 -0
- package/dist/mcp/client.js +161 -0
- package/dist/mcp/config.d.ts +15 -0
- package/dist/mcp/config.js +85 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.js +7 -0
- package/dist/mcp/install-manager.d.ts +31 -0
- package/dist/mcp/install-manager.js +158 -0
- package/dist/mcp/lifecycle.d.ts +41 -0
- package/dist/mcp/lifecycle.js +175 -0
- package/dist/mcp/process-transport.d.ts +21 -0
- package/dist/mcp/process-transport.js +59 -0
- package/dist/mcp/side-effect.d.ts +5 -0
- package/dist/mcp/side-effect.js +21 -0
- package/dist/mcp/system.d.ts +95 -0
- package/dist/mcp/system.js +279 -0
- package/dist/memory/companion-session.d.ts +22 -0
- package/dist/memory/companion-session.js +77 -0
- package/dist/memory/compression-boundary.d.ts +20 -0
- package/dist/memory/compression-boundary.js +40 -0
- package/dist/memory/conversation.d.ts +34 -0
- package/dist/memory/conversation.js +107 -0
- package/dist/memory/events.d.ts +42 -0
- package/dist/memory/events.js +56 -0
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.js +6 -0
- package/dist/memory/memory-store.d.ts +11 -0
- package/dist/memory/memory-store.js +51 -0
- package/dist/memory/session-allowlist.d.ts +11 -0
- package/dist/memory/session-allowlist.js +50 -0
- package/dist/memory/session.d.ts +48 -0
- package/dist/memory/session.js +275 -0
- package/dist/memory/stats.d.ts +23 -0
- package/dist/memory/stats.js +59 -0
- package/dist/memory/summary.d.ts +7 -0
- package/dist/memory/summary.js +23 -0
- package/dist/multimodal/index.d.ts +66 -0
- package/dist/multimodal/index.js +210 -0
- package/dist/orchestrator/index.d.ts +5 -0
- package/dist/orchestrator/index.js +4 -0
- package/dist/orchestrator/loop.d.ts +331 -0
- package/dist/orchestrator/loop.js +2443 -0
- package/dist/orchestrator/plan-store.d.ts +81 -0
- package/dist/orchestrator/plan-store.js +167 -0
- package/dist/orchestrator/planner.d.ts +20 -0
- package/dist/orchestrator/planner.js +34 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.js +2 -0
- package/dist/parser/router.d.ts +30 -0
- package/dist/parser/router.js +61 -0
- package/dist/plugins/api.d.ts +39 -0
- package/dist/plugins/api.js +85 -0
- package/dist/plugins/define.d.ts +27 -0
- package/dist/plugins/define.js +32 -0
- package/dist/plugins/index.d.ts +9 -0
- package/dist/plugins/index.js +5 -0
- package/dist/plugins/loader.d.ts +39 -0
- package/dist/plugins/loader.js +128 -0
- package/dist/plugins/manager.d.ts +61 -0
- package/dist/plugins/manager.js +257 -0
- package/dist/plugins/types.d.ts +82 -0
- package/dist/plugins/types.js +2 -0
- package/dist/prompts/agents/code-reviewer.md +16 -0
- package/dist/prompts/agents/security-auditor.md +17 -0
- package/dist/prompts/agents/test-writer.md +15 -0
- package/dist/prompts/attention/attention.md +12 -0
- package/dist/prompts/environment/environment.md +18 -0
- package/dist/prompts/environment/feishu.md +107 -0
- package/dist/prompts/flows/bootstrap-confirm.md +14 -0
- package/dist/prompts/flows/bootstrap-identity.md +11 -0
- package/dist/prompts/flows/bootstrap-soul.md +19 -0
- package/dist/prompts/flows/bootstrap-user.md +11 -0
- package/dist/prompts/flows/spec-checklist.md +27 -0
- package/dist/prompts/flows/spec-define.md +64 -0
- package/dist/prompts/flows/spec-executing-checklist.md +15 -0
- package/dist/prompts/flows/spec-executing-tasks.md +15 -0
- package/dist/prompts/flows/spec-spec.md +51 -0
- package/dist/prompts/flows/spec-tasks.md +32 -0
- package/dist/prompts/flows/todo-execution.md +7 -0
- package/dist/prompts/flows/todo-planning.md +18 -0
- package/dist/prompts/framework/architecture.md +131 -0
- package/dist/prompts/identity/identity.md +2 -0
- package/dist/prompts/loader.d.ts +24 -0
- package/dist/prompts/loader.js +102 -0
- package/dist/prompts/loader.ts +119 -0
- package/dist/prompts/orchestration/summary.md +14 -0
- package/dist/prompts/persona/BOOTSTRAP.md +5 -0
- package/dist/prompts/persona/IDENTITY.md +16 -0
- package/dist/prompts/persona/PartnerMemory.md +5 -0
- package/dist/prompts/persona/PartnerSoul.md +7 -0
- package/dist/prompts/persona/SOUL.md +30 -0
- package/dist/prompts/persona/USER.md +16 -0
- package/dist/prompts/precise/analyze.md +23 -0
- package/dist/prompts/precise/persona.md +18 -0
- package/dist/prompts/safety/coding-standards.md +5 -0
- package/dist/prompts/safety/safety.md +4 -0
- package/dist/prompts/skills/code-review.md +4 -0
- package/dist/prompts/skills/debug.md +7 -0
- package/dist/prompts/skills/framework-reference.md +131 -0
- package/dist/prompts/skills/refactor.md +6 -0
- package/dist/prompts/summary.md +22 -0
- package/dist/prompts/tools/framework-capabilities.md +241 -0
- package/dist/prompts/tools/tool-rules.md +15 -0
- package/dist/provider/anthropic.d.ts +62 -0
- package/dist/provider/anthropic.js +361 -0
- package/dist/provider/catalog.d.ts +58 -0
- package/dist/provider/catalog.js +97 -0
- package/dist/provider/compatible.d.ts +89 -0
- package/dist/provider/compatible.js +328 -0
- package/dist/provider/config.d.ts +23 -0
- package/dist/provider/config.js +158 -0
- package/dist/provider/deepseek.d.ts +25 -0
- package/dist/provider/deepseek.js +37 -0
- package/dist/provider/fallback.d.ts +51 -0
- package/dist/provider/fallback.js +113 -0
- package/dist/provider/gemini.d.ts +27 -0
- package/dist/provider/gemini.js +170 -0
- package/dist/provider/index.d.ts +36 -0
- package/dist/provider/index.js +42 -0
- package/dist/provider/interface.d.ts +62 -0
- package/dist/provider/interface.js +2 -0
- package/dist/provider/local-config.d.ts +37 -0
- package/dist/provider/local-config.js +146 -0
- package/dist/provider/local.d.ts +45 -0
- package/dist/provider/local.js +248 -0
- package/dist/provider/manager.d.ts +67 -0
- package/dist/provider/manager.js +355 -0
- package/dist/provider/mimo.d.ts +19 -0
- package/dist/provider/mimo.js +30 -0
- package/dist/provider/minimax.d.ts +22 -0
- package/dist/provider/minimax.js +33 -0
- package/dist/provider/model-catalog-loader.d.ts +42 -0
- package/dist/provider/model-catalog-loader.js +89 -0
- package/dist/provider/model-channel-registry.d.ts +130 -0
- package/dist/provider/model-channel-registry.js +488 -0
- package/dist/provider/model-router.d.ts +60 -0
- package/dist/provider/model-router.js +87 -0
- package/dist/provider/openai.d.ts +54 -0
- package/dist/provider/openai.js +274 -0
- package/dist/provider/qwen.d.ts +19 -0
- package/dist/provider/qwen.js +30 -0
- package/dist/provider/resilient.d.ts +46 -0
- package/dist/provider/resilient.js +181 -0
- package/dist/provider/retry.d.ts +16 -0
- package/dist/provider/retry.js +78 -0
- package/dist/provider/router.d.ts +68 -0
- package/dist/provider/router.js +145 -0
- package/dist/provider/tool-args-recovery.d.ts +36 -0
- package/dist/provider/tool-args-recovery.js +91 -0
- package/dist/provider/user-id.d.ts +13 -0
- package/dist/provider/user-id.js +53 -0
- package/dist/provider/zhipu.d.ts +19 -0
- package/dist/provider/zhipu.js +32 -0
- package/dist/registry/agent.registry.d.ts +57 -0
- package/dist/registry/agent.registry.js +224 -0
- package/dist/registry/base.d.ts +54 -0
- package/dist/registry/base.js +99 -0
- package/dist/registry/channel.registry.d.ts +53 -0
- package/dist/registry/channel.registry.js +87 -0
- package/dist/registry/index.d.ts +9 -0
- package/dist/registry/index.js +10 -0
- package/dist/registry/mcp.registry.d.ts +2 -0
- package/dist/registry/mcp.registry.js +2 -0
- package/dist/registry/plugin.registry.d.ts +33 -0
- package/dist/registry/plugin.registry.js +66 -0
- package/dist/registry/provider.registry.d.ts +51 -0
- package/dist/registry/provider.registry.js +104 -0
- package/dist/registry/skill.registry.d.ts +33 -0
- package/dist/registry/skill.registry.js +95 -0
- package/dist/registry/tool.registry.d.ts +68 -0
- package/dist/registry/tool.registry.js +185 -0
- package/dist/repair/loop-guard.d.ts +98 -0
- package/dist/repair/loop-guard.js +217 -0
- package/dist/repair/scavenge.d.ts +19 -0
- package/dist/repair/scavenge.js +81 -0
- package/dist/repair/storm.d.ts +7 -0
- package/dist/repair/storm.js +7 -0
- package/dist/rollback/index.d.ts +5 -0
- package/dist/rollback/index.js +4 -0
- package/dist/rollback/rollback-tool.d.ts +13 -0
- package/dist/rollback/rollback-tool.js +167 -0
- package/dist/rollback/turn-recorder.d.ts +37 -0
- package/dist/rollback/turn-recorder.js +183 -0
- package/dist/rollback/turn-store.d.ts +29 -0
- package/dist/rollback/turn-store.js +114 -0
- package/dist/rollback/types.d.ts +51 -0
- package/dist/rollback/types.js +9 -0
- package/dist/runtime/config-center.d.ts +92 -0
- package/dist/runtime/config-center.js +467 -0
- package/dist/runtime/config-schema.d.ts +201 -0
- package/dist/runtime/config-schema.js +2 -0
- package/dist/runtime/defaults.d.ts +3 -0
- package/dist/runtime/defaults.js +146 -0
- package/dist/schedule/cron.d.ts +24 -0
- package/dist/schedule/cron.js +145 -0
- package/dist/schedule/index.d.ts +6 -0
- package/dist/schedule/index.js +4 -0
- package/dist/schedule/persistence.d.ts +33 -0
- package/dist/schedule/persistence.js +106 -0
- package/dist/schedule/scheduler.d.ts +85 -0
- package/dist/schedule/scheduler.js +630 -0
- package/dist/schedule/types.d.ts +185 -0
- package/dist/schedule/types.js +2 -0
- package/dist/setup/config.d.ts +189 -0
- package/dist/setup/config.js +253 -0
- package/dist/setup/index.d.ts +3 -0
- package/dist/setup/index.js +3 -0
- package/dist/setup/model-defaults.d.ts +13 -0
- package/dist/setup/model-defaults.js +87 -0
- package/dist/setup/persona-bootstrap.d.ts +42 -0
- package/dist/setup/persona-bootstrap.js +379 -0
- package/dist/setup/wizard.d.ts +32 -0
- package/dist/setup/wizard.js +384 -0
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.js +4 -0
- package/dist/skills/loader.d.ts +12 -0
- package/dist/skills/loader.js +83 -0
- package/dist/skills/registry.d.ts +2 -0
- package/dist/skills/registry.js +2 -0
- package/dist/skills/skill-tool.d.ts +20 -0
- package/dist/skills/skill-tool.js +49 -0
- package/dist/tools/archive.d.ts +17 -0
- package/dist/tools/archive.js +131 -0
- package/dist/tools/ask-user.d.ts +9 -0
- package/dist/tools/ask-user.js +62 -0
- package/dist/tools/background-registry.d.ts +45 -0
- package/dist/tools/background-registry.js +164 -0
- package/dist/tools/bash.d.ts +56 -0
- package/dist/tools/bash.js +391 -0
- package/dist/tools/bundle-registry.d.ts +42 -0
- package/dist/tools/bundle-registry.js +239 -0
- package/dist/tools/bundle-tools.d.ts +11 -0
- package/dist/tools/bundle-tools.js +168 -0
- package/dist/tools/channel-info.d.ts +5 -0
- package/dist/tools/channel-info.js +38 -0
- package/dist/tools/compression.d.ts +7 -0
- package/dist/tools/compression.js +21 -0
- package/dist/tools/config.d.ts +23 -0
- package/dist/tools/config.js +255 -0
- package/dist/tools/db-query.d.ts +12 -0
- package/dist/tools/db-query.js +107 -0
- package/dist/tools/diagnostics.d.ts +30 -0
- package/dist/tools/diagnostics.js +111 -0
- package/dist/tools/diff-channel.d.ts +9 -0
- package/dist/tools/diff-channel.js +17 -0
- package/dist/tools/diff-files.d.ts +17 -0
- package/dist/tools/diff-files.js +88 -0
- package/dist/tools/disk-usage.d.ts +34 -0
- package/dist/tools/disk-usage.js +258 -0
- package/dist/tools/edit.d.ts +30 -0
- package/dist/tools/edit.js +235 -0
- package/dist/tools/executor.d.ts +32 -0
- package/dist/tools/executor.js +66 -0
- package/dist/tools/file-tracker.d.ts +20 -0
- package/dist/tools/file-tracker.js +44 -0
- package/dist/tools/filtered-registry.d.ts +29 -0
- package/dist/tools/filtered-registry.js +50 -0
- package/dist/tools/flow.d.ts +10 -0
- package/dist/tools/flow.js +180 -0
- package/dist/tools/git-tool.d.ts +24 -0
- package/dist/tools/git-tool.js +113 -0
- package/dist/tools/glob.d.ts +29 -0
- package/dist/tools/glob.js +152 -0
- package/dist/tools/grep.d.ts +14 -0
- package/dist/tools/grep.js +325 -0
- package/dist/tools/http-request.d.ts +14 -0
- package/dist/tools/http-request.js +126 -0
- package/dist/tools/index.d.ts +43 -0
- package/dist/tools/index.js +76 -0
- package/dist/tools/injection-filter.d.ts +6 -0
- package/dist/tools/injection-filter.js +71 -0
- package/dist/tools/insert.d.ts +13 -0
- package/dist/tools/insert.js +61 -0
- package/dist/tools/interface.d.ts +30 -0
- package/dist/tools/interface.js +2 -0
- package/dist/tools/json-edit.d.ts +15 -0
- package/dist/tools/json-edit.js +122 -0
- package/dist/tools/multi-edit.d.ts +9 -0
- package/dist/tools/multi-edit.js +146 -0
- package/dist/tools/path-sandbox.d.ts +14 -0
- package/dist/tools/path-sandbox.js +60 -0
- package/dist/tools/process-tools.d.ts +15 -0
- package/dist/tools/process-tools.js +95 -0
- package/dist/tools/python-bridge/bridge.d.ts +24 -0
- package/dist/tools/python-bridge/bridge.js +39 -0
- package/dist/tools/python-bridge/executor.d.ts +6 -0
- package/dist/tools/python-bridge/executor.js +69 -0
- package/dist/tools/python-bridge/index.d.ts +5 -0
- package/dist/tools/python-bridge/index.js +4 -0
- package/dist/tools/python-bridge/parser.d.ts +21 -0
- package/dist/tools/python-bridge/parser.js +258 -0
- package/dist/tools/read.d.ts +16 -0
- package/dist/tools/read.js +276 -0
- package/dist/tools/registry.d.ts +2 -0
- package/dist/tools/registry.js +2 -0
- package/dist/tools/restart.d.ts +10 -0
- package/dist/tools/restart.js +46 -0
- package/dist/tools/result-buffer.d.ts +66 -0
- package/dist/tools/result-buffer.js +146 -0
- package/dist/tools/runtime-control.d.ts +163 -0
- package/dist/tools/runtime-control.js +1780 -0
- package/dist/tools/symbol-references.d.ts +5 -0
- package/dist/tools/symbol-references.js +331 -0
- package/dist/tools/system-info.d.ts +3 -0
- package/dist/tools/system-info.js +55 -0
- package/dist/tools/write.d.ts +18 -0
- package/dist/tools/write.js +118 -0
- package/dist/tools/xref/index.d.ts +25 -0
- package/dist/tools/xref/index.js +25 -0
- package/dist/tools/xref/manager.d.ts +85 -0
- package/dist/tools/xref/manager.js +948 -0
- package/dist/tools/xref/parser.d.ts +34 -0
- package/dist/tools/xref/parser.js +64 -0
- package/dist/tools/xref/regex-parser.d.ts +26 -0
- package/dist/tools/xref/regex-parser.js +446 -0
- package/dist/tools/xref/schema.d.ts +104 -0
- package/dist/tools/xref/schema.js +68 -0
- package/dist/tools/xref/ts-parser.d.ts +20 -0
- package/dist/tools/xref/ts-parser.js +403 -0
- package/dist/tools/xref/xref-build.d.ts +20 -0
- package/dist/tools/xref/xref-build.js +128 -0
- package/dist/tools/xref/xref-graph.d.ts +24 -0
- package/dist/tools/xref/xref-graph.js +88 -0
- package/dist/tools/xref/xref-query.d.ts +30 -0
- package/dist/tools/xref/xref-query.js +123 -0
- package/dist/types.d.ts +217 -0
- package/dist/types.js +2 -0
- package/dist/ui/assistant-message.d.ts +7 -0
- package/dist/ui/assistant-message.js +18 -0
- package/dist/ui/chat-log.d.ts +52 -0
- package/dist/ui/chat-log.js +246 -0
- package/dist/ui/command-registry.d.ts +73 -0
- package/dist/ui/command-registry.js +838 -0
- package/dist/ui/diff-component.d.ts +14 -0
- package/dist/ui/diff-component.js +42 -0
- package/dist/ui/hyperlink-markdown.d.ts +10 -0
- package/dist/ui/hyperlink-markdown.js +21 -0
- package/dist/ui/markdown-message.d.ts +10 -0
- package/dist/ui/markdown-message.js +16 -0
- package/dist/ui/osc8-hyperlinks.d.ts +4 -0
- package/dist/ui/osc8-hyperlinks.js +142 -0
- package/dist/ui/pi-tui-editor.d.ts +35 -0
- package/dist/ui/pi-tui-editor.js +79 -0
- package/dist/ui/slash-commands.d.ts +16 -0
- package/dist/ui/slash-commands.js +29 -0
- package/dist/ui/slash-panel.d.ts +54 -0
- package/dist/ui/slash-panel.js +199 -0
- package/dist/ui/theme.d.ts +120 -0
- package/dist/ui/theme.js +154 -0
- package/dist/ui/tool-display.d.ts +13 -0
- package/dist/ui/tool-display.js +85 -0
- package/dist/ui/tool-execution.d.ts +22 -0
- package/dist/ui/tool-execution.js +87 -0
- package/dist/ui/tui-formatters.d.ts +2 -0
- package/dist/ui/tui-formatters.js +145 -0
- package/dist/ui/user-message.d.ts +5 -0
- package/dist/ui/user-message.js +11 -0
- package/dist/update/check.d.ts +8 -0
- package/dist/update/check.js +28 -0
- package/dist/update/config.d.ts +6 -0
- package/dist/update/config.js +18 -0
- package/dist/update/download.d.ts +3 -0
- package/dist/update/download.js +27 -0
- package/dist/update/index.d.ts +6 -0
- package/dist/update/index.js +5 -0
- package/dist/update/install.d.ts +3 -0
- package/dist/update/install.js +33 -0
- package/dist/update/types.d.ts +16 -0
- package/dist/update/types.js +2 -0
- package/dist/utils/diff.d.ts +9 -0
- package/dist/utils/diff.js +45 -0
- package/dist/utils/misc.d.ts +12 -0
- package/dist/utils/misc.js +34 -0
- package/dist/world-engine/agent.d.ts +41 -0
- package/dist/world-engine/agent.js +385 -0
- package/dist/world-engine/index.d.ts +45 -0
- package/dist/world-engine/index.js +160 -0
- package/dist/world-engine/sim.d.ts +14 -0
- package/dist/world-engine/sim.js +120 -0
- package/dist/world-engine/store.d.ts +110 -0
- package/dist/world-engine/store.js +519 -0
- package/dist/world-engine/ticker.d.ts +37 -0
- package/dist/world-engine/ticker.js +214 -0
- package/dist/world-engine/tools.d.ts +6 -0
- package/dist/world-engine/tools.js +380 -0
- package/dist/world-engine/types.d.ts +202 -0
- package/dist/world-engine/types.js +56 -0
- package/docs/api.md +180 -0
- package/docs/architecture.md +206 -0
- package/docs/diagnostics/2026-06-08-config-prompt-guidance.md +67 -0
- package/docs/superpowers/plans/2026-06-08-global-bootstrap-mode.md +89 -0
- package/docs/superpowers/specs/2026-06-08-global-bootstrap-mode-design.md +174 -0
- package/docs/user-guide.md +226 -0
- package/package.json +63 -0
- package/plugins/example-greeter/index.js +55 -0
- package/plugins/example-greeter/plugin.json +8 -0
- package/pnpm-workspace.yaml +5 -0
- package/provider_arch.md +179 -0
- package/start-webui.sh +27 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/webui-channel-design.md +789 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// world-engine / ticker — WorldTicker
|
|
3
|
+
// ============================================================
|
|
4
|
+
//
|
|
5
|
+
// 世界的"自动管理程序":用模块内部定时器推进环境基础内容。
|
|
6
|
+
// 不依赖任务调度器,start() 起定时器、stop() 清定时器,保证模块自包含。
|
|
7
|
+
//
|
|
8
|
+
// 职责(Ticker 独占写的字段):
|
|
9
|
+
// 1. 推进世界时间(ambient.time),按 timeScale 相对现实时间流逝
|
|
10
|
+
// 2. 依时间推导季节
|
|
11
|
+
// 3. 低概率变天气
|
|
12
|
+
// 4. 按 home + roaming 概率放置 NPC(跳过被 pin 的),不乱窜
|
|
13
|
+
// 5. 清理已过期的时间型 pin
|
|
14
|
+
// ============================================================
|
|
15
|
+
import { periodOf } from './types.js';
|
|
16
|
+
import { evolveSim } from './sim.js';
|
|
17
|
+
// 天气只在相邻状态间过渡,避免"晴→暴雨"式突变;数组内重复项 = 更倾向保持/趋向该状态
|
|
18
|
+
const WEATHER_TRANSITIONS = {
|
|
19
|
+
'晴': ['晴', '晴', '晴', '多云'],
|
|
20
|
+
'多云': ['多云', '多云', '晴', '阴', '雾'],
|
|
21
|
+
'阴': ['阴', '阴', '多云', '小雨'],
|
|
22
|
+
'小雨': ['小雨', '小雨', '阴'],
|
|
23
|
+
'雪': ['雪', '雪', '阴'],
|
|
24
|
+
'雾': ['雾', '多云', '晴'],
|
|
25
|
+
};
|
|
26
|
+
/** 各季节基准气温 */
|
|
27
|
+
const SEASON_BASE_TEMP = { '春': 18, '夏': 30, '秋': 16, '冬': 4 };
|
|
28
|
+
/**
|
|
29
|
+
* 让天气符合季节:冬天的降水是雪、其余季节是雨;防止"夏天下雪""冬天下雨"这类不合理天气。
|
|
30
|
+
*/
|
|
31
|
+
function seasonalizeWeather(weather, season) {
|
|
32
|
+
if (season === '冬') {
|
|
33
|
+
if (weather === '小雨')
|
|
34
|
+
return '雪'; // 冬天降水 → 雪
|
|
35
|
+
}
|
|
36
|
+
else if (weather === '雪') {
|
|
37
|
+
return '小雨'; // 非冬季不下雪 → 转为雨
|
|
38
|
+
}
|
|
39
|
+
return weather;
|
|
40
|
+
}
|
|
41
|
+
/** 把世界时间格式化为本地可读串(YYYY-MM-DD HH:mm),供旁白/展示 */
|
|
42
|
+
function fmtLocalTime(d) {
|
|
43
|
+
const p = (n) => String(n).padStart(2, '0');
|
|
44
|
+
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
|
|
45
|
+
}
|
|
46
|
+
/** 由月份推导季节(北半球) */
|
|
47
|
+
function seasonOf(month) {
|
|
48
|
+
if (month >= 3 && month <= 5)
|
|
49
|
+
return '春';
|
|
50
|
+
if (month >= 6 && month <= 8)
|
|
51
|
+
return '夏';
|
|
52
|
+
if (month >= 9 && month <= 11)
|
|
53
|
+
return '秋';
|
|
54
|
+
return '冬';
|
|
55
|
+
}
|
|
56
|
+
/** 昼夜温差:正午偏暖,凌晨偏冷 */
|
|
57
|
+
function dayNightOffset(hour) {
|
|
58
|
+
if (hour >= 12 && hour < 16)
|
|
59
|
+
return 3;
|
|
60
|
+
if (hour >= 10 && hour < 18)
|
|
61
|
+
return 1;
|
|
62
|
+
if (hour >= 6 && hour < 10)
|
|
63
|
+
return -2;
|
|
64
|
+
if (hour >= 18 && hour < 22)
|
|
65
|
+
return -1;
|
|
66
|
+
return -4; // 深夜/凌晨
|
|
67
|
+
}
|
|
68
|
+
export class WorldTicker {
|
|
69
|
+
store;
|
|
70
|
+
heartbeatMs;
|
|
71
|
+
timeScale;
|
|
72
|
+
weatherAvgHours;
|
|
73
|
+
overcastHoursBeforeRain;
|
|
74
|
+
timer = null;
|
|
75
|
+
/** 当前天气已持续的【世界小时】数(用于"阴天酝酿够久才下雨",按世界时间而非心跳数计) */
|
|
76
|
+
weatherDwellHours = 0;
|
|
77
|
+
constructor(store, opts = {}) {
|
|
78
|
+
this.store = store;
|
|
79
|
+
this.heartbeatMs = opts.heartbeatMs ?? 5000;
|
|
80
|
+
this.timeScale = opts.timeScale ?? 1;
|
|
81
|
+
this.weatherAvgHours = opts.weatherAvgHours ?? 4;
|
|
82
|
+
this.overcastHoursBeforeRain = opts.overcastHoursBeforeRain ?? 1.5;
|
|
83
|
+
}
|
|
84
|
+
/** 本次心跳流逝的世界小时数(= 现实流逝 × timeScale) */
|
|
85
|
+
worldHoursPerTick() {
|
|
86
|
+
return (this.heartbeatMs * this.timeScale) / 3_600_000;
|
|
87
|
+
}
|
|
88
|
+
start() {
|
|
89
|
+
if (this.timer)
|
|
90
|
+
return;
|
|
91
|
+
this.timer = setInterval(() => this.tick(), this.heartbeatMs);
|
|
92
|
+
// 定时器不应阻止进程退出
|
|
93
|
+
if (typeof this.timer === 'object' && this.timer && 'unref' in this.timer) {
|
|
94
|
+
this.timer.unref();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
stop() {
|
|
98
|
+
if (this.timer) {
|
|
99
|
+
clearInterval(this.timer);
|
|
100
|
+
this.timer = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** 单次推进(也可供测试直接调用) */
|
|
104
|
+
tick(now = new Date()) {
|
|
105
|
+
const w = this.store.getWorld();
|
|
106
|
+
if (!w)
|
|
107
|
+
return;
|
|
108
|
+
const worldHours = this.worldHoursPerTick();
|
|
109
|
+
const prevWeather = w.ambient.weather;
|
|
110
|
+
this.store.batch(world => {
|
|
111
|
+
this.advanceTime(world, now);
|
|
112
|
+
this.maybeChangeWeather(world, worldHours);
|
|
113
|
+
this.evolveSimObjects(world, worldHours); // 在 ambient 更新后,让雪等对象按最新温度演化
|
|
114
|
+
// 【未来·用户↔NPC 交互】此处曾调 cleanExpiredPins(清理过期的 NPC 钉住),随 pin 机制清理而移除
|
|
115
|
+
this.placeNpcs(world);
|
|
116
|
+
});
|
|
117
|
+
// 记录天气驻留时长(世界小时):不变则累加流逝,变了则清零
|
|
118
|
+
const now2 = this.store.getWorld();
|
|
119
|
+
if (now2)
|
|
120
|
+
this.weatherDwellHours = now2.ambient.weather === prevWeather ? this.weatherDwellHours + worldHours : 0;
|
|
121
|
+
}
|
|
122
|
+
// ── 动态对象演化(雪化/植物生长/计时) ───────────────────
|
|
123
|
+
evolveSimObjects(w, worldHours) {
|
|
124
|
+
for (const [id, sim] of Object.entries(w.simObjects)) {
|
|
125
|
+
if (!evolveSim(sim, w.ambient, worldHours, w.customKinds))
|
|
126
|
+
delete w.simObjects[id];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// ── 时间 + 季节 ─────────────────────────────────────────
|
|
130
|
+
advanceTime(w, now) {
|
|
131
|
+
const createdMs = Date.parse(w.meta.createdAt);
|
|
132
|
+
if (isNaN(createdMs))
|
|
133
|
+
return;
|
|
134
|
+
// 世界时间 = 创建时刻 + 现实流逝 × 倍率。
|
|
135
|
+
// timeScale=1 时即与现实时间精确 1:1(无累积漂移;进程离线后重启也不会落后,每次按现实实时计算)。
|
|
136
|
+
const worldDate = new Date(createdMs + (now.getTime() - createdMs) * this.timeScale);
|
|
137
|
+
// 用本地时间分量,让"时段/季节"贴合用户真实所在时区
|
|
138
|
+
w.ambient.time = fmtLocalTime(worldDate);
|
|
139
|
+
w.ambient.period = periodOf(worldDate.getHours());
|
|
140
|
+
w.ambient.season = seasonOf(worldDate.getMonth() + 1);
|
|
141
|
+
// 换季后修正不合季节的天气(如入春后仍是"雪"→改"小雨")
|
|
142
|
+
w.ambient.weather = seasonalizeWeather(w.ambient.weather, w.ambient.season);
|
|
143
|
+
this.driftTemperature(w, worldDate.getHours());
|
|
144
|
+
}
|
|
145
|
+
/** 温度平滑趋近"季节基准+昼夜偏移"的目标,每次最多变 1 度,不突变 */
|
|
146
|
+
driftTemperature(w, hour) {
|
|
147
|
+
const base = SEASON_BASE_TEMP[w.ambient.season] ?? 20;
|
|
148
|
+
let target = base + dayNightOffset(hour);
|
|
149
|
+
const wx = w.ambient.weather;
|
|
150
|
+
if (wx === '小雨' || wx === '阴' || wx === '雪')
|
|
151
|
+
target -= 2; // 阴雨雪天更冷
|
|
152
|
+
if (w.ambient.temperature < target)
|
|
153
|
+
w.ambient.temperature += 1;
|
|
154
|
+
else if (w.ambient.temperature > target)
|
|
155
|
+
w.ambient.temperature -= 1;
|
|
156
|
+
}
|
|
157
|
+
maybeChangeWeather(w, worldHours) {
|
|
158
|
+
// 变天概率按【世界时间】算:平均每 weatherAvgHours 世界小时变一次天气。
|
|
159
|
+
// 于是 1:1 时天气几小时才变一次(贴合现实);timeScale 越大变得越快,自动缩放。
|
|
160
|
+
const changeProb = worldHours / this.weatherAvgHours;
|
|
161
|
+
if (Math.random() >= changeProb)
|
|
162
|
+
return;
|
|
163
|
+
// 只跳到相邻天气,保证渐变(晴→多云→阴→小雨),不会晴天秒变暴雨
|
|
164
|
+
const options = WEATHER_TRANSITIONS[w.ambient.weather] ?? ['晴', '多云'];
|
|
165
|
+
let next = seasonalizeWeather(options[Math.floor(Math.random() * options.length)], w.ambient.season);
|
|
166
|
+
// 逻辑链条:降水(雨/雪)必须在"阴"酝酿够久(按世界小时)之后才发生;否则继续保持阴天铺垫
|
|
167
|
+
if ((next === '小雨' || next === '雪') && this.weatherDwellHours < this.overcastHoursBeforeRain) {
|
|
168
|
+
next = '阴';
|
|
169
|
+
}
|
|
170
|
+
w.ambient.weather = next;
|
|
171
|
+
}
|
|
172
|
+
// ── NPC 放置(概率驱动,锚定 home,不乱窜) ───────────────
|
|
173
|
+
placeNpcs(w) {
|
|
174
|
+
// 【未来·用户↔NPC 交互】曾在此跳过"被剧情 pin 的 NPC",随 pin 机制清理而移除
|
|
175
|
+
for (const [, npc] of Object.entries(w.npcs)) {
|
|
176
|
+
// 正在当前场景(陪伴角色所在地)里的 NPC 不挪走,避免对话中途 NPC 凭空消失
|
|
177
|
+
const scene = w.state.companionLocation || w.state.location;
|
|
178
|
+
if (scene && npc.location === scene)
|
|
179
|
+
continue;
|
|
180
|
+
if (npc.mobility === 'anchored' && npc.home.includes(npc.location)) {
|
|
181
|
+
// 锚定型且已在 home:小概率出门
|
|
182
|
+
if (Math.random() < npc.roaming) {
|
|
183
|
+
const target = this.pickRoamTarget(w, npc.location);
|
|
184
|
+
if (target)
|
|
185
|
+
npc.location = target;
|
|
186
|
+
}
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
// free 型或不在 home:按 roaming 决定出门 or 回家
|
|
190
|
+
if (Math.random() < npc.roaming) {
|
|
191
|
+
const target = this.pickRoamTarget(w, npc.location);
|
|
192
|
+
if (target)
|
|
193
|
+
npc.location = target;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
// 回到 home 中的一个
|
|
197
|
+
const home = npc.home[Math.floor(Math.random() * npc.home.length)];
|
|
198
|
+
if (home && w.locations[home])
|
|
199
|
+
npc.location = home;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/** 从当前地点的相邻可达地点里挑一个(只走一步,不会瞬移到地图另一端) */
|
|
204
|
+
pickRoamTarget(w, from) {
|
|
205
|
+
const loc = w.locations[from];
|
|
206
|
+
if (!loc || loc.connects.length === 0)
|
|
207
|
+
return null;
|
|
208
|
+
const candidates = loc.connects.filter(id => w.locations[id]);
|
|
209
|
+
if (candidates.length === 0)
|
|
210
|
+
return null;
|
|
211
|
+
return candidates[Math.floor(Math.random() * candidates.length)];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=ticker.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../types.js';
|
|
2
|
+
import type { WorldStore } from './store.js';
|
|
3
|
+
export declare const WORLD_TOOLS: ToolDefinition[];
|
|
4
|
+
/** 执行一个世界工具,返回给模型的结果字符串 */
|
|
5
|
+
export declare function executeWorldTool(store: WorldStore, name: string, input: Record<string, unknown>): Promise<string>;
|
|
6
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// world-engine / tools — 模块内工具
|
|
3
|
+
// ============================================================
|
|
4
|
+
//
|
|
5
|
+
// 后置 WorldAgent 用来"生长世界"的定制工具。按 world.json 格式定制,
|
|
6
|
+
// 直连 WorldStore。不进全局 tool.registry,不被主 agent 看见。
|
|
7
|
+
// ============================================================
|
|
8
|
+
export const WORLD_TOOLS = [
|
|
9
|
+
{
|
|
10
|
+
name: 'world_upsert_location',
|
|
11
|
+
description: '创建或更新一个地点。对话中提到但世界里还没有的地点,用它"造"出来。visible=能看见的邻近地点,connects=能走过去的地点。',
|
|
12
|
+
input_schema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
id: { type: 'string', description: '地点名(唯一标识,如"森林""木屋")' },
|
|
16
|
+
desc: { type: 'string', description: '地点描述' },
|
|
17
|
+
objects: { type: 'array', items: { type: 'string' }, description: '地点内的物品' },
|
|
18
|
+
visible: { type: 'array', items: { type: 'string' }, description: '能看见的邻近地点 id' },
|
|
19
|
+
connects: { type: 'array', items: { type: 'string' }, description: '能走过去的地点 id' },
|
|
20
|
+
owner: { type: 'string', description: '地点主人(角色名,如"柔柔")。私人住所要填;公共场所留空。主人在自己地盘是主人不是客人' },
|
|
21
|
+
},
|
|
22
|
+
required: ['id', 'desc'],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'world_upsert_npc',
|
|
27
|
+
description: '创建或更新一个 NPC。世界从对话中逐渐长细节:所有字段都可以【后续丰富】——第一次也许只知道"一个店员",后来了解到名字/性格/住处,再调用它补上即可(只传你要更新的字段)。home=常驻地点,roaming=0~1 离开常驻地点的概率,mobility=anchored(基本不动)/free(会逛)。',
|
|
28
|
+
input_schema: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
id: { type: 'string', description: 'NPC 主标识(选一个固定名字,之后都用它)' },
|
|
32
|
+
aliases: { type: 'array', items: { type: 'string' }, description: '该 NPC 的其他称呼(昵称/头衔/全名等,如徐青的[小青,蛋糕店老板]),都指同一人' },
|
|
33
|
+
race: { type: 'string', description: '种族/物种(如"兔子""天马")。是属性不是身份:同种族的不同个体各建各的条目,绝不因同族合并' },
|
|
34
|
+
note: { type: 'string', description: '认知留痕:这个 NPC 是如何被逐渐了解的(初见→得知名字/性格/住处…)' },
|
|
35
|
+
desc: { type: 'string', description: '外观/身份描述(可随了解加深而更新)' },
|
|
36
|
+
persona: { type: 'string', description: '性格人设(可随了解加深而更新)' },
|
|
37
|
+
home: { type: 'array', items: { type: 'string' }, description: '常驻地点 id(可更新)' },
|
|
38
|
+
roaming: { type: 'number', description: '离开常驻地点的概率 0~1(可更新)' },
|
|
39
|
+
mobility: { type: 'string', enum: ['anchored', 'free'], description: '移动性(可更新)' },
|
|
40
|
+
state: { type: 'string', description: '当前状态描述(可随时更新)' },
|
|
41
|
+
},
|
|
42
|
+
required: ['id'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'world_set_character',
|
|
47
|
+
description: '设置/更新【主角】或【陪伴角色】的动态身份信息(种族、别名、认知历程)。' +
|
|
48
|
+
'主角和陪伴角色不是 NPC,但你对他们的了解会随对话深入——第一次可能只知道种族/长相,' +
|
|
49
|
+
'后来才得知名字、昵称、外号——用此工具逐步补充。' +
|
|
50
|
+
'name=角色的【规范主名】(如前文已用"天角兽"就一直用它;若之前不知主名,用你当前所知最稳定的称呼)。' +
|
|
51
|
+
'aliases=这把学到的其他称呼(小名/外号/全名)汇进去,与新学到的合并,不覆盖已记录的。' +
|
|
52
|
+
'race=种族/物种(关键属性,非身份键:同种族的不同个体各建各的,绝不因同族合并)。' +
|
|
53
|
+
'note=留痕——何时从"只知种族"到"得知名字/昵称",帮助此后追踪认知变化。' +
|
|
54
|
+
'只在确实学到了新信息时调用;没有新信息就不调。',
|
|
55
|
+
input_schema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
name: { type: 'string', description: '角色规范主名(已用的固定名,如"天角兽""柔柔")' },
|
|
59
|
+
race: { type: 'string', description: '种族/物种' },
|
|
60
|
+
aliases: { type: 'array', items: { type: 'string' }, description: '新学到的其他称呼(小名/外号/全名)' },
|
|
61
|
+
note: { type: 'string', description: '认知留痕,如"初见时只知是独角兽;第N轮得知本名XXX"' },
|
|
62
|
+
},
|
|
63
|
+
required: ['name'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'world_remove_npc',
|
|
68
|
+
description: '删除一个错误创建的 NPC。最常见的用途:之前把「主角」或「陪伴角色」误当成 NPC 建了条目,用它删掉。',
|
|
69
|
+
input_schema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: { id: { type: 'string', description: '要删除的 NPC id' } },
|
|
72
|
+
required: ['id'],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'world_remove_character',
|
|
77
|
+
description: '删除一个误建的重复角色条目(state.characters 里的)。用于清理把同一人的别名当成独立角色、建了多余条目的情况。删前先确认该角色的信息已合并到正确条目。',
|
|
78
|
+
input_schema: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: { name: { type: 'string', description: '要删除的角色条目名(state.characters 的 key)' } },
|
|
81
|
+
required: ['name'],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'world_set_relationship',
|
|
86
|
+
description: '设置/更新/删除两个角色间的社会关系。关系随对话发展而变。' +
|
|
87
|
+
'对称关系(朋友/好友/恋人/伴侣/夫妻/家人/同事/同学/熟人/邻居/室友):两个人互为同一类关系,只记一条(方向任意,工具会自动去重)。' +
|
|
88
|
+
'有向关系(宠物/主人/老师/学生/老板/下属):方向有意义,可分别记录。' +
|
|
89
|
+
'删除建错的或已结束的关系:传 remove=true。只在对话确实体现了关系建立/变化/结束时才调用。',
|
|
90
|
+
input_schema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
from: { type: 'string', description: '角色 A(关系的主体)' },
|
|
94
|
+
to: { type: 'string', description: '角色 B(关系的对象)' },
|
|
95
|
+
type: { type: 'string', description: '关系类型:陌生人/朋友/好友/恋人/家人/宠物/主人/同事…(remove=true 时可省略)' },
|
|
96
|
+
note: { type: 'string', description: '可选补充,如"刚认识,还有些拘谨"' },
|
|
97
|
+
remove: { type: 'boolean', description: 'true=删除 from→to 这条关系(建错了/关系结束了)' },
|
|
98
|
+
},
|
|
99
|
+
required: ['from', 'to'],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'world_move',
|
|
104
|
+
description: '移动角色所在地点。who:both=两人一起移动(最常见,默认);user=只有用户/主角移动(与陪伴角色分开了);companion=只有陪伴角色移动。两人分开后,环境旁白会以【陪伴角色】所在地作为场景。',
|
|
105
|
+
input_schema: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: {
|
|
108
|
+
location: { type: 'string', description: '新地点 id' },
|
|
109
|
+
who: { type: 'string', enum: ['both', 'user', 'companion'], description: '谁移动,默认 both' },
|
|
110
|
+
},
|
|
111
|
+
required: ['location'],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'world_scene_change',
|
|
116
|
+
description: '记录对当前环境的临时变更(如"灯关了""窗户开着")。value 传空字符串表示撤销该变更。',
|
|
117
|
+
input_schema: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
properties: {
|
|
120
|
+
key: { type: 'string', description: '变更项(如"灯光")' },
|
|
121
|
+
value: { type: 'string', description: '变更后的状态;空字符串=撤销' },
|
|
122
|
+
},
|
|
123
|
+
required: ['key', 'value'],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'world_define_kind',
|
|
128
|
+
description: '声明一个"新的动态对象类型",交给框架按规则自动演化。当内置类型(snow/plant/timer)覆盖不了对话里出现的动态之物时用它(如融化的冰淇淋、越烧越短的蜡烛、逐渐枯萎的花)。声明后即可用 world_spawn_sim 以该 kind 生成实例。用规则而非代码描述:ratePerHour=每世界小时的变化量(正=增/负=减),tempFactor=温度影响(如冰淇淋填负数,越热化越快),removeAtOrBelow=降到该值就消失。',
|
|
129
|
+
input_schema: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
kind: { type: 'string', description: '类型名(如 icecream、candle、wilting_flower)' },
|
|
133
|
+
desc: { type: 'string', description: '这类东西是什么' },
|
|
134
|
+
ratePerHour: { type: 'number', description: 'amount 每世界小时的基础变化(正=增长,负=衰减)' },
|
|
135
|
+
tempFactor: { type: 'number', description: '温度影响:有效速率 += tempFactor × 温度(越热化越快就填负数)' },
|
|
136
|
+
max: { type: 'number', description: 'amount 上限,默认 100' },
|
|
137
|
+
removeAtOrBelow: { type: 'number', description: 'amount ≤ 此值则消失(如融尽=0)' },
|
|
138
|
+
start: { type: 'number', description: '初始 amount(不填:衰减型默满,增长型默 0)' },
|
|
139
|
+
phases: {
|
|
140
|
+
type: 'array',
|
|
141
|
+
description: '阶段标签,按 amount 阈值从高到低',
|
|
142
|
+
items: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: { atOrAbove: { type: 'number' }, label: { type: 'string' } },
|
|
145
|
+
required: ['atOrAbove', 'label'],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
required: ['kind', 'ratePerHour'],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'world_spawn_sim',
|
|
154
|
+
description: '生成一个"由框架自动维护"的动态对象——之后它会随世界时间/环境自行变化,你不用再管它。内置类型:snow(随温度融化消失)、plant(生长成熟;采摘用 world_harvest)、timer(计时装置如烤面包机,到点变"完成")。也可用先前 world_define_kind 声明的自定义类型。当对话里出现这类东西时才生成。',
|
|
155
|
+
input_schema: {
|
|
156
|
+
type: 'object',
|
|
157
|
+
properties: {
|
|
158
|
+
id: { type: 'string', description: '对象名(如"院子里的雪""窗台的番茄""烤着的面包机")' },
|
|
159
|
+
kind: { type: 'string', description: '类型:snow/plant/timer 或已声明的自定义类型' },
|
|
160
|
+
location: { type: 'string', description: '所在地点 id(通常是主角当前地点)' },
|
|
161
|
+
desc: { type: 'string', description: '简短描述' },
|
|
162
|
+
multiHarvest: { type: 'boolean', description: 'plant 专用:true=多茬生(采后重长),false=一茬生(采后消失)' },
|
|
163
|
+
durationHours: { type: 'number', description: 'timer 专用:多少"世界小时"后完成(面包机可填 0.05)' },
|
|
164
|
+
},
|
|
165
|
+
required: ['id', 'kind', 'location'],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'world_object',
|
|
170
|
+
description: '与物体交互并记录其影响。物体可以是地点里的静物,也可以是动态对象(雪/植物等)。' +
|
|
171
|
+
'action:move=把物体搬到另一个地点(需 to);remove=物体被消耗/用掉/毁坏而消失;' +
|
|
172
|
+
'harvest=采摘已成熟的植物(多茬生重长/一茬生消失);' +
|
|
173
|
+
'place=设置物体的相对位置(需 relation+anchor),如"花瓶 place 上 柜子"=花瓶在柜子上、"柜子 place 旁边 床"。用它记住屋里东西的相对摆放。',
|
|
174
|
+
input_schema: {
|
|
175
|
+
type: 'object',
|
|
176
|
+
properties: {
|
|
177
|
+
object: { type: 'string', description: '物体名 / id' },
|
|
178
|
+
action: { type: 'string', enum: ['move', 'remove', 'harvest', 'place'], description: '交互类型' },
|
|
179
|
+
to: { type: 'string', description: 'move 时的目标地点 id' },
|
|
180
|
+
relation: { type: 'string', description: 'place 时的关系:上/里/下/旁边/附近 等' },
|
|
181
|
+
anchor: { type: 'string', description: 'place 时的参照物(另一件物品/家具,如"柜子""床")' },
|
|
182
|
+
},
|
|
183
|
+
required: ['object', 'action'],
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'world_note_event',
|
|
188
|
+
description: '记录这一轮对话中发生的、对世界有意义的事件(简短一句)。',
|
|
189
|
+
input_schema: {
|
|
190
|
+
type: 'object',
|
|
191
|
+
properties: { event: { type: 'string', description: '事件描述' } },
|
|
192
|
+
required: ['event'],
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
];
|
|
196
|
+
/** 执行一个世界工具,返回给模型的结果字符串 */
|
|
197
|
+
export async function executeWorldTool(store, name, input) {
|
|
198
|
+
switch (name) {
|
|
199
|
+
case 'world_upsert_location': {
|
|
200
|
+
const id = String(input.id ?? '').trim();
|
|
201
|
+
if (!id)
|
|
202
|
+
return 'error: id 缺失';
|
|
203
|
+
await store.upsertLocation(id, {
|
|
204
|
+
desc: input.desc,
|
|
205
|
+
objects: input.objects,
|
|
206
|
+
visible: input.visible,
|
|
207
|
+
connects: input.connects,
|
|
208
|
+
owner: input.owner,
|
|
209
|
+
});
|
|
210
|
+
return `ok: 地点 "${id}" 已保存`;
|
|
211
|
+
}
|
|
212
|
+
case 'world_upsert_npc': {
|
|
213
|
+
const id = String(input.id ?? '').trim();
|
|
214
|
+
if (!id)
|
|
215
|
+
return 'error: id 缺失';
|
|
216
|
+
await store.upsertNpc(id, {
|
|
217
|
+
desc: input.desc,
|
|
218
|
+
aliases: Array.isArray(input.aliases) ? input.aliases : undefined,
|
|
219
|
+
race: input.race,
|
|
220
|
+
note: input.note,
|
|
221
|
+
persona: input.persona,
|
|
222
|
+
home: input.home,
|
|
223
|
+
roaming: input.roaming,
|
|
224
|
+
mobility: input.mobility,
|
|
225
|
+
state: input.state,
|
|
226
|
+
});
|
|
227
|
+
return `ok: NPC "${id}" 已保存`;
|
|
228
|
+
}
|
|
229
|
+
case 'world_set_character': {
|
|
230
|
+
const name = String(input.name ?? '').trim();
|
|
231
|
+
if (!name)
|
|
232
|
+
return 'error: name 缺失';
|
|
233
|
+
await store.setCharacter(name, {
|
|
234
|
+
race: input.race,
|
|
235
|
+
aliases: Array.isArray(input.aliases) ? input.aliases : undefined,
|
|
236
|
+
note: input.note,
|
|
237
|
+
});
|
|
238
|
+
return `ok: 角色 "${name}" 的身份信息已更新`;
|
|
239
|
+
}
|
|
240
|
+
case 'world_remove_character': {
|
|
241
|
+
const name = String(input.name ?? '').trim();
|
|
242
|
+
if (!name)
|
|
243
|
+
return 'error: name 缺失';
|
|
244
|
+
await store.removeCharacter(name);
|
|
245
|
+
return `ok: 角色条目 "${name}" 已删除`;
|
|
246
|
+
}
|
|
247
|
+
case 'world_remove_npc': {
|
|
248
|
+
const id = String(input.id ?? '').trim();
|
|
249
|
+
if (!id)
|
|
250
|
+
return 'error: id 缺失';
|
|
251
|
+
await store.removeNpc(id);
|
|
252
|
+
return `ok: NPC "${id}" 已删除`;
|
|
253
|
+
}
|
|
254
|
+
case 'world_set_relationship': {
|
|
255
|
+
const from = String(input.from ?? '').trim();
|
|
256
|
+
const to = String(input.to ?? '').trim();
|
|
257
|
+
if (!from || !to)
|
|
258
|
+
return 'error: from/to 缺失';
|
|
259
|
+
if (input.remove === true) {
|
|
260
|
+
await store.removeRelationship(from, to);
|
|
261
|
+
return `ok: 已删除关系 ${from}→${to}`;
|
|
262
|
+
}
|
|
263
|
+
const type = String(input.type ?? '').trim();
|
|
264
|
+
if (!type)
|
|
265
|
+
return 'error: type 缺失(或用 remove=true 删除)';
|
|
266
|
+
await store.setRelationship(from, to, type, input.note);
|
|
267
|
+
return `ok: 关系已记录(${to} 是 ${from} 的${type})`;
|
|
268
|
+
}
|
|
269
|
+
case 'world_move': {
|
|
270
|
+
const location = String(input.location ?? '').trim();
|
|
271
|
+
if (!location)
|
|
272
|
+
return 'error: location 缺失';
|
|
273
|
+
const who = String(input.who ?? 'both');
|
|
274
|
+
if (who === 'user') {
|
|
275
|
+
await store.moveUser(location);
|
|
276
|
+
return `ok: 用户/主角现在在 "${location}"(与陪伴角色分开)`;
|
|
277
|
+
}
|
|
278
|
+
if (who === 'companion') {
|
|
279
|
+
await store.moveCompanion(location);
|
|
280
|
+
return `ok: 陪伴角色现在在 "${location}"`;
|
|
281
|
+
}
|
|
282
|
+
await store.moveBoth(location);
|
|
283
|
+
return `ok: 两人现在都在 "${location}"`;
|
|
284
|
+
}
|
|
285
|
+
case 'world_scene_change': {
|
|
286
|
+
const key = String(input.key ?? '').trim();
|
|
287
|
+
if (!key)
|
|
288
|
+
return 'error: key 缺失';
|
|
289
|
+
const value = String(input.value ?? '');
|
|
290
|
+
await store.setSceneOverride(key, value === '' ? null : value);
|
|
291
|
+
return `ok: 环境变更 "${key}" 已记录`;
|
|
292
|
+
}
|
|
293
|
+
case 'world_define_kind': {
|
|
294
|
+
const kind = String(input.kind ?? '').trim();
|
|
295
|
+
if (!kind)
|
|
296
|
+
return 'error: kind 缺失';
|
|
297
|
+
if (typeof input.ratePerHour !== 'number')
|
|
298
|
+
return 'error: ratePerHour 必须是数字';
|
|
299
|
+
await store.defineKind({
|
|
300
|
+
kind,
|
|
301
|
+
desc: input.desc,
|
|
302
|
+
ratePerHour: input.ratePerHour,
|
|
303
|
+
tempFactor: typeof input.tempFactor === 'number' ? input.tempFactor : undefined,
|
|
304
|
+
max: typeof input.max === 'number' ? input.max : undefined,
|
|
305
|
+
removeAtOrBelow: typeof input.removeAtOrBelow === 'number' ? input.removeAtOrBelow : undefined,
|
|
306
|
+
start: typeof input.start === 'number' ? input.start : undefined,
|
|
307
|
+
phases: Array.isArray(input.phases)
|
|
308
|
+
? input.phases
|
|
309
|
+
.filter(p => typeof p?.atOrAbove === 'number' && typeof p?.label === 'string')
|
|
310
|
+
.map(p => ({ atOrAbove: p.atOrAbove, label: p.label }))
|
|
311
|
+
: undefined,
|
|
312
|
+
});
|
|
313
|
+
return `ok: 已声明动态类型 "${kind}",可用 world_spawn_sim 生成它`;
|
|
314
|
+
}
|
|
315
|
+
case 'world_spawn_sim': {
|
|
316
|
+
const id = String(input.id ?? '').trim();
|
|
317
|
+
const kind = String(input.kind ?? '').trim();
|
|
318
|
+
const location = String(input.location ?? '').trim();
|
|
319
|
+
if (!id || !kind || !location)
|
|
320
|
+
return 'error: id/kind/location 缺失';
|
|
321
|
+
const params = {};
|
|
322
|
+
if (typeof input.multiHarvest === 'boolean')
|
|
323
|
+
params.multiHarvest = input.multiHarvest;
|
|
324
|
+
if (typeof input.durationHours === 'number')
|
|
325
|
+
params.durationHours = input.durationHours;
|
|
326
|
+
await store.spawnSimObject(id, kind, location, input.desc, params);
|
|
327
|
+
return `ok: 动态对象 "${id}"(${kind}) 已生成,框架将自动维护`;
|
|
328
|
+
}
|
|
329
|
+
case 'world_object': {
|
|
330
|
+
const object = String(input.object ?? '').trim();
|
|
331
|
+
const action = String(input.action ?? '').trim();
|
|
332
|
+
if (!object || !action)
|
|
333
|
+
return 'error: object/action 缺失';
|
|
334
|
+
switch (action) {
|
|
335
|
+
case 'move': {
|
|
336
|
+
const to = String(input.to ?? '').trim();
|
|
337
|
+
if (!to)
|
|
338
|
+
return 'error: move 需要 to(目标地点)';
|
|
339
|
+
await store.moveObject(object, to);
|
|
340
|
+
return `ok: "${object}" 已搬到 "${to}"`;
|
|
341
|
+
}
|
|
342
|
+
case 'remove':
|
|
343
|
+
await store.removeObject(object);
|
|
344
|
+
return `ok: "${object}" 已消失`;
|
|
345
|
+
case 'place': {
|
|
346
|
+
const relation = String(input.relation ?? '').trim();
|
|
347
|
+
const anchor = String(input.anchor ?? '').trim();
|
|
348
|
+
if (!relation || !anchor)
|
|
349
|
+
return 'error: place 需要 relation 和 anchor';
|
|
350
|
+
await store.placeObject(object, relation, anchor);
|
|
351
|
+
return `ok: "${object}" 在 "${anchor}" ${relation}`;
|
|
352
|
+
}
|
|
353
|
+
case 'harvest': {
|
|
354
|
+
const sim = store.getWorld()?.simObjects[object];
|
|
355
|
+
if (!sim)
|
|
356
|
+
return `error: 没有 "${object}" 这个动态对象`;
|
|
357
|
+
if (sim.kind !== 'plant')
|
|
358
|
+
return `error: "${object}" 不是可采摘的植物`;
|
|
359
|
+
if (sim.amount < 100)
|
|
360
|
+
return `"${object}" 还没成熟(当前 ${Math.round(sim.amount)}%)`;
|
|
361
|
+
const multi = sim.params?.multiHarvest === true;
|
|
362
|
+
await store.harvestSim(object);
|
|
363
|
+
return multi ? `ok: 已采摘 "${object}",会重新生长` : `ok: 已采摘 "${object}"(一茬生,已消失)`;
|
|
364
|
+
}
|
|
365
|
+
default:
|
|
366
|
+
return `error: 未知 action "${action}"`;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
case 'world_note_event': {
|
|
370
|
+
const event = String(input.event ?? '').trim();
|
|
371
|
+
if (!event)
|
|
372
|
+
return 'error: event 缺失';
|
|
373
|
+
await store.addEvent(event);
|
|
374
|
+
return 'ok: 事件已记录';
|
|
375
|
+
}
|
|
376
|
+
default:
|
|
377
|
+
return `error: 未知工具 "${name}"`;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=tools.js.map
|