@runcore-sh/runcore 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -19
- package/brain-template/agents/README.md +20 -0
- package/brain-template/identity/README.md +20 -0
- package/brain-template/identity/brand.md +25 -0
- package/brain-template/identity/principles.md +21 -0
- package/brain-template/identity/tone-of-voice.md +23 -0
- package/brain-template/knowledge/notes/tier-gated-ui-spec.md +1 -1
- package/brain-template/metrics/README.md +13 -0
- package/brain-template/operations/goals.yaml +12 -0
- package/brain-template/operations/todos.md +17 -0
- package/brain-template/ops/README.md +13 -0
- package/brain-template/scheduling/README.md +2 -2
- package/brain-template/skills/README.md +23 -0
- package/brain-template/templates/README.md +9 -0
- package/brain-template/training/README.md +20 -0
- package/dictionary.json +2 -2
- package/dist/activity/log.d.ts +3 -0
- package/dist/activity/log.d.ts.map +1 -1
- package/dist/activity/log.js +12 -0
- package/dist/activity/log.js.map +1 -1
- package/dist/agents/autonomous.js +1 -0
- package/dist/agents/autonomous.js.map +1 -1
- package/dist/agents/commit.d.ts.map +1 -1
- package/dist/agents/commit.js +3 -10
- package/dist/agents/commit.js.map +1 -1
- package/dist/agents/dedup-guard.d.ts.map +1 -1
- package/dist/agents/dedup-guard.js +26 -23
- package/dist/agents/dedup-guard.js.map +1 -1
- package/dist/agents/feed.d.ts +69 -0
- package/dist/agents/feed.d.ts.map +1 -0
- package/dist/agents/feed.js +176 -0
- package/dist/agents/feed.js.map +1 -0
- package/dist/agents/governance.d.ts +14 -0
- package/dist/agents/governance.d.ts.map +1 -1
- package/dist/agents/governance.js +73 -1
- package/dist/agents/governance.js.map +1 -1
- package/dist/agents/governed-spawn.d.ts +12 -0
- package/dist/agents/governed-spawn.d.ts.map +1 -1
- package/dist/agents/governed-spawn.js +8 -2
- package/dist/agents/governed-spawn.js.map +1 -1
- package/dist/agents/index.d.ts +2 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +1 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/issue-reporter.d.ts +15 -0
- package/dist/agents/issue-reporter.d.ts.map +1 -0
- package/dist/agents/issue-reporter.js +123 -0
- package/dist/agents/issue-reporter.js.map +1 -0
- package/dist/agents/issues.d.ts +33 -0
- package/dist/agents/issues.d.ts.map +1 -0
- package/dist/agents/issues.js +141 -0
- package/dist/agents/issues.js.map +1 -0
- package/dist/agents/reflection.js +3 -3
- package/dist/agents/reflection.js.map +1 -1
- package/dist/agents/runtime/driver.d.ts.map +1 -1
- package/dist/agents/runtime/driver.js +1 -2
- package/dist/agents/runtime/driver.js.map +1 -1
- package/dist/agents/runtime/manager.d.ts.map +1 -1
- package/dist/agents/runtime/manager.js +1 -0
- package/dist/agents/runtime/manager.js.map +1 -1
- package/dist/agents/runtime/types.d.ts +2 -0
- package/dist/agents/runtime/types.d.ts.map +1 -1
- package/dist/agents/spawn.d.ts.map +1 -1
- package/dist/agents/spawn.js +20 -26
- package/dist/agents/spawn.js.map +1 -1
- package/dist/agents/store.d.ts.map +1 -1
- package/dist/agents/store.js +34 -1
- package/dist/agents/store.js.map +1 -1
- package/dist/agents/types.d.ts +27 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/auth/identity.d.ts +3 -0
- package/dist/auth/identity.d.ts.map +1 -1
- package/dist/auth/identity.js +9 -1
- package/dist/auth/identity.js.map +1 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +4 -0
- package/dist/auth/middleware.js.map +1 -1
- package/dist/calibration/conversation.d.ts +46 -0
- package/dist/calibration/conversation.d.ts.map +1 -0
- package/dist/calibration/conversation.js +295 -0
- package/dist/calibration/conversation.js.map +1 -0
- package/dist/calibration/index.d.ts +5 -0
- package/dist/calibration/index.d.ts.map +1 -0
- package/dist/calibration/index.js +5 -0
- package/dist/calibration/index.js.map +1 -0
- package/dist/calibration/runner.d.ts +127 -0
- package/dist/calibration/runner.d.ts.map +1 -0
- package/dist/calibration/runner.js +307 -0
- package/dist/calibration/runner.js.map +1 -0
- package/dist/calibration/store.d.ts +49 -0
- package/dist/calibration/store.d.ts.map +1 -0
- package/dist/calibration/store.js +140 -0
- package/dist/calibration/store.js.map +1 -0
- package/dist/calibration/types.d.ts +93 -0
- package/dist/calibration/types.d.ts.map +1 -0
- package/dist/calibration/types.js +53 -0
- package/dist/calibration/types.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +17 -2
- package/dist/cli.js.map +1 -1
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +28 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +181 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +76 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +93 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/dictionary/challenge.d.ts +66 -0
- package/dist/dictionary/challenge.d.ts.map +1 -0
- package/dist/dictionary/challenge.js +145 -0
- package/dist/dictionary/challenge.js.map +1 -0
- package/dist/dictionary/client.d.ts +32 -0
- package/dist/dictionary/client.d.ts.map +1 -0
- package/dist/dictionary/client.js +139 -0
- package/dist/dictionary/client.js.map +1 -0
- package/dist/dictionary/compatibility.d.ts +8 -0
- package/dist/dictionary/compatibility.d.ts.map +1 -0
- package/dist/dictionary/compatibility.js +56 -0
- package/dist/dictionary/compatibility.js.map +1 -0
- package/dist/dictionary/index.d.ts +22 -0
- package/dist/dictionary/index.d.ts.map +1 -0
- package/dist/dictionary/index.js +15 -0
- package/dist/dictionary/index.js.map +1 -0
- package/dist/dictionary/matcher.d.ts +18 -0
- package/dist/dictionary/matcher.d.ts.map +1 -0
- package/dist/dictionary/matcher.js +98 -0
- package/dist/dictionary/matcher.js.map +1 -0
- package/dist/dictionary/publisher.d.ts +17 -0
- package/dist/dictionary/publisher.d.ts.map +1 -0
- package/dist/dictionary/publisher.js +156 -0
- package/dist/dictionary/publisher.js.map +1 -0
- package/dist/dictionary/sync.d.ts +28 -0
- package/dist/dictionary/sync.d.ts.map +1 -0
- package/dist/dictionary/sync.js +268 -0
- package/dist/dictionary/sync.js.map +1 -0
- package/dist/dictionary/types.d.ts +75 -0
- package/dist/dictionary/types.d.ts.map +1 -0
- package/dist/dictionary/types.js +8 -0
- package/dist/dictionary/types.js.map +1 -0
- package/dist/dictionary/updater.d.ts +23 -0
- package/dist/dictionary/updater.d.ts.map +1 -0
- package/dist/dictionary/updater.js +84 -0
- package/dist/dictionary/updater.js.map +1 -0
- package/dist/dictionary/versioning.d.ts +15 -0
- package/dist/dictionary/versioning.d.ts.map +1 -0
- package/dist/dictionary/versioning.js +52 -0
- package/dist/dictionary/versioning.js.map +1 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +66 -0
- package/dist/errors.js.map +1 -0
- package/dist/events/event-bus.d.ts +37 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/event-bus.js +261 -0
- package/dist/events/event-bus.js.map +1 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +2 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/types.d.ts +71 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +7 -0
- package/dist/events/types.js.map +1 -0
- package/dist/feed/client.d.ts +34 -0
- package/dist/feed/client.d.ts.map +1 -0
- package/dist/feed/client.js +206 -0
- package/dist/feed/client.js.map +1 -0
- package/dist/feed/index.d.ts +61 -0
- package/dist/feed/index.d.ts.map +1 -0
- package/dist/feed/index.js +115 -0
- package/dist/feed/index.js.map +1 -0
- package/dist/feed/metrics.d.ts +51 -0
- package/dist/feed/metrics.d.ts.map +1 -0
- package/dist/feed/metrics.js +84 -0
- package/dist/feed/metrics.js.map +1 -0
- package/dist/feed/mixer.d.ts +89 -0
- package/dist/feed/mixer.d.ts.map +1 -0
- package/dist/feed/mixer.js +230 -0
- package/dist/feed/mixer.js.map +1 -0
- package/dist/feed/tiers.d.ts +15 -0
- package/dist/feed/tiers.d.ts.map +1 -0
- package/dist/feed/tiers.js +75 -0
- package/dist/feed/tiers.js.map +1 -0
- package/dist/feed/types.d.ts +76 -0
- package/dist/feed/types.d.ts.map +1 -0
- package/dist/feed/types.js +6 -0
- package/dist/feed/types.js.map +1 -0
- package/dist/files/registry.d.ts +77 -0
- package/dist/files/registry.d.ts.map +1 -0
- package/dist/files/registry.js +222 -0
- package/dist/files/registry.js.map +1 -0
- package/dist/google/plugin.d.ts +17 -0
- package/dist/google/plugin.d.ts.map +1 -0
- package/dist/google/plugin.js +169 -0
- package/dist/google/plugin.js.map +1 -0
- package/dist/health/checker.d.ts.map +1 -1
- package/dist/health/checker.js +14 -4
- package/dist/health/checker.js.map +1 -1
- package/dist/health/checks/openrouter.js +1 -1
- package/dist/health/checks/openrouter.js.map +1 -1
- package/dist/health/checks.d.ts +1 -1
- package/dist/health/checks.d.ts.map +1 -1
- package/dist/health/checks.js +9 -3
- package/dist/health/checks.js.map +1 -1
- package/dist/ledger/distance.d.ts +19 -0
- package/dist/ledger/distance.d.ts.map +1 -0
- package/dist/ledger/distance.js +70 -0
- package/dist/ledger/distance.js.map +1 -0
- package/dist/ledger/index.d.ts +8 -0
- package/dist/ledger/index.d.ts.map +1 -0
- package/dist/ledger/index.js +7 -0
- package/dist/ledger/index.js.map +1 -0
- package/dist/ledger/store.d.ts +27 -0
- package/dist/ledger/store.d.ts.map +1 -0
- package/dist/ledger/store.js +123 -0
- package/dist/ledger/store.js.map +1 -0
- package/dist/ledger/types.d.ts +109 -0
- package/dist/ledger/types.d.ts.map +1 -0
- package/dist/ledger/types.js +57 -0
- package/dist/ledger/types.js.map +1 -0
- package/dist/literacy.d.ts +50 -0
- package/dist/literacy.d.ts.map +1 -0
- package/dist/literacy.js +141 -0
- package/dist/literacy.js.map +1 -0
- package/dist/llm/complete.d.ts.map +1 -1
- package/dist/llm/complete.js +36 -3
- package/dist/llm/complete.js.map +1 -1
- package/dist/llm/fetch-guard.d.ts.map +1 -1
- package/dist/llm/fetch-guard.js +2 -0
- package/dist/llm/fetch-guard.js.map +1 -1
- package/dist/llm/membrane.d.ts +5 -0
- package/dist/llm/membrane.d.ts.map +1 -1
- package/dist/llm/membrane.js +48 -8
- package/dist/llm/membrane.js.map +1 -1
- package/dist/llm/nlp-detect.d.ts +17 -0
- package/dist/llm/nlp-detect.d.ts.map +1 -0
- package/dist/llm/nlp-detect.js +45 -0
- package/dist/llm/nlp-detect.js.map +1 -0
- package/dist/llm/ollama.d.ts +5 -0
- package/dist/llm/ollama.d.ts.map +1 -1
- package/dist/llm/ollama.js +39 -1
- package/dist/llm/ollama.js.map +1 -1
- package/dist/llm/openrouter.d.ts.map +1 -1
- package/dist/llm/openrouter.js +17 -1
- package/dist/llm/openrouter.js.map +1 -1
- package/dist/llm/providers/ollama.d.ts +7 -2
- package/dist/llm/providers/ollama.d.ts.map +1 -1
- package/dist/llm/providers/ollama.js +109 -17
- package/dist/llm/providers/ollama.js.map +1 -1
- package/dist/llm/providers/openrouter.js +1 -1
- package/dist/llm/providers/openrouter.js.map +1 -1
- package/dist/llm/sensitive-registry.d.ts +6 -0
- package/dist/llm/sensitive-registry.d.ts.map +1 -1
- package/dist/llm/sensitive-registry.js +60 -1
- package/dist/llm/sensitive-registry.js.map +1 -1
- package/dist/mcp-server.js +25 -18
- package/dist/mcp-server.js.map +1 -1
- package/dist/metrics/collector.d.ts +6 -0
- package/dist/metrics/collector.d.ts.map +1 -1
- package/dist/metrics/collector.js +150 -0
- package/dist/metrics/collector.js.map +1 -1
- package/dist/metrics/types.d.ts +1 -1
- package/dist/metrics/types.d.ts.map +1 -1
- package/dist/middleware/error-handler.d.ts +13 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +71 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/notifications/channels/adapter.d.ts +28 -0
- package/dist/notifications/channels/adapter.d.ts.map +1 -0
- package/dist/notifications/channels/adapter.js +55 -0
- package/dist/notifications/channels/adapter.js.map +1 -0
- package/dist/notifications/channels/index.d.ts +6 -0
- package/dist/notifications/channels/index.d.ts.map +1 -0
- package/dist/notifications/channels/index.js +6 -0
- package/dist/notifications/channels/index.js.map +1 -0
- package/dist/notifications/channels/log.d.ts +15 -0
- package/dist/notifications/channels/log.d.ts.map +1 -0
- package/dist/notifications/channels/log.js +29 -0
- package/dist/notifications/channels/log.js.map +1 -0
- package/dist/notifications/engine.d.ts +37 -0
- package/dist/notifications/engine.d.ts.map +1 -0
- package/dist/notifications/engine.js +198 -0
- package/dist/notifications/engine.js.map +1 -0
- package/dist/notifications/index.d.ts +12 -3
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +15 -3
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/types.d.ts +97 -0
- package/dist/notifications/types.d.ts.map +1 -0
- package/dist/notifications/types.js +14 -0
- package/dist/notifications/types.js.map +1 -0
- package/dist/onboarding/bootstrap.d.ts +51 -0
- package/dist/onboarding/bootstrap.d.ts.map +1 -0
- package/dist/onboarding/bootstrap.js +92 -0
- package/dist/onboarding/bootstrap.js.map +1 -0
- package/dist/onboarding/conversation.d.ts +131 -0
- package/dist/onboarding/conversation.d.ts.map +1 -0
- package/dist/onboarding/conversation.js +259 -0
- package/dist/onboarding/conversation.js.map +1 -0
- package/dist/onboarding/flow.d.ts +63 -0
- package/dist/onboarding/flow.d.ts.map +1 -0
- package/dist/onboarding/flow.js +287 -0
- package/dist/onboarding/flow.js.map +1 -0
- package/dist/onboarding/index.d.ts +17 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +23 -0
- package/dist/onboarding/index.js.map +1 -0
- package/dist/onboarding/name-extraction.d.ts +42 -0
- package/dist/onboarding/name-extraction.d.ts.map +1 -0
- package/dist/onboarding/name-extraction.js +164 -0
- package/dist/onboarding/name-extraction.js.map +1 -0
- package/dist/onboarding/nerve-link.d.ts +23 -0
- package/dist/onboarding/nerve-link.d.ts.map +1 -0
- package/dist/onboarding/nerve-link.js +24 -0
- package/dist/onboarding/nerve-link.js.map +1 -0
- package/dist/onboarding/phases.d.ts +66 -0
- package/dist/onboarding/phases.d.ts.map +1 -0
- package/dist/onboarding/phases.js +167 -0
- package/dist/onboarding/phases.js.map +1 -0
- package/dist/onboarding/safe-word.d.ts +39 -0
- package/dist/onboarding/safe-word.d.ts.map +1 -0
- package/dist/onboarding/safe-word.js +90 -0
- package/dist/onboarding/safe-word.js.map +1 -0
- package/dist/onboarding/types.d.ts +124 -0
- package/dist/onboarding/types.d.ts.map +1 -0
- package/dist/onboarding/types.js +46 -0
- package/dist/onboarding/types.js.map +1 -0
- package/dist/openloop/resolution-scanner.d.ts +1 -1
- package/dist/openloop/resolution-scanner.d.ts.map +1 -1
- package/dist/openloop/resolution-scanner.js +4 -14
- package/dist/openloop/resolution-scanner.js.map +1 -1
- package/dist/plugins/index.d.ts +24 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +91 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/status.d.ts +10 -0
- package/dist/plugins/status.d.ts.map +1 -0
- package/dist/plugins/status.js +12 -0
- package/dist/plugins/status.js.map +1 -0
- package/dist/posture/index.d.ts +2 -2
- package/dist/posture/index.d.ts.map +1 -1
- package/dist/posture/index.js +1 -1
- package/dist/posture/index.js.map +1 -1
- package/dist/posture/types.d.ts +34 -0
- package/dist/posture/types.d.ts.map +1 -1
- package/dist/posture/types.js +28 -0
- package/dist/posture/types.js.map +1 -1
- package/dist/pulse/activation-event.d.ts +5 -4
- package/dist/pulse/activation-event.d.ts.map +1 -1
- package/dist/pulse/activation-event.js +31 -8
- package/dist/pulse/activation-event.js.map +1 -1
- package/dist/pulse/activation-log.d.ts.map +1 -1
- package/dist/pulse/activation-log.js.map +1 -1
- package/dist/pulse/index.d.ts +3 -0
- package/dist/pulse/index.d.ts.map +1 -1
- package/dist/pulse/index.js +4 -0
- package/dist/pulse/index.js.map +1 -1
- package/dist/pulse/tier.d.ts +67 -0
- package/dist/pulse/tier.d.ts.map +1 -0
- package/dist/pulse/tier.js +104 -0
- package/dist/pulse/tier.js.map +1 -0
- package/dist/pulse/work.d.ts +66 -0
- package/dist/pulse/work.d.ts.map +1 -0
- package/dist/pulse/work.js +117 -0
- package/dist/pulse/work.js.map +1 -0
- package/dist/runtime-lock.d.ts +51 -0
- package/dist/runtime-lock.d.ts.map +1 -0
- package/dist/runtime-lock.js +147 -0
- package/dist/runtime-lock.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1244 -188
- package/dist/server.js.map +1 -1
- package/dist/services/whatsapp.js +1 -1
- package/dist/services/whatsapp.js.map +1 -1
- package/dist/settings.d.ts +15 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +48 -1
- package/dist/settings.js.map +1 -1
- package/dist/skills/index.d.ts +2 -2
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +2 -2
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/registry.d.ts +53 -142
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +249 -611
- package/dist/skills/registry.js.map +1 -1
- package/dist/stream/emitter.d.ts +36 -0
- package/dist/stream/emitter.d.ts.map +1 -0
- package/dist/stream/emitter.js +177 -0
- package/dist/stream/emitter.js.map +1 -0
- package/dist/stream/index.d.ts +4 -0
- package/dist/stream/index.d.ts.map +1 -0
- package/dist/stream/index.js +3 -0
- package/dist/stream/index.js.map +1 -0
- package/dist/stream/types.d.ts +100 -0
- package/dist/stream/types.d.ts.map +1 -0
- package/dist/stream/types.js +19 -0
- package/dist/stream/types.js.map +1 -0
- package/dist/threads/index.d.ts +3 -0
- package/dist/threads/index.d.ts.map +1 -0
- package/dist/threads/index.js +2 -0
- package/dist/threads/index.js.map +1 -0
- package/dist/threads/store.d.ts +36 -0
- package/dist/threads/store.d.ts.map +1 -0
- package/dist/threads/store.js +171 -0
- package/dist/threads/store.js.map +1 -0
- package/dist/threads/types.d.ts +16 -0
- package/dist/threads/types.d.ts.map +1 -0
- package/dist/threads/types.js +6 -0
- package/dist/threads/types.js.map +1 -0
- package/dist/tick/index.d.ts +10 -0
- package/dist/tick/index.d.ts.map +1 -0
- package/dist/tick/index.js +8 -0
- package/dist/tick/index.js.map +1 -0
- package/dist/tick/runner.d.ts +56 -0
- package/dist/tick/runner.d.ts.map +1 -0
- package/dist/tick/runner.js +235 -0
- package/dist/tick/runner.js.map +1 -0
- package/dist/tick/types.d.ts +73 -0
- package/dist/tick/types.d.ts.map +1 -0
- package/dist/tick/types.js +8 -0
- package/dist/tick/types.js.map +1 -0
- package/dist/tier/types.js +3 -3
- package/dist/tier/types.js.map +1 -1
- package/dist/ui-sync.d.ts +34 -0
- package/dist/ui-sync.d.ts.map +1 -0
- package/dist/ui-sync.js +108 -0
- package/dist/ui-sync.js.map +1 -0
- package/dist/utils/git.d.ts +12 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +44 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/volumes/index.d.ts +3 -0
- package/dist/volumes/index.d.ts.map +1 -0
- package/dist/volumes/index.js +2 -0
- package/dist/volumes/index.js.map +1 -0
- package/dist/volumes/manager.d.ts +83 -0
- package/dist/volumes/manager.d.ts.map +1 -0
- package/dist/volumes/manager.js +462 -0
- package/dist/volumes/manager.js.map +1 -0
- package/dist/volumes/types.d.ts +66 -0
- package/dist/volumes/types.d.ts.map +1 -0
- package/dist/volumes/types.js +8 -0
- package/dist/volumes/types.js.map +1 -0
- package/package.json +8 -5
- package/public/avatar/Hey-Dash_en_windows_v4_0_0.zip +0 -0
- package/public/avatar/README.md +43 -0
- package/public/avatar/cache/06fa55aececcc478.mp4 +0 -0
- package/public/avatar/cache/07a65738ba170827.mp4 +0 -0
- package/public/avatar/cache/08b6f4880f59a385.mp4 +0 -0
- package/public/avatar/cache/0ef9e0e78d715af4.mp4 +0 -0
- package/public/avatar/cache/0fa85e9e8f444a8b.mp4 +0 -0
- package/public/avatar/cache/1185fd491f413406.mp4 +0 -0
- package/public/avatar/cache/1b374d5390258fea.mp4 +0 -0
- package/public/avatar/cache/1e2367029b92f8aa.mp4 +0 -0
- package/public/avatar/cache/272c004a41087de5.mp4 +0 -0
- package/public/avatar/cache/2a0f3ff34d92521a.mp4 +0 -0
- package/public/avatar/cache/307a6f70859aeab8.mp4 +0 -0
- package/public/avatar/cache/332384e088ca214b.mp4 +0 -0
- package/public/avatar/cache/39fc4e81574d14ed.mp4 +0 -0
- package/public/avatar/cache/4a5c6051c1ef6a71.mp4 +0 -0
- package/public/avatar/cache/51f4aa76398c8c29.mp4 +0 -0
- package/public/avatar/cache/5d9a960bbf71732c.mp4 +0 -0
- package/public/avatar/cache/5e0954401e15af89.mp4 +0 -0
- package/public/avatar/cache/884ae6717fcacdd5.mp4 +0 -0
- package/public/avatar/cache/8ea0b7220d139615.mp4 +0 -0
- package/public/avatar/cache/9b9c4f7b8508eecc.mp4 +0 -0
- package/public/avatar/cache/9be1030ec2aa2b01.mp4 +0 -0
- package/public/avatar/cache/b35f7a3d558f22cb.mp4 +0 -0
- package/public/avatar/cache/be89f49970672374.mp4 +0 -0
- package/public/avatar/cache/c11fdc99479492b6.mp4 +0 -0
- package/public/avatar/cache/c900811e3382ac6d.mp4 +0 -0
- package/public/avatar/cache/d42a73667acf5716.mp4 +0 -0
- package/public/avatar/cache/e539f247a8908603.mp4 +0 -0
- package/public/avatar/cache/e78fceae2373b7c1.mp4 +0 -0
- package/public/avatar/cache/ec95af57d33b3f07.mp4 +0 -0
- package/public/avatar/cache/eeb8d775f40dbe2c.mp4 +0 -0
- package/public/avatar/dash_headhshot_v1.png +0 -0
- package/public/avatar/idle.mp4 +0 -0
- package/public/avatar/photo.png +0 -0
- package/public/board.html +6 -0
- package/public/browser.html +6 -2
- package/public/demo-data/Family Photos/2024/christmas-dinner.txt +13 -0
- package/public/demo-data/Family Photos/2025/summer-cookout.txt +13 -0
- package/public/demo-data/Financial/Insurance/auto-policy.txt +26 -0
- package/public/demo-data/Financial/Insurance/homeowners-policy.txt +20 -0
- package/public/demo-data/Financial/Taxes/property-tax-2025.txt +18 -0
- package/public/demo-data/Financial/Taxes/w2-2025.txt +18 -0
- package/public/demo-data/Health Records/lab-results-2026.txt +26 -0
- package/public/demo-data/Health Records/prescription-list.txt +24 -0
- package/public/demo-data/Health Records/vaccination-record.csv +8 -0
- package/public/demo-data/Legal/Estate/beneficiary-contacts.csv +4 -0
- package/public/demo-data/Legal/Estate/will-summary.txt +22 -0
- package/public/demo-data/Recipes/christmas-cookies.md +25 -0
- package/public/demo-data/Recipes/grandmas-chili.md +30 -0
- package/public/demo-data/Work/Contracts/lawn-service-2026.txt +23 -0
- package/public/demo-data/Work/Projects/project-status.md +19 -0
- package/public/demo-data/passwords.txt +13 -0
- package/public/demo-ingest.html +388 -0
- package/public/help.html +4 -1
- package/public/icon-192.png +0 -0
- package/public/icon-512.png +0 -0
- package/public/index.html +2641 -574
- package/public/library.html +51 -29
- package/public/manifest.json +21 -0
- package/public/nerve/icon-192.svg +6 -0
- package/public/nerve/icon-512.svg +6 -0
- package/public/nerve/index.html +698 -0
- package/public/nerve/manifest.json +24 -0
- package/public/nerve/sw.js +84 -0
- package/public/observatory.html +5 -1
- package/public/ops.html +33 -3
- package/public/pulse.html +3 -0
- package/public/registry.html +6 -2
- package/public/roadmap.html +7 -2
- package/public/sw.js +65 -0
- package/brain-template/registry.md +0 -566
- package/brain-template/rest_api-integration.md +0 -522
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart notification system types.
|
|
3
|
+
*
|
|
4
|
+
* Defines rule-based notification routing with priority,
|
|
5
|
+
* context awareness, and channel preferences.
|
|
6
|
+
*/
|
|
7
|
+
/** Notification priority levels, highest to lowest. */
|
|
8
|
+
export type NotificationPriority = "critical" | "high" | "normal" | "low";
|
|
9
|
+
/** Priority ordering for comparison. */
|
|
10
|
+
export declare const PRIORITY_ORDER: Record<NotificationPriority, number>;
|
|
11
|
+
/** Context available when evaluating notification rules. */
|
|
12
|
+
export interface NotificationContext {
|
|
13
|
+
/** Current gear: calm or crisis. */
|
|
14
|
+
gear: "calm" | "crisis";
|
|
15
|
+
/** ISO timestamp of the event. */
|
|
16
|
+
timestamp: string;
|
|
17
|
+
/** Source system that produced the event (e.g., "health", "board", "agent"). */
|
|
18
|
+
source: string;
|
|
19
|
+
/** Event type identifier (e.g., "alert.fired", "task.completed", "agent.error"). */
|
|
20
|
+
eventType: string;
|
|
21
|
+
/** Arbitrary event payload — shape depends on source/eventType. */
|
|
22
|
+
payload: Record<string, unknown>;
|
|
23
|
+
/** Tags for rule matching (e.g., ["ops", "memory", "critical"]). */
|
|
24
|
+
tags: string[];
|
|
25
|
+
/** Optional user/agent ID this event is associated with. */
|
|
26
|
+
actor?: string;
|
|
27
|
+
}
|
|
28
|
+
/** A single condition within a rule. All conditions in a rule must match (AND). */
|
|
29
|
+
export interface RuleCondition {
|
|
30
|
+
/** The field path to evaluate (dot notation into NotificationContext). */
|
|
31
|
+
field: string;
|
|
32
|
+
/** Comparison operator. */
|
|
33
|
+
operator: "eq" | "neq" | "in" | "not_in" | "contains" | "gt" | "lt" | "exists";
|
|
34
|
+
/** Value to compare against. Type depends on operator. */
|
|
35
|
+
value: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** Delivery preferences when a rule matches. */
|
|
38
|
+
export interface RuleAction {
|
|
39
|
+
/** Which channels to deliver through. Empty = use defaults. */
|
|
40
|
+
channels: string[];
|
|
41
|
+
/** Priority override. If omitted, derived from context. */
|
|
42
|
+
priority?: NotificationPriority;
|
|
43
|
+
/** Minimum seconds between repeat notifications for the same rule+source. */
|
|
44
|
+
cooldownSeconds?: number;
|
|
45
|
+
/** Whether to aggregate similar notifications. */
|
|
46
|
+
aggregate?: boolean;
|
|
47
|
+
/** Template name for message formatting. */
|
|
48
|
+
template?: string;
|
|
49
|
+
}
|
|
50
|
+
/** A notification rule: when conditions match, perform the action. */
|
|
51
|
+
export interface NotificationRule {
|
|
52
|
+
/** Unique rule identifier. */
|
|
53
|
+
id: string;
|
|
54
|
+
/** Human-readable name. */
|
|
55
|
+
name: string;
|
|
56
|
+
/** Whether this rule is active. */
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
/** Conditions that must ALL match for this rule to fire (AND logic). */
|
|
59
|
+
conditions: RuleCondition[];
|
|
60
|
+
/** What to do when the rule matches. */
|
|
61
|
+
action: RuleAction;
|
|
62
|
+
/** Higher weight rules are evaluated first and can short-circuit. */
|
|
63
|
+
weight: number;
|
|
64
|
+
/** Optional: stop evaluating further rules if this one matches. */
|
|
65
|
+
terminal?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** Result of evaluating a single rule against a context. */
|
|
68
|
+
export interface RuleMatch {
|
|
69
|
+
rule: NotificationRule;
|
|
70
|
+
/** Whether all conditions passed. */
|
|
71
|
+
matched: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Result of the full engine evaluation. */
|
|
74
|
+
export interface EvaluationResult {
|
|
75
|
+
/** The context that was evaluated. */
|
|
76
|
+
context: NotificationContext;
|
|
77
|
+
/** Rules that matched, in evaluation order. */
|
|
78
|
+
matchedRules: NotificationRule[];
|
|
79
|
+
/** Resolved priority (highest from matched rules, or derived from context). */
|
|
80
|
+
priority: NotificationPriority;
|
|
81
|
+
/** Channels to deliver to (union of all matched rule channels, deduplicated). */
|
|
82
|
+
channels: string[];
|
|
83
|
+
/** Whether delivery should proceed (false if all rules were suppressed by cooldown). */
|
|
84
|
+
shouldDeliver: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** Extended channel interface for smart notifications. */
|
|
87
|
+
export interface SmartChannel {
|
|
88
|
+
/** Channel identifier. */
|
|
89
|
+
name: string;
|
|
90
|
+
/** Whether this channel is enabled. */
|
|
91
|
+
enabled: boolean;
|
|
92
|
+
/** Minimum priority this channel accepts. Messages below are dropped. */
|
|
93
|
+
minPriority: NotificationPriority;
|
|
94
|
+
/** Send a notification. Returns true on success. */
|
|
95
|
+
send(context: NotificationContext, priority: NotificationPriority): Promise<boolean>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE1E,wCAAwC;AACxC,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAK/D,CAAC;AAIF,4DAA4D;AAC5D,MAAM,WAAW,mBAAmB;IAClC,oCAAoC;IACpC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,oEAAoE;IACpE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID,mFAAmF;AACnF,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,QAAQ,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,QAAQ,CAAC;IAC/E,0DAA0D;IAC1D,KAAK,EAAE,OAAO,CAAC;CAChB;AAID,gDAAgD;AAChD,MAAM,WAAW,UAA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CAAC;IAClC,oDAAoD;IACpD,IAAI,CAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart notification system types.
|
|
3
|
+
*
|
|
4
|
+
* Defines rule-based notification routing with priority,
|
|
5
|
+
* context awareness, and channel preferences.
|
|
6
|
+
*/
|
|
7
|
+
/** Priority ordering for comparison. */
|
|
8
|
+
export const PRIORITY_ORDER = {
|
|
9
|
+
critical: 4,
|
|
10
|
+
high: 3,
|
|
11
|
+
normal: 2,
|
|
12
|
+
low: 1,
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,wCAAwC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAyC;IAClE,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;CACP,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Bootstrap — initializes the brain after onboarding.
|
|
3
|
+
*
|
|
4
|
+
* Creates the human identity, ensures brain directories exist,
|
|
5
|
+
* assigns the Founder archetype, and initializes pulse dots at zero.
|
|
6
|
+
* This is the automatic phase — no user input required.
|
|
7
|
+
*
|
|
8
|
+
* Portable: identity pairing is injectable via IdentityPairer interface
|
|
9
|
+
* instead of importing a specific auth/identity module.
|
|
10
|
+
*/
|
|
11
|
+
import type { BootstrapResult } from "./types.js";
|
|
12
|
+
/** Result of a successful identity pairing. */
|
|
13
|
+
export interface PairResult {
|
|
14
|
+
session: {
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interface for identity pairing during bootstrap.
|
|
20
|
+
* Inject an implementation that wraps your auth/identity.pair function.
|
|
21
|
+
*/
|
|
22
|
+
export interface IdentityPairer {
|
|
23
|
+
pair(input: {
|
|
24
|
+
code: string;
|
|
25
|
+
name: string;
|
|
26
|
+
safeWord: string;
|
|
27
|
+
skipCodeCheck: boolean;
|
|
28
|
+
recoveryQuestion?: string;
|
|
29
|
+
recoveryAnswer?: string;
|
|
30
|
+
}): Promise<PairResult | {
|
|
31
|
+
error: string;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export interface BootstrapInput {
|
|
35
|
+
name: string;
|
|
36
|
+
safeWord: string;
|
|
37
|
+
pairingCode?: string | null;
|
|
38
|
+
recoveryQuestion?: string | null;
|
|
39
|
+
recoveryAnswer?: string | null;
|
|
40
|
+
identityPairer?: IdentityPairer;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Bootstrap the agent after onboarding conversation completes.
|
|
44
|
+
*
|
|
45
|
+
* 1. Ensures brain directory structure exists
|
|
46
|
+
* 2. Creates human identity (via identity pairer if provided)
|
|
47
|
+
* 3. Reads calibration results (already saved by CalibrationRunner)
|
|
48
|
+
* 4. Returns the bootstrap result with archetype, thresholds, and pulse dots
|
|
49
|
+
*/
|
|
50
|
+
export declare function bootstrapAgent(input: BootstrapInput): Promise<BootstrapResult>;
|
|
51
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/onboarding/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAsBlD,+CAA+C;AAC/C,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,KAAK,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,OAAO,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,UAAU,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7C;AAID,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAyDpF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Bootstrap — initializes the brain after onboarding.
|
|
3
|
+
*
|
|
4
|
+
* Creates the human identity, ensures brain directories exist,
|
|
5
|
+
* assigns the Founder archetype, and initializes pulse dots at zero.
|
|
6
|
+
* This is the automatic phase — no user input required.
|
|
7
|
+
*
|
|
8
|
+
* Portable: identity pairing is injectable via IdentityPairer interface
|
|
9
|
+
* instead of importing a specific auth/identity module.
|
|
10
|
+
*/
|
|
11
|
+
import { mkdir } from "node:fs/promises";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { BRAIN_DIR } from "../lib/paths.js";
|
|
14
|
+
import { getCurrentCalibration } from "../calibration/store.js";
|
|
15
|
+
import { DEFAULT_THRESHOLDS, DEFAULT_DOT_THRESHOLDS } from "../calibration/types.js";
|
|
16
|
+
import { createLogger } from "../utils/logger.js";
|
|
17
|
+
import { INITIAL_PULSE_DOTS } from "./types.js";
|
|
18
|
+
const log = createLogger("onboarding:bootstrap");
|
|
19
|
+
// ── Brain directory structure ──────────────────────────────────────────────
|
|
20
|
+
/** Directories that must exist for a functioning brain. */
|
|
21
|
+
const REQUIRED_DIRS = [
|
|
22
|
+
"identity",
|
|
23
|
+
"memory",
|
|
24
|
+
"content",
|
|
25
|
+
"operations",
|
|
26
|
+
"knowledge",
|
|
27
|
+
"calibration",
|
|
28
|
+
"vault",
|
|
29
|
+
"agents",
|
|
30
|
+
"bonds",
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Bootstrap the agent after onboarding conversation completes.
|
|
34
|
+
*
|
|
35
|
+
* 1. Ensures brain directory structure exists
|
|
36
|
+
* 2. Creates human identity (via identity pairer if provided)
|
|
37
|
+
* 3. Reads calibration results (already saved by CalibrationRunner)
|
|
38
|
+
* 4. Returns the bootstrap result with archetype, thresholds, and pulse dots
|
|
39
|
+
*/
|
|
40
|
+
export async function bootstrapAgent(input) {
|
|
41
|
+
log.info("Starting agent bootstrap", { name: input.name });
|
|
42
|
+
// 1. Ensure brain directories
|
|
43
|
+
const createdDirs = [];
|
|
44
|
+
for (const dir of REQUIRED_DIRS) {
|
|
45
|
+
const fullPath = join(BRAIN_DIR, dir);
|
|
46
|
+
try {
|
|
47
|
+
await mkdir(fullPath, { recursive: true });
|
|
48
|
+
createdDirs.push(dir);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Directory already exists
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
log.info("Brain directories ensured", { count: createdDirs.length });
|
|
55
|
+
// 2. Create human identity via pairing (if pairer provided)
|
|
56
|
+
if (input.identityPairer) {
|
|
57
|
+
const pairResult = await input.identityPairer.pair({
|
|
58
|
+
code: input.pairingCode ?? "",
|
|
59
|
+
name: input.name,
|
|
60
|
+
safeWord: input.safeWord,
|
|
61
|
+
skipCodeCheck: !input.pairingCode,
|
|
62
|
+
recoveryQuestion: input.recoveryQuestion ?? undefined,
|
|
63
|
+
recoveryAnswer: input.recoveryAnswer ?? undefined,
|
|
64
|
+
});
|
|
65
|
+
if ("error" in pairResult) {
|
|
66
|
+
log.error("Pairing failed during bootstrap", { error: pairResult.error });
|
|
67
|
+
throw new Error(`Bootstrap pairing failed: ${pairResult.error}`);
|
|
68
|
+
}
|
|
69
|
+
log.info("Human identity created", { name: input.name, sessionId: pairResult.session.id });
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
log.info("No identity pairer provided — skipping pairing step");
|
|
73
|
+
}
|
|
74
|
+
// 3. Read calibration results (saved by CalibrationRunner during calibration phase)
|
|
75
|
+
const calibration = await getCurrentCalibration();
|
|
76
|
+
const thresholds = calibration?.thresholds ?? DEFAULT_THRESHOLDS;
|
|
77
|
+
const dotThresholds = calibration?.derived ?? DEFAULT_DOT_THRESHOLDS;
|
|
78
|
+
// 4. Build result
|
|
79
|
+
const result = {
|
|
80
|
+
archetype: "founder",
|
|
81
|
+
thresholds,
|
|
82
|
+
dotThresholds,
|
|
83
|
+
brainDirs: REQUIRED_DIRS.map(d => join(BRAIN_DIR, d)),
|
|
84
|
+
pulseDots: INITIAL_PULSE_DOTS,
|
|
85
|
+
};
|
|
86
|
+
log.info("Agent bootstrap complete", {
|
|
87
|
+
archetype: result.archetype,
|
|
88
|
+
calibrated: !!calibration,
|
|
89
|
+
});
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/onboarding/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,i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E,MAAM,CAAC,SAAS;QAC3B,UAAU,EAAE,CAAC,CAAC,WAAW;KAC1B,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding Conversation — core conversational state machine.
|
|
3
|
+
*
|
|
4
|
+
* Manages the lower-level conversation mechanics:
|
|
5
|
+
* - Message logging (agent + human with timestamps)
|
|
6
|
+
* - Name extraction from free-text input
|
|
7
|
+
* - Safe word creation sub-flow (validate → confirm → strength feedback)
|
|
8
|
+
* - Strict forward-only phase transitions
|
|
9
|
+
* - Event emission for phase transitions and milestones
|
|
10
|
+
* - State query methods
|
|
11
|
+
*
|
|
12
|
+
* This is the composable engine that OnboardingFlow orchestrates.
|
|
13
|
+
*/
|
|
14
|
+
import { type OnboardingState, type OnboardingPhase, type OnboardingMessage, type OnboardingListener } from "./types.js";
|
|
15
|
+
import { type SafeWordStrength } from "./safe-word.js";
|
|
16
|
+
/**
|
|
17
|
+
* Extract a name from free-text input.
|
|
18
|
+
* Thin wrapper for backward compatibility — returns just the string.
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractName(input: string): string;
|
|
21
|
+
export type SafeWordStep = "ask" | "confirm";
|
|
22
|
+
export type RecoveryQuestionStep = "ask_question" | "ask_answer" | "confirm_answer";
|
|
23
|
+
export interface SafeWordResult {
|
|
24
|
+
confirmed: boolean;
|
|
25
|
+
strength?: SafeWordStrength;
|
|
26
|
+
strengthMsg?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class OnboardingConversation {
|
|
29
|
+
private state;
|
|
30
|
+
private messages;
|
|
31
|
+
private listeners;
|
|
32
|
+
/** Safe word sub-flow tracking */
|
|
33
|
+
private safeWordStep;
|
|
34
|
+
private pendingSafeWord;
|
|
35
|
+
/** Recovery question sub-flow tracking */
|
|
36
|
+
private recoveryStep;
|
|
37
|
+
private pendingRecoveryQuestion;
|
|
38
|
+
private pendingRecoveryAnswer;
|
|
39
|
+
constructor(initialState?: OnboardingState);
|
|
40
|
+
/** Register a listener for onboarding events. */
|
|
41
|
+
onEvent(listener: OnboardingListener): void;
|
|
42
|
+
/** Remove a listener. */
|
|
43
|
+
offEvent(listener: OnboardingListener): void;
|
|
44
|
+
private emit;
|
|
45
|
+
/** Log an agent message and return the content (for chaining). */
|
|
46
|
+
logAgent(content: string): string;
|
|
47
|
+
/** Log a human message. */
|
|
48
|
+
logHuman(content: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Advance to a target phase. Throws if the target is not strictly
|
|
51
|
+
* ahead of the current phase in PHASE_ORDER.
|
|
52
|
+
*/
|
|
53
|
+
advanceTo(target: OnboardingPhase): void;
|
|
54
|
+
/**
|
|
55
|
+
* Handle a greeting response. Extracts the name and emits name_captured.
|
|
56
|
+
* Returns the extracted name, or null if input was empty.
|
|
57
|
+
*/
|
|
58
|
+
handleGreeting(input: string): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Process a safe word input. Manages the ask → confirm sub-flow.
|
|
61
|
+
*/
|
|
62
|
+
handleSafeWord(input: string): SafeWordResponse;
|
|
63
|
+
/** Get the pending (unconfirmed) safe word, if in confirm step. */
|
|
64
|
+
getPendingSafeWord(): string | null;
|
|
65
|
+
/** Get the current safe word sub-step. */
|
|
66
|
+
getSafeWordStep(): SafeWordStep;
|
|
67
|
+
/**
|
|
68
|
+
* Process a recovery question input. Manages the ask_question → ask_answer → confirm_answer sub-flow.
|
|
69
|
+
*/
|
|
70
|
+
handleRecoveryQuestion(input: string): RecoveryQuestionResponse;
|
|
71
|
+
/** Get the pending recovery question. */
|
|
72
|
+
getPendingRecoveryQuestion(): string | null;
|
|
73
|
+
/** Get the pending recovery answer. */
|
|
74
|
+
getPendingRecoveryAnswer(): string | null;
|
|
75
|
+
/** Get the current recovery question sub-step. */
|
|
76
|
+
getRecoveryStep(): RecoveryQuestionStep;
|
|
77
|
+
/** Mark calibration as complete on the state. */
|
|
78
|
+
markCalibrated(): void;
|
|
79
|
+
/** Mark bootstrap as complete on the state. */
|
|
80
|
+
markBootstrapped(): void;
|
|
81
|
+
/** Mark nerve link as offered. */
|
|
82
|
+
markNerveLinkOffered(): void;
|
|
83
|
+
/** Mark nerve link as completed. */
|
|
84
|
+
markNerveLinkCompleted(): void;
|
|
85
|
+
/** Mark onboarding as complete. Sets completedAt and emits event. */
|
|
86
|
+
markComplete(): void;
|
|
87
|
+
/** Set the human's name directly (e.g., if corrected later). */
|
|
88
|
+
setName(name: string): void;
|
|
89
|
+
/** Get a snapshot of the current onboarding state. */
|
|
90
|
+
getState(): OnboardingState;
|
|
91
|
+
/** Get all conversation messages (agent + human). */
|
|
92
|
+
getMessages(): OnboardingMessage[];
|
|
93
|
+
/** Whether onboarding has reached the complete phase. */
|
|
94
|
+
isComplete(): boolean;
|
|
95
|
+
/** The current phase. */
|
|
96
|
+
currentPhase(): OnboardingPhase;
|
|
97
|
+
/** The human's name, if captured. */
|
|
98
|
+
getName(): string | null;
|
|
99
|
+
/** Total number of messages in the conversation. */
|
|
100
|
+
messageCount(): number;
|
|
101
|
+
}
|
|
102
|
+
export type SafeWordResponse = {
|
|
103
|
+
type: "invalid";
|
|
104
|
+
reason: string;
|
|
105
|
+
} | {
|
|
106
|
+
type: "needs_confirm";
|
|
107
|
+
} | {
|
|
108
|
+
type: "mismatch";
|
|
109
|
+
} | {
|
|
110
|
+
type: "confirmed";
|
|
111
|
+
strength: SafeWordStrength;
|
|
112
|
+
strengthMsg: string;
|
|
113
|
+
};
|
|
114
|
+
export type RecoveryQuestionResponse = {
|
|
115
|
+
type: "skipped";
|
|
116
|
+
} | {
|
|
117
|
+
type: "too_short";
|
|
118
|
+
} | {
|
|
119
|
+
type: "needs_answer";
|
|
120
|
+
question: string;
|
|
121
|
+
} | {
|
|
122
|
+
type: "empty_answer";
|
|
123
|
+
} | {
|
|
124
|
+
type: "needs_confirm";
|
|
125
|
+
} | {
|
|
126
|
+
type: "mismatch";
|
|
127
|
+
} | {
|
|
128
|
+
type: "confirmed";
|
|
129
|
+
question: string;
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/onboarding/conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EAGxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAQxB;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjD;AAID,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,SAAS,CAAC;AAC7C,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAEpF,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAID,qBAAa,sBAAsB;IACjC,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,SAAS,CAA4B;IAE7C,kCAAkC;IAClC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,eAAe,CAAuB;IAE9C,0CAA0C;IAC1C,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,uBAAuB,CAAuB;IACtD,OAAO,CAAC,qBAAqB,CAAuB;gBAExC,YAAY,CAAC,EAAE,eAAe;IAM1C,iDAAiD;IACjD,OAAO,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAI3C,yBAAyB;IACzB,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAI5C,OAAO,CAAC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I,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,wBAAwB,GAChC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding Conversation — core conversational state machine.
|
|
3
|
+
*
|
|
4
|
+
* Manages the lower-level conversation mechanics:
|
|
5
|
+
* - Message logging (agent + human with timestamps)
|
|
6
|
+
* - Name extraction from free-text input
|
|
7
|
+
* - Safe word creation sub-flow (validate → confirm → strength feedback)
|
|
8
|
+
* - Strict forward-only phase transitions
|
|
9
|
+
* - Event emission for phase transitions and milestones
|
|
10
|
+
* - State query methods
|
|
11
|
+
*
|
|
12
|
+
* This is the composable engine that OnboardingFlow orchestrates.
|
|
13
|
+
*/
|
|
14
|
+
import { PHASE_ORDER, createInitialState, } from "./types.js";
|
|
15
|
+
import { validateSafeWord, safeWordsMatch, assessStrength, strengthMessage, } from "./safe-word.js";
|
|
16
|
+
import { extractName as extractNameFull, } from "./name-extraction.js";
|
|
17
|
+
// ── Name extraction (delegates to name-extraction module) ────────────────────
|
|
18
|
+
/**
|
|
19
|
+
* Extract a name from free-text input.
|
|
20
|
+
* Thin wrapper for backward compatibility — returns just the string.
|
|
21
|
+
*/
|
|
22
|
+
export function extractName(input) {
|
|
23
|
+
const result = extractNameFull(input);
|
|
24
|
+
return result.name ?? input.trim();
|
|
25
|
+
}
|
|
26
|
+
// ── Conversation engine ─────────────────────────────────────────────────────
|
|
27
|
+
export class OnboardingConversation {
|
|
28
|
+
state;
|
|
29
|
+
messages = [];
|
|
30
|
+
listeners = [];
|
|
31
|
+
/** Safe word sub-flow tracking */
|
|
32
|
+
safeWordStep = "ask";
|
|
33
|
+
pendingSafeWord = null;
|
|
34
|
+
/** Recovery question sub-flow tracking */
|
|
35
|
+
recoveryStep = "ask_question";
|
|
36
|
+
pendingRecoveryQuestion = null;
|
|
37
|
+
pendingRecoveryAnswer = null;
|
|
38
|
+
constructor(initialState) {
|
|
39
|
+
this.state = initialState ?? createInitialState();
|
|
40
|
+
}
|
|
41
|
+
// ── Event system ────────────────────────────────────────────────────────
|
|
42
|
+
/** Register a listener for onboarding events. */
|
|
43
|
+
onEvent(listener) {
|
|
44
|
+
this.listeners.push(listener);
|
|
45
|
+
}
|
|
46
|
+
/** Remove a listener. */
|
|
47
|
+
offEvent(listener) {
|
|
48
|
+
this.listeners = this.listeners.filter(l => l !== listener);
|
|
49
|
+
}
|
|
50
|
+
emit(event) {
|
|
51
|
+
for (const listener of this.listeners) {
|
|
52
|
+
listener(event);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// ── Message logging ─────────────────────────────────────────────────────
|
|
56
|
+
/** Log an agent message and return the content (for chaining). */
|
|
57
|
+
logAgent(content) {
|
|
58
|
+
this.messages.push({
|
|
59
|
+
role: "agent",
|
|
60
|
+
content,
|
|
61
|
+
phase: this.state.phase,
|
|
62
|
+
ts: new Date().toISOString(),
|
|
63
|
+
});
|
|
64
|
+
return content;
|
|
65
|
+
}
|
|
66
|
+
/** Log a human message. */
|
|
67
|
+
logHuman(content) {
|
|
68
|
+
this.messages.push({
|
|
69
|
+
role: "human",
|
|
70
|
+
content,
|
|
71
|
+
phase: this.state.phase,
|
|
72
|
+
ts: new Date().toISOString(),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// ── Phase transitions (strict forward-only) ────────────────────────────
|
|
76
|
+
/**
|
|
77
|
+
* Advance to a target phase. Throws if the target is not strictly
|
|
78
|
+
* ahead of the current phase in PHASE_ORDER.
|
|
79
|
+
*/
|
|
80
|
+
advanceTo(target) {
|
|
81
|
+
const currentIdx = PHASE_ORDER.indexOf(this.state.phase);
|
|
82
|
+
const targetIdx = PHASE_ORDER.indexOf(target);
|
|
83
|
+
if (targetIdx < 0) {
|
|
84
|
+
throw new Error(`Unknown phase: ${target}`);
|
|
85
|
+
}
|
|
86
|
+
if (targetIdx <= currentIdx) {
|
|
87
|
+
throw new Error(`Cannot move from "${this.state.phase}" to "${target}" — phases only advance forward.`);
|
|
88
|
+
}
|
|
89
|
+
this.state.phase = target;
|
|
90
|
+
this.emit({ type: "phase_entered", phase: target });
|
|
91
|
+
}
|
|
92
|
+
// ── Greeting phase ─────────────────────────────────────────────────────
|
|
93
|
+
/**
|
|
94
|
+
* Handle a greeting response. Extracts the name and emits name_captured.
|
|
95
|
+
* Returns the extracted name, or null if input was empty.
|
|
96
|
+
*/
|
|
97
|
+
handleGreeting(input) {
|
|
98
|
+
const trimmed = input.trim();
|
|
99
|
+
if (!trimmed)
|
|
100
|
+
return null;
|
|
101
|
+
const name = extractName(trimmed);
|
|
102
|
+
this.state.name = name;
|
|
103
|
+
this.emit({ type: "name_captured", name });
|
|
104
|
+
return name;
|
|
105
|
+
}
|
|
106
|
+
// ── Safe word phase ────────────────────────────────────────────────────
|
|
107
|
+
/**
|
|
108
|
+
* Process a safe word input. Manages the ask → confirm sub-flow.
|
|
109
|
+
*/
|
|
110
|
+
handleSafeWord(input) {
|
|
111
|
+
if (this.safeWordStep === "ask") {
|
|
112
|
+
const validation = validateSafeWord(input);
|
|
113
|
+
if (!validation.valid) {
|
|
114
|
+
return { type: "invalid", reason: validation.reason };
|
|
115
|
+
}
|
|
116
|
+
this.pendingSafeWord = input;
|
|
117
|
+
this.safeWordStep = "confirm";
|
|
118
|
+
return { type: "needs_confirm" };
|
|
119
|
+
}
|
|
120
|
+
// Confirm step
|
|
121
|
+
if (!this.pendingSafeWord || !safeWordsMatch(this.pendingSafeWord, input)) {
|
|
122
|
+
this.pendingSafeWord = null;
|
|
123
|
+
this.safeWordStep = "ask";
|
|
124
|
+
return { type: "mismatch" };
|
|
125
|
+
}
|
|
126
|
+
// Confirmed
|
|
127
|
+
const strength = assessStrength(this.pendingSafeWord);
|
|
128
|
+
this.state.safeWordConfirmed = true;
|
|
129
|
+
this.emit({ type: "safe_word_created" });
|
|
130
|
+
const result = {
|
|
131
|
+
type: "confirmed",
|
|
132
|
+
strength,
|
|
133
|
+
strengthMsg: strengthMessage(strength),
|
|
134
|
+
};
|
|
135
|
+
// Reset sub-flow state
|
|
136
|
+
this.pendingSafeWord = null;
|
|
137
|
+
this.safeWordStep = "ask";
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
/** Get the pending (unconfirmed) safe word, if in confirm step. */
|
|
141
|
+
getPendingSafeWord() {
|
|
142
|
+
return this.pendingSafeWord;
|
|
143
|
+
}
|
|
144
|
+
/** Get the current safe word sub-step. */
|
|
145
|
+
getSafeWordStep() {
|
|
146
|
+
return this.safeWordStep;
|
|
147
|
+
}
|
|
148
|
+
// ── Recovery question phase ─────────────────────────────────────────────
|
|
149
|
+
/**
|
|
150
|
+
* Process a recovery question input. Manages the ask_question → ask_answer → confirm_answer sub-flow.
|
|
151
|
+
*/
|
|
152
|
+
handleRecoveryQuestion(input) {
|
|
153
|
+
const lower = input.toLowerCase();
|
|
154
|
+
if (lower === "skip" || lower === "skip it" || lower === "later") {
|
|
155
|
+
this.emit({ type: "recovery_question_skipped" });
|
|
156
|
+
return { type: "skipped" };
|
|
157
|
+
}
|
|
158
|
+
switch (this.recoveryStep) {
|
|
159
|
+
case "ask_question": {
|
|
160
|
+
if (!input || input.length < 3) {
|
|
161
|
+
return { type: "too_short" };
|
|
162
|
+
}
|
|
163
|
+
this.pendingRecoveryQuestion = input;
|
|
164
|
+
this.recoveryStep = "ask_answer";
|
|
165
|
+
return { type: "needs_answer", question: input };
|
|
166
|
+
}
|
|
167
|
+
case "ask_answer": {
|
|
168
|
+
if (!input || input.length < 1) {
|
|
169
|
+
return { type: "empty_answer" };
|
|
170
|
+
}
|
|
171
|
+
this.pendingRecoveryAnswer = input;
|
|
172
|
+
this.recoveryStep = "confirm_answer";
|
|
173
|
+
return { type: "needs_confirm" };
|
|
174
|
+
}
|
|
175
|
+
case "confirm_answer": {
|
|
176
|
+
if (!this.pendingRecoveryAnswer || input.trim().toLowerCase() !== this.pendingRecoveryAnswer.trim().toLowerCase()) {
|
|
177
|
+
this.pendingRecoveryAnswer = null;
|
|
178
|
+
this.recoveryStep = "ask_answer";
|
|
179
|
+
return { type: "mismatch" };
|
|
180
|
+
}
|
|
181
|
+
// Confirmed
|
|
182
|
+
this.state.recoveryQuestionSet = true;
|
|
183
|
+
this.emit({ type: "recovery_question_set" });
|
|
184
|
+
const question = this.pendingRecoveryQuestion;
|
|
185
|
+
// Reset sub-flow state
|
|
186
|
+
this.recoveryStep = "ask_question";
|
|
187
|
+
return { type: "confirmed", question };
|
|
188
|
+
}
|
|
189
|
+
default:
|
|
190
|
+
return { type: "skipped" };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Get the pending recovery question. */
|
|
194
|
+
getPendingRecoveryQuestion() {
|
|
195
|
+
return this.pendingRecoveryQuestion;
|
|
196
|
+
}
|
|
197
|
+
/** Get the pending recovery answer. */
|
|
198
|
+
getPendingRecoveryAnswer() {
|
|
199
|
+
return this.pendingRecoveryAnswer;
|
|
200
|
+
}
|
|
201
|
+
/** Get the current recovery question sub-step. */
|
|
202
|
+
getRecoveryStep() {
|
|
203
|
+
return this.recoveryStep;
|
|
204
|
+
}
|
|
205
|
+
// ── State mutation helpers ──────────────────────────────────────────────
|
|
206
|
+
/** Mark calibration as complete on the state. */
|
|
207
|
+
markCalibrated() {
|
|
208
|
+
this.state.calibrated = true;
|
|
209
|
+
this.emit({ type: "calibration_completed" });
|
|
210
|
+
}
|
|
211
|
+
/** Mark bootstrap as complete on the state. */
|
|
212
|
+
markBootstrapped() {
|
|
213
|
+
this.state.bootstrapped = true;
|
|
214
|
+
}
|
|
215
|
+
/** Mark nerve link as offered. */
|
|
216
|
+
markNerveLinkOffered() {
|
|
217
|
+
this.state.nerveLinkOffered = true;
|
|
218
|
+
}
|
|
219
|
+
/** Mark nerve link as completed. */
|
|
220
|
+
markNerveLinkCompleted() {
|
|
221
|
+
this.state.nerveLinkCompleted = true;
|
|
222
|
+
}
|
|
223
|
+
/** Mark onboarding as complete. Sets completedAt and emits event. */
|
|
224
|
+
markComplete() {
|
|
225
|
+
this.state.completedAt = new Date().toISOString();
|
|
226
|
+
const durationMs = Date.now() - new Date(this.state.startedAt).getTime();
|
|
227
|
+
this.emit({ type: "onboarding_completed", durationMs });
|
|
228
|
+
}
|
|
229
|
+
/** Set the human's name directly (e.g., if corrected later). */
|
|
230
|
+
setName(name) {
|
|
231
|
+
this.state.name = name;
|
|
232
|
+
}
|
|
233
|
+
// ── State queries ───────────────────────────────────────────────────────
|
|
234
|
+
/** Get a snapshot of the current onboarding state. */
|
|
235
|
+
getState() {
|
|
236
|
+
return { ...this.state };
|
|
237
|
+
}
|
|
238
|
+
/** Get all conversation messages (agent + human). */
|
|
239
|
+
getMessages() {
|
|
240
|
+
return [...this.messages];
|
|
241
|
+
}
|
|
242
|
+
/** Whether onboarding has reached the complete phase. */
|
|
243
|
+
isComplete() {
|
|
244
|
+
return this.state.phase === "complete";
|
|
245
|
+
}
|
|
246
|
+
/** The current phase. */
|
|
247
|
+
currentPhase() {
|
|
248
|
+
return this.state.phase;
|
|
249
|
+
}
|
|
250
|
+
/** The human's name, if captured. */
|
|
251
|
+
getName() {
|
|
252
|
+
return this.state.name;
|
|
253
|
+
}
|
|
254
|
+
/** Total number of messages in the conversation. */
|
|
255
|
+
messageCount() {
|
|
256
|
+
return this.messages.length;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=conversation.js.map
|