rookery-agent 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 +3 -3
- package/docs/updates.md +12 -0
- package/package.json +1 -1
- package/packages/cli/dist/commands/chat.d.ts.map +1 -1
- package/packages/cli/dist/commands/chat.js +37 -74
- package/packages/cli/dist/commands/chat.js.map +1 -1
- package/packages/cli/dist/commands/config.js +4 -4
- package/packages/cli/dist/commands/config.js.map +1 -1
- package/packages/cli/dist/commands/doctor.d.ts.map +1 -1
- package/packages/cli/dist/commands/doctor.js +113 -91
- package/packages/cli/dist/commands/doctor.js.map +1 -1
- package/packages/cli/dist/commands/memory.d.ts.map +1 -1
- package/packages/cli/dist/commands/memory.js +28 -31
- package/packages/cli/dist/commands/memory.js.map +1 -1
- package/packages/cli/dist/commands/org.d.ts.map +1 -1
- package/packages/cli/dist/commands/org.js +36 -103
- package/packages/cli/dist/commands/org.js.map +1 -1
- package/packages/cli/dist/commands/serve.d.ts.map +1 -1
- package/packages/cli/dist/commands/serve.js +8 -6
- package/packages/cli/dist/commands/serve.js.map +1 -1
- package/packages/cli/dist/commands/sessions.d.ts.map +1 -1
- package/packages/cli/dist/commands/sessions.js +18 -17
- package/packages/cli/dist/commands/sessions.js.map +1 -1
- package/packages/cli/dist/commands/shared.d.ts +26 -5
- package/packages/cli/dist/commands/shared.d.ts.map +1 -1
- package/packages/cli/dist/commands/shared.js +85 -63
- package/packages/cli/dist/commands/shared.js.map +1 -1
- package/packages/cli/dist/commands/slash.d.ts +51 -0
- package/packages/cli/dist/commands/slash.d.ts.map +1 -0
- package/packages/cli/dist/commands/slash.js +110 -0
- package/packages/cli/dist/commands/slash.js.map +1 -0
- package/packages/cli/dist/commands/tasks.d.ts.map +1 -1
- package/packages/cli/dist/commands/tasks.js +74 -115
- package/packages/cli/dist/commands/tasks.js.map +1 -1
- package/packages/cli/dist/commands/tools.d.ts.map +1 -1
- package/packages/cli/dist/commands/tools.js +51 -34
- package/packages/cli/dist/commands/tools.js.map +1 -1
- package/packages/cli/dist/index.js +42 -52
- package/packages/cli/dist/index.js.map +1 -1
- package/packages/cli/dist/repl.d.ts +1 -25
- package/packages/cli/dist/repl.d.ts.map +1 -1
- package/packages/cli/dist/repl.js +165 -726
- package/packages/cli/dist/repl.js.map +1 -1
- package/packages/cli/dist/replInput.d.ts +33 -0
- package/packages/cli/dist/replInput.d.ts.map +1 -0
- package/packages/cli/dist/replInput.js +97 -0
- package/packages/cli/dist/replInput.js.map +1 -0
- package/packages/cli/dist/replOutput.d.ts +11 -0
- package/packages/cli/dist/replOutput.d.ts.map +1 -0
- package/packages/cli/dist/replOutput.js +22 -0
- package/packages/cli/dist/replOutput.js.map +1 -0
- package/packages/cli/dist/replQuestions.d.ts +32 -0
- package/packages/cli/dist/replQuestions.d.ts.map +1 -0
- package/packages/cli/dist/replQuestions.js +122 -0
- package/packages/cli/dist/replQuestions.js.map +1 -0
- package/packages/cli/dist/replSlash.d.ts +24 -0
- package/packages/cli/dist/replSlash.d.ts.map +1 -0
- package/packages/cli/dist/replSlash.js +311 -0
- package/packages/cli/dist/replSlash.js.map +1 -0
- package/packages/cli/dist/replState.d.ts +56 -0
- package/packages/cli/dist/replState.d.ts.map +1 -0
- package/packages/cli/dist/replState.js +89 -0
- package/packages/cli/dist/replState.js.map +1 -0
- package/packages/cli/dist/tui/App.d.ts +7 -24
- package/packages/cli/dist/tui/App.d.ts.map +1 -1
- package/packages/cli/dist/tui/App.js +139 -513
- package/packages/cli/dist/tui/App.js.map +1 -1
- package/packages/cli/dist/tui/LiveRegion.d.ts +16 -0
- package/packages/cli/dist/tui/LiveRegion.d.ts.map +1 -0
- package/packages/cli/dist/tui/LiveRegion.js +37 -0
- package/packages/cli/dist/tui/LiveRegion.js.map +1 -0
- package/packages/cli/dist/tui/boot.d.ts +34 -0
- package/packages/cli/dist/tui/boot.d.ts.map +1 -0
- package/packages/cli/dist/tui/boot.js +133 -0
- package/packages/cli/dist/tui/boot.js.map +1 -0
- package/packages/cli/dist/tui/commands.d.ts +3 -4
- package/packages/cli/dist/tui/commands.d.ts.map +1 -1
- package/packages/cli/dist/tui/commands.js +339 -405
- package/packages/cli/dist/tui/commands.js.map +1 -1
- package/packages/cli/dist/tui/components/ActivityLine.d.ts +1 -1
- package/packages/cli/dist/tui/components/ActivityLine.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/ActivityLine.js +2 -2
- package/packages/cli/dist/tui/components/ActivityLine.js.map +1 -1
- package/packages/cli/dist/tui/components/AssignmentsView.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/AssignmentsView.js +34 -20
- package/packages/cli/dist/tui/components/AssignmentsView.js.map +1 -1
- package/packages/cli/dist/tui/components/Logo.d.ts +3 -19
- package/packages/cli/dist/tui/components/Logo.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Logo.js +13 -13
- package/packages/cli/dist/tui/components/Logo.js.map +1 -1
- package/packages/cli/dist/tui/components/Markdown.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Markdown.js +201 -146
- package/packages/cli/dist/tui/components/Markdown.js.map +1 -1
- package/packages/cli/dist/tui/components/QuestionView.d.ts +0 -2
- package/packages/cli/dist/tui/components/QuestionView.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/QuestionView.js +21 -12
- package/packages/cli/dist/tui/components/QuestionView.js.map +1 -1
- package/packages/cli/dist/tui/components/Scrollback.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Scrollback.js +6 -3
- package/packages/cli/dist/tui/components/Scrollback.js.map +1 -1
- package/packages/cli/dist/tui/components/SlashPalette.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/SlashPalette.js +14 -9
- package/packages/cli/dist/tui/components/SlashPalette.js.map +1 -1
- package/packages/cli/dist/tui/components/StatusLine.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/StatusLine.js +45 -22
- package/packages/cli/dist/tui/components/StatusLine.js.map +1 -1
- package/packages/cli/dist/tui/components/ToolGroup.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/ToolGroup.js +12 -7
- package/packages/cli/dist/tui/components/ToolGroup.js.map +1 -1
- package/packages/cli/dist/tui/components/WatchView.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/WatchView.js +28 -17
- package/packages/cli/dist/tui/components/WatchView.js.map +1 -1
- package/packages/cli/dist/tui/highlight.d.ts +0 -2
- package/packages/cli/dist/tui/highlight.d.ts.map +1 -1
- package/packages/cli/dist/tui/highlight.js +8 -6
- package/packages/cli/dist/tui/highlight.js.map +1 -1
- package/packages/cli/dist/tui/history.d.ts +30 -4
- package/packages/cli/dist/tui/history.d.ts.map +1 -1
- package/packages/cli/dist/tui/history.js +100 -75
- package/packages/cli/dist/tui/history.js.map +1 -1
- package/packages/cli/dist/tui/hooks/coalescer.d.ts +18 -0
- package/packages/cli/dist/tui/hooks/coalescer.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/coalescer.js +36 -0
- package/packages/cli/dist/tui/hooks/coalescer.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useColumns.d.ts +2 -7
- package/packages/cli/dist/tui/hooks/useColumns.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useColumns.js +6 -11
- package/packages/cli/dist/tui/hooks/useColumns.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useHistory.d.ts +7 -4
- package/packages/cli/dist/tui/hooks/useHistory.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useHistory.js +21 -18
- package/packages/cli/dist/tui/hooks/useHistory.js.map +1 -1
- package/packages/cli/dist/tui/hooks/usePrompt.d.ts +27 -0
- package/packages/cli/dist/tui/hooks/usePrompt.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/usePrompt.js +169 -0
- package/packages/cli/dist/tui/hooks/usePrompt.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useQuestion.d.ts +23 -0
- package/packages/cli/dist/tui/hooks/useQuestion.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useQuestion.js +43 -0
- package/packages/cli/dist/tui/hooks/useQuestion.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useScrollback.d.ts +18 -0
- package/packages/cli/dist/tui/hooks/useScrollback.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useScrollback.js +29 -0
- package/packages/cli/dist/tui/hooks/useScrollback.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useSession.d.ts +25 -0
- package/packages/cli/dist/tui/hooks/useSession.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useSession.js +36 -0
- package/packages/cli/dist/tui/hooks/useSession.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useSlash.d.ts +0 -2
- package/packages/cli/dist/tui/hooks/useSlash.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useSlash.js +0 -1
- package/packages/cli/dist/tui/hooks/useSlash.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useSpeech.d.ts +19 -0
- package/packages/cli/dist/tui/hooks/useSpeech.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useSpeech.js +33 -0
- package/packages/cli/dist/tui/hooks/useSpeech.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useTicker.d.ts +13 -0
- package/packages/cli/dist/tui/hooks/useTicker.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useTicker.js +24 -0
- package/packages/cli/dist/tui/hooks/useTicker.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useTurn.d.ts +4 -4
- package/packages/cli/dist/tui/hooks/useTurn.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useTurn.js +167 -289
- package/packages/cli/dist/tui/hooks/useTurn.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useWatch.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useWatch.js +15 -48
- package/packages/cli/dist/tui/hooks/useWatch.js.map +1 -1
- package/packages/cli/dist/tui/inkTheme.d.ts.map +1 -1
- package/packages/cli/dist/tui/inkTheme.js +9 -11
- package/packages/cli/dist/tui/inkTheme.js.map +1 -1
- package/packages/cli/dist/tui/theme.d.ts +7 -13
- package/packages/cli/dist/tui/theme.d.ts.map +1 -1
- package/packages/cli/dist/tui/theme.js +18 -15
- package/packages/cli/dist/tui/theme.js.map +1 -1
- package/packages/cli/dist/tui/types.d.ts +10 -23
- package/packages/cli/dist/tui/types.d.ts.map +1 -1
- package/packages/cli/dist/tui/types.js +13 -31
- package/packages/cli/dist/tui/types.js.map +1 -1
- package/packages/cli/dist/ui/modelNames.d.ts.map +1 -1
- package/packages/cli/dist/ui/modelNames.js +45 -37
- package/packages/cli/dist/ui/modelNames.js.map +1 -1
- package/packages/cli/dist/ui/render.d.ts +32 -14
- package/packages/cli/dist/ui/render.d.ts.map +1 -1
- package/packages/cli/dist/ui/render.js +155 -98
- package/packages/cli/dist/ui/render.js.map +1 -1
- package/packages/cli/dist/ui/speech.d.ts +4 -7
- package/packages/cli/dist/ui/speech.d.ts.map +1 -1
- package/packages/cli/dist/ui/speech.js +37 -51
- package/packages/cli/dist/ui/speech.js.map +1 -1
- package/packages/cli/dist/ui/spinner.d.ts +1 -4
- package/packages/cli/dist/ui/spinner.d.ts.map +1 -1
- package/packages/cli/dist/ui/spinner.js +1 -12
- package/packages/cli/dist/ui/spinner.js.map +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/core/dist/agents/persona.d.ts.map +1 -1
- package/packages/core/dist/agents/persona.js +27 -11
- package/packages/core/dist/agents/persona.js.map +1 -1
- package/packages/core/dist/assistant/board-watch.d.ts +72 -0
- package/packages/core/dist/assistant/board-watch.d.ts.map +1 -0
- package/packages/core/dist/assistant/board-watch.js +224 -0
- package/packages/core/dist/assistant/board-watch.js.map +1 -0
- package/packages/core/dist/assistant/chat-turn.d.ts +14 -0
- package/packages/core/dist/assistant/chat-turn.d.ts.map +1 -0
- package/packages/core/dist/assistant/chat-turn.js +159 -0
- package/packages/core/dist/assistant/chat-turn.js.map +1 -0
- package/packages/core/dist/assistant/dream-recorder.d.ts +74 -0
- package/packages/core/dist/assistant/dream-recorder.d.ts.map +1 -0
- package/packages/core/dist/assistant/dream-recorder.js +282 -0
- package/packages/core/dist/assistant/dream-recorder.js.map +1 -0
- package/packages/core/dist/assistant/headless-turn.d.ts +17 -0
- package/packages/core/dist/assistant/headless-turn.d.ts.map +1 -0
- package/packages/core/dist/assistant/headless-turn.js +330 -0
- package/packages/core/dist/assistant/headless-turn.js.map +1 -0
- package/packages/core/dist/assistant/journalled-turn.d.ts +39 -0
- package/packages/core/dist/assistant/journalled-turn.d.ts.map +1 -0
- package/packages/core/dist/assistant/journalled-turn.js +75 -0
- package/packages/core/dist/assistant/journalled-turn.js.map +1 -0
- package/packages/core/dist/assistant/memory-learning.d.ts +27 -0
- package/packages/core/dist/assistant/memory-learning.d.ts.map +1 -0
- package/packages/core/dist/assistant/memory-learning.js +82 -0
- package/packages/core/dist/assistant/memory-learning.js.map +1 -0
- package/packages/core/dist/assistant/promotion-notice.d.ts +14 -0
- package/packages/core/dist/assistant/promotion-notice.d.ts.map +1 -0
- package/packages/core/dist/assistant/promotion-notice.js +33 -0
- package/packages/core/dist/assistant/promotion-notice.js.map +1 -0
- package/packages/core/dist/assistant/scheduled-runs.d.ts +30 -0
- package/packages/core/dist/assistant/scheduled-runs.d.ts.map +1 -0
- package/packages/core/dist/assistant/scheduled-runs.js +184 -0
- package/packages/core/dist/assistant/scheduled-runs.js.map +1 -0
- package/packages/core/dist/assistant/sessions.d.ts +44 -0
- package/packages/core/dist/assistant/sessions.d.ts.map +1 -0
- package/packages/core/dist/assistant/sessions.js +75 -0
- package/packages/core/dist/assistant/sessions.js.map +1 -0
- package/packages/core/dist/assistant/terminal-turn.d.ts +18 -0
- package/packages/core/dist/assistant/terminal-turn.d.ts.map +1 -0
- package/packages/core/dist/assistant/terminal-turn.js +228 -0
- package/packages/core/dist/assistant/terminal-turn.js.map +1 -0
- package/packages/core/dist/assistant/terminals.d.ts +91 -0
- package/packages/core/dist/assistant/terminals.d.ts.map +1 -0
- package/packages/core/dist/assistant/terminals.js +266 -0
- package/packages/core/dist/assistant/terminals.js.map +1 -0
- package/packages/core/dist/assistant/turn-support.d.ts +109 -0
- package/packages/core/dist/assistant/turn-support.d.ts.map +1 -0
- package/packages/core/dist/assistant/turn-support.js +80 -0
- package/packages/core/dist/assistant/turn-support.js.map +1 -0
- package/packages/core/dist/assistant/turn-transcript.d.ts +44 -0
- package/packages/core/dist/assistant/turn-transcript.d.ts.map +1 -0
- package/packages/core/dist/assistant/turn-transcript.js +82 -0
- package/packages/core/dist/assistant/turn-transcript.js.map +1 -0
- package/packages/core/dist/assistant/types.d.ts +120 -0
- package/packages/core/dist/assistant/types.d.ts.map +1 -0
- package/packages/core/dist/assistant/types.js +2 -0
- package/packages/core/dist/assistant/types.js.map +1 -0
- package/packages/core/dist/computer/accessibility.d.ts.map +1 -1
- package/packages/core/dist/computer/accessibility.js +40 -35
- package/packages/core/dist/computer/accessibility.js.map +1 -1
- package/packages/core/dist/computer/mcp-server.js +426 -364
- package/packages/core/dist/computer/mcp-server.js.map +1 -1
- package/packages/core/dist/computer/powershell.d.ts.map +1 -1
- package/packages/core/dist/computer/powershell.js +25 -16
- package/packages/core/dist/computer/powershell.js.map +1 -1
- package/packages/core/dist/computer/screen-text.d.ts.map +1 -1
- package/packages/core/dist/computer/screen-text.js +54 -34
- package/packages/core/dist/computer/screen-text.js.map +1 -1
- package/packages/core/dist/computer/sketch.d.ts.map +1 -1
- package/packages/core/dist/computer/sketch.js +185 -128
- package/packages/core/dist/computer/sketch.js.map +1 -1
- package/packages/core/dist/computer/tools.d.ts +2 -0
- package/packages/core/dist/computer/tools.d.ts.map +1 -1
- package/packages/core/dist/computer/tools.js +31 -27
- package/packages/core/dist/computer/tools.js.map +1 -1
- package/packages/core/dist/computer/validation.d.ts +16 -16
- package/packages/core/dist/computer/validation.d.ts.map +1 -1
- package/packages/core/dist/computer/validation.js +28 -20
- package/packages/core/dist/computer/validation.js.map +1 -1
- package/packages/core/dist/config.d.ts +10 -1
- package/packages/core/dist/config.d.ts.map +1 -1
- package/packages/core/dist/config.js +64 -23
- package/packages/core/dist/config.js.map +1 -1
- package/packages/core/dist/cron/parse.d.ts.map +1 -1
- package/packages/core/dist/cron/parse.js +90 -77
- package/packages/core/dist/cron/parse.js.map +1 -1
- package/packages/core/dist/cron/scheduler.d.ts.map +1 -1
- package/packages/core/dist/cron/scheduler.js +99 -65
- package/packages/core/dist/cron/scheduler.js.map +1 -1
- package/packages/core/dist/cron/script.d.ts.map +1 -1
- package/packages/core/dist/cron/script.js +72 -42
- package/packages/core/dist/cron/script.js.map +1 -1
- package/packages/core/dist/external/claude-code.d.ts.map +1 -1
- package/packages/core/dist/external/claude-code.js +41 -28
- package/packages/core/dist/external/claude-code.js.map +1 -1
- package/packages/core/dist/external/discovery.d.ts.map +1 -1
- package/packages/core/dist/external/discovery.js +14 -11
- package/packages/core/dist/external/discovery.js.map +1 -1
- package/packages/core/dist/external/shared.d.ts.map +1 -1
- package/packages/core/dist/external/shared.js +55 -74
- package/packages/core/dist/external/shared.js.map +1 -1
- package/packages/core/dist/gateway/policy.d.ts.map +1 -1
- package/packages/core/dist/gateway/policy.js +5 -2
- package/packages/core/dist/gateway/policy.js.map +1 -1
- package/packages/core/dist/logger.d.ts.map +1 -1
- package/packages/core/dist/logger.js +11 -11
- package/packages/core/dist/logger.js.map +1 -1
- package/packages/core/dist/memory/db.d.ts.map +1 -1
- package/packages/core/dist/memory/db.js +175 -226
- package/packages/core/dist/memory/db.js.map +1 -1
- package/packages/core/dist/memory/dream/admission.d.ts +5 -0
- package/packages/core/dist/memory/dream/admission.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/admission.js +8 -14
- package/packages/core/dist/memory/dream/admission.js.map +1 -1
- package/packages/core/dist/memory/dream/candidate.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/candidate.js +119 -92
- package/packages/core/dist/memory/dream/candidate.js.map +1 -1
- package/packages/core/dist/memory/dream/evaluate.d.ts +13 -4
- package/packages/core/dist/memory/dream/evaluate.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/evaluate.js +264 -288
- package/packages/core/dist/memory/dream/evaluate.js.map +1 -1
- package/packages/core/dist/memory/dream/frame.d.ts +6 -0
- package/packages/core/dist/memory/dream/frame.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/frame.js +137 -91
- package/packages/core/dist/memory/dream/frame.js.map +1 -1
- package/packages/core/dist/memory/dream/label.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/label.js +6 -9
- package/packages/core/dist/memory/dream/label.js.map +1 -1
- package/packages/core/dist/memory/dream/measure.d.ts +4 -0
- package/packages/core/dist/memory/dream/measure.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/measure.js +13 -58
- package/packages/core/dist/memory/dream/measure.js.map +1 -1
- package/packages/core/dist/memory/dream/policy.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/policy.js +4 -2
- package/packages/core/dist/memory/dream/policy.js.map +1 -1
- package/packages/core/dist/memory/dream/probe.d.ts +31 -4
- package/packages/core/dist/memory/dream/probe.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/probe.js +290 -289
- package/packages/core/dist/memory/dream/probe.js.map +1 -1
- package/packages/core/dist/memory/dream/promote.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/promote.js +10 -11
- package/packages/core/dist/memory/dream/promote.js.map +1 -1
- package/packages/core/dist/memory/dream/score.d.ts +9 -0
- package/packages/core/dist/memory/dream/score.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/score.js +6 -7
- package/packages/core/dist/memory/dream/score.js.map +1 -1
- package/packages/core/dist/memory/dream/slots.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/slots.js +0 -0
- package/packages/core/dist/memory/dream/slots.js.map +1 -1
- package/packages/core/dist/memory/dream/trajectory.d.ts.map +1 -1
- package/packages/core/dist/memory/dream/trajectory.js +76 -53
- package/packages/core/dist/memory/dream/trajectory.js.map +1 -1
- package/packages/core/dist/memory/dream/util.d.ts +44 -0
- package/packages/core/dist/memory/dream/util.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/util.js +83 -0
- package/packages/core/dist/memory/dream/util.js.map +1 -0
- package/packages/core/dist/memory/extractor.d.ts.map +1 -1
- package/packages/core/dist/memory/extractor.js +67 -46
- package/packages/core/dist/memory/extractor.js.map +1 -1
- package/packages/core/dist/memory/gate.d.ts.map +1 -1
- package/packages/core/dist/memory/gate.js +55 -44
- package/packages/core/dist/memory/gate.js.map +1 -1
- package/packages/core/dist/memory/recall.d.ts +1 -1
- package/packages/core/dist/memory/recall.d.ts.map +1 -1
- package/packages/core/dist/memory/recall.js +42 -39
- package/packages/core/dist/memory/recall.js.map +1 -1
- package/packages/core/dist/memory/sleep-dream.d.ts +210 -0
- package/packages/core/dist/memory/sleep-dream.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep-dream.js +1109 -0
- package/packages/core/dist/memory/sleep-dream.js.map +1 -0
- package/packages/core/dist/memory/sleep-frames.d.ts +40 -0
- package/packages/core/dist/memory/sleep-frames.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep-frames.js +127 -0
- package/packages/core/dist/memory/sleep-frames.js.map +1 -0
- package/packages/core/dist/memory/sleep-limits.d.ts +18 -0
- package/packages/core/dist/memory/sleep-limits.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep-limits.js +34 -0
- package/packages/core/dist/memory/sleep-limits.js.map +1 -0
- package/packages/core/dist/memory/sleep-model.d.ts +36 -0
- package/packages/core/dist/memory/sleep-model.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep-model.js +80 -0
- package/packages/core/dist/memory/sleep-model.js.map +1 -0
- package/packages/core/dist/memory/sleep-policy.d.ts +19 -0
- package/packages/core/dist/memory/sleep-policy.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep-policy.js +79 -0
- package/packages/core/dist/memory/sleep-policy.js.map +1 -0
- package/packages/core/dist/memory/sleep-prompts.d.ts +15 -0
- package/packages/core/dist/memory/sleep-prompts.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep-prompts.js +212 -0
- package/packages/core/dist/memory/sleep-prompts.js.map +1 -0
- package/packages/core/dist/memory/sleep-report.d.ts +63 -0
- package/packages/core/dist/memory/sleep-report.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep-report.js +97 -0
- package/packages/core/dist/memory/sleep-report.js.map +1 -0
- package/packages/core/dist/memory/sleep-verdicts.d.ts +77 -0
- package/packages/core/dist/memory/sleep-verdicts.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep-verdicts.js +198 -0
- package/packages/core/dist/memory/sleep-verdicts.js.map +1 -0
- package/packages/core/dist/memory/sleep.d.ts +6 -61
- package/packages/core/dist/memory/sleep.d.ts.map +1 -1
- package/packages/core/dist/memory/sleep.js +1099 -2458
- package/packages/core/dist/memory/sleep.js.map +1 -1
- package/packages/core/dist/memory/store-rows.d.ts +43 -0
- package/packages/core/dist/memory/store-rows.d.ts.map +1 -0
- package/packages/core/dist/memory/store-rows.js +330 -0
- package/packages/core/dist/memory/store-rows.js.map +1 -0
- package/packages/core/dist/memory/store.d.ts +34 -20
- package/packages/core/dist/memory/store.d.ts.map +1 -1
- package/packages/core/dist/memory/store.js +634 -861
- package/packages/core/dist/memory/store.js.map +1 -1
- package/packages/core/dist/migration-cron.d.ts +2 -1
- package/packages/core/dist/migration-cron.d.ts.map +1 -1
- package/packages/core/dist/migration-cron.js +197 -154
- package/packages/core/dist/migration-cron.js.map +1 -1
- package/packages/core/dist/migration-scripts.d.ts +11 -3
- package/packages/core/dist/migration-scripts.d.ts.map +1 -1
- package/packages/core/dist/migration-scripts.js +81 -61
- package/packages/core/dist/migration-scripts.js.map +1 -1
- package/packages/core/dist/migration-shared.d.ts +9 -0
- package/packages/core/dist/migration-shared.d.ts.map +1 -0
- package/packages/core/dist/migration-shared.js +16 -0
- package/packages/core/dist/migration-shared.js.map +1 -0
- package/packages/core/dist/migration.d.ts.map +1 -1
- package/packages/core/dist/migration.js +150 -111
- package/packages/core/dist/migration.js.map +1 -1
- package/packages/core/dist/org/assignment-log.d.ts +28 -0
- package/packages/core/dist/org/assignment-log.d.ts.map +1 -0
- package/packages/core/dist/org/assignment-log.js +86 -0
- package/packages/core/dist/org/assignment-log.js.map +1 -0
- package/packages/core/dist/org/bridge.d.ts.map +1 -1
- package/packages/core/dist/org/bridge.js +32 -30
- package/packages/core/dist/org/bridge.js.map +1 -1
- package/packages/core/dist/org/controller.d.ts +18 -21
- package/packages/core/dist/org/controller.d.ts.map +1 -1
- package/packages/core/dist/org/controller.js +2042 -1848
- package/packages/core/dist/org/controller.js.map +1 -1
- package/packages/core/dist/org/json-reply.d.ts +6 -0
- package/packages/core/dist/org/json-reply.d.ts.map +1 -0
- package/packages/core/dist/org/json-reply.js +23 -0
- package/packages/core/dist/org/json-reply.js.map +1 -0
- package/packages/core/dist/org/mcp-bridge.js +34 -26
- package/packages/core/dist/org/mcp-bridge.js.map +1 -1
- package/packages/core/dist/org/planner.d.ts.map +1 -1
- package/packages/core/dist/org/planner.js +38 -42
- package/packages/core/dist/org/planner.js.map +1 -1
- package/packages/core/dist/org/project-mcp.d.ts.map +1 -1
- package/packages/core/dist/org/project-mcp.js +2 -5
- package/packages/core/dist/org/project-mcp.js.map +1 -1
- package/packages/core/dist/org/prompts.d.ts.map +1 -1
- package/packages/core/dist/org/prompts.js +176 -156
- package/packages/core/dist/org/prompts.js.map +1 -1
- package/packages/core/dist/org/questions.d.ts.map +1 -1
- package/packages/core/dist/org/questions.js +19 -14
- package/packages/core/dist/org/questions.js.map +1 -1
- package/packages/core/dist/org/review.d.ts.map +1 -1
- package/packages/core/dist/org/review.js +27 -43
- package/packages/core/dist/org/review.js.map +1 -1
- package/packages/core/dist/org/store.d.ts +19 -32
- package/packages/core/dist/org/store.d.ts.map +1 -1
- package/packages/core/dist/org/store.js +250 -206
- package/packages/core/dist/org/store.js.map +1 -1
- package/packages/core/dist/org/tool-args.d.ts +54 -0
- package/packages/core/dist/org/tool-args.d.ts.map +1 -0
- package/packages/core/dist/org/tool-args.js +104 -0
- package/packages/core/dist/org/tool-args.js.map +1 -0
- package/packages/core/dist/org/tools.d.ts.map +1 -1
- package/packages/core/dist/org/tools.js +238 -443
- package/packages/core/dist/org/tools.js.map +1 -1
- package/packages/core/dist/profile.d.ts.map +1 -1
- package/packages/core/dist/profile.js +114 -57
- package/packages/core/dist/profile.js.map +1 -1
- package/packages/core/dist/providers/catalogue.d.ts.map +1 -1
- package/packages/core/dist/providers/catalogue.js +89 -60
- package/packages/core/dist/providers/catalogue.js.map +1 -1
- package/packages/core/dist/providers/claude-code.d.ts.map +1 -1
- package/packages/core/dist/providers/claude-code.js +418 -357
- package/packages/core/dist/providers/claude-code.js.map +1 -1
- package/packages/core/dist/providers/claude-tui.d.ts +13 -9
- package/packages/core/dist/providers/claude-tui.d.ts.map +1 -1
- package/packages/core/dist/providers/claude-tui.js +568 -396
- package/packages/core/dist/providers/claude-tui.js.map +1 -1
- package/packages/core/dist/providers/codex-auth.d.ts +3 -0
- package/packages/core/dist/providers/codex-auth.d.ts.map +1 -1
- package/packages/core/dist/providers/codex-auth.js +9 -7
- package/packages/core/dist/providers/codex-auth.js.map +1 -1
- package/packages/core/dist/providers/codex-bridge.d.ts +24 -7
- package/packages/core/dist/providers/codex-bridge.d.ts.map +1 -1
- package/packages/core/dist/providers/codex-bridge.js +128 -168
- package/packages/core/dist/providers/codex-bridge.js.map +1 -1
- package/packages/core/dist/providers/codex-translate.d.ts.map +1 -1
- package/packages/core/dist/providers/codex-translate.js +195 -197
- package/packages/core/dist/providers/codex-translate.js.map +1 -1
- package/packages/core/dist/providers/loopback-server.d.ts +33 -0
- package/packages/core/dist/providers/loopback-server.d.ts.map +1 -0
- package/packages/core/dist/providers/loopback-server.js +104 -0
- package/packages/core/dist/providers/loopback-server.js.map +1 -0
- package/packages/core/dist/providers/model-gateway.d.ts +2 -4
- package/packages/core/dist/providers/model-gateway.d.ts.map +1 -1
- package/packages/core/dist/providers/model-gateway.js +39 -75
- package/packages/core/dist/providers/model-gateway.js.map +1 -1
- package/packages/core/dist/providers/process.d.ts.map +1 -1
- package/packages/core/dist/providers/process.js +32 -23
- package/packages/core/dist/providers/process.js.map +1 -1
- package/packages/core/dist/providers/provider-catalog.d.ts.map +1 -1
- package/packages/core/dist/providers/provider-catalog.js +21 -23
- package/packages/core/dist/providers/provider-catalog.js.map +1 -1
- package/packages/core/dist/providers/quota.d.ts.map +1 -1
- package/packages/core/dist/providers/quota.js +37 -37
- package/packages/core/dist/providers/quota.js.map +1 -1
- package/packages/core/dist/providers/registry.d.ts.map +1 -1
- package/packages/core/dist/providers/registry.js +3 -1
- package/packages/core/dist/providers/registry.js.map +1 -1
- package/packages/core/dist/providers/user-settings-guard.d.ts.map +1 -1
- package/packages/core/dist/providers/user-settings-guard.js +7 -2
- package/packages/core/dist/providers/user-settings-guard.js.map +1 -1
- package/packages/core/dist/runtime.d.ts +45 -158
- package/packages/core/dist/runtime.d.ts.map +1 -1
- package/packages/core/dist/runtime.js +184 -1701
- package/packages/core/dist/runtime.js.map +1 -1
- package/packages/core/dist/skills/import.d.ts.map +1 -1
- package/packages/core/dist/skills/import.js +52 -36
- package/packages/core/dist/skills/import.js.map +1 -1
- package/packages/core/dist/skills/shelf.d.ts +14 -0
- package/packages/core/dist/skills/shelf.d.ts.map +1 -1
- package/packages/core/dist/skills/shelf.js +2 -3
- package/packages/core/dist/skills/shelf.js.map +1 -1
- package/packages/core/dist/skills/store.d.ts +2 -0
- package/packages/core/dist/skills/store.d.ts.map +1 -1
- package/packages/core/dist/skills/store.js +17 -12
- package/packages/core/dist/skills/store.js.map +1 -1
- package/packages/core/dist/tools/catalog.d.ts.map +1 -1
- package/packages/core/dist/tools/catalog.js +6 -2
- package/packages/core/dist/tools/catalog.js.map +1 -1
- package/packages/core/dist/tools/hub.d.ts.map +1 -1
- package/packages/core/dist/tools/hub.js +97 -79
- package/packages/core/dist/tools/hub.js.map +1 -1
- package/packages/core/dist/turns/journal.d.ts.map +1 -1
- package/packages/core/dist/turns/journal.js +12 -18
- package/packages/core/dist/turns/journal.js.map +1 -1
- package/packages/core/dist/types.d.ts +12 -3
- package/packages/core/dist/types.d.ts.map +1 -1
- package/packages/core/dist/types.js.map +1 -1
- package/packages/core/dist/util/blocks.d.ts.map +1 -1
- package/packages/core/dist/util/blocks.js +14 -22
- package/packages/core/dist/util/blocks.js.map +1 -1
- package/packages/core/dist/util/queue.d.ts +0 -2
- package/packages/core/dist/util/queue.d.ts.map +1 -1
- package/packages/core/dist/util/queue.js +0 -6
- package/packages/core/dist/util/queue.js.map +1 -1
- package/packages/core/package.json +1 -1
- package/packages/server/dist/auth.d.ts +8 -0
- package/packages/server/dist/auth.d.ts.map +1 -1
- package/packages/server/dist/auth.js +8 -8
- package/packages/server/dist/auth.js.map +1 -1
- package/packages/server/dist/env.d.ts.map +1 -1
- package/packages/server/dist/env.js +18 -15
- package/packages/server/dist/env.js.map +1 -1
- package/packages/server/dist/errors.d.ts +3 -0
- package/packages/server/dist/errors.d.ts.map +1 -0
- package/packages/server/dist/errors.js +5 -0
- package/packages/server/dist/errors.js.map +1 -0
- package/packages/server/dist/gateways/attachments.d.ts.map +1 -1
- package/packages/server/dist/gateways/attachments.js +38 -21
- package/packages/server/dist/gateways/attachments.js.map +1 -1
- package/packages/server/dist/gateways/markdown.d.ts.map +1 -1
- package/packages/server/dist/gateways/markdown.js +30 -12
- package/packages/server/dist/gateways/markdown.js.map +1 -1
- package/packages/server/dist/gateways/push.d.ts +6 -6
- package/packages/server/dist/gateways/push.d.ts.map +1 -1
- package/packages/server/dist/gateways/push.js +101 -74
- package/packages/server/dist/gateways/push.js.map +1 -1
- package/packages/server/dist/gateways/telegram-api.d.ts.map +1 -1
- package/packages/server/dist/gateways/telegram-api.js +61 -44
- package/packages/server/dist/gateways/telegram-api.js.map +1 -1
- package/packages/server/dist/gateways/telegram.d.ts +5 -0
- package/packages/server/dist/gateways/telegram.d.ts.map +1 -1
- package/packages/server/dist/gateways/telegram.js +985 -753
- package/packages/server/dist/gateways/telegram.js.map +1 -1
- package/packages/server/dist/gateways/threads.d.ts.map +1 -1
- package/packages/server/dist/gateways/threads.js +144 -130
- package/packages/server/dist/gateways/threads.js.map +1 -1
- package/packages/server/dist/listeners/imap.d.ts.map +1 -1
- package/packages/server/dist/listeners/imap.js +0 -0
- package/packages/server/dist/listeners/imap.js.map +1 -1
- package/packages/server/dist/listeners/registry.d.ts.map +1 -1
- package/packages/server/dist/listeners/registry.js +15 -15
- package/packages/server/dist/listeners/registry.js.map +1 -1
- package/packages/server/dist/main.js +3 -2
- package/packages/server/dist/main.js.map +1 -1
- package/packages/server/dist/routes/chat.d.ts.map +1 -1
- package/packages/server/dist/routes/chat.js +5 -8
- package/packages/server/dist/routes/chat.js.map +1 -1
- package/packages/server/dist/routes/config.d.ts +6 -0
- package/packages/server/dist/routes/config.d.ts.map +1 -1
- package/packages/server/dist/routes/config.js +34 -31
- package/packages/server/dist/routes/config.js.map +1 -1
- package/packages/server/dist/routes/cron.d.ts.map +1 -1
- package/packages/server/dist/routes/cron.js +33 -23
- package/packages/server/dist/routes/cron.js.map +1 -1
- package/packages/server/dist/routes/dream.d.ts +1 -1
- package/packages/server/dist/routes/dream.d.ts.map +1 -1
- package/packages/server/dist/routes/dream.js +16 -34
- package/packages/server/dist/routes/dream.js.map +1 -1
- package/packages/server/dist/routes/gateways.d.ts.map +1 -1
- package/packages/server/dist/routes/gateways.js +8 -13
- package/packages/server/dist/routes/gateways.js.map +1 -1
- package/packages/server/dist/routes/memories.d.ts.map +1 -1
- package/packages/server/dist/routes/memories.js +16 -29
- package/packages/server/dist/routes/memories.js.map +1 -1
- package/packages/server/dist/routes/night.d.ts +31 -0
- package/packages/server/dist/routes/night.d.ts.map +1 -0
- package/packages/server/dist/routes/night.js +28 -0
- package/packages/server/dist/routes/night.js.map +1 -0
- package/packages/server/dist/routes/org.d.ts.map +1 -1
- package/packages/server/dist/routes/org.js +125 -119
- package/packages/server/dist/routes/org.js.map +1 -1
- package/packages/server/dist/routes/profile.d.ts.map +1 -1
- package/packages/server/dist/routes/profile.js +5 -6
- package/packages/server/dist/routes/profile.js.map +1 -1
- package/packages/server/dist/routes/providers.d.ts.map +1 -1
- package/packages/server/dist/routes/providers.js +1 -3
- package/packages/server/dist/routes/providers.js.map +1 -1
- package/packages/server/dist/routes/query.d.ts +10 -0
- package/packages/server/dist/routes/query.d.ts.map +1 -0
- package/packages/server/dist/routes/query.js +17 -0
- package/packages/server/dist/routes/query.js.map +1 -0
- package/packages/server/dist/routes/questions.d.ts.map +1 -1
- package/packages/server/dist/routes/questions.js +5 -11
- package/packages/server/dist/routes/questions.js.map +1 -1
- package/packages/server/dist/routes/sessions.d.ts.map +1 -1
- package/packages/server/dist/routes/sessions.js +20 -28
- package/packages/server/dist/routes/sessions.js.map +1 -1
- package/packages/server/dist/routes/sleep.d.ts.map +1 -1
- package/packages/server/dist/routes/sleep.js +21 -36
- package/packages/server/dist/routes/sleep.js.map +1 -1
- package/packages/server/dist/routes/stats.d.ts.map +1 -1
- package/packages/server/dist/routes/stats.js +2 -7
- package/packages/server/dist/routes/stats.js.map +1 -1
- package/packages/server/dist/routes/terminals.d.ts.map +1 -1
- package/packages/server/dist/routes/terminals.js +19 -14
- package/packages/server/dist/routes/terminals.js.map +1 -1
- package/packages/server/dist/routes/tools.d.ts.map +1 -1
- package/packages/server/dist/routes/tools.js +7 -5
- package/packages/server/dist/routes/tools.js.map +1 -1
- package/packages/server/dist/routes/ws.d.ts.map +1 -1
- package/packages/server/dist/routes/ws.js +235 -207
- package/packages/server/dist/routes/ws.js.map +1 -1
- package/packages/server/dist/schemas.d.ts +30 -21
- package/packages/server/dist/schemas.d.ts.map +1 -1
- package/packages/server/dist/schemas.js +3 -2
- package/packages/server/dist/schemas.js.map +1 -1
- package/packages/server/dist/server.d.ts.map +1 -1
- package/packages/server/dist/server.js +250 -230
- package/packages/server/dist/server.js.map +1 -1
- package/packages/server/dist/services/stream.d.ts.map +1 -1
- package/packages/server/dist/services/stream.js +6 -4
- package/packages/server/dist/services/stream.js.map +1 -1
- package/packages/server/dist/services/stt.d.ts +1 -1
- package/packages/server/dist/services/stt.d.ts.map +1 -1
- package/packages/server/dist/services/stt.js +175 -124
- package/packages/server/dist/services/stt.js.map +1 -1
- package/packages/server/dist/services/tts.d.ts.map +1 -1
- package/packages/server/dist/services/tts.js +82 -54
- package/packages/server/dist/services/tts.js.map +1 -1
- package/packages/server/dist/services/turns.d.ts +8 -6
- package/packages/server/dist/services/turns.d.ts.map +1 -1
- package/packages/server/dist/services/turns.js +36 -32
- package/packages/server/dist/services/turns.js.map +1 -1
- package/packages/server/dist/services/updates.d.ts +1 -0
- package/packages/server/dist/services/updates.d.ts.map +1 -1
- package/packages/server/dist/services/updates.js +150 -91
- package/packages/server/dist/services/updates.js.map +1 -1
- package/packages/server/dist/services/voice-keys.d.ts.map +1 -1
- package/packages/server/dist/services/voice-keys.js +4 -2
- package/packages/server/dist/services/voice-keys.js.map +1 -1
- package/packages/server/dist/static.d.ts +1 -1
- package/packages/server/dist/static.d.ts.map +1 -1
- package/packages/server/dist/static.js +7 -7
- package/packages/server/dist/static.js.map +1 -1
- package/packages/server/package.json +1 -1
- package/packages/web/dist/assets/{abnfDiagram-O67JEVCF-D7YyFndQ.js → abnfDiagram-O67JEVCF-c90Gs7pG.js} +1 -1
- package/packages/web/dist/assets/{arc-C_Zgk2dJ.js → arc-C28-SQX8.js} +1 -1
- package/packages/web/dist/assets/{architectureDiagram-NJMV4G6O-eI0adu1B.js → architectureDiagram-NJMV4G6O-CBPhVAKx.js} +1 -1
- package/packages/web/dist/assets/{blockDiagram-BEXU5L5S-WAoOFUA9.js → blockDiagram-BEXU5L5S-CwKMvCbh.js} +1 -1
- package/packages/web/dist/assets/{c4Diagram-YGBWAQC7-DE8Zyhng.js → c4Diagram-YGBWAQC7-CsL4YtmG.js} +1 -1
- package/packages/web/dist/assets/channel-gYp6Rt3b.js +1 -0
- package/packages/web/dist/assets/{chunk-2Q5K7J3B-bnqLP2XD.js → chunk-2Q5K7J3B-C9Bji_Nr.js} +1 -1
- package/packages/web/dist/assets/{chunk-3FUC2YCW-Ck1_SVe0.js → chunk-3FUC2YCW-BUnPWClf.js} +2 -2
- package/packages/web/dist/assets/{chunk-5VM5RSS4-hDmC41gD.js → chunk-5VM5RSS4-CdfpfDTC.js} +1 -1
- package/packages/web/dist/assets/{chunk-GTNCS2PH-PoWvfCrT.js → chunk-GTNCS2PH-BZrKT8Ne.js} +1 -1
- package/packages/web/dist/assets/{chunk-GWA4HPMP-D3V0IG43.js → chunk-GWA4HPMP-C0jEzDJu.js} +1 -1
- package/packages/web/dist/assets/{chunk-JWPE2WC7-BryfpHM5.js → chunk-JWPE2WC7-CkLRmEro.js} +1 -1
- package/packages/web/dist/assets/{chunk-NETBCI7D-8ic1iEdT.js → chunk-NETBCI7D-BBeWMDmk.js} +1 -1
- package/packages/web/dist/assets/{chunk-WEXAMYUT-nM8tmQT2.js → chunk-WEXAMYUT-B6IqsBxs.js} +1 -1
- package/packages/web/dist/assets/{chunk-XXDRQBXY-Do28F482.js → chunk-XXDRQBXY-BPXeDnB2.js} +1 -1
- package/packages/web/dist/assets/{classDiagram-v2-NBCMYWYE-Bop9oNNO.js → classDiagram-v2-NBCMYWYE-2kqq2mJ8.js} +1 -1
- package/packages/web/dist/assets/{cose-bilkent-JH36ORCC-a7f_bpnt.js → cose-bilkent-JH36ORCC-G49FKtk6.js} +1 -1
- package/packages/web/dist/assets/{cynefin-OW5HDTMX-DnArcis_.js → cynefin-OW5HDTMX-98M_mPg9.js} +1 -1
- package/packages/web/dist/assets/{cynefinDiagram-VND7K2PF-vEuTb1GD.js → cynefinDiagram-VND7K2PF-BYJTAxOT.js} +1 -1
- package/packages/web/dist/assets/{dagre-6A5THRUB-BgG4MynJ.js → dagre-6A5THRUB-Bxcb5kkl.js} +1 -1
- package/packages/web/dist/assets/{diagram-22UHCM2B-DRCQpafv.js → diagram-22UHCM2B-DK7wAztC.js} +1 -1
- package/packages/web/dist/assets/{diagram-3UASUU5V-BKgmAXde.js → diagram-3UASUU5V-BMRz0ele.js} +1 -1
- package/packages/web/dist/assets/{diagram-ATOU4E4O-B6Hsy36X.js → diagram-ATOU4E4O-O23sdVpm.js} +1 -1
- package/packages/web/dist/assets/{diagram-CDSNMT55-JflyfyoB.js → diagram-CDSNMT55-CGxai-zV.js} +1 -1
- package/packages/web/dist/assets/{diagram-MLGK6HIB-Dd2QPJjT.js → diagram-MLGK6HIB-B_29W-sW.js} +1 -1
- package/packages/web/dist/assets/{diagram-MPIPVDR6-DE5QU60x.js → diagram-MPIPVDR6-OSt1qPU_.js} +1 -1
- package/packages/web/dist/assets/{ebnfDiagram-ZINNZB2B-D7AQ741b.js → ebnfDiagram-ZINNZB2B-DnZcwiew.js} +1 -1
- package/packages/web/dist/assets/{elk-276RUBZZ-CeewBVLF.js → elk-276RUBZZ-BP6-xQAF.js} +1 -1
- package/packages/web/dist/assets/{erDiagram-OPXOYQCR-mLLYkZ5c.js → erDiagram-OPXOYQCR-DhG7UZtA.js} +1 -1
- package/packages/web/dist/assets/{flowDiagram-KWPJA3E3-DtpSpsQN.js → flowDiagram-KWPJA3E3-CNTS1YPA.js} +1 -1
- package/packages/web/dist/assets/{ganttDiagram-FUAMR5RP-1_lh-3ky.js → ganttDiagram-FUAMR5RP-_eKkbUxc.js} +1 -1
- package/packages/web/dist/assets/{gitGraphDiagram-X574FWY7-DoPXZuT5.js → gitGraphDiagram-X574FWY7-N_PXNE-o.js} +1 -1
- package/packages/web/dist/assets/index-DGq8BOVF.js +646 -0
- package/packages/web/dist/assets/index-DgMuFFt3.css +32 -0
- package/packages/web/dist/assets/{infoDiagram-VRGFBTTK-DQpRGGiD.js → infoDiagram-VRGFBTTK-vj_EDhft.js} +1 -1
- package/packages/web/dist/assets/{ishikawaDiagram-OU5B5YK6-gH5C9Q2e.js → ishikawaDiagram-OU5B5YK6-Dr0BodVq.js} +1 -1
- package/packages/web/dist/assets/{journeyDiagram-ZHPQQLJL-Bg-oeFjb.js → journeyDiagram-ZHPQQLJL-DykOPAu9.js} +1 -1
- package/packages/web/dist/assets/{kanban-definition-PNTS6WVX-BnpI4VH8.js → kanban-definition-PNTS6WVX-zslQcJnX.js} +1 -1
- package/packages/web/dist/assets/{mermaid.core-BwBKxlRA.js → mermaid.core-C888eQE1.js} +4 -4
- package/packages/web/dist/assets/{mindmap-definition-NLK3R4M7-NBnnxEoO.js → mindmap-definition-NLK3R4M7-CpdltDoL.js} +1 -1
- package/packages/web/dist/assets/{pegDiagram-GJSIUBJH-RrXXbIvO.js → pegDiagram-GJSIUBJH-Dsx3NmVN.js} +1 -1
- package/packages/web/dist/assets/{pieDiagram-5QR66LMP-B27q6Gso.js → pieDiagram-5QR66LMP-D_4DJLkr.js} +1 -1
- package/packages/web/dist/assets/{quadrantDiagram-O4NWA36T-DGDsdur2.js → quadrantDiagram-O4NWA36T-BXgGWrJ1.js} +1 -1
- package/packages/web/dist/assets/{railroadDiagram-XR7U4H2S-GdjkE3mI.js → railroadDiagram-XR7U4H2S-WMsrl4TR.js} +1 -1
- package/packages/web/dist/assets/{requirementDiagram-PLB6GJNP-DjK0GfgO.js → requirementDiagram-PLB6GJNP-m2PpXDpq.js} +1 -1
- package/packages/web/dist/assets/{sankeyDiagram-IPEJSGJF-BG_AIkwF.js → sankeyDiagram-IPEJSGJF-DfcxNy3C.js} +1 -1
- package/packages/web/dist/assets/scene-BA1PRRU7.js +4620 -0
- package/packages/web/dist/assets/{sequenceDiagram-PO4LG4MO-CIQwUb4y.js → sequenceDiagram-PO4LG4MO-B8yIKbJ8.js} +1 -1
- package/packages/web/dist/assets/{sizeCapture-INFHLROL-bpIoPxdJ.js → sizeCapture-INFHLROL-Cic9nV7h.js} +1 -1
- package/packages/web/dist/assets/{stateDiagram-v2-GCMORJYK-8hYXvPPv.js → stateDiagram-v2-GCMORJYK-oOFJPdg1.js} +1 -1
- package/packages/web/dist/assets/{swimlanes-2SLR337P-gfflUMF9.js → swimlanes-2SLR337P-UCvVVk9j.js} +1 -1
- package/packages/web/dist/assets/swimlanesDiagram-TC7HE7FX-B8q2Z_Nb.js +8 -0
- package/packages/web/dist/assets/{timeline-definition-EJHVYXUP-PHMNoGTZ.js → timeline-definition-EJHVYXUP-BLgviPCi.js} +1 -1
- package/packages/web/dist/assets/{usecaseDiagram-POWQR4AR-B2j5iteO.js → usecaseDiagram-POWQR4AR-CV7U5Y4h.js} +1 -1
- package/packages/web/dist/assets/{vennDiagram-UO4OBE2U-BzxtZ-_2.js → vennDiagram-UO4OBE2U-C8OA0JqM.js} +1 -1
- package/packages/web/dist/assets/{wardleyDiagram-VNRHLVJA-DL7YbMpY.js → wardleyDiagram-VNRHLVJA-F55WtNqt.js} +1 -1
- package/packages/web/dist/assets/{xychartDiagram-PMCCYNJV-CisgP1cT.js → xychartDiagram-PMCCYNJV-C93Bzul9.js} +1 -1
- package/packages/web/dist/index.html +2 -2
- package/packages/web/package.json +1 -1
- package/packages/web/dist/assets/channel-egZxcyUK.js +0 -1
- package/packages/web/dist/assets/index-Cw2Opmx7.js +0 -648
- package/packages/web/dist/assets/index-j0zBRCgT.css +0 -32
- package/packages/web/dist/assets/scene-D4LPicHk.js +0 -4620
- package/packages/web/dist/assets/swimlanesDiagram-TC7HE7FX-9wdzGXU-.js +0 -8
|
@@ -0,0 +1,1109 @@
|
|
|
1
|
+
import { ASSISTANT_MEMORY_OWNER, } from '../types.js';
|
|
2
|
+
import { admit } from './dream/admission.js';
|
|
3
|
+
import { proposeCandidates, withIncumbent } from './dream/candidate.js';
|
|
4
|
+
import { DEFAULT_SPLIT_RATES, agreementReport, renderEvidenceDigest, selectOnTraining, splitPool, } from './dream/evaluate.js';
|
|
5
|
+
import { gainFrom, correctionLabels, mergeLabels } from './dream/label.js';
|
|
6
|
+
import { measure } from './dream/measure.js';
|
|
7
|
+
import { factoryPolicy, resolvePolicy } from './dream/policy.js';
|
|
8
|
+
import { buildGrid, runGridProbe } from './dream/probe.js';
|
|
9
|
+
import { applyPromotion, freezeFor, freezeReasonFor, promotionDecision, renderRationale, } from './dream/promote.js';
|
|
10
|
+
import { NIGHT_PHASES, yieldRates } from './dream/slots.js';
|
|
11
|
+
import { clampCount } from './sleep-limits.js';
|
|
12
|
+
import { liftPolicy, paramsOf, policyFromParams } from './sleep-policy.js';
|
|
13
|
+
import { aggregateCases, coverageOf, promptedOf } from './sleep-frames.js';
|
|
14
|
+
import { describeWakeTest, plural } from './sleep-report.js';
|
|
15
|
+
/** Frames one night reads: the pool `framesFor` walks, oldest first. */
|
|
16
|
+
const DREAM_POOL_LIMIT = 500;
|
|
17
|
+
/** Ids per label read: SQLite takes at most 999 bound parameters. */
|
|
18
|
+
const LABEL_BATCH = 200;
|
|
19
|
+
/** How deep into the version history a proposal may still be offered from. */
|
|
20
|
+
const PROPOSAL_WINDOW = 50;
|
|
21
|
+
/**
|
|
22
|
+
* How long one night lasts for the run-global model-call ceiling. With
|
|
23
|
+
* `sleep.scope: 'all'` the runtime runs the due banks sequentially in one
|
|
24
|
+
* loop, so they all draw on one wallet; half a day opens a new one.
|
|
25
|
+
*/
|
|
26
|
+
const DREAM_NIGHT_WINDOW_MS = 12 * 60 * 60 * 1000;
|
|
27
|
+
/**
|
|
28
|
+
* The dream's half of a night: measure the retrieval policy, write the
|
|
29
|
+
* labels the measurement stands on, propose candidates for the night after,
|
|
30
|
+
* and - when every condition holds - put a better one in force. Everything
|
|
31
|
+
* here is model-free except the candidate writer, which is why the night can
|
|
32
|
+
* run it above the provider guard.
|
|
33
|
+
*/
|
|
34
|
+
export class DreamPhase {
|
|
35
|
+
#store;
|
|
36
|
+
#config;
|
|
37
|
+
#log;
|
|
38
|
+
#onPromotion;
|
|
39
|
+
/**
|
|
40
|
+
* The run-global dream wallet (concept 9.4). With `sleep.scope: 'all'` the
|
|
41
|
+
* runtime runs one night per owner, sequentially, in one loop - so a
|
|
42
|
+
* per-run ceiling would multiply the candidate calls by the number of
|
|
43
|
+
* banks. This counter spans those runs: a window opens with the first
|
|
44
|
+
* budget query of a night and closes `DREAM_NIGHT_WINDOW_MS` after it
|
|
45
|
+
* opened, which is what "one night" means for a process that has no
|
|
46
|
+
* calendar.
|
|
47
|
+
*/
|
|
48
|
+
#wallet = { since: 0, spent: 0 };
|
|
49
|
+
constructor(options) {
|
|
50
|
+
this.#store = options.store;
|
|
51
|
+
this.#config = options.config;
|
|
52
|
+
this.#log = options.logger;
|
|
53
|
+
this.#onPromotion = options.onPromotion;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The probe, then - when `dream.slots` carries it - the recall slot. One
|
|
57
|
+
* catch around the whole of it: a dream that throws costs the night its
|
|
58
|
+
* measurement, never its consolidation (10.5: a degraded path is never
|
|
59
|
+
* turned into an error). What the probe already reported is kept.
|
|
60
|
+
*/
|
|
61
|
+
async measure(sitting) {
|
|
62
|
+
const dream = this.#config.memory.dream;
|
|
63
|
+
let report = '';
|
|
64
|
+
try {
|
|
65
|
+
report += this.#probe(sitting);
|
|
66
|
+
// `dream.slots` is what the night CARRIES (9.3, S18). `recall` is the
|
|
67
|
+
// one slot this stage has a promotion path for; `budget` and `retry`
|
|
68
|
+
// are measured after the cycles and carried by nobody yet.
|
|
69
|
+
if (dream.slots.includes('recall'))
|
|
70
|
+
report += await this.#recallSlot(sitting);
|
|
71
|
+
}
|
|
72
|
+
catch (cause) {
|
|
73
|
+
const message = cause.message;
|
|
74
|
+
this.#log.warn('The dream phase failed', { owner: sitting.owner, error: message });
|
|
75
|
+
report += ' The dream phase failed: ' + message + '.';
|
|
76
|
+
}
|
|
77
|
+
return report;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The grid probe (stage 1): the declared placements, scored against each
|
|
81
|
+
* frame's own incumbent. Unchanged by stage 2 on purpose - it takes ONE
|
|
82
|
+
* gain function for a whole pool, and a gain is a statement about one
|
|
83
|
+
* turn, so a label-derived gain handed in here would let a memory proven
|
|
84
|
+
* relevant in one turn score in every other. The labelled measurement is
|
|
85
|
+
* `#recallSlot` below, which carries a gain per turn.
|
|
86
|
+
*/
|
|
87
|
+
#probe({ owner, runId, counters, deadline, signal }) {
|
|
88
|
+
const dream = this.#config.memory.dream;
|
|
89
|
+
// The night's deadline, not a second one computed from the same key.
|
|
90
|
+
// Without this the probe could spend the whole of `dream.maxEvalMs` and
|
|
91
|
+
// `#recallSlot` would start already past its own - every evaluation
|
|
92
|
+
// invalid, no row written, and last night's proposals retired for a
|
|
93
|
+
// measurement that never happened (concept 6.1).
|
|
94
|
+
const probe = runGridProbe(this.#store, this.#config, owner, runId, signal, {
|
|
95
|
+
deadline,
|
|
96
|
+
});
|
|
97
|
+
counters.dreamTracesSeen = probe.tracesSeen;
|
|
98
|
+
counters.dreamFramesScored = probe.framesScored;
|
|
99
|
+
let report = '';
|
|
100
|
+
if (probe.invalidated > 0) {
|
|
101
|
+
// Concept 3.3: frames older than a reindex or bulk import are declared
|
|
102
|
+
// invalid outright, and the night report says so instead of letting
|
|
103
|
+
// every following night guess at it as corpus drift.
|
|
104
|
+
const since = probe.invalidatedAt
|
|
105
|
+
? new Date(probe.invalidatedAt).toISOString()
|
|
106
|
+
: 'an unknown import';
|
|
107
|
+
report +=
|
|
108
|
+
' ' + probe.invalidated + ' of ' + probe.frames +
|
|
109
|
+
' dream frames unusable since the import/reindex at ' + since + '.';
|
|
110
|
+
}
|
|
111
|
+
if (probe.poolTruncated) {
|
|
112
|
+
// The pool walks the oldest frames first, so above the cap it is the
|
|
113
|
+
// NEWEST frames that fall out of the measurement - a smaller pool must
|
|
114
|
+
// be reported, not passed off as the whole one.
|
|
115
|
+
report +=
|
|
116
|
+
' The dream probe read the ' + probe.frames + ' oldest of ' +
|
|
117
|
+
probe.framesTotal + ' stored dream frames.';
|
|
118
|
+
}
|
|
119
|
+
// R18: the probe is model-free, and the run-global ceiling is what
|
|
120
|
+
// certifies it. A probe that ever exceeds it has stopped being the
|
|
121
|
+
// probe, and the night should say so rather than shrug.
|
|
122
|
+
const ceiling = Math.max(0, Math.round(dream.maxCallsPerNight));
|
|
123
|
+
if (probe.modelCalls > ceiling) {
|
|
124
|
+
this.#log.warn('Dream probe exceeded dream.maxCallsPerNight', {
|
|
125
|
+
owner,
|
|
126
|
+
calls: probe.modelCalls,
|
|
127
|
+
ceiling,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
this.#log.info('Dream probe measured', {
|
|
131
|
+
owner,
|
|
132
|
+
tracesSeen: probe.tracesSeen,
|
|
133
|
+
frames: probe.frames,
|
|
134
|
+
framesTotal: probe.framesTotal,
|
|
135
|
+
poolTruncated: probe.poolTruncated,
|
|
136
|
+
framesScored: probe.framesScored,
|
|
137
|
+
evalMs: probe.evalMs,
|
|
138
|
+
modelCalls: probe.modelCalls,
|
|
139
|
+
deadlineHit: probe.deadlineHit,
|
|
140
|
+
error: probe.error ?? undefined,
|
|
141
|
+
});
|
|
142
|
+
return report;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The `recall` slot, end to end: candidates, admission, selection, the
|
|
146
|
+
* three sensors, the freeze and the gate.
|
|
147
|
+
*
|
|
148
|
+
* The order is the contract and it is not taste:
|
|
149
|
+
*
|
|
150
|
+
* 1. The candidates - last night's proposals and tonight's declared
|
|
151
|
+
* grid, the incumbent first (E2/6.3).
|
|
152
|
+
* 2. Admission BEFORE the measurement (S17/10.1). Every mechanism in the
|
|
153
|
+
* gaming table is a legal point inside the box, so a comparison on
|
|
154
|
+
* the score cannot catch one; what catches it is a predicate about
|
|
155
|
+
* the candidate's shape, decided without touching a score.
|
|
156
|
+
* 3. Selection on the training half, exactly one candidate on the
|
|
157
|
+
* holdout, the frozen audit set opened only when a promotion is
|
|
158
|
+
* actually on the table (E4/S12/S13).
|
|
159
|
+
* 4. The label agreement sensor over the pool's labels, `user`
|
|
160
|
+
* privileged (5.5b).
|
|
161
|
+
* 5. The wake test on what is already in force (5.5c), then the freeze,
|
|
162
|
+
* then the gate - so tonight's regression alarm blocks tonight's
|
|
163
|
+
* promotion rather than the one after it.
|
|
164
|
+
*/
|
|
165
|
+
async #recallSlot(sitting) {
|
|
166
|
+
const { owner, runId } = sitting;
|
|
167
|
+
// The NEWEST frames, not the oldest. Everything below means the frames
|
|
168
|
+
// nearest to now - the box of the last one, the wake test's "since the
|
|
169
|
+
// last promotion" filter, the admission sample's trailing slice - and an
|
|
170
|
+
// owner holding more frames than the cap would otherwise pin all three
|
|
171
|
+
// to a weeks-old slice for good, silently (S3).
|
|
172
|
+
const pool = this.#store.framesFor(owner, { limit: DREAM_POOL_LIMIT, newest: true });
|
|
173
|
+
// A night never scores its own writes.
|
|
174
|
+
const entries = pool.filter((entry) => entry.trace.sleepRunId !== runId);
|
|
175
|
+
if (!entries.length)
|
|
176
|
+
return this.#evidenceNote(owner, entries);
|
|
177
|
+
let report = this.#truncationNote(owner, pool.length);
|
|
178
|
+
const frame = this.#openSlotFrame(sitting, entries);
|
|
179
|
+
const offer = this.#offerCandidates(frame);
|
|
180
|
+
const admission = this.#admitOffered(frame, offer);
|
|
181
|
+
const measured = this.#measureRecall(frame, offer, admission);
|
|
182
|
+
report += this.#wakeAndFreeze(frame, measured);
|
|
183
|
+
report += await this.#decideRecall(frame, measured);
|
|
184
|
+
// A night that read no evaluation says why instead of staying silent: an
|
|
185
|
+
// empty pool and a pool the gate never opens look the same from outside.
|
|
186
|
+
if (!measured.selection.holdout)
|
|
187
|
+
report += this.#evidenceNote(owner, entries);
|
|
188
|
+
report += this.#retireMeasured(offer, admission, measured.selection);
|
|
189
|
+
return report;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Disclosed the way the probe discloses its own cut: a measurement over
|
|
193
|
+
* part of the store must be visible as one, never pass for the whole of it.
|
|
194
|
+
*/
|
|
195
|
+
#truncationNote(owner, poolSize) {
|
|
196
|
+
const framesTotal = this.#store.dreamFrameCount(owner);
|
|
197
|
+
if (framesTotal <= poolSize)
|
|
198
|
+
return '';
|
|
199
|
+
return ' The recall slot measured the ' + poolSize + ' newest of ' + framesTotal + ' stored dream frames.';
|
|
200
|
+
}
|
|
201
|
+
#openSlotFrame(sitting, entries) {
|
|
202
|
+
const slot = 'recall';
|
|
203
|
+
const incumbent = resolvePolicy(this.#store, this.#config, sitting.owner, slot);
|
|
204
|
+
// The box of the newest frame in the pool. The recorder derives it from
|
|
205
|
+
// the policy in force, so every frame recorded under one policy carries
|
|
206
|
+
// the same one; a candidate that leaves an older frame's box costs that
|
|
207
|
+
// frame an abstention (`limit-out-of-box`), counted like every other.
|
|
208
|
+
const box = entries[entries.length - 1].frame.box;
|
|
209
|
+
// The frozen audit set is touched exactly once per promotion and serves
|
|
210
|
+
// neither for selection nor as a holdout (5.5d). `selectOnTraining`
|
|
211
|
+
// splits the pool itself, so every OTHER reader of the pool has to keep
|
|
212
|
+
// the audit sessions out on its own: the admission predicate reads the
|
|
213
|
+
// training half, exactly as the candidate writer does, and the wake test
|
|
214
|
+
// reads everything but the audit.
|
|
215
|
+
const split = splitPool(entries, DEFAULT_SPLIT_RATES);
|
|
216
|
+
const audited = new Set(split.audit);
|
|
217
|
+
const awake = entries.filter((entry) => !audited.has(entry));
|
|
218
|
+
return { ...sitting, slot, incumbent, box, entries, split, awake };
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Last night's proposals and tonight's declared grid, the incumbent first
|
|
222
|
+
* and a repeated point dropped: every delta is then paired against a
|
|
223
|
+
* number measured tonight, on tonight's frames, never against a number
|
|
224
|
+
* from yesterday (E2).
|
|
225
|
+
*/
|
|
226
|
+
#offerCandidates({ owner, slot, incumbent, box }) {
|
|
227
|
+
const dream = this.#config.memory.dream;
|
|
228
|
+
const proposals = this.#proposals(owner, slot, incumbent, dream.candidates);
|
|
229
|
+
const versionOf = new Map(proposals.map((entry) => [entry.policy, entry.version]));
|
|
230
|
+
const grid = buildGrid(incumbent, box, dream.gridSize).map((placement) => liftPolicy(placement, incumbent));
|
|
231
|
+
const offered = withIncumbent([...proposals.map((entry) => entry.policy), ...grid], incumbent);
|
|
232
|
+
return { proposals, versionOf, offered };
|
|
233
|
+
}
|
|
234
|
+
/** Admission, before the measurement. */
|
|
235
|
+
#admitOffered({ owner, incumbent, box, split, deadline, signal }, { proposals, versionOf, offered }) {
|
|
236
|
+
const admissions = new Map();
|
|
237
|
+
const admitted = [offered[0]];
|
|
238
|
+
// Which admitted position carries which proposal, and which proposals
|
|
239
|
+
// the night has reached a verdict on. Only a settled proposal is retired
|
|
240
|
+
// at the end; one that was never measured is carried over (7).
|
|
241
|
+
const proposalAt = new Map();
|
|
242
|
+
const settled = new Set();
|
|
243
|
+
const onOffer = new Set(offered);
|
|
244
|
+
for (const entry of proposals) {
|
|
245
|
+
// Dropped as a duplicate of a point already on offer - the incumbent's
|
|
246
|
+
// own, usually (E2). There is nothing to measure about it tonight or
|
|
247
|
+
// any other night, so it is spent rather than carried forever.
|
|
248
|
+
if (!onOffer.has(entry.policy))
|
|
249
|
+
settled.add(entry.version.id);
|
|
250
|
+
}
|
|
251
|
+
const incumbentCoverage = coverageOf(split.train, incumbent, deadline, signal);
|
|
252
|
+
let refused = 0;
|
|
253
|
+
for (let index = 1; index < offered.length; index += 1) {
|
|
254
|
+
const candidate = offered[index];
|
|
255
|
+
const verdict = admit(candidate, incumbent, box, {
|
|
256
|
+
coverage: {
|
|
257
|
+
candidate: coverageOf(split.train, candidate, deadline, signal),
|
|
258
|
+
incumbent: incumbentCoverage,
|
|
259
|
+
},
|
|
260
|
+
// H3: only the write gate's reinforcement branch ever un-parks a
|
|
261
|
+
// memory, and this stage ships no `gate` slot - so neither arm
|
|
262
|
+
// revives anything. Two measured zeroes, not a waived predicate.
|
|
263
|
+
revivalRate: { candidate: 0, incumbent: 0 },
|
|
264
|
+
});
|
|
265
|
+
const version = versionOf.get(candidate);
|
|
266
|
+
if (!verdict.ok) {
|
|
267
|
+
refused += 1;
|
|
268
|
+
// A refusal is a decision about the candidate's SHAPE, taken without
|
|
269
|
+
// a score, so it comes out the same tomorrow and every night after:
|
|
270
|
+
// the proposal is spent. Carrying it over would block the quota for
|
|
271
|
+
// good rather than give it another chance.
|
|
272
|
+
if (version)
|
|
273
|
+
settled.add(version.id);
|
|
274
|
+
this.#log.debug('A dream candidate was refused admission', {
|
|
275
|
+
owner,
|
|
276
|
+
findings: verdict.findings.join(','),
|
|
277
|
+
});
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
// Keyed by the position the candidate takes in `admitted`, which is
|
|
281
|
+
// the index `selectOnTraining` reports back on the chosen one.
|
|
282
|
+
if (version)
|
|
283
|
+
proposalAt.set(admitted.length, version);
|
|
284
|
+
admissions.set(admitted.length, verdict);
|
|
285
|
+
admitted.push(candidate);
|
|
286
|
+
}
|
|
287
|
+
return { admitted, admissions, proposalAt, settled, refused };
|
|
288
|
+
}
|
|
289
|
+
/** Selection on the training half, then the label agreement sensor. */
|
|
290
|
+
#measureRecall(frame, offer, admission) {
|
|
291
|
+
const { owner, slot, incumbent, entries, deadline, signal } = frame;
|
|
292
|
+
const dream = this.#config.memory.dream;
|
|
293
|
+
const selection = selectOnTraining(this.#store, {
|
|
294
|
+
owner,
|
|
295
|
+
slot,
|
|
296
|
+
config: this.#config,
|
|
297
|
+
entries,
|
|
298
|
+
incumbent,
|
|
299
|
+
// The frozen audit set is scored against the set the product shipped
|
|
300
|
+
// with, never against last night's winner (10.2, condition 2b).
|
|
301
|
+
factory: factoryPolicy(),
|
|
302
|
+
candidates: admission.admitted,
|
|
303
|
+
// Tonight's fingerprint, as the probe above just stamped it: a frame
|
|
304
|
+
// whose corpus has moved abstains instead of being scored (5.4).
|
|
305
|
+
corpus: this.#store.currentCorpusStamp(owner),
|
|
306
|
+
freshness: true,
|
|
307
|
+
sourceDeltas: true,
|
|
308
|
+
deadline,
|
|
309
|
+
signal,
|
|
310
|
+
});
|
|
311
|
+
const agreement = agreementReport(this.#labelsFor(entries, owner), {
|
|
312
|
+
floor: dream.agreementFloor,
|
|
313
|
+
margin: dream.margin,
|
|
314
|
+
deltaBySource: selection.holdout?.detail?.deltaBySource,
|
|
315
|
+
requireUserLabels: dream.requireUserLabels,
|
|
316
|
+
});
|
|
317
|
+
this.#log.info('The dream measured the recall slot', {
|
|
318
|
+
owner,
|
|
319
|
+
split: selection.split,
|
|
320
|
+
offered: offer.offered.length,
|
|
321
|
+
admitted: admission.admitted.length - 1,
|
|
322
|
+
refused: admission.refused,
|
|
323
|
+
findings: selection.findings.join(','),
|
|
324
|
+
delta: selection.holdout?.delta,
|
|
325
|
+
ciLow: selection.holdout?.ciLow,
|
|
326
|
+
valid: selection.holdout?.valid,
|
|
327
|
+
violations: selection.holdout?.violations.join(','),
|
|
328
|
+
agreement: agreement.findings.join(','),
|
|
329
|
+
});
|
|
330
|
+
return { selection, agreement, admissions: admission.admissions };
|
|
331
|
+
}
|
|
332
|
+
/** The wake test on what is already in force, then the freeze it may call for. */
|
|
333
|
+
#wakeAndFreeze({ owner, slot, incumbent, awake, deadline, signal }, { selection, agreement }) {
|
|
334
|
+
const wake = this.#wakeTest(owner, slot, awake, incumbent, deadline, signal);
|
|
335
|
+
const report = wake ? describeWakeTest(wake) : '';
|
|
336
|
+
return report + this.#freeze(owner, slot, wake, selection.holdout, agreement);
|
|
337
|
+
}
|
|
338
|
+
/** The gate: promote the chosen candidate, or record that it was measured and kept out. */
|
|
339
|
+
async #decideRecall(frame, { selection, agreement, admissions }) {
|
|
340
|
+
const { owner, slot, incumbent, counters } = frame;
|
|
341
|
+
const { holdout, audit, chosen } = selection;
|
|
342
|
+
const params = chosen ? paramsOf(chosen.policy, incumbent) : {};
|
|
343
|
+
const decision = promotionDecision({
|
|
344
|
+
config: this.#config,
|
|
345
|
+
holdout,
|
|
346
|
+
audit,
|
|
347
|
+
// Exactly one candidate reaches the holdout, or none did (E4/S12).
|
|
348
|
+
holdoutChecks: holdout ? 1 : 0,
|
|
349
|
+
agreement,
|
|
350
|
+
admission: chosen ? admissions.get(chosen.index) ?? null : null,
|
|
351
|
+
// Read after the freeze above, so a slot frozen tonight blocks
|
|
352
|
+
// tonight's promotion (condition 7a).
|
|
353
|
+
slotState: this.#store.slotState(owner, slot),
|
|
354
|
+
lastTraceSetHash: this.#store.lastPromotedTraceSetHash(owner, slot),
|
|
355
|
+
incumbentOrigin: incumbent.origin,
|
|
356
|
+
params,
|
|
357
|
+
// Stage 2 promotes for the assistant alone, so the night's own count
|
|
358
|
+
// is the count across every slot (condition 8).
|
|
359
|
+
promotionsTonight: counters.dreamPromoted,
|
|
360
|
+
});
|
|
361
|
+
let report = '';
|
|
362
|
+
if (holdout && chosen && decision.promote) {
|
|
363
|
+
report = await this.#putInForce(frame, { holdout, audit, params });
|
|
364
|
+
}
|
|
365
|
+
else if (holdout && chosen) {
|
|
366
|
+
report = this.#recordMeasured(frame, { holdout, audit, params }, decision.blockers);
|
|
367
|
+
}
|
|
368
|
+
this.#log.info('The dream gate answered', {
|
|
369
|
+
owner,
|
|
370
|
+
slot,
|
|
371
|
+
promote: decision.promote,
|
|
372
|
+
blockers: decision.blockers.join(','),
|
|
373
|
+
});
|
|
374
|
+
return report;
|
|
375
|
+
}
|
|
376
|
+
async #putInForce({ owner, slot, runId, counters, box }, { holdout, audit, params }) {
|
|
377
|
+
const record = applyPromotion(this.#store, {
|
|
378
|
+
owner,
|
|
379
|
+
slot,
|
|
380
|
+
sleepRunId: runId,
|
|
381
|
+
config: this.#config,
|
|
382
|
+
params,
|
|
383
|
+
box: box,
|
|
384
|
+
holdout,
|
|
385
|
+
audit,
|
|
386
|
+
});
|
|
387
|
+
counters.dreamPromoted += record.promoted;
|
|
388
|
+
await this.#announcePromotion({
|
|
389
|
+
owner,
|
|
390
|
+
slot,
|
|
391
|
+
runId,
|
|
392
|
+
version: record.version,
|
|
393
|
+
evaluation: record.evaluation,
|
|
394
|
+
prevActiveId: record.prevActiveId,
|
|
395
|
+
rationale: record.version.rationale ?? renderRationale(holdout, audit),
|
|
396
|
+
cooldownUntil: record.cooldownUntil,
|
|
397
|
+
});
|
|
398
|
+
return (' A new ' + slot + ' policy is in force (version ' + record.version.version + '): ' +
|
|
399
|
+
record.version.rationale + '. It can be taken back.');
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* A night that measures and does not promote is the common case, and the
|
|
403
|
+
* record of it is what the next calibration stands on. The evaluation row
|
|
404
|
+
* needs a version to hang off - `dream_evals.policy_id` is a foreign key -
|
|
405
|
+
* so the candidate becomes an unpromoted version carrying its own replay
|
|
406
|
+
* numbers, which is also what keeps it from coming back tomorrow as an
|
|
407
|
+
* unmeasured proposal.
|
|
408
|
+
*/
|
|
409
|
+
#recordMeasured({ owner, slot, runId, box }, { holdout, audit, params }, blockers) {
|
|
410
|
+
const version = this.#store.createPolicyVersion({
|
|
411
|
+
owner,
|
|
412
|
+
slot,
|
|
413
|
+
params,
|
|
414
|
+
box: box,
|
|
415
|
+
origin: 'dream',
|
|
416
|
+
parentId: this.#store.activePolicy(owner, slot)?.id,
|
|
417
|
+
sleepRunId: runId,
|
|
418
|
+
rationale: renderRationale(holdout, audit),
|
|
419
|
+
replayScore: holdout.score,
|
|
420
|
+
replayN: holdout.closed,
|
|
421
|
+
baselineScore: holdout.baseline,
|
|
422
|
+
auditDelta: audit?.delta ?? holdout.auditDelta,
|
|
423
|
+
auditCiLow: audit?.ciLow ?? holdout.auditCiLow,
|
|
424
|
+
});
|
|
425
|
+
this.#recordEval(holdout, version.id, runId, false);
|
|
426
|
+
// Only worth a sentence when promoting is switched on at all -
|
|
427
|
+
// otherwise every night would end with the same blocker.
|
|
428
|
+
if (!this.#config.memory.dream.promote)
|
|
429
|
+
return '';
|
|
430
|
+
return ' A ' + slot + ' candidate was measured and not promoted: ' + blockers.join(', ') + '.';
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* A proposal is offered exactly once - once it has been MEASURED.
|
|
434
|
+
* Measured means a number exists for it: its training evaluation closed
|
|
435
|
+
* at least one trace. A night that ran out of wall clock, or aborted, or
|
|
436
|
+
* stood on a pool that closed nothing, measured none of them, and
|
|
437
|
+
* retiring them for it would burn `dream.maxCallsPerNight` every night
|
|
438
|
+
* forever on proposals that never got a number (7). What was measured,
|
|
439
|
+
* or refused on its shape, is spent; the rest is carried over.
|
|
440
|
+
*/
|
|
441
|
+
#retireMeasured({ proposals }, { settled, proposalAt }, selection) {
|
|
442
|
+
const spent = new Set(settled);
|
|
443
|
+
for (const ranked of selection.ranked) {
|
|
444
|
+
if (ranked.training.closed <= 0)
|
|
445
|
+
continue;
|
|
446
|
+
const version = proposalAt.get(ranked.index);
|
|
447
|
+
if (version)
|
|
448
|
+
spent.add(version.id);
|
|
449
|
+
}
|
|
450
|
+
let retired = 0;
|
|
451
|
+
for (const entry of proposals) {
|
|
452
|
+
if (!spent.has(entry.version.id))
|
|
453
|
+
continue;
|
|
454
|
+
this.#store.retirePolicyVersion(entry.version.id);
|
|
455
|
+
retired += 1;
|
|
456
|
+
}
|
|
457
|
+
const carried = proposals.length - retired;
|
|
458
|
+
if (carried <= 0)
|
|
459
|
+
return '';
|
|
460
|
+
return (' ' + plural(carried, 'proposal was', 'proposals were') +
|
|
461
|
+
' carried over to the next night: nothing measured ' +
|
|
462
|
+
(carried === 1 ? 'it' : 'them') + ' tonight.');
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* One sentence on what the dream has to work with: how many frames, from
|
|
466
|
+
* how many sessions, how they split, what an evaluation needs, and how many
|
|
467
|
+
* recent turns were recorded without a frame at all (the recorder refused
|
|
468
|
+
* them, or a delete took the frame). The first answer to "why does nothing
|
|
469
|
+
* happen".
|
|
470
|
+
*/
|
|
471
|
+
#evidenceNote(owner, entries) {
|
|
472
|
+
const dream = this.#config.memory.dream;
|
|
473
|
+
const sessions = new Set(entries.map((entry) => entry.trace.sessionId)).size;
|
|
474
|
+
const split = splitPool(entries, DEFAULT_SPLIT_RATES);
|
|
475
|
+
const frameless = this.#store.countFramelessTraces(owner, Date.now() - DREAM_NIGHT_WINDOW_MS);
|
|
476
|
+
return (' Dream evidence: ' + plural(entries.length, 'frame', 'frames') + ' from ' +
|
|
477
|
+
plural(sessions, 'session', 'sessions') + ' (train ' + split.train.length + ', holdout ' +
|
|
478
|
+
split.holdout.length + ', audit ' + split.audit.length + '); an evaluation needs ' +
|
|
479
|
+
dream.minTraces + ' closed traces.' +
|
|
480
|
+
(frameless > 0
|
|
481
|
+
? ' ' + plural(frameless, 'turn', 'turns') + ' of the last day had no frame.'
|
|
482
|
+
: ''));
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* The wake test (concept 5.5c): after `dream.calibrationTraces` traces,
|
|
486
|
+
* how far the live score has moved from what the promotion promised.
|
|
487
|
+
*
|
|
488
|
+
* It is a **regression alarm, not a calibration**, and the report says so.
|
|
489
|
+
* The replay value and the live value come out of the same estimator and
|
|
490
|
+
* the same labels, so if the labels are wrong the two agree with each
|
|
491
|
+
* other and both are wrong together. What this catches is the trace
|
|
492
|
+
* distribution shifting after a promotion - that, and nothing more.
|
|
493
|
+
*
|
|
494
|
+
* The arm is the policy in force, which `resolvePolicy` has already laid
|
|
495
|
+
* the promoted parameters into, and it is measured frame by frame with
|
|
496
|
+
* `measure` - the same estimator and the same per-turn gains the holdout
|
|
497
|
+
* used, which is the whole basis of the comparison. Deliberately NOT
|
|
498
|
+
* through `evaluateCandidate`: that machinery is paired, and an arm
|
|
499
|
+
* scored against itself moves nothing on any trace, so every one of them
|
|
500
|
+
* would drop out as `no-labelled-move` and the pool would close empty.
|
|
501
|
+
*
|
|
502
|
+
* What it is allowed to conclude anything from is the frames that CLOSED.
|
|
503
|
+
* `dream.calibrationTraces` decides when the test is due - that many
|
|
504
|
+
* frames since the promotion have to exist at all - and then decides again
|
|
505
|
+
* whether the pool it actually read is thick enough to read a verdict off.
|
|
506
|
+
* The abstentions in between are counted by reason and reported, because
|
|
507
|
+
* they are the finding when they dominate: the alternative, a verdict off
|
|
508
|
+
* one trace out of fifty, freezes a slot until somebody thaws it by hand
|
|
509
|
+
* (5.4, 10.3).
|
|
510
|
+
*/
|
|
511
|
+
#wakeTest(owner, slot, entries, arm, deadline, signal) {
|
|
512
|
+
const dream = this.#config.memory.dream;
|
|
513
|
+
const active = this.#store.activePolicy(owner, slot);
|
|
514
|
+
// Nothing has been promoted, or the promotion carries no promise to
|
|
515
|
+
// compare against: there is no regression to alarm about.
|
|
516
|
+
if (!active?.promotedAt || active.replayScore === undefined)
|
|
517
|
+
return null;
|
|
518
|
+
const promotedAt = active.promotedAt;
|
|
519
|
+
const required = clampCount(dream.calibrationTraces);
|
|
520
|
+
const fresh = entries.filter((entry) => entry.frame.createdAt >= promotedAt);
|
|
521
|
+
// Not due yet. Fewer frames exist since the promotion than the floor
|
|
522
|
+
// asks for, so no pool could clear it and there is nothing to say.
|
|
523
|
+
if (fresh.length < required)
|
|
524
|
+
return null;
|
|
525
|
+
const costWeight = Math.min(1, Math.max(0, dream.costWeight));
|
|
526
|
+
const gainFor = this.#gainsFor(fresh, owner);
|
|
527
|
+
const reasons = {};
|
|
528
|
+
let total = 0;
|
|
529
|
+
let closed = 0;
|
|
530
|
+
let abstained = 0;
|
|
531
|
+
for (const entry of fresh) {
|
|
532
|
+
if (signal.aborted || Date.now() > deadline)
|
|
533
|
+
break;
|
|
534
|
+
const result = measure(entry.frame.payload, arm, gainFor(entry.trace.turnId), costWeight);
|
|
535
|
+
// An abstention is not a low score; it is the absence of one - and a
|
|
536
|
+
// counted quantity with a name (5.4), never a frame that drops out of
|
|
537
|
+
// the pool unnoticed.
|
|
538
|
+
if (!result.ok) {
|
|
539
|
+
abstained += 1;
|
|
540
|
+
reasons[result.abstain] = (reasons[result.abstain] ?? 0) + 1;
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
total += result.score;
|
|
544
|
+
closed += 1;
|
|
545
|
+
}
|
|
546
|
+
const seen = {
|
|
547
|
+
offered: fresh.length,
|
|
548
|
+
closed,
|
|
549
|
+
abstained,
|
|
550
|
+
reasons,
|
|
551
|
+
required,
|
|
552
|
+
promised: active.replayScore,
|
|
553
|
+
};
|
|
554
|
+
// The floor is read against what CLOSED, not against what was offered.
|
|
555
|
+
// Fifty offered frames of which forty-nine abstain carry one trace of
|
|
556
|
+
// noise, and `calibration` is a freeze a person has to undo by hand
|
|
557
|
+
// (10.3): a test that could not close enough frames reports that it
|
|
558
|
+
// could not run, and freezes nothing.
|
|
559
|
+
if (closed < required)
|
|
560
|
+
return { ...seen, drift: null, observed: null };
|
|
561
|
+
const observed = total / closed;
|
|
562
|
+
// The reading itself goes on the version it judges. The drift decides
|
|
563
|
+
// whether the slot freezes tonight; `online_score` is what a person
|
|
564
|
+
// reads next to `replay_score` later - "this is what the promise was
|
|
565
|
+
// worth once it was actually in force" (5.5c). A test that could not
|
|
566
|
+
// close enough frames returned above and writes nothing: an absent
|
|
567
|
+
// reading stays absent rather than being recorded as a bad one.
|
|
568
|
+
this.#store.setPolicyOnlineScore(active.id, observed);
|
|
569
|
+
return { ...seen, drift: observed - active.replayScore, observed };
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Freeze the slot if one of the four causes of 10.3 fired.
|
|
573
|
+
*
|
|
574
|
+
* A frozen slot keeps measuring and stops promoting, which is what makes
|
|
575
|
+
* it readable later: the evaluations written while it was frozen are the
|
|
576
|
+
* evidence a person thaws it on. An already frozen slot keeps the reason
|
|
577
|
+
* it was frozen for - re-stamping tonight's cause over last night's would
|
|
578
|
+
* lose the one thing somebody needs in order to decide.
|
|
579
|
+
*/
|
|
580
|
+
#freeze(owner, slot, wake, holdout, agreement) {
|
|
581
|
+
const state = this.#store.slotState(owner, slot);
|
|
582
|
+
if (state.frozenAt)
|
|
583
|
+
return '';
|
|
584
|
+
const reason = freezeReasonFor({
|
|
585
|
+
// Null where the wake test could not read a verdict: a drift nobody
|
|
586
|
+
// measured freezes nothing (10.3).
|
|
587
|
+
calibrationDrift: wake ? wake.drift : null,
|
|
588
|
+
tolerance: this.#config.memory.dream.tolerance,
|
|
589
|
+
signAgree: holdout?.signAgree ?? null,
|
|
590
|
+
agreement,
|
|
591
|
+
});
|
|
592
|
+
if (!reason)
|
|
593
|
+
return '';
|
|
594
|
+
freezeFor(this.#store, owner, slot, reason);
|
|
595
|
+
this.#log.warn('A dream slot was frozen', { owner, slot, reason });
|
|
596
|
+
return (' The ' + slot + ' slot is frozen (' + reason +
|
|
597
|
+
'): it goes on measuring and stops promoting until somebody thaws it.');
|
|
598
|
+
}
|
|
599
|
+
/** Tell whoever wants to know that a parameter set went in force (S26). */
|
|
600
|
+
async #announcePromotion(notice) {
|
|
601
|
+
this.#log.info('A retrieval policy went in force', {
|
|
602
|
+
owner: notice.owner,
|
|
603
|
+
slot: notice.slot,
|
|
604
|
+
version: notice.version.version,
|
|
605
|
+
policy: notice.version.id,
|
|
606
|
+
previous: notice.prevActiveId,
|
|
607
|
+
run: notice.runId,
|
|
608
|
+
});
|
|
609
|
+
if (!this.#onPromotion)
|
|
610
|
+
return;
|
|
611
|
+
try {
|
|
612
|
+
await this.#onPromotion(notice);
|
|
613
|
+
}
|
|
614
|
+
catch (cause) {
|
|
615
|
+
// Telling somebody is not part of the promotion. A hook that throws
|
|
616
|
+
// costs the message, never the night.
|
|
617
|
+
this.#log.warn('The promotion hook failed', {
|
|
618
|
+
owner: notice.owner,
|
|
619
|
+
error: cause.message,
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* The candidate writer (concept 6.2): one model call per candidate, on
|
|
625
|
+
* `dream.model`, at `dream.effort` - never at `ask`'s wired `'low'`,
|
|
626
|
+
* because designing a parameter set out of failure cases is judgement and
|
|
627
|
+
* not extraction (S16/E14). Its own caller lives in `dream/candidate.ts`
|
|
628
|
+
* for exactly that reason.
|
|
629
|
+
*
|
|
630
|
+
* What it writes are PROPOSALS, not policies: unpromoted `policy_versions`
|
|
631
|
+
* rows that the next night's dream measures, ranks and possibly promotes.
|
|
632
|
+
* That is what keeps the promotion path model-free and above the provider
|
|
633
|
+
* guard - a night without a provider proposes nothing and still promotes
|
|
634
|
+
* what the last one proposed.
|
|
635
|
+
*
|
|
636
|
+
* The wallet is run-global (`dream.maxCallsPerNight` across ALL owners,
|
|
637
|
+
* concept 9.4): with `sleep.scope: 'all'` the runtime runs one night per
|
|
638
|
+
* bank, sequentially, so a per-run ceiling would multiply by the number of
|
|
639
|
+
* banks. The budget arrives already measured; the first line spends
|
|
640
|
+
* nothing if there is none, and there is no abort throw between here and
|
|
641
|
+
* the caller's next one.
|
|
642
|
+
*/
|
|
643
|
+
async propose(scope, budget) {
|
|
644
|
+
const { owner, runId } = scope;
|
|
645
|
+
const { provider, signal } = scope.voice;
|
|
646
|
+
if (budget <= 0 || signal.aborted)
|
|
647
|
+
return { written: 0, calls: 0 };
|
|
648
|
+
const idle = { written: 0, calls: 0 };
|
|
649
|
+
const dream = this.#config.memory.dream;
|
|
650
|
+
if (!dream.enabled || owner !== ASSISTANT_MEMORY_OWNER)
|
|
651
|
+
return idle;
|
|
652
|
+
if (!dream.slots.includes('recall'))
|
|
653
|
+
return idle;
|
|
654
|
+
// The newest frames, for the reason `#recallSlot` gives: a writer that
|
|
655
|
+
// reads the oldest slice of a full store writes candidates for a day
|
|
656
|
+
// weeks gone (S3).
|
|
657
|
+
const entries = this.#store
|
|
658
|
+
.framesFor(owner, { limit: DREAM_POOL_LIMIT, newest: true })
|
|
659
|
+
.filter((entry) => entry.trace.sleepRunId !== runId);
|
|
660
|
+
// The writer reads the TRAINING half and nothing else. A proposal
|
|
661
|
+
// written out of holdout traces is a proposal measured on evidence the
|
|
662
|
+
// search has already seen, and the one interval that will be read would
|
|
663
|
+
// stop being the one interval nobody looked at (E4/6.2).
|
|
664
|
+
const pool = splitPool(entries, DEFAULT_SPLIT_RATES).train;
|
|
665
|
+
if (!pool.length)
|
|
666
|
+
return idle;
|
|
667
|
+
const incumbent = resolvePolicy(this.#store, this.#config, owner, 'recall');
|
|
668
|
+
const box = pool[pool.length - 1].frame.box;
|
|
669
|
+
const aggregates = aggregateCases(pool, this.#gainsFor(pool, owner), incumbent);
|
|
670
|
+
// Nothing went wrong that a parameter set could have fixed, so nothing
|
|
671
|
+
// is asked of a model.
|
|
672
|
+
if (!aggregates.cases)
|
|
673
|
+
return idle;
|
|
674
|
+
const proposal = await proposeCandidates(provider, {
|
|
675
|
+
aggregates,
|
|
676
|
+
box,
|
|
677
|
+
incumbent,
|
|
678
|
+
count: Math.min(Math.max(0, Math.round(dream.candidates)), budget),
|
|
679
|
+
model: dream.model.trim() || undefined,
|
|
680
|
+
effort: dream.effort,
|
|
681
|
+
}, signal);
|
|
682
|
+
const parentId = this.#store.activePolicy(owner, 'recall')?.id;
|
|
683
|
+
for (const candidate of proposal.candidates) {
|
|
684
|
+
this.#store.createPolicyVersion({
|
|
685
|
+
owner,
|
|
686
|
+
slot: 'recall',
|
|
687
|
+
params: paramsOf(candidate, incumbent),
|
|
688
|
+
box: box,
|
|
689
|
+
origin: 'dream',
|
|
690
|
+
parentId,
|
|
691
|
+
sleepRunId: runId,
|
|
692
|
+
// Numbers and this file's vocabulary, never a word out of the frames
|
|
693
|
+
// it was written from: a version row outlives every one of them
|
|
694
|
+
// (E19/S21).
|
|
695
|
+
rationale: 'proposal cases=' + aggregates.cases +
|
|
696
|
+
' scored=' + aggregates.scored +
|
|
697
|
+
' missed=' + aggregates.missedRows.toFixed(2) +
|
|
698
|
+
' budget-cut=' + aggregates.budgetCutShare.toFixed(3) +
|
|
699
|
+
' hop2=' + aggregates.hop2Share.toFixed(3),
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
this.#log.info('The dream wrote candidates', {
|
|
703
|
+
owner,
|
|
704
|
+
cases: aggregates.cases,
|
|
705
|
+
calls: proposal.calls,
|
|
706
|
+
written: proposal.candidates.length,
|
|
707
|
+
failures: proposal.failures,
|
|
708
|
+
rejected: proposal.rejected,
|
|
709
|
+
});
|
|
710
|
+
return { written: proposal.candidates.length, calls: proposal.calls };
|
|
711
|
+
}
|
|
712
|
+
/** `gain(m)` per turn over a pool, read once and folded per turn (4.1). */
|
|
713
|
+
#gainsFor(entries, owner) {
|
|
714
|
+
const byTurn = new Map();
|
|
715
|
+
for (const label of this.#labelsFor(entries, owner)) {
|
|
716
|
+
const bucket = byTurn.get(label.turnId);
|
|
717
|
+
if (bucket)
|
|
718
|
+
bucket.push(label);
|
|
719
|
+
else
|
|
720
|
+
byTurn.set(label.turnId, [label]);
|
|
721
|
+
}
|
|
722
|
+
const cache = new Map();
|
|
723
|
+
return (turnId) => {
|
|
724
|
+
const known = cache.get(turnId);
|
|
725
|
+
if (known)
|
|
726
|
+
return known;
|
|
727
|
+
// `gainFrom` is what refuses a session-wide label and a `review` row a
|
|
728
|
+
// gain, so no caller here has to remember to (S3/S8).
|
|
729
|
+
const gain = gainFrom(byTurn.get(turnId) ?? []).gain;
|
|
730
|
+
cache.set(turnId, gain);
|
|
731
|
+
return gain;
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Every label behind a pool: the turn-scoped ones that can carry a gain,
|
|
736
|
+
* and the session-scoped ones that cannot but still count for the
|
|
737
|
+
* agreement sensor and the coverage rate (4.4/5.5b). Read in batches, so a
|
|
738
|
+
* pool of five hundred frames cannot walk into SQLite's bound-parameter
|
|
739
|
+
* limit, and owner-filtered in SQL the way 10.5 asks.
|
|
740
|
+
*/
|
|
741
|
+
#labelsFor(entries, owner) {
|
|
742
|
+
const turnIds = [...new Set(entries.map((entry) => entry.trace.turnId))];
|
|
743
|
+
const sessionIds = [
|
|
744
|
+
...new Set(entries.map((entry) => entry.trace.sessionId).filter((id) => !!id)),
|
|
745
|
+
];
|
|
746
|
+
const labels = [];
|
|
747
|
+
for (let index = 0; index < turnIds.length; index += LABEL_BATCH) {
|
|
748
|
+
labels.push(...this.#store.labelsForTurns(turnIds.slice(index, index + LABEL_BATCH), owner));
|
|
749
|
+
}
|
|
750
|
+
for (let index = 0; index < sessionIds.length; index += LABEL_BATCH) {
|
|
751
|
+
labels.push(...this.#store.labelsForSessions(sessionIds.slice(index, index + LABEL_BATCH), owner));
|
|
752
|
+
}
|
|
753
|
+
return labels;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* The proposals a previous night wrote and nothing has measured yet.
|
|
757
|
+
*
|
|
758
|
+
* The discriminator is `replayScore`: a version that carries one has had
|
|
759
|
+
* its night, and one that was promoted or retired is not on offer. Nothing
|
|
760
|
+
* else is needed, because a measured candidate gets its replay numbers
|
|
761
|
+
* written onto its row in the same breath as its evaluation.
|
|
762
|
+
*/
|
|
763
|
+
#proposals(owner, slot, incumbent, limit) {
|
|
764
|
+
const wanted = Math.max(0, Math.round(limit));
|
|
765
|
+
if (!wanted)
|
|
766
|
+
return [];
|
|
767
|
+
const out = [];
|
|
768
|
+
for (const version of this.#store.policyHistory(owner, slot, PROPOSAL_WINDOW)) {
|
|
769
|
+
if (version.origin !== 'dream' || version.promotedAt || version.retiredAt)
|
|
770
|
+
continue;
|
|
771
|
+
if (version.replayScore !== undefined)
|
|
772
|
+
continue;
|
|
773
|
+
// A row nobody can read back into a policy point is not a candidate.
|
|
774
|
+
const policy = policyFromParams(version.params, incumbent);
|
|
775
|
+
if (!policy)
|
|
776
|
+
continue;
|
|
777
|
+
out.push({ version, policy });
|
|
778
|
+
if (out.length >= wanted)
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
return out;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* One `dream_evals` row out of one finished evaluation (concept 8.6).
|
|
785
|
+
*
|
|
786
|
+
* Written out field by field rather than spread: `DreamEvalResult` also
|
|
787
|
+
* carries the certificate (`valid`, `violations`, `error`) and the paired
|
|
788
|
+
* counts, and those belong to the decision, not to the row.
|
|
789
|
+
*/
|
|
790
|
+
#recordEval(result, policyId, sleepRunId, promoted) {
|
|
791
|
+
return this.#store.recordDreamEval({
|
|
792
|
+
sleepRunId,
|
|
793
|
+
policyId,
|
|
794
|
+
slot: result.slot,
|
|
795
|
+
traces: result.traces,
|
|
796
|
+
closed: result.closed,
|
|
797
|
+
abstained: result.abstained,
|
|
798
|
+
abstainReasons: result.abstainReasons,
|
|
799
|
+
reachableRate: result.reachableRate,
|
|
800
|
+
labelCoverage: result.labelCoverage,
|
|
801
|
+
costOnlyShare: result.costOnlyShare,
|
|
802
|
+
score: result.score,
|
|
803
|
+
baseline: result.baseline,
|
|
804
|
+
delta: result.delta,
|
|
805
|
+
ciLow: result.ciLow,
|
|
806
|
+
ciHigh: result.ciHigh,
|
|
807
|
+
auditDelta: result.auditDelta,
|
|
808
|
+
auditCiLow: result.auditCiLow,
|
|
809
|
+
deltaLive: result.deltaLive,
|
|
810
|
+
signAgree: result.signAgree,
|
|
811
|
+
evalMs: result.evalMs,
|
|
812
|
+
traceSetHash: result.traceSetHash,
|
|
813
|
+
evidenceDigest: result.evidenceDigest ?? renderEvidenceDigest(result),
|
|
814
|
+
promoted,
|
|
815
|
+
detail: result.detail,
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* From the corrections this replay wrote to the labels they prove
|
|
820
|
+
* (concept 4.2a, step 2).
|
|
821
|
+
*
|
|
822
|
+
* The pass runs once, after every session has been read, because
|
|
823
|
+
* `addCorrection` hands no id back and a label's evidence is the
|
|
824
|
+
* correction's id - so the rows are read back out of the table, which is
|
|
825
|
+
* also where the turn reference the write already put on them lives.
|
|
826
|
+
*
|
|
827
|
+
* Two refusals are built in. A located turn whose frame was never recorded
|
|
828
|
+
* (`dream.frameRate` frames a quarter of the sessions) has no reachable
|
|
829
|
+
* set of its own, so its label goes out session-wide rather than claiming
|
|
830
|
+
* a turn over a union of other turns' rows. And an unlocatable quote is
|
|
831
|
+
* anchored at the session's start, which is no later than any of its turns
|
|
832
|
+
* and therefore the conservative side of the anachronism lock (S4).
|
|
833
|
+
*/
|
|
834
|
+
writeCorrectionLabels(owner, sessions, since) {
|
|
835
|
+
const idle = { labelled: 0, labels: 0, failed: 0 };
|
|
836
|
+
if (!this.#config.memory.dream.enabled || !sessions.length)
|
|
837
|
+
return idle;
|
|
838
|
+
try {
|
|
839
|
+
return this.#correctionLabelPass(owner, sessions, since);
|
|
840
|
+
}
|
|
841
|
+
catch (cause) {
|
|
842
|
+
// The dream never turns a degraded path into an error (10.5). One
|
|
843
|
+
// unreadable frame payload, or a store that refuses the write, used to
|
|
844
|
+
// throw all the way into the night's outer catch - which ends the run
|
|
845
|
+
// failed and skips `recountEntities` AND every retention sweep behind
|
|
846
|
+
// it, so the verbatim frame store outlives its window for exactly the
|
|
847
|
+
// reason the dream must never cause (10.4, 8.7). It costs its labels
|
|
848
|
+
// and nothing else.
|
|
849
|
+
this.#log.warn('Writing correction labels failed', {
|
|
850
|
+
owner,
|
|
851
|
+
error: cause.message,
|
|
852
|
+
});
|
|
853
|
+
return { labelled: 0, labels: 0, failed: 1 };
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
/** The body of `writeCorrectionLabels`, inside its caller's catch. */
|
|
857
|
+
#correctionLabelPass(owner, sessions, since) {
|
|
858
|
+
const idle = { labelled: 0, labels: 0, failed: 0 };
|
|
859
|
+
const rows = this.#store.correctionsSince(owner, since);
|
|
860
|
+
if (!rows.length)
|
|
861
|
+
return idle;
|
|
862
|
+
const bySession = new Map(sessions.map((session) => [session.id, session]));
|
|
863
|
+
const frames = this.#framesBySession(owner, sessions);
|
|
864
|
+
const threshold = this.#config.memory.gate.duplicateThreshold;
|
|
865
|
+
const now = Date.now();
|
|
866
|
+
const labels = [];
|
|
867
|
+
let labelled = 0;
|
|
868
|
+
for (const row of rows) {
|
|
869
|
+
const session = row.sessionId ? bySession.get(row.sessionId) : undefined;
|
|
870
|
+
if (!session)
|
|
871
|
+
continue;
|
|
872
|
+
const pool = frames.get(session.id) ?? [];
|
|
873
|
+
if (!pool.length)
|
|
874
|
+
continue;
|
|
875
|
+
const anchored = row.turnId
|
|
876
|
+
? pool.find((entry) => entry.trace.turnId === row.turnId)
|
|
877
|
+
: undefined;
|
|
878
|
+
const scope = anchored ? [anchored] : pool;
|
|
879
|
+
const reachable = new Map();
|
|
880
|
+
const prompted = new Set();
|
|
881
|
+
for (const entry of scope) {
|
|
882
|
+
for (const record of Object.values(entry.frame.payload.records)) {
|
|
883
|
+
reachable.set(record.id, record);
|
|
884
|
+
}
|
|
885
|
+
for (const id of promptedOf(entry))
|
|
886
|
+
prompted.add(id);
|
|
887
|
+
}
|
|
888
|
+
const made = correctionLabels({
|
|
889
|
+
text: row.text,
|
|
890
|
+
owner,
|
|
891
|
+
sessionId: session.id,
|
|
892
|
+
turn: anchored && row.turnId ? { id: row.turnId, startedAt: anchored.trace.startedAt } : null,
|
|
893
|
+
sessionStartedAt: session.createdAt,
|
|
894
|
+
reachable: [...reachable.values()],
|
|
895
|
+
prompted: [...prompted],
|
|
896
|
+
// The same arithmetic the write gate already owns; passed in,
|
|
897
|
+
// because `label.ts` reads no config.
|
|
898
|
+
duplicateThreshold: threshold,
|
|
899
|
+
evidence: row.id,
|
|
900
|
+
now,
|
|
901
|
+
});
|
|
902
|
+
if (made.length)
|
|
903
|
+
labelled += 1;
|
|
904
|
+
labels.push(...made);
|
|
905
|
+
}
|
|
906
|
+
return { labelled, labels: this.#store.putLabels(labels), failed: 0 };
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* The `merge` labels of one condensation pass (concept 4.2c, S7).
|
|
910
|
+
*
|
|
911
|
+
* The claim is narrow and it only points one way: if two rows stood in ONE
|
|
912
|
+
* prompt and later fell into the same condensation cluster, the
|
|
913
|
+
* worse-placed of the two is proven redundant. Redundant is not
|
|
914
|
+
* "irrelevant to this question", so no positive label can come out of this
|
|
915
|
+
* source and none is written.
|
|
916
|
+
*
|
|
917
|
+
* At most one `supersedes` hop, and it is the map this night filled that
|
|
918
|
+
* enforces it: re-reading `superseded_by` off the bank would pick up
|
|
919
|
+
* chains from earlier nights, and a label that walks that far has stopped
|
|
920
|
+
* describing the prompt it observed. The pre-filter is what keeps this
|
|
921
|
+
* cheap - a frame that never held two of tonight's victims cannot carry a
|
|
922
|
+
* cluster, and replaying it would cost a pipeline run for nothing.
|
|
923
|
+
*/
|
|
924
|
+
writeMergeLabels(owner, superseded) {
|
|
925
|
+
if (!this.#config.memory.dream.enabled || superseded.size < 2) {
|
|
926
|
+
return { labels: 0, failed: 0 };
|
|
927
|
+
}
|
|
928
|
+
try {
|
|
929
|
+
return { labels: this.#mergeLabelPass(owner, superseded), failed: 0 };
|
|
930
|
+
}
|
|
931
|
+
catch (cause) {
|
|
932
|
+
// Its own failure, caught here for the reason `writeCorrectionLabels`
|
|
933
|
+
// gives above: a label is worth a condensation, never a night (10.5).
|
|
934
|
+
this.#log.warn('Writing merge labels failed', {
|
|
935
|
+
owner,
|
|
936
|
+
error: cause.message,
|
|
937
|
+
});
|
|
938
|
+
return { labels: 0, failed: 1 };
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
/** The body of `writeMergeLabels`, inside its caller's catch. */
|
|
942
|
+
#mergeLabelPass(owner, superseded) {
|
|
943
|
+
const now = Date.now();
|
|
944
|
+
const labels = [];
|
|
945
|
+
// The newest frames, like every other reader that means "lately": an
|
|
946
|
+
// owner past the cap would otherwise have its merge labels written only
|
|
947
|
+
// against a slice of frames weeks older than the condensation they
|
|
948
|
+
// describe (S3).
|
|
949
|
+
for (const entry of this.#store.framesFor(owner, { limit: DREAM_POOL_LIMIT, newest: true })) {
|
|
950
|
+
let held = 0;
|
|
951
|
+
for (const id of Object.keys(entry.frame.payload.records)) {
|
|
952
|
+
if (superseded.has(id))
|
|
953
|
+
held += 1;
|
|
954
|
+
}
|
|
955
|
+
if (held < 2)
|
|
956
|
+
continue;
|
|
957
|
+
const prompted = promptedOf(entry);
|
|
958
|
+
if (prompted.length < 2)
|
|
959
|
+
continue;
|
|
960
|
+
labels.push(...mergeLabels({
|
|
961
|
+
owner,
|
|
962
|
+
sessionId: entry.trace.sessionId,
|
|
963
|
+
turnId: entry.trace.turnId,
|
|
964
|
+
prompted,
|
|
965
|
+
targets: prompted.map((id) => {
|
|
966
|
+
const into = superseded.get(id);
|
|
967
|
+
return into ? { id, supersededBy: into } : { id };
|
|
968
|
+
}),
|
|
969
|
+
now,
|
|
970
|
+
}));
|
|
971
|
+
}
|
|
972
|
+
return this.#store.putLabels(labels);
|
|
973
|
+
}
|
|
974
|
+
/** The frames of the replayed sessions, grouped by session. */
|
|
975
|
+
#framesBySession(owner, sessions) {
|
|
976
|
+
const map = new Map();
|
|
977
|
+
if (!sessions.length)
|
|
978
|
+
return map;
|
|
979
|
+
const wanted = new Set(sessions.map((session) => session.id));
|
|
980
|
+
// From the oldest replayed session onwards, not from the last night: a
|
|
981
|
+
// conversation that began days ago has its early frames back there too.
|
|
982
|
+
const since = Math.min(...sessions.map((session) => session.createdAt));
|
|
983
|
+
for (const entry of this.#store.framesFor(owner, { since, limit: DREAM_POOL_LIMIT })) {
|
|
984
|
+
const id = entry.trace.sessionId;
|
|
985
|
+
if (!id || !wanted.has(id))
|
|
986
|
+
continue;
|
|
987
|
+
const bucket = map.get(id);
|
|
988
|
+
if (bucket)
|
|
989
|
+
bucket.push(entry);
|
|
990
|
+
else
|
|
991
|
+
map.set(id, [entry]);
|
|
992
|
+
}
|
|
993
|
+
return map;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* What `correction` actually yielded tonight, and what the night says when
|
|
997
|
+
* it is not enough (`dream.correctionPrecisionFloor`, concept 4.2a).
|
|
998
|
+
*
|
|
999
|
+
* Be exact about what this number is. The concept asks for the hand-judged
|
|
1000
|
+
* hit rate over at least fifty corrections, and no night can compute that.
|
|
1001
|
+
* What a night CAN observe without a model is the yield: the share of
|
|
1002
|
+
* admitted corrections that found any target at all. The two are not the
|
|
1003
|
+
* same quantity, and the asymmetry is what makes the yield worth reading -
|
|
1004
|
+
* a source that finds nothing cannot be precise about anything, so a yield
|
|
1005
|
+
* under the floor is reason enough to distrust `correction`, while a yield
|
|
1006
|
+
* over it proves nothing about precision.
|
|
1007
|
+
*
|
|
1008
|
+
* And when it falls short, the night SAYS so rather than carrying on
|
|
1009
|
+
* quietly. The named alternative is a model call per correction, which is
|
|
1010
|
+
* `dream.labelModelCalls` and is 0: the post exists in the report so that
|
|
1011
|
+
* turning it on is a decision somebody takes, not a default that arrives.
|
|
1012
|
+
*/
|
|
1013
|
+
correctionPrecision(replayed) {
|
|
1014
|
+
const dream = this.#config.memory.dream;
|
|
1015
|
+
if (!dream.enabled || replayed.corrections <= 0)
|
|
1016
|
+
return '';
|
|
1017
|
+
const precision = replayed.labelled / replayed.corrections;
|
|
1018
|
+
this.#log.info('Correction labelling measured', {
|
|
1019
|
+
corrections: replayed.corrections,
|
|
1020
|
+
labelled: replayed.labelled,
|
|
1021
|
+
labels: replayed.labels,
|
|
1022
|
+
precision,
|
|
1023
|
+
floor: dream.correctionPrecisionFloor,
|
|
1024
|
+
modelCalls: dream.labelModelCalls,
|
|
1025
|
+
});
|
|
1026
|
+
if (precision >= dream.correctionPrecisionFloor)
|
|
1027
|
+
return '';
|
|
1028
|
+
return (' Correction labelling reached ' + Math.round(precision * 100) + ' percent of ' +
|
|
1029
|
+
plural(replayed.corrections, 'correction', 'corrections') +
|
|
1030
|
+
', below dream.correctionPrecisionFloor (' + dream.correctionPrecisionFloor +
|
|
1031
|
+
'): while it stays there, corrections are not a label source. The named alternative is a' +
|
|
1032
|
+
' model call per correction (dream.labelModelCalls is ' + dream.labelModelCalls +
|
|
1033
|
+
'), and it is not built.');
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* The `budget` and `retry` slots, measured (concept 7.1, S24).
|
|
1037
|
+
*
|
|
1038
|
+
* `budget` is measured out of what this night actually spent per phase and
|
|
1039
|
+
* got back for it - `yieldRates` reports the observed rate WITH its
|
|
1040
|
+
* spread, labelled approximate, and a projection that would have to
|
|
1041
|
+
* extrapolate past the call counts anybody was ever seen spending abstains
|
|
1042
|
+
* instead of guessing. One night is one sample; the record accumulates in
|
|
1043
|
+
* the log, night by night, which is what a later stage would promote on.
|
|
1044
|
+
*
|
|
1045
|
+
* `retry` is not measured here and the reason is worth writing down: it
|
|
1046
|
+
* judges a realized sequence of attempts, and no attempt sequence reaches
|
|
1047
|
+
* this file. Those live on the assignment path, which is the organisation's
|
|
1048
|
+
* side of the house. `judgeRetry` is built and tested; its caller is not
|
|
1049
|
+
* the night.
|
|
1050
|
+
*
|
|
1051
|
+
* Neither slot is carried. `dream.slots` is what decides that, and this
|
|
1052
|
+
* stage has a promotion path for `recall` alone - so a `budget` in the
|
|
1053
|
+
* list changes exactly one thing today: this line says the night would
|
|
1054
|
+
* have carried it.
|
|
1055
|
+
*/
|
|
1056
|
+
measureSlots(owner, spend) {
|
|
1057
|
+
const dream = this.#config.memory.dream;
|
|
1058
|
+
if (!dream.enabled)
|
|
1059
|
+
return;
|
|
1060
|
+
const rates = yieldRates(NIGHT_PHASES.map((phase) => ({
|
|
1061
|
+
owner,
|
|
1062
|
+
phase,
|
|
1063
|
+
calls: spend[phase].calls,
|
|
1064
|
+
value: spend[phase].value,
|
|
1065
|
+
})));
|
|
1066
|
+
if (!rates.length)
|
|
1067
|
+
return;
|
|
1068
|
+
this.#log.info('The night measured its own yield', {
|
|
1069
|
+
owner,
|
|
1070
|
+
wouldCarry: dream.slots.filter((slot) => slot !== 'recall').join(',') || 'nothing',
|
|
1071
|
+
rates: rates.map((rate) => ({
|
|
1072
|
+
phase: rate.phase,
|
|
1073
|
+
perCall: rate.meanPerCall,
|
|
1074
|
+
low: rate.low,
|
|
1075
|
+
high: rate.high,
|
|
1076
|
+
calls: rate.callsRange,
|
|
1077
|
+
samples: rate.samples,
|
|
1078
|
+
approximated: rate.approximated,
|
|
1079
|
+
})),
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* What is left of the run-global dream wallet (concept 9.4).
|
|
1084
|
+
*
|
|
1085
|
+
* A window opens with the first query of a night and closes
|
|
1086
|
+
* `DREAM_NIGHT_WINDOW_MS` after it opened. That is what "one night" has to
|
|
1087
|
+
* mean for a process with no calendar: the runtime runs the due banks in
|
|
1088
|
+
* one sequential loop, so every one of them draws on the same wallet, and
|
|
1089
|
+
* a night a day later starts with a full one.
|
|
1090
|
+
*/
|
|
1091
|
+
remainingCalls() {
|
|
1092
|
+
const ceiling = Math.max(0, Math.round(this.#config.memory.dream.maxCallsPerNight));
|
|
1093
|
+
return Math.max(0, ceiling - this.#openWallet().spent);
|
|
1094
|
+
}
|
|
1095
|
+
/** Book model calls against that wallet, spent or wasted. */
|
|
1096
|
+
bookCalls(calls) {
|
|
1097
|
+
if (calls <= 0)
|
|
1098
|
+
return;
|
|
1099
|
+
this.#openWallet().spent += calls;
|
|
1100
|
+
}
|
|
1101
|
+
/** The wallet of the night in progress; a night that has run its course gets a fresh one. */
|
|
1102
|
+
#openWallet() {
|
|
1103
|
+
const now = Date.now();
|
|
1104
|
+
if (now - this.#wallet.since > DREAM_NIGHT_WINDOW_MS)
|
|
1105
|
+
this.#wallet = { since: now, spent: 0 };
|
|
1106
|
+
return this.#wallet;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
//# sourceMappingURL=sleep-dream.js.map
|