rookery-agent 0.1.0 → 0.3.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 +467 -367
- package/docs/migration.md +88 -88
- package/docs/updates.md +112 -0
- package/package.json +13 -3
- package/packages/cli/dist/commands/config.js +2 -2
- package/packages/cli/dist/commands/doctor.d.ts.map +1 -1
- package/packages/cli/dist/commands/doctor.js +13 -9
- package/packages/cli/dist/commands/doctor.js.map +1 -1
- package/packages/cli/dist/commands/memory.js +1 -1
- package/packages/cli/dist/commands/org.d.ts +2 -2
- package/packages/cli/dist/commands/org.d.ts.map +1 -1
- package/packages/cli/dist/commands/org.js +19 -17
- package/packages/cli/dist/commands/org.js.map +1 -1
- package/packages/cli/dist/commands/serve.js +1 -1
- package/packages/cli/dist/commands/serve.js.map +1 -1
- package/packages/cli/dist/commands/shared.d.ts.map +1 -1
- package/packages/cli/dist/commands/shared.js +2 -1
- package/packages/cli/dist/commands/shared.js.map +1 -1
- package/packages/cli/dist/commands/tasks.d.ts.map +1 -1
- package/packages/cli/dist/commands/tasks.js +25 -11
- package/packages/cli/dist/commands/tasks.js.map +1 -1
- package/packages/cli/dist/commands/tools.js +1 -1
- package/packages/cli/dist/commands/tools.js.map +1 -1
- package/packages/cli/dist/index.js +13 -13
- package/packages/cli/dist/index.js.map +1 -1
- package/packages/cli/dist/repl.d.ts +12 -0
- package/packages/cli/dist/repl.d.ts.map +1 -1
- package/packages/cli/dist/repl.js +170 -16
- package/packages/cli/dist/repl.js.map +1 -1
- package/packages/cli/dist/tui/App.d.ts +7 -3
- package/packages/cli/dist/tui/App.d.ts.map +1 -1
- package/packages/cli/dist/tui/App.js +182 -16
- package/packages/cli/dist/tui/App.js.map +1 -1
- package/packages/cli/dist/tui/commands.d.ts +7 -0
- package/packages/cli/dist/tui/commands.d.ts.map +1 -1
- package/packages/cli/dist/tui/commands.js +70 -8
- package/packages/cli/dist/tui/commands.js.map +1 -1
- package/packages/cli/dist/tui/components/AssignmentsView.js +4 -4
- package/packages/cli/dist/tui/components/AssignmentsView.js.map +1 -1
- package/packages/cli/dist/tui/components/Banner.d.ts +11 -2
- package/packages/cli/dist/tui/components/Banner.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Banner.js +7 -10
- package/packages/cli/dist/tui/components/Banner.js.map +1 -1
- package/packages/cli/dist/tui/components/CodeBlock.js +2 -2
- package/packages/cli/dist/tui/components/CodeBlock.js.map +1 -1
- package/packages/cli/dist/tui/components/InputBox.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/InputBox.js +4 -4
- package/packages/cli/dist/tui/components/InputBox.js.map +1 -1
- package/packages/cli/dist/tui/components/Logo.d.ts +56 -0
- package/packages/cli/dist/tui/components/Logo.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/Logo.js +50 -0
- package/packages/cli/dist/tui/components/Logo.js.map +1 -0
- package/packages/cli/dist/tui/components/Markdown.js +8 -8
- package/packages/cli/dist/tui/components/Markdown.js.map +1 -1
- package/packages/cli/dist/tui/components/Message.d.ts +1 -1
- package/packages/cli/dist/tui/components/Message.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Message.js +5 -4
- package/packages/cli/dist/tui/components/Message.js.map +1 -1
- package/packages/cli/dist/tui/components/QuestionView.d.ts +29 -0
- package/packages/cli/dist/tui/components/QuestionView.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/QuestionView.js +53 -0
- package/packages/cli/dist/tui/components/QuestionView.js.map +1 -0
- package/packages/cli/dist/tui/components/SlashPalette.d.ts +5 -2
- package/packages/cli/dist/tui/components/SlashPalette.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/SlashPalette.js +2 -2
- package/packages/cli/dist/tui/components/SlashPalette.js.map +1 -1
- package/packages/cli/dist/tui/components/StatusLine.d.ts +0 -2
- package/packages/cli/dist/tui/components/StatusLine.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/StatusLine.js +8 -5
- package/packages/cli/dist/tui/components/StatusLine.js.map +1 -1
- package/packages/cli/dist/tui/components/ToolGroup.js +2 -2
- package/packages/cli/dist/tui/components/ToolGroup.js.map +1 -1
- package/packages/cli/dist/tui/components/WatchView.d.ts +21 -0
- package/packages/cli/dist/tui/components/WatchView.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/WatchView.js +36 -0
- package/packages/cli/dist/tui/components/WatchView.js.map +1 -0
- package/packages/cli/dist/tui/history.d.ts +20 -0
- package/packages/cli/dist/tui/history.d.ts.map +1 -0
- package/packages/cli/dist/tui/history.js +105 -0
- package/packages/cli/dist/tui/history.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useSlash.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useSlash.js +3 -2
- package/packages/cli/dist/tui/hooks/useSlash.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useTurn.d.ts +58 -1
- package/packages/cli/dist/tui/hooks/useTurn.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useTurn.js +214 -36
- package/packages/cli/dist/tui/hooks/useTurn.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useWatch.d.ts +52 -0
- package/packages/cli/dist/tui/hooks/useWatch.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useWatch.js +145 -0
- package/packages/cli/dist/tui/hooks/useWatch.js.map +1 -0
- package/packages/cli/dist/tui/inkTheme.d.ts +19 -0
- package/packages/cli/dist/tui/inkTheme.d.ts.map +1 -0
- package/packages/cli/dist/tui/inkTheme.js +81 -0
- package/packages/cli/dist/tui/inkTheme.js.map +1 -0
- package/packages/cli/dist/tui/theme.d.ts +39 -29
- package/packages/cli/dist/tui/theme.d.ts.map +1 -1
- package/packages/cli/dist/tui/theme.js +35 -25
- package/packages/cli/dist/tui/theme.js.map +1 -1
- package/packages/cli/dist/tui/types.d.ts +56 -3
- package/packages/cli/dist/tui/types.d.ts.map +1 -1
- package/packages/cli/dist/tui/types.js +85 -0
- package/packages/cli/dist/tui/types.js.map +1 -1
- package/packages/cli/dist/ui/modelNames.d.ts +51 -0
- package/packages/cli/dist/ui/modelNames.d.ts.map +1 -0
- package/packages/cli/dist/ui/modelNames.js +134 -0
- package/packages/cli/dist/ui/modelNames.js.map +1 -0
- package/packages/cli/dist/ui/render.d.ts.map +1 -1
- package/packages/cli/dist/ui/render.js +17 -8
- package/packages/cli/dist/ui/render.js.map +1 -1
- package/packages/cli/dist/ui/speech.js +5 -0
- package/packages/cli/dist/ui/speech.js.map +1 -1
- package/packages/cli/dist/ui/theme.d.ts +33 -9
- package/packages/cli/dist/ui/theme.d.ts.map +1 -1
- package/packages/cli/dist/ui/theme.js +33 -9
- package/packages/cli/dist/ui/theme.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 +5 -2
- package/packages/core/dist/agents/persona.js.map +1 -1
- package/packages/core/dist/computer/accessibility.d.ts +78 -0
- package/packages/core/dist/computer/accessibility.d.ts.map +1 -0
- package/packages/core/dist/computer/accessibility.js +270 -0
- package/packages/core/dist/computer/accessibility.js.map +1 -0
- package/packages/core/dist/computer/assemblies.d.ts +17 -0
- package/packages/core/dist/computer/assemblies.d.ts.map +1 -0
- package/packages/core/dist/computer/assemblies.js +55 -0
- package/packages/core/dist/computer/assemblies.js.map +1 -0
- package/packages/core/dist/computer/browser-init.d.ts +9 -0
- package/packages/core/dist/computer/browser-init.d.ts.map +1 -0
- package/packages/core/dist/computer/browser-init.js +133 -0
- package/packages/core/dist/computer/browser-init.js.map +1 -0
- package/packages/core/dist/computer/cursor.d.ts +30 -0
- package/packages/core/dist/computer/cursor.d.ts.map +1 -0
- package/packages/core/dist/computer/cursor.js +30 -0
- package/packages/core/dist/computer/cursor.js.map +1 -0
- package/packages/core/dist/computer/mcp-server.js +524 -82
- package/packages/core/dist/computer/mcp-server.js.map +1 -1
- package/packages/core/dist/computer/powershell.d.ts +4 -0
- package/packages/core/dist/computer/powershell.d.ts.map +1 -1
- package/packages/core/dist/computer/powershell.js +471 -81
- package/packages/core/dist/computer/powershell.js.map +1 -1
- package/packages/core/dist/computer/screen-text.d.ts +82 -0
- package/packages/core/dist/computer/screen-text.d.ts.map +1 -0
- package/packages/core/dist/computer/screen-text.js +243 -0
- package/packages/core/dist/computer/screen-text.js.map +1 -0
- package/packages/core/dist/computer/sketch.d.ts +66 -0
- package/packages/core/dist/computer/sketch.d.ts.map +1 -0
- package/packages/core/dist/computer/sketch.js +540 -0
- package/packages/core/dist/computer/sketch.js.map +1 -0
- package/packages/core/dist/computer/tools.d.ts +8 -8
- package/packages/core/dist/computer/tools.d.ts.map +1 -1
- package/packages/core/dist/computer/tools.js +186 -31
- package/packages/core/dist/computer/tools.js.map +1 -1
- package/packages/core/dist/computer/validation.d.ts +555 -0
- package/packages/core/dist/computer/validation.d.ts.map +1 -0
- package/packages/core/dist/computer/validation.js +111 -0
- package/packages/core/dist/computer/validation.js.map +1 -0
- package/packages/core/dist/computer/windows-cursor.d.ts +14 -0
- package/packages/core/dist/computer/windows-cursor.d.ts.map +1 -0
- package/packages/core/dist/computer/windows-cursor.js +713 -0
- package/packages/core/dist/computer/windows-cursor.js.map +1 -0
- package/packages/core/dist/config.d.ts +34 -1
- package/packages/core/dist/config.d.ts.map +1 -1
- package/packages/core/dist/config.js +362 -11
- package/packages/core/dist/config.js.map +1 -1
- package/packages/core/dist/cron/scheduler.d.ts +59 -6
- package/packages/core/dist/cron/scheduler.d.ts.map +1 -1
- package/packages/core/dist/cron/scheduler.js +295 -27
- package/packages/core/dist/cron/scheduler.js.map +1 -1
- package/packages/core/dist/cron/store.d.ts +19 -1
- package/packages/core/dist/cron/store.d.ts.map +1 -1
- package/packages/core/dist/cron/store.js +36 -8
- package/packages/core/dist/cron/store.js.map +1 -1
- package/packages/core/dist/external/claude-code.d.ts +4 -0
- package/packages/core/dist/external/claude-code.d.ts.map +1 -0
- package/packages/core/dist/external/claude-code.js +111 -0
- package/packages/core/dist/external/claude-code.js.map +1 -0
- package/packages/core/dist/external/discovery.d.ts +33 -0
- package/packages/core/dist/external/discovery.d.ts.map +1 -0
- package/packages/core/dist/external/discovery.js +144 -0
- package/packages/core/dist/external/discovery.js.map +1 -0
- package/packages/core/dist/external/homes.d.ts +26 -0
- package/packages/core/dist/external/homes.d.ts.map +1 -0
- package/packages/core/dist/external/homes.js +49 -0
- package/packages/core/dist/external/homes.js.map +1 -0
- package/packages/core/dist/external/shared.d.ts +201 -0
- package/packages/core/dist/external/shared.d.ts.map +1 -0
- package/packages/core/dist/external/shared.js +308 -0
- package/packages/core/dist/external/shared.js.map +1 -0
- package/packages/core/dist/gateway/policy.d.ts +117 -2
- package/packages/core/dist/gateway/policy.d.ts.map +1 -1
- package/packages/core/dist/gateway/policy.js +286 -6
- package/packages/core/dist/gateway/policy.js.map +1 -1
- package/packages/core/dist/index.d.ts +38 -12
- package/packages/core/dist/index.d.ts.map +1 -1
- package/packages/core/dist/index.js +66 -12
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/memory/db.d.ts +1 -1
- package/packages/core/dist/memory/db.d.ts.map +1 -1
- package/packages/core/dist/memory/db.js +878 -1
- package/packages/core/dist/memory/db.js.map +1 -1
- package/packages/core/dist/memory/dream/admission.d.ts +124 -0
- package/packages/core/dist/memory/dream/admission.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/admission.js +116 -0
- package/packages/core/dist/memory/dream/admission.js.map +1 -0
- package/packages/core/dist/memory/dream/candidate.d.ts +152 -0
- package/packages/core/dist/memory/dream/candidate.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/candidate.js +547 -0
- package/packages/core/dist/memory/dream/candidate.js.map +1 -0
- package/packages/core/dist/memory/dream/evaluate.d.ts +394 -0
- package/packages/core/dist/memory/dream/evaluate.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/evaluate.js +1032 -0
- package/packages/core/dist/memory/dream/evaluate.js.map +1 -0
- package/packages/core/dist/memory/dream/frame.d.ts +61 -0
- package/packages/core/dist/memory/dream/frame.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/frame.js +292 -0
- package/packages/core/dist/memory/dream/frame.js.map +1 -0
- package/packages/core/dist/memory/dream/label.d.ts +370 -0
- package/packages/core/dist/memory/dream/label.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/label.js +439 -0
- package/packages/core/dist/memory/dream/label.js.map +1 -0
- package/packages/core/dist/memory/dream/measure.d.ts +114 -0
- package/packages/core/dist/memory/dream/measure.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/measure.js +205 -0
- package/packages/core/dist/memory/dream/measure.js.map +1 -0
- package/packages/core/dist/memory/dream/policy.d.ts +21 -0
- package/packages/core/dist/memory/dream/policy.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/policy.js +157 -0
- package/packages/core/dist/memory/dream/policy.js.map +1 -0
- package/packages/core/dist/memory/dream/probe.d.ts +202 -0
- package/packages/core/dist/memory/dream/probe.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/probe.js +671 -0
- package/packages/core/dist/memory/dream/probe.js.map +1 -0
- package/packages/core/dist/memory/dream/promote.d.ts +312 -0
- package/packages/core/dist/memory/dream/promote.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/promote.js +528 -0
- package/packages/core/dist/memory/dream/promote.js.map +1 -0
- package/packages/core/dist/memory/dream/score.d.ts +103 -0
- package/packages/core/dist/memory/dream/score.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/score.js +334 -0
- package/packages/core/dist/memory/dream/score.js.map +1 -0
- package/packages/core/dist/memory/dream/slots.d.ts +193 -0
- package/packages/core/dist/memory/dream/slots.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/slots.js +0 -0
- package/packages/core/dist/memory/dream/slots.js.map +1 -0
- package/packages/core/dist/memory/dream/trajectory.d.ts +262 -0
- package/packages/core/dist/memory/dream/trajectory.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/trajectory.js +366 -0
- package/packages/core/dist/memory/dream/trajectory.js.map +1 -0
- package/packages/core/dist/memory/extractor.d.ts +7 -0
- package/packages/core/dist/memory/extractor.d.ts.map +1 -1
- package/packages/core/dist/memory/extractor.js +35 -12
- package/packages/core/dist/memory/extractor.js.map +1 -1
- package/packages/core/dist/memory/gate.d.ts +43 -7
- package/packages/core/dist/memory/gate.d.ts.map +1 -1
- package/packages/core/dist/memory/gate.js +91 -4
- package/packages/core/dist/memory/gate.js.map +1 -1
- package/packages/core/dist/memory/recall.d.ts +57 -0
- package/packages/core/dist/memory/recall.d.ts.map +1 -1
- package/packages/core/dist/memory/recall.js +60 -123
- package/packages/core/dist/memory/recall.js.map +1 -1
- package/packages/core/dist/memory/sleep.d.ts +131 -4
- package/packages/core/dist/memory/sleep.d.ts.map +1 -1
- package/packages/core/dist/memory/sleep.js +2384 -65
- package/packages/core/dist/memory/sleep.js.map +1 -1
- package/packages/core/dist/memory/store.d.ts +564 -10
- package/packages/core/dist/memory/store.d.ts.map +1 -1
- package/packages/core/dist/memory/store.js +1673 -102
- package/packages/core/dist/memory/store.js.map +1 -1
- package/packages/core/dist/org/controller.d.ts +268 -4
- package/packages/core/dist/org/controller.d.ts.map +1 -1
- package/packages/core/dist/org/controller.js +2298 -248
- package/packages/core/dist/org/controller.js.map +1 -1
- package/packages/core/dist/org/ponytail.d.ts +1 -1
- package/packages/core/dist/org/ponytail.js +1 -1
- package/packages/core/dist/org/project-mcp.d.ts +3 -3
- package/packages/core/dist/org/prompts.d.ts +44 -30
- package/packages/core/dist/org/prompts.d.ts.map +1 -1
- package/packages/core/dist/org/prompts.js +209 -92
- package/packages/core/dist/org/prompts.js.map +1 -1
- package/packages/core/dist/org/questions.d.ts +104 -0
- package/packages/core/dist/org/questions.d.ts.map +1 -0
- package/packages/core/dist/org/questions.js +136 -0
- package/packages/core/dist/org/questions.js.map +1 -0
- package/packages/core/dist/org/review.d.ts +100 -0
- package/packages/core/dist/org/review.d.ts.map +1 -0
- package/packages/core/dist/org/review.js +256 -0
- package/packages/core/dist/org/review.js.map +1 -0
- package/packages/core/dist/org/store.d.ts +311 -2
- package/packages/core/dist/org/store.d.ts.map +1 -1
- package/packages/core/dist/org/store.js +981 -13
- package/packages/core/dist/org/store.js.map +1 -1
- package/packages/core/dist/org/tools.d.ts +33 -3
- package/packages/core/dist/org/tools.d.ts.map +1 -1
- package/packages/core/dist/org/tools.js +380 -67
- package/packages/core/dist/org/tools.js.map +1 -1
- package/packages/core/dist/providers/catalogue.d.ts +1 -1
- package/packages/core/dist/providers/catalogue.d.ts.map +1 -1
- package/packages/core/dist/providers/catalogue.js +2 -2
- package/packages/core/dist/providers/catalogue.js.map +1 -1
- package/packages/core/dist/providers/claude-code.d.ts +19 -3
- package/packages/core/dist/providers/claude-code.d.ts.map +1 -1
- package/packages/core/dist/providers/claude-code.js +501 -40
- package/packages/core/dist/providers/claude-code.js.map +1 -1
- package/packages/core/dist/providers/claude-tui.d.ts +288 -0
- package/packages/core/dist/providers/claude-tui.d.ts.map +1 -0
- package/packages/core/dist/providers/claude-tui.js +1118 -0
- package/packages/core/dist/providers/claude-tui.js.map +1 -0
- package/packages/core/dist/providers/codex-auth.d.ts +15 -0
- package/packages/core/dist/providers/codex-auth.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-auth.js +127 -0
- package/packages/core/dist/providers/codex-auth.js.map +1 -0
- package/packages/core/dist/providers/codex-bridge.d.ts +58 -0
- package/packages/core/dist/providers/codex-bridge.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-bridge.js +375 -0
- package/packages/core/dist/providers/codex-bridge.js.map +1 -0
- package/packages/core/dist/providers/codex-translate.d.ts +75 -0
- package/packages/core/dist/providers/codex-translate.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-translate.js +383 -0
- package/packages/core/dist/providers/codex-translate.js.map +1 -0
- package/packages/core/dist/providers/model-gateway.d.ts +56 -0
- package/packages/core/dist/providers/model-gateway.d.ts.map +1 -0
- package/packages/core/dist/providers/model-gateway.js +119 -0
- package/packages/core/dist/providers/model-gateway.js.map +1 -0
- package/packages/core/dist/providers/process.d.ts +3 -1
- package/packages/core/dist/providers/process.d.ts.map +1 -1
- package/packages/core/dist/providers/process.js +3 -3
- package/packages/core/dist/providers/process.js.map +1 -1
- package/packages/core/dist/providers/profiles.d.ts +11 -0
- package/packages/core/dist/providers/profiles.d.ts.map +1 -0
- package/packages/core/dist/providers/profiles.js +28 -0
- package/packages/core/dist/providers/profiles.js.map +1 -0
- package/packages/core/dist/providers/provider-catalog.d.ts +72 -0
- package/packages/core/dist/providers/provider-catalog.d.ts.map +1 -0
- package/packages/core/dist/providers/provider-catalog.js +144 -0
- package/packages/core/dist/providers/provider-catalog.js.map +1 -0
- package/packages/core/dist/providers/quota.d.ts +40 -1
- package/packages/core/dist/providers/quota.d.ts.map +1 -1
- package/packages/core/dist/providers/quota.js +288 -25
- package/packages/core/dist/providers/quota.js.map +1 -1
- package/packages/core/dist/providers/registry.d.ts +46 -3
- package/packages/core/dist/providers/registry.d.ts.map +1 -1
- package/packages/core/dist/providers/registry.js +148 -13
- package/packages/core/dist/providers/registry.js.map +1 -1
- package/packages/core/dist/providers/router.d.ts +28 -0
- package/packages/core/dist/providers/router.d.ts.map +1 -0
- package/packages/core/dist/providers/router.js +88 -0
- package/packages/core/dist/providers/router.js.map +1 -0
- package/packages/core/dist/providers/user-settings-guard.d.ts +12 -0
- package/packages/core/dist/providers/user-settings-guard.d.ts.map +1 -0
- package/packages/core/dist/providers/user-settings-guard.js +130 -0
- package/packages/core/dist/providers/user-settings-guard.js.map +1 -0
- package/packages/core/dist/runtime.d.ts +193 -7
- package/packages/core/dist/runtime.d.ts.map +1 -1
- package/packages/core/dist/runtime.js +1676 -219
- package/packages/core/dist/runtime.js.map +1 -1
- package/packages/core/dist/skills/builtin.d.ts +34 -0
- package/packages/core/dist/skills/builtin.d.ts.map +1 -0
- package/packages/core/dist/skills/builtin.js +305 -0
- package/packages/core/dist/skills/builtin.js.map +1 -0
- package/packages/core/dist/skills/shelf.d.ts +30 -0
- package/packages/core/dist/skills/shelf.d.ts.map +1 -0
- package/packages/core/dist/skills/shelf.js +159 -0
- package/packages/core/dist/skills/shelf.js.map +1 -0
- package/packages/core/dist/skills/store.d.ts +66 -4
- package/packages/core/dist/skills/store.d.ts.map +1 -1
- package/packages/core/dist/skills/store.js +105 -18
- package/packages/core/dist/skills/store.js.map +1 -1
- package/packages/core/dist/skills/suggest.d.ts +21 -0
- package/packages/core/dist/skills/suggest.d.ts.map +1 -0
- package/packages/core/dist/skills/suggest.js +150 -0
- package/packages/core/dist/skills/suggest.js.map +1 -0
- package/packages/core/dist/tools/catalog.d.ts +1 -3
- package/packages/core/dist/tools/catalog.d.ts.map +1 -1
- package/packages/core/dist/tools/catalog.js +38 -26
- package/packages/core/dist/tools/catalog.js.map +1 -1
- package/packages/core/dist/tools/hub.d.ts +136 -10
- package/packages/core/dist/tools/hub.d.ts.map +1 -1
- package/packages/core/dist/tools/hub.js +418 -24
- package/packages/core/dist/tools/hub.js.map +1 -1
- package/packages/core/dist/turns/journal.d.ts +78 -0
- package/packages/core/dist/turns/journal.d.ts.map +1 -0
- package/packages/core/dist/turns/journal.js +104 -0
- package/packages/core/dist/turns/journal.js.map +1 -0
- package/packages/core/dist/types.d.ts +1776 -12
- 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 +41 -0
- package/packages/core/dist/util/blocks.d.ts.map +1 -0
- package/packages/core/dist/util/blocks.js +175 -0
- package/packages/core/dist/util/blocks.js.map +1 -0
- package/packages/core/dist/util/queue.d.ts +12 -0
- package/packages/core/dist/util/queue.d.ts.map +1 -1
- package/packages/core/dist/util/queue.js +16 -0
- package/packages/core/dist/util/queue.js.map +1 -1
- package/packages/core/dist/util/time.d.ts +39 -0
- package/packages/core/dist/util/time.d.ts.map +1 -0
- package/packages/core/dist/util/time.js +71 -0
- package/packages/core/dist/util/time.js.map +1 -0
- package/packages/core/package.json +1 -1
- package/packages/server/dist/auth.d.ts +14 -1
- package/packages/server/dist/auth.d.ts.map +1 -1
- package/packages/server/dist/auth.js +19 -0
- package/packages/server/dist/auth.js.map +1 -1
- package/packages/server/dist/context.d.ts +35 -1
- package/packages/server/dist/context.d.ts.map +1 -1
- package/packages/server/dist/context.js +39 -10
- package/packages/server/dist/context.js.map +1 -1
- package/packages/server/dist/gateways/attachments.d.ts +32 -0
- package/packages/server/dist/gateways/attachments.d.ts.map +1 -0
- package/packages/server/dist/gateways/attachments.js +167 -0
- package/packages/server/dist/gateways/attachments.js.map +1 -0
- package/packages/server/dist/gateways/markdown.d.ts +9 -0
- package/packages/server/dist/gateways/markdown.d.ts.map +1 -0
- package/packages/server/dist/gateways/markdown.js +170 -0
- package/packages/server/dist/gateways/markdown.js.map +1 -0
- package/packages/server/dist/gateways/push.d.ts +1 -1
- package/packages/server/dist/gateways/push.d.ts.map +1 -1
- package/packages/server/dist/gateways/push.js +420 -13
- package/packages/server/dist/gateways/push.js.map +1 -1
- package/packages/server/dist/gateways/telegram-api.d.ts +70 -1
- package/packages/server/dist/gateways/telegram-api.d.ts.map +1 -1
- package/packages/server/dist/gateways/telegram-api.js +140 -1
- package/packages/server/dist/gateways/telegram-api.js.map +1 -1
- package/packages/server/dist/gateways/telegram.d.ts +181 -1
- package/packages/server/dist/gateways/telegram.d.ts.map +1 -1
- package/packages/server/dist/gateways/telegram.js +1572 -78
- package/packages/server/dist/gateways/telegram.js.map +1 -1
- package/packages/server/dist/gateways/threads.d.ts +84 -0
- package/packages/server/dist/gateways/threads.d.ts.map +1 -0
- package/packages/server/dist/gateways/threads.js +289 -0
- package/packages/server/dist/gateways/threads.js.map +1 -0
- package/packages/server/dist/index.d.ts +2 -1
- package/packages/server/dist/index.d.ts.map +1 -1
- package/packages/server/dist/index.js +2 -1
- package/packages/server/dist/index.js.map +1 -1
- package/packages/server/dist/listeners/imap.d.ts +13 -0
- package/packages/server/dist/listeners/imap.d.ts.map +1 -0
- package/packages/server/dist/listeners/imap.js +0 -0
- package/packages/server/dist/listeners/imap.js.map +1 -0
- package/packages/server/dist/listeners/registry.d.ts +18 -0
- package/packages/server/dist/listeners/registry.d.ts.map +1 -0
- package/packages/server/dist/listeners/registry.js +88 -0
- package/packages/server/dist/listeners/registry.js.map +1 -0
- package/packages/server/dist/listeners/types.d.ts +55 -0
- package/packages/server/dist/listeners/types.d.ts.map +1 -0
- package/packages/server/dist/listeners/types.js +2 -0
- package/packages/server/dist/listeners/types.js.map +1 -0
- package/packages/server/dist/main.js +15 -1
- package/packages/server/dist/main.js.map +1 -1
- package/packages/server/dist/routes/chat.d.ts +7 -3
- package/packages/server/dist/routes/chat.d.ts.map +1 -1
- package/packages/server/dist/routes/chat.js +8 -17
- package/packages/server/dist/routes/chat.js.map +1 -1
- package/packages/server/dist/routes/config.d.ts.map +1 -1
- package/packages/server/dist/routes/config.js +66 -7
- 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 +65 -8
- package/packages/server/dist/routes/cron.js.map +1 -1
- package/packages/server/dist/routes/dream.d.ts +22 -0
- package/packages/server/dist/routes/dream.d.ts.map +1 -0
- package/packages/server/dist/routes/dream.js +152 -0
- package/packages/server/dist/routes/dream.js.map +1 -0
- package/packages/server/dist/routes/hooks.d.ts +18 -0
- package/packages/server/dist/routes/hooks.d.ts.map +1 -0
- package/packages/server/dist/routes/hooks.js +62 -0
- package/packages/server/dist/routes/hooks.js.map +1 -0
- package/packages/server/dist/routes/listeners.d.ts +10 -0
- package/packages/server/dist/routes/listeners.d.ts.map +1 -0
- package/packages/server/dist/routes/listeners.js +12 -0
- package/packages/server/dist/routes/listeners.js.map +1 -0
- package/packages/server/dist/routes/memories.d.ts.map +1 -1
- package/packages/server/dist/routes/memories.js +55 -3
- package/packages/server/dist/routes/memories.js.map +1 -1
- package/packages/server/dist/routes/org.d.ts.map +1 -1
- package/packages/server/dist/routes/org.js +289 -49
- 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 +6 -3
- 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 +66 -7
- package/packages/server/dist/routes/providers.js.map +1 -1
- package/packages/server/dist/routes/questions.d.ts +45 -0
- package/packages/server/dist/routes/questions.d.ts.map +1 -0
- package/packages/server/dist/routes/questions.js +73 -0
- package/packages/server/dist/routes/questions.js.map +1 -0
- package/packages/server/dist/routes/sessions.d.ts.map +1 -1
- package/packages/server/dist/routes/sessions.js +26 -6
- 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 +71 -2
- package/packages/server/dist/routes/sleep.js.map +1 -1
- package/packages/server/dist/routes/terminals.d.ts +25 -0
- package/packages/server/dist/routes/terminals.d.ts.map +1 -0
- package/packages/server/dist/routes/terminals.js +35 -0
- package/packages/server/dist/routes/terminals.js.map +1 -0
- package/packages/server/dist/routes/tools.d.ts.map +1 -1
- package/packages/server/dist/routes/tools.js +140 -6
- package/packages/server/dist/routes/tools.js.map +1 -1
- package/packages/server/dist/routes/updates.d.ts +10 -0
- package/packages/server/dist/routes/updates.d.ts.map +1 -0
- package/packages/server/dist/routes/updates.js +22 -0
- package/packages/server/dist/routes/updates.js.map +1 -0
- package/packages/server/dist/routes/ws.d.ts +11 -5
- package/packages/server/dist/routes/ws.d.ts.map +1 -1
- package/packages/server/dist/routes/ws.js +168 -28
- package/packages/server/dist/routes/ws.js.map +1 -1
- package/packages/server/dist/schemas.d.ts +1177 -215
- package/packages/server/dist/schemas.d.ts.map +1 -1
- package/packages/server/dist/schemas.js +317 -12
- package/packages/server/dist/schemas.js.map +1 -1
- package/packages/server/dist/server.d.ts +7 -1
- package/packages/server/dist/server.d.ts.map +1 -1
- package/packages/server/dist/server.js +210 -3
- package/packages/server/dist/server.js.map +1 -1
- package/packages/server/dist/services/stream.d.ts +94 -5
- package/packages/server/dist/services/stream.d.ts.map +1 -1
- package/packages/server/dist/services/stream.js +9 -20
- package/packages/server/dist/services/stream.js.map +1 -1
- package/packages/server/dist/services/stt.d.ts +65 -0
- package/packages/server/dist/services/stt.d.ts.map +1 -0
- package/packages/server/dist/services/stt.js +306 -0
- package/packages/server/dist/services/stt.js.map +1 -0
- package/packages/server/dist/services/turns.d.ts +54 -0
- package/packages/server/dist/services/turns.d.ts.map +1 -0
- package/packages/server/dist/services/turns.js +186 -0
- package/packages/server/dist/services/turns.js.map +1 -0
- package/packages/server/dist/services/updates.d.ts +99 -0
- package/packages/server/dist/services/updates.d.ts.map +1 -0
- package/packages/server/dist/services/updates.js +316 -0
- package/packages/server/dist/services/updates.js.map +1 -0
- package/packages/server/package.json +1 -1
- package/packages/web/dist/app-icon.svg +2 -0
- package/packages/web/dist/apple-touch-icon.png +0 -0
- package/packages/web/dist/assets/abnfDiagram-O67JEVCF-D7YyFndQ.js +1 -0
- package/packages/web/dist/assets/arc-C_Zgk2dJ.js +1 -0
- package/packages/web/dist/assets/architectureDiagram-NJMV4G6O-eI0adu1B.js +36 -0
- package/packages/web/dist/assets/blockDiagram-BEXU5L5S-WAoOFUA9.js +140 -0
- package/packages/web/dist/assets/c4Diagram-YGBWAQC7-DE8Zyhng.js +38 -0
- package/packages/web/dist/assets/channel-egZxcyUK.js +1 -0
- package/packages/web/dist/assets/chunk-2Q5K7J3B-bnqLP2XD.js +1 -0
- package/packages/web/dist/assets/chunk-3FUC2YCW-Ck1_SVe0.js +2 -0
- package/packages/web/dist/assets/chunk-5VM5RSS4-hDmC41gD.js +15 -0
- package/packages/web/dist/assets/chunk-GTNCS2PH-PoWvfCrT.js +88 -0
- package/packages/web/dist/assets/chunk-GWA4HPMP-D3V0IG43.js +1 -0
- package/packages/web/dist/assets/chunk-JWPE2WC7-BryfpHM5.js +1 -0
- package/packages/web/dist/assets/chunk-NETBCI7D-8ic1iEdT.js +1 -0
- package/packages/web/dist/assets/chunk-WEXAMYUT-nM8tmQT2.js +1 -0
- package/packages/web/dist/assets/chunk-XXDRQBXY-Do28F482.js +1 -0
- package/packages/web/dist/assets/classDiagram-v2-NBCMYWYE-Bop9oNNO.js +217 -0
- package/packages/web/dist/assets/cose-bilkent-JH36ORCC-a7f_bpnt.js +1 -0
- package/packages/web/dist/assets/cynefin-OW5HDTMX-DnArcis_.js +178 -0
- package/packages/web/dist/assets/cynefinDiagram-VND7K2PF-vEuTb1GD.js +62 -0
- package/packages/web/dist/assets/cytoscape.esm-Ix0LnXOy.js +331 -0
- package/packages/web/dist/assets/dagre-6A5THRUB-BgG4MynJ.js +4 -0
- package/packages/web/dist/assets/diagram-22UHCM2B-DRCQpafv.js +200 -0
- package/packages/web/dist/assets/diagram-3UASUU5V-BKgmAXde.js +24 -0
- package/packages/web/dist/assets/diagram-ATOU4E4O-B6Hsy36X.js +3 -0
- package/packages/web/dist/assets/diagram-CDSNMT55-JflyfyoB.js +30 -0
- package/packages/web/dist/assets/diagram-MLGK6HIB-Dd2QPJjT.js +24 -0
- package/packages/web/dist/assets/diagram-MPIPVDR6-DE5QU60x.js +41 -0
- package/packages/web/dist/assets/draco_decoder-C32yEggz.wasm +0 -0
- package/packages/web/dist/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
- package/packages/web/dist/assets/draco_decoder-fzg4nYZr.js +34 -0
- package/packages/web/dist/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
- package/packages/web/dist/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
- package/packages/web/dist/assets/ebnfDiagram-ZINNZB2B-D7AQ741b.js +1 -0
- package/packages/web/dist/assets/elk-276RUBZZ-CeewBVLF.js +27 -0
- package/packages/web/dist/assets/erDiagram-OPXOYQCR-mLLYkZ5c.js +99 -0
- package/packages/web/dist/assets/flowDiagram-KWPJA3E3-DtpSpsQN.js +213 -0
- package/packages/web/dist/assets/ganttDiagram-FUAMR5RP-1_lh-3ky.js +292 -0
- package/packages/web/dist/assets/gitGraphDiagram-X574FWY7-DoPXZuT5.js +106 -0
- package/packages/web/dist/assets/graph-Bn3Yngep.js +1 -0
- package/packages/web/dist/assets/index-Cw2Opmx7.js +648 -0
- package/packages/web/dist/assets/index-j0zBRCgT.css +32 -0
- package/packages/web/dist/assets/infoDiagram-VRGFBTTK-DQpRGGiD.js +2 -0
- package/packages/web/dist/assets/ishikawaDiagram-OU5B5YK6-gH5C9Q2e.js +70 -0
- package/packages/web/dist/assets/journeyDiagram-ZHPQQLJL-Bg-oeFjb.js +139 -0
- package/packages/web/dist/assets/kanban-definition-PNTS6WVX-BnpI4VH8.js +89 -0
- package/packages/web/dist/assets/katex-C5jXJg4s.js +257 -0
- package/packages/web/dist/assets/mermaid.core-BwBKxlRA.js +313 -0
- package/packages/web/dist/assets/mindmap-definition-NLK3R4M7-NBnnxEoO.js +96 -0
- package/packages/web/dist/assets/pegDiagram-GJSIUBJH-RrXXbIvO.js +1 -0
- package/packages/web/dist/assets/pieDiagram-5QR66LMP-B27q6Gso.js +39 -0
- package/packages/web/dist/assets/quadrantDiagram-O4NWA36T-DGDsdur2.js +7 -0
- package/packages/web/dist/assets/railroadDiagram-XR7U4H2S-GdjkE3mI.js +1 -0
- package/packages/web/dist/assets/requirementDiagram-PLB6GJNP-DjK0GfgO.js +84 -0
- package/packages/web/dist/assets/sankeyDiagram-IPEJSGJF-BG_AIkwF.js +40 -0
- package/packages/web/dist/assets/scene-D4LPicHk.js +4620 -0
- package/packages/web/dist/assets/sequenceDiagram-PO4LG4MO-CIQwUb4y.js +169 -0
- package/packages/web/dist/assets/sizeCapture-INFHLROL-bpIoPxdJ.js +1 -0
- package/packages/web/dist/assets/stateDiagram-v2-GCMORJYK-8hYXvPPv.js +291 -0
- package/packages/web/dist/assets/swimlanes-2SLR337P-gfflUMF9.js +1 -0
- package/packages/web/dist/assets/swimlanesDiagram-TC7HE7FX-9wdzGXU-.js +8 -0
- package/packages/web/dist/assets/timeline-definition-EJHVYXUP-PHMNoGTZ.js +120 -0
- package/packages/web/dist/assets/usecaseDiagram-POWQR4AR-B2j5iteO.js +370 -0
- package/packages/web/dist/assets/vennDiagram-UO4OBE2U-BzxtZ-_2.js +34 -0
- package/packages/web/dist/assets/wardleyDiagram-VNRHLVJA-DL7YbMpY.js +78 -0
- package/packages/web/dist/assets/xychartDiagram-PMCCYNJV-CisgP1cT.js +7 -0
- package/packages/web/dist/draco/draco_decoder.js +33 -0
- package/packages/web/dist/draco/draco_decoder.wasm +0 -0
- package/packages/web/dist/draco/draco_wasm_wrapper.js +116 -0
- package/packages/web/dist/favicon-16.png +0 -0
- package/packages/web/dist/favicon-32.png +0 -0
- package/packages/web/dist/favicon-48.png +0 -0
- package/packages/web/dist/favicon.ico +0 -0
- package/packages/web/dist/favicon.svg +1 -1
- package/packages/web/dist/icon-192.png +0 -0
- package/packages/web/dist/icon-512.png +0 -0
- package/packages/web/dist/index.html +12 -4
- package/packages/web/dist/logo-light.svg +1 -1
- package/packages/web/dist/logo-mono.svg +2 -0
- package/packages/web/dist/logo-stacked-light.svg +2 -0
- package/packages/web/dist/logo-stacked.svg +2 -0
- package/packages/web/dist/logo-white.svg +2 -0
- package/packages/web/dist/logo.svg +1 -1
- package/packages/web/dist/mark-light.svg +1 -1
- package/packages/web/dist/mark-mono.svg +2 -0
- package/packages/web/dist/mark-small-light.svg +2 -0
- package/packages/web/dist/mark-small.svg +2 -0
- package/packages/web/dist/mark-white.svg +2 -0
- package/packages/web/dist/mark.svg +1 -1
- package/packages/web/dist/models/LICENSE.txt +5 -0
- package/packages/web/dist/models/brain.glb +0 -0
- package/packages/web/dist/site.webmanifest +23 -0
- package/packages/web/dist/wordmark-light.svg +2 -0
- package/packages/web/dist/wordmark.svg +2 -0
- package/packages/web/package.json +1 -1
- package/scripts/rookery.mjs +204 -122
- package/scripts/updater.mjs +227 -0
- package/packages/cli/dist/tui/components/Wordmark.d.ts +0 -35
- package/packages/cli/dist/tui/components/Wordmark.d.ts.map +0 -1
- package/packages/cli/dist/tui/components/Wordmark.js +0 -81
- package/packages/cli/dist/tui/components/Wordmark.js.map +0 -1
- package/packages/core/dist/agents/orchestrator.d.ts +0 -24
- package/packages/core/dist/agents/orchestrator.d.ts.map +0 -1
- package/packages/core/dist/agents/orchestrator.js +0 -88
- package/packages/core/dist/agents/orchestrator.js.map +0 -1
- package/packages/core/dist/agents/roles.d.ts +0 -21
- package/packages/core/dist/agents/roles.d.ts.map +0 -1
- package/packages/core/dist/agents/roles.js +0 -81
- package/packages/core/dist/agents/roles.js.map +0 -1
- package/packages/core/dist/agents/team.d.ts +0 -105
- package/packages/core/dist/agents/team.d.ts.map +0 -1
- package/packages/core/dist/agents/team.js +0 -623
- package/packages/core/dist/agents/team.js.map +0 -1
- package/packages/core/dist/providers/codex.d.ts +0 -10
- package/packages/core/dist/providers/codex.d.ts.map +0 -1
- package/packages/core/dist/providers/codex.js +0 -375
- package/packages/core/dist/providers/codex.js.map +0 -1
- package/packages/core/dist/tools/browser.d.ts +0 -20
- package/packages/core/dist/tools/browser.d.ts.map +0 -1
- package/packages/core/dist/tools/browser.js +0 -72
- package/packages/core/dist/tools/browser.js.map +0 -1
- package/packages/server/dist/routes/agents.d.ts +0 -5
- package/packages/server/dist/routes/agents.d.ts.map +0 -1
- package/packages/server/dist/routes/agents.js +0 -6
- package/packages/server/dist/routes/agents.js.map +0 -1
- package/packages/server/dist/routes/team.d.ts +0 -11
- package/packages/server/dist/routes/team.d.ts.map +0 -1
- package/packages/server/dist/routes/team.js +0 -36
- package/packages/server/dist/routes/team.js.map +0 -1
- package/packages/web/dist/assets/3d-force-graph-BPZmoydi.js +0 -1163
- package/packages/web/dist/assets/index-IBSTzK7-.js +0 -1255
- package/packages/web/dist/assets/index-qUXUui7W.css +0 -1
- package/packages/web/dist/assets/three-spritetext-B9ZIW7c-.js +0 -4
- package/packages/web/dist/assets/three.module-cmFfBtHS.js +0 -4228
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import type { CronJob, CronJobKind, CronScript, CronRun, PermissionLevel, RequesterKind } from '../types.js';
|
|
2
|
+
import type { CronEventOutcome, CronJob, CronJobKind, CronScript, CronRun, CronTriggerMode, PermissionLevel, RequesterKind } from '../types.js';
|
|
3
|
+
import type { NotifyUserInput } from '../org/controller.js';
|
|
3
4
|
import type { Logger } from '../logger.js';
|
|
4
5
|
import type { Store } from '../memory/store.js';
|
|
5
6
|
/**
|
|
@@ -12,16 +13,16 @@ import type { Store } from '../memory/store.js';
|
|
|
12
13
|
* never runs twice at once, what happens to a missed run after a restart -
|
|
13
14
|
* and hands the actual execution to a runner the runtime supplies.
|
|
14
15
|
*
|
|
15
|
-
* Every outcome is recorded as a run and
|
|
16
|
-
*
|
|
16
|
+
* Every outcome is recorded as a run and reaches the user as a `schedule`
|
|
17
|
+
* notification, so what happened overnight is waiting for them in the morning.
|
|
17
18
|
*/
|
|
18
19
|
export interface CronRunOutcome {
|
|
19
20
|
status: 'done' | 'failed';
|
|
20
|
-
/** A script pre-check
|
|
21
|
+
/** A script pre-check or a `[SILENT]` reply suppresses the outcome notification. */
|
|
21
22
|
silent?: boolean;
|
|
22
23
|
result?: string;
|
|
23
24
|
error?: string;
|
|
24
|
-
/** The conversation
|
|
25
|
+
/** The conversation this one run happened in - recorded on the run, not kept on the job. */
|
|
25
26
|
sessionId?: string;
|
|
26
27
|
assignmentId?: string;
|
|
27
28
|
}
|
|
@@ -34,17 +35,35 @@ export interface CronSchedulerOptions {
|
|
|
34
35
|
catchUpWindowMs?: number;
|
|
35
36
|
/** Hard stop for one run. */
|
|
36
37
|
timeoutMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Where a run's outcome goes - the controller's `notifyUser`, handed in as
|
|
40
|
+
* a closure because the scheduler is built before the controller exists.
|
|
41
|
+
* Left out, the scheduler stores the notification itself and emits it.
|
|
42
|
+
*/
|
|
43
|
+
notify?: (input: NotifyUserInput) => void;
|
|
37
44
|
}
|
|
38
45
|
export interface CronJobInput {
|
|
46
|
+
/** Fixed id for a job that must stay findable across restarts (e.g. the board watcher); random otherwise. */
|
|
47
|
+
id?: string;
|
|
39
48
|
orgId: string;
|
|
40
49
|
name: string;
|
|
50
|
+
/** May be empty when `triggerMode` is `event`: such a job has no clock. */
|
|
41
51
|
schedule: string;
|
|
52
|
+
triggerMode?: CronTriggerMode;
|
|
53
|
+
/** Shortest gap between runs before an event starts another; the default otherwise. */
|
|
54
|
+
eventCooldownMs?: number;
|
|
42
55
|
kind?: CronJobKind;
|
|
43
56
|
script?: CronScript;
|
|
44
57
|
remainingRuns?: number;
|
|
45
58
|
prompt: string;
|
|
46
59
|
agentId?: string;
|
|
47
60
|
projectId?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Pin the job to an existing conversation instead of letting the first run
|
|
63
|
+
* create a dedicated one - the "reply in this same chat" case for a
|
|
64
|
+
* one-off follow-up. Only meaningful for the assistant's own jobs.
|
|
65
|
+
*/
|
|
66
|
+
sessionId?: string;
|
|
48
67
|
permission?: PermissionLevel;
|
|
49
68
|
enabled?: boolean;
|
|
50
69
|
once?: boolean;
|
|
@@ -53,6 +72,8 @@ export interface CronJobInput {
|
|
|
53
72
|
export interface CronJobPatch {
|
|
54
73
|
name?: string;
|
|
55
74
|
schedule?: string;
|
|
75
|
+
triggerMode?: CronTriggerMode;
|
|
76
|
+
eventCooldownMs?: number | null;
|
|
56
77
|
kind?: CronJobKind;
|
|
57
78
|
script?: CronScript | null;
|
|
58
79
|
remainingRuns?: number | null;
|
|
@@ -75,12 +96,22 @@ export declare class CronScheduler extends EventEmitter {
|
|
|
75
96
|
start(): void;
|
|
76
97
|
/** Stop the clock and abort whatever is running. */
|
|
77
98
|
stop(): void;
|
|
78
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The schedules a person can see. The nightly memory run is Rookery's own
|
|
101
|
+
* clockwork, not one of them: it rides the same timer and ledger, but it
|
|
102
|
+
* is shown, edited, switched off and fired from the memory page alone, so
|
|
103
|
+
* every user-facing list leaves it out unless it is asked for by name.
|
|
104
|
+
*/
|
|
105
|
+
list(orgId: string, options?: {
|
|
106
|
+
includeSystem?: boolean;
|
|
107
|
+
}): CronJob[];
|
|
79
108
|
get(id: string): CronJob | null;
|
|
80
109
|
find(orgId: string, ref: string): CronJob | null;
|
|
81
110
|
runs(jobId: string, limit?: number): CronRun[];
|
|
82
111
|
recentRuns(orgId: string, limit?: number): CronRun[];
|
|
83
112
|
isRunning(jobId: string): boolean;
|
|
113
|
+
/** How many runs are in flight right now, the nightly memory run included. */
|
|
114
|
+
get runningCount(): number;
|
|
84
115
|
/** Create a job. Throws CronSyntaxError for a bad expression, Error for a bad kind. */
|
|
85
116
|
create(input: CronJobInput): CronJob;
|
|
86
117
|
/** Change a job. Only the fields given change; a new schedule or switching on recomputes the next run. */
|
|
@@ -91,6 +122,28 @@ export declare class CronScheduler extends EventEmitter {
|
|
|
91
122
|
* running is not started twice; the run in flight is what comes back.
|
|
92
123
|
*/
|
|
93
124
|
runNow(id: string): Promise<CronRun>;
|
|
125
|
+
/**
|
|
126
|
+
* Offer an event to a schedule: a webhook call, or a listener that saw
|
|
127
|
+
* something happen. `source` says who, in words that end up on the run.
|
|
128
|
+
*
|
|
129
|
+
* Nothing is dropped and nothing piles up. A job already running gets one
|
|
130
|
+
* more run after this one; a job still resting fires when the rest is over;
|
|
131
|
+
* and however many events arrive meanwhile, they collapse into that one
|
|
132
|
+
* run. A switched-off job ignores events entirely - the switch is what a
|
|
133
|
+
* person reaches for to make it stop, and it would be a nasty surprise if a
|
|
134
|
+
* URL handed out weeks ago still woke it up.
|
|
135
|
+
*/
|
|
136
|
+
runEvent(id: string, source: string): Promise<CronEventOutcome>;
|
|
137
|
+
/**
|
|
138
|
+
* Mint the secret that lets an outside caller fire this job, replacing
|
|
139
|
+
* whatever it had. The previous URL stops working the moment this returns,
|
|
140
|
+
* which is what makes it a rotation as well as a first issue.
|
|
141
|
+
*/
|
|
142
|
+
enableWebhook(id: string): CronJob;
|
|
143
|
+
/** Take the webhook away. The URL answers "no such hook" from here on. */
|
|
144
|
+
disableWebhook(id: string): CronJob;
|
|
145
|
+
/** The job a webhook secret opens, or null. A blank secret opens nothing. */
|
|
146
|
+
findByWebhookToken(token: string): CronJob | null;
|
|
94
147
|
/**
|
|
95
148
|
* Fire every job that is due. The timer calls this; tests call it with a
|
|
96
149
|
* clock of their own. Resolves once the runs it started have finished.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/cron/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/cron/scheduler.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
2
3
|
import { silentLogger } from '../logger.js';
|
|
3
4
|
import { clip } from '../util/queue.js';
|
|
4
5
|
import { CronSyntaxError, describeCron, nextCronRun, parseCron } from './parse.js';
|
|
@@ -8,18 +9,34 @@ const MAX_SLEEP_MS = 60_000;
|
|
|
8
9
|
const MIN_SLEEP_MS = 200;
|
|
9
10
|
const DEFAULT_CATCH_UP_MS = 10 * 60 * 1000;
|
|
10
11
|
const DEFAULT_TIMEOUT_MS = 45 * 60 * 1000;
|
|
11
|
-
/** How much of a result goes into the
|
|
12
|
-
const
|
|
12
|
+
/** How much of a result goes into the outcome notification. */
|
|
13
|
+
const NOTICE_BUDGET = 1500;
|
|
14
|
+
/**
|
|
15
|
+
* How long a job rests after a run before an event may start the next one.
|
|
16
|
+
*
|
|
17
|
+
* This is what keeps a chatty source honest: ten mails arriving in a minute
|
|
18
|
+
* are one reason to look at the mailbox, not ten. Nothing is lost - the
|
|
19
|
+
* events that arrive during the rest collapse into a single run at the end of
|
|
20
|
+
* it - and a job that wants every single event sets its cooldown to 0.
|
|
21
|
+
*/
|
|
22
|
+
const DEFAULT_EVENT_COOLDOWN_MS = 60_000;
|
|
13
23
|
export class CronScheduler extends EventEmitter {
|
|
14
24
|
#store;
|
|
15
25
|
#runner;
|
|
16
26
|
#log;
|
|
17
27
|
#catchUpMs;
|
|
18
28
|
#timeoutMs;
|
|
29
|
+
#notify;
|
|
19
30
|
#timer = null;
|
|
20
31
|
#started = false;
|
|
21
32
|
/** Abort controllers of runs in flight, by job id: one run per job at a time. */
|
|
22
33
|
#running = new Map();
|
|
34
|
+
/**
|
|
35
|
+
* Events that arrived while their job was busy or resting, one entry per
|
|
36
|
+
* job. Deliberately in memory: it says "something happened that this job has
|
|
37
|
+
* not looked at yet", which a restart answers by looking anyway.
|
|
38
|
+
*/
|
|
39
|
+
#pending = new Map();
|
|
23
40
|
constructor(options) {
|
|
24
41
|
super();
|
|
25
42
|
this.#store = options.store;
|
|
@@ -27,6 +44,7 @@ export class CronScheduler extends EventEmitter {
|
|
|
27
44
|
this.#log = options.logger ?? silentLogger;
|
|
28
45
|
this.#catchUpMs = options.catchUpWindowMs ?? DEFAULT_CATCH_UP_MS;
|
|
29
46
|
this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
47
|
+
this.#notify = options.notify;
|
|
30
48
|
}
|
|
31
49
|
/* ------------------------------- lifecycle ------------------------------ */
|
|
32
50
|
get started() {
|
|
@@ -46,6 +64,11 @@ export class CronScheduler extends EventEmitter {
|
|
|
46
64
|
this.#log.warn('Failed stale schedule runs from a previous process', { count: stale });
|
|
47
65
|
const now = Date.now();
|
|
48
66
|
for (const job of this.#store.cron.enabledJobs()) {
|
|
67
|
+
// A job off the clock has no slot to miss and no expression to compute
|
|
68
|
+
// one from. Without this, a single event-only schedule in the database
|
|
69
|
+
// would take the whole server down on the next start.
|
|
70
|
+
if (!this.#onTheClock(job))
|
|
71
|
+
continue;
|
|
49
72
|
const missedBy = job.nextRunAt === undefined ? Infinity : now - job.nextRunAt;
|
|
50
73
|
if (missedBy <= this.#catchUpMs)
|
|
51
74
|
continue;
|
|
@@ -66,12 +89,23 @@ export class CronScheduler extends EventEmitter {
|
|
|
66
89
|
if (this.#timer)
|
|
67
90
|
clearTimeout(this.#timer);
|
|
68
91
|
this.#timer = null;
|
|
92
|
+
for (const id of [...this.#pending.keys()])
|
|
93
|
+
this.#forget(id);
|
|
69
94
|
for (const controller of this.#running.values())
|
|
70
95
|
controller.abort();
|
|
71
96
|
}
|
|
72
97
|
/* --------------------------------- CRUD --------------------------------- */
|
|
73
|
-
|
|
74
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The schedules a person can see. The nightly memory run is Rookery's own
|
|
100
|
+
* clockwork, not one of them: it rides the same timer and ledger, but it
|
|
101
|
+
* is shown, edited, switched off and fired from the memory page alone, so
|
|
102
|
+
* every user-facing list leaves it out unless it is asked for by name.
|
|
103
|
+
*/
|
|
104
|
+
list(orgId, options = {}) {
|
|
105
|
+
const jobs = this.#store.cron.listJobs(orgId);
|
|
106
|
+
if (options.includeSystem)
|
|
107
|
+
return jobs;
|
|
108
|
+
return jobs.filter((job) => job.kind !== 'sleep');
|
|
75
109
|
}
|
|
76
110
|
get(id) {
|
|
77
111
|
return this.#store.cron.getJob(id);
|
|
@@ -83,14 +117,24 @@ export class CronScheduler extends EventEmitter {
|
|
|
83
117
|
return this.#store.cron.listRuns(jobId, limit);
|
|
84
118
|
}
|
|
85
119
|
recentRuns(orgId, limit) {
|
|
86
|
-
|
|
120
|
+
const runs = this.#store.cron.listRecentRuns(orgId, limit);
|
|
121
|
+
const kinds = new Map(this.#store.cron.listJobs(orgId).map((job) => [job.id, job.kind]));
|
|
122
|
+
return runs.filter((run) => kinds.get(run.jobId) !== 'sleep');
|
|
87
123
|
}
|
|
88
124
|
isRunning(jobId) {
|
|
89
125
|
return this.#running.has(jobId);
|
|
90
126
|
}
|
|
127
|
+
/** How many runs are in flight right now, the nightly memory run included. */
|
|
128
|
+
get runningCount() {
|
|
129
|
+
return this.#running.size;
|
|
130
|
+
}
|
|
91
131
|
/** Create a job. Throws CronSyntaxError for a bad expression, Error for a bad kind. */
|
|
92
132
|
create(input) {
|
|
93
|
-
const
|
|
133
|
+
const triggerMode = input.triggerMode ?? 'schedule';
|
|
134
|
+
// An event-only job has no clock and so needs no expression. One given
|
|
135
|
+
// anyway is still normalised, so putting the job back on the clock later
|
|
136
|
+
// is a change of mode and nothing else.
|
|
137
|
+
const schedule = triggerMode === 'event' && !input.schedule.trim() ? '' : parseCron(input.schedule).expression;
|
|
94
138
|
const kind = input.kind ?? (input.agentId ? 'agent' : 'assistant');
|
|
95
139
|
if (kind === 'agent' && !input.agentId)
|
|
96
140
|
throw new Error('An agent schedule needs an agent.');
|
|
@@ -100,13 +144,15 @@ export class CronScheduler extends EventEmitter {
|
|
|
100
144
|
input = { ...input, prompt: 'assistant' };
|
|
101
145
|
const enabled = input.enabled ?? true;
|
|
102
146
|
validateExecution({ kind, script: input.script, permission: input.permission, enabled, remainingRuns: input.remainingRuns });
|
|
103
|
-
const
|
|
104
|
-
|
|
147
|
+
const onTheClock = triggerMode === 'schedule' && schedule !== '';
|
|
148
|
+
const nextRunAt = enabled && onTheClock ? this.#next(schedule, Date.now()) : null;
|
|
149
|
+
if (enabled && onTheClock && nextRunAt === null) {
|
|
105
150
|
throw new CronSyntaxError('The schedule "' + schedule + '" never matches a real date.');
|
|
106
151
|
}
|
|
107
152
|
const job = this.#store.cron.createJob({
|
|
108
153
|
...input,
|
|
109
154
|
schedule,
|
|
155
|
+
triggerMode,
|
|
110
156
|
kind,
|
|
111
157
|
agentId: kind === 'agent' ? input.agentId : undefined,
|
|
112
158
|
enabled,
|
|
@@ -121,7 +167,11 @@ export class CronScheduler extends EventEmitter {
|
|
|
121
167
|
const current = this.#store.cron.getJob(id);
|
|
122
168
|
if (!current)
|
|
123
169
|
throw new Error('No schedule ' + id + '.');
|
|
124
|
-
const
|
|
170
|
+
const triggerMode = patch.triggerMode ?? current.triggerMode;
|
|
171
|
+
const wanted = patch.schedule !== undefined ? patch.schedule : current.schedule;
|
|
172
|
+
// Putting a job back on the clock without an expression is the one case
|
|
173
|
+
// that must still fail loudly: parseCron says so in its own words.
|
|
174
|
+
const schedule = triggerMode === 'event' && !wanted.trim() ? '' : parseCron(wanted).expression;
|
|
125
175
|
const kind = patch.kind ?? (patch.agentId ? 'agent' : patch.agentId === null ? 'assistant' : current.kind);
|
|
126
176
|
const agentId = patch.agentId === undefined ? current.agentId : (patch.agentId ?? undefined);
|
|
127
177
|
if (kind === 'agent' && !agentId)
|
|
@@ -131,14 +181,22 @@ export class CronScheduler extends EventEmitter {
|
|
|
131
181
|
const permission = patch.permission === undefined ? current.permission : patch.permission ?? undefined;
|
|
132
182
|
const remainingRuns = patch.remainingRuns === undefined ? current.remainingRuns : patch.remainingRuns ?? undefined;
|
|
133
183
|
validateExecution({ kind, script, permission, enabled, remainingRuns });
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
184
|
+
const onTheClock = triggerMode === 'schedule' && schedule !== '';
|
|
185
|
+
const reschedule = schedule !== current.schedule ||
|
|
186
|
+
enabled !== current.enabled ||
|
|
187
|
+
triggerMode !== current.triggerMode ||
|
|
188
|
+
current.nextRunAt === undefined;
|
|
189
|
+
// Off the clock, the next run is not "unknown" but "never": null clears it
|
|
190
|
+
// so neither `dueJobs` nor the timer ever considers this job again.
|
|
191
|
+
const nextRunAt = !enabled || !onTheClock ? null : reschedule ? this.#next(schedule, Date.now()) : undefined;
|
|
192
|
+
if (enabled && onTheClock && reschedule && nextRunAt === null) {
|
|
137
193
|
throw new CronSyntaxError('The schedule "' + schedule + '" never matches a real date.');
|
|
138
194
|
}
|
|
139
195
|
this.#store.cron.updateJob(id, {
|
|
140
196
|
name: patch.name,
|
|
141
197
|
schedule,
|
|
198
|
+
triggerMode,
|
|
199
|
+
eventCooldownMs: patch.eventCooldownMs,
|
|
142
200
|
kind,
|
|
143
201
|
prompt: patch.prompt,
|
|
144
202
|
script: kind === 'script' ? script : null,
|
|
@@ -174,8 +232,97 @@ export class CronScheduler extends EventEmitter {
|
|
|
174
232
|
const job = this.#store.cron.getJob(id);
|
|
175
233
|
if (!job)
|
|
176
234
|
throw new Error('No schedule ' + id + '.');
|
|
235
|
+
// Same guard as tick(): one run per job. A second execution would
|
|
236
|
+
// overwrite the abort controller and leave the first run unabortable.
|
|
237
|
+
if (this.#running.has(id)) {
|
|
238
|
+
const latest = this.#store.cron.listRuns(id, 1)[0];
|
|
239
|
+
if (latest)
|
|
240
|
+
return latest;
|
|
241
|
+
}
|
|
177
242
|
return this.#execute(job, 'manual');
|
|
178
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Offer an event to a schedule: a webhook call, or a listener that saw
|
|
246
|
+
* something happen. `source` says who, in words that end up on the run.
|
|
247
|
+
*
|
|
248
|
+
* Nothing is dropped and nothing piles up. A job already running gets one
|
|
249
|
+
* more run after this one; a job still resting fires when the rest is over;
|
|
250
|
+
* and however many events arrive meanwhile, they collapse into that one
|
|
251
|
+
* run. A switched-off job ignores events entirely - the switch is what a
|
|
252
|
+
* person reaches for to make it stop, and it would be a nasty surprise if a
|
|
253
|
+
* URL handed out weeks ago still woke it up.
|
|
254
|
+
*/
|
|
255
|
+
async runEvent(id, source) {
|
|
256
|
+
const job = this.#store.cron.getJob(id);
|
|
257
|
+
if (!job)
|
|
258
|
+
return { status: 'ignored', reason: 'No schedule ' + id + '.' };
|
|
259
|
+
if (!job.enabled)
|
|
260
|
+
return { status: 'ignored', reason: 'The schedule is switched off.' };
|
|
261
|
+
if (job.remainingRuns === 0)
|
|
262
|
+
return { status: 'ignored', reason: 'This schedule has no remaining runs.' };
|
|
263
|
+
try {
|
|
264
|
+
// The same gate a manual run passes: an unreviewed script does not run
|
|
265
|
+
// because something outside asked nicely.
|
|
266
|
+
validateExecution({ ...job, enabled: true });
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
return { status: 'ignored', reason: error.message };
|
|
270
|
+
}
|
|
271
|
+
if (this.#running.has(id)) {
|
|
272
|
+
this.#remember(id, source);
|
|
273
|
+
return { status: 'coalesced' };
|
|
274
|
+
}
|
|
275
|
+
const waitMs = this.#restLeft(job);
|
|
276
|
+
if (waitMs > 0) {
|
|
277
|
+
this.#remember(id, source);
|
|
278
|
+
this.#armEvent(id, waitMs);
|
|
279
|
+
return { status: 'queued', waitMs };
|
|
280
|
+
}
|
|
281
|
+
// Detached on purpose. Whoever offered the event is answered as soon as the
|
|
282
|
+
// run is booked, not when it finishes: a webhook sender that is made to
|
|
283
|
+
// wait out a model run times out and sends again, and one event would
|
|
284
|
+
// become several. The run row is written before `#execute` reaches its
|
|
285
|
+
// first await, so the answer can still name the run it started.
|
|
286
|
+
let booked;
|
|
287
|
+
void this.#execute(job, 'event', source, (run) => {
|
|
288
|
+
booked = run;
|
|
289
|
+
}).catch((error) => {
|
|
290
|
+
this.#log.error('Event run crashed', { job: job.name, error: String(error) });
|
|
291
|
+
});
|
|
292
|
+
// Nothing was booked: the job went away between the checks above and the
|
|
293
|
+
// booking, which only a concurrent delete can do.
|
|
294
|
+
if (!booked)
|
|
295
|
+
return { status: 'ignored', reason: 'The schedule went away before it could run.' };
|
|
296
|
+
return { status: 'started', run: booked };
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Mint the secret that lets an outside caller fire this job, replacing
|
|
300
|
+
* whatever it had. The previous URL stops working the moment this returns,
|
|
301
|
+
* which is what makes it a rotation as well as a first issue.
|
|
302
|
+
*/
|
|
303
|
+
enableWebhook(id) {
|
|
304
|
+
const job = this.#store.cron.getJob(id);
|
|
305
|
+
if (!job)
|
|
306
|
+
throw new Error('No schedule ' + id + '.');
|
|
307
|
+
this.#store.cron.updateJob(id, { webhookToken: randomUUID() });
|
|
308
|
+
const updated = this.#store.cron.getJob(id) ?? job;
|
|
309
|
+
this.#announce(updated);
|
|
310
|
+
return updated;
|
|
311
|
+
}
|
|
312
|
+
/** Take the webhook away. The URL answers "no such hook" from here on. */
|
|
313
|
+
disableWebhook(id) {
|
|
314
|
+
const job = this.#store.cron.getJob(id);
|
|
315
|
+
if (!job)
|
|
316
|
+
throw new Error('No schedule ' + id + '.');
|
|
317
|
+
this.#store.cron.updateJob(id, { webhookToken: null });
|
|
318
|
+
const updated = this.#store.cron.getJob(id) ?? job;
|
|
319
|
+
this.#announce(updated);
|
|
320
|
+
return updated;
|
|
321
|
+
}
|
|
322
|
+
/** The job a webhook secret opens, or null. A blank secret opens nothing. */
|
|
323
|
+
findByWebhookToken(token) {
|
|
324
|
+
return this.#store.cron.findJobByWebhookToken(token);
|
|
325
|
+
}
|
|
179
326
|
/**
|
|
180
327
|
* Fire every job that is due. The timer calls this; tests call it with a
|
|
181
328
|
* clock of their own. Resolves once the runs it started have finished.
|
|
@@ -189,7 +336,9 @@ export class CronScheduler extends EventEmitter {
|
|
|
189
336
|
}
|
|
190
337
|
this.#arm();
|
|
191
338
|
}
|
|
192
|
-
async #execute(job, trigger
|
|
339
|
+
async #execute(job, trigger, source,
|
|
340
|
+
/** Called the moment the run is on the books, before any work starts. */
|
|
341
|
+
onBooked) {
|
|
193
342
|
if (this.#running.has(job.id)) {
|
|
194
343
|
// One run at a time. The clock moves on so the job is not re-armed for
|
|
195
344
|
// the same minute again and again while a long run is under way.
|
|
@@ -209,10 +358,14 @@ export class CronScheduler extends EventEmitter {
|
|
|
209
358
|
if (job.once || job.remainingRuns === 1) {
|
|
210
359
|
this.#store.cron.updateJob(job.id, { enabled: false, nextRunAt: null }, false);
|
|
211
360
|
}
|
|
212
|
-
else {
|
|
361
|
+
else if (this.#onTheClock(job)) {
|
|
362
|
+
// A run is a run whoever asked for it, so an event run restarts the
|
|
363
|
+
// backstop too: the clock is there to catch the events that never
|
|
364
|
+
// arrive, and one just did.
|
|
213
365
|
this.#store.cron.updateJob(job.id, { nextRunAt: this.#next(job.schedule, started) }, false);
|
|
214
366
|
}
|
|
215
|
-
const run = this.#store.cron.createRun({ jobId: job.id, orgId: job.orgId, trigger, sessionId: job.sessionId });
|
|
367
|
+
const run = this.#store.cron.createRun({ jobId: job.id, orgId: job.orgId, trigger, sessionId: job.sessionId, source });
|
|
368
|
+
onBooked?.(run);
|
|
216
369
|
const controller = new AbortController();
|
|
217
370
|
this.#running.set(job.id, controller);
|
|
218
371
|
const timer = setTimeout(() => controller.abort(), this.#timeoutMs);
|
|
@@ -251,29 +404,133 @@ export class CronScheduler extends EventEmitter {
|
|
|
251
404
|
lastStatus: outcome.status,
|
|
252
405
|
lastError: outcome.error ?? null,
|
|
253
406
|
runCount: current.runCount + 1,
|
|
254
|
-
sessionId: outcome.sessionId && !current.sessionId ? outcome.sessionId : undefined,
|
|
255
407
|
}, false);
|
|
256
408
|
if (!outcome.silent)
|
|
257
|
-
this.#
|
|
409
|
+
this.#postOutcome(current, run.id, outcome, source);
|
|
258
410
|
}
|
|
259
411
|
const finishedRun = this.#store.cron.getRun(run.id) ?? run;
|
|
260
412
|
this.#announce(this.#store.cron.getJob(job.id) ?? job, finishedRun);
|
|
261
413
|
this.#log.info('Schedule run finished', { job: job.name, status: outcome.status, durationMs: finished - started });
|
|
414
|
+
// An event that arrived while this was running has not been looked at by
|
|
415
|
+
// anything yet. Detached on purpose: whoever started this run is waiting
|
|
416
|
+
// for this run, not for the one the next event earned.
|
|
417
|
+
void this.#drain(job.id);
|
|
262
418
|
return finishedRun;
|
|
263
419
|
}
|
|
264
|
-
|
|
265
|
-
|
|
420
|
+
/* ---------------------------- pending events ---------------------------- */
|
|
421
|
+
/** Note that something happened, keeping only the most recent reason. */
|
|
422
|
+
#remember(id, source) {
|
|
423
|
+
const state = this.#pending.get(id);
|
|
424
|
+
if (state)
|
|
425
|
+
state.source = source;
|
|
426
|
+
else
|
|
427
|
+
this.#pending.set(id, { source });
|
|
428
|
+
}
|
|
429
|
+
#forget(id) {
|
|
430
|
+
const state = this.#pending.get(id);
|
|
431
|
+
if (state?.timer)
|
|
432
|
+
clearTimeout(state.timer);
|
|
433
|
+
this.#pending.delete(id);
|
|
434
|
+
}
|
|
435
|
+
/** How much of the job's rest is still to come, in milliseconds. */
|
|
436
|
+
#restLeft(job) {
|
|
437
|
+
const cooldown = job.eventCooldownMs ?? DEFAULT_EVENT_COOLDOWN_MS;
|
|
438
|
+
if (cooldown <= 0 || job.lastRunAt === undefined)
|
|
439
|
+
return 0;
|
|
440
|
+
return Math.max(0, job.lastRunAt + cooldown - Date.now());
|
|
441
|
+
}
|
|
442
|
+
/** Whether the clock has anything to say about this job. */
|
|
443
|
+
#onTheClock(job) {
|
|
444
|
+
return job.triggerMode === 'schedule' && job.schedule !== '';
|
|
445
|
+
}
|
|
446
|
+
#armEvent(id, waitMs) {
|
|
447
|
+
const state = this.#pending.get(id);
|
|
448
|
+
if (!state || state.timer)
|
|
449
|
+
return;
|
|
450
|
+
const timer = setTimeout(() => {
|
|
451
|
+
const current = this.#pending.get(id);
|
|
452
|
+
if (current)
|
|
453
|
+
current.timer = undefined;
|
|
454
|
+
void this.#drain(id);
|
|
455
|
+
}, waitMs);
|
|
456
|
+
timer.unref?.();
|
|
457
|
+
state.timer = timer;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Act on an event that had to wait. Called when a run ends and when a rest
|
|
461
|
+
* is over; either way it fires at most one run and drops the note, so a
|
|
462
|
+
* burst of events can never become a burst of runs.
|
|
463
|
+
*/
|
|
464
|
+
async #drain(id) {
|
|
465
|
+
const state = this.#pending.get(id);
|
|
466
|
+
if (!state || state.timer)
|
|
467
|
+
return;
|
|
468
|
+
const job = this.#store.cron.getJob(id);
|
|
469
|
+
if (!job || !job.enabled || job.remainingRuns === 0) {
|
|
470
|
+
this.#forget(id);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
// Still busy: the run in flight calls this again when it finishes.
|
|
474
|
+
if (this.#running.has(id))
|
|
475
|
+
return;
|
|
476
|
+
const waitMs = this.#restLeft(job);
|
|
477
|
+
if (waitMs > 0) {
|
|
478
|
+
this.#armEvent(id, waitMs);
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const { source } = state;
|
|
482
|
+
this.#forget(id);
|
|
483
|
+
try {
|
|
484
|
+
await this.#execute(job, 'event', source);
|
|
485
|
+
}
|
|
486
|
+
catch (error) {
|
|
487
|
+
this.#log.error('Event run crashed', { job: job.name, error: String(error) });
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* What the user reads about one run, from whoever ran the job: a
|
|
492
|
+
* notification of kind `schedule` - the same title and text the inbox mail
|
|
493
|
+
* used to carry, now pointing at the job, the run and the conversation it
|
|
494
|
+
* ran in, so a reply to it can continue right there.
|
|
495
|
+
*
|
|
496
|
+
* Through the runtime's `notify` when there is one - the controller's
|
|
497
|
+
* `notifyUser`, the one road to the user. A scheduler built on its own (a
|
|
498
|
+
* test, a one-off command) writes the row itself and announces it on its
|
|
499
|
+
* own emitter instead.
|
|
500
|
+
*/
|
|
501
|
+
#postOutcome(job, runId, outcome, source) {
|
|
266
502
|
const when = new Date().toLocaleString('en-GB', { dateStyle: 'short', timeStyle: 'short' });
|
|
267
|
-
const
|
|
503
|
+
const title = 'Schedule "' + job.name + '" ' + (outcome.status === 'done' ? 'completed' : 'failed');
|
|
504
|
+
// Why it ran at all: the expression when the clock asked, and the name of
|
|
505
|
+
// whatever happened when something else did. An event-only job has no
|
|
506
|
+
// expression to quote, so quoting one would be an invention.
|
|
507
|
+
const because = source ? 'fired by ' + source : job.schedule ? describeCron(job.schedule) : 'on events';
|
|
268
508
|
const body = outcome.status === 'done'
|
|
269
|
-
? '
|
|
270
|
-
|
|
509
|
+
? 'Completed at ' + when + ' (' + because + '). Result: ' +
|
|
510
|
+
(clip(outcome.result ?? '', NOTICE_BUDGET) || '(no text)')
|
|
511
|
+
: 'Failed at ' + when + ' (' + because + '): ' + (outcome.error ?? 'unknown error');
|
|
512
|
+
const byAgent = job.kind === 'agent' && Boolean(job.agentId);
|
|
513
|
+
const input = {
|
|
514
|
+
orgId: job.orgId,
|
|
515
|
+
kind: 'schedule',
|
|
516
|
+
title,
|
|
517
|
+
body,
|
|
518
|
+
fromKind: byAgent ? 'agent' : 'assistant',
|
|
519
|
+
fromAgentId: byAgent ? job.agentId : undefined,
|
|
520
|
+
cronJobId: job.id,
|
|
521
|
+
cronRunId: runId,
|
|
522
|
+
sessionId: outcome.sessionId,
|
|
523
|
+
};
|
|
271
524
|
try {
|
|
272
|
-
|
|
273
|
-
|
|
525
|
+
if (this.#notify) {
|
|
526
|
+
this.#notify(input);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const notification = this.#store.org.createNotification({ ...input, orgId: job.orgId });
|
|
530
|
+
this.emit('notification', { type: 'notification', notification });
|
|
274
531
|
}
|
|
275
532
|
catch (error) {
|
|
276
|
-
this.#log.warn('Could not post schedule outcome
|
|
533
|
+
this.#log.warn('Could not post the schedule outcome', { error: error.message });
|
|
277
534
|
}
|
|
278
535
|
}
|
|
279
536
|
/* -------------------------------- internals ------------------------------ */
|
|
@@ -312,11 +569,22 @@ export function describeCronJob(job, agentSlug) {
|
|
|
312
569
|
: job.kind === 'sleep'
|
|
313
570
|
? 'the memory itself'
|
|
314
571
|
: 'you';
|
|
315
|
-
|
|
572
|
+
// An event job is not "off" because it has no next time - it is waiting.
|
|
573
|
+
// Saying "off" would read as broken and invite someone to fix what works.
|
|
574
|
+
const next = !job.enabled
|
|
575
|
+
? 'off'
|
|
576
|
+
: job.nextRunAt
|
|
577
|
+
? 'next ' + new Date(job.nextRunAt).toLocaleString('en-GB')
|
|
578
|
+
: job.triggerMode === 'event'
|
|
579
|
+
? 'waiting for events'
|
|
580
|
+
: 'off';
|
|
316
581
|
const last = job.lastRunAt
|
|
317
582
|
? ', last ' + new Date(job.lastRunAt).toLocaleString('en-GB') + ' ' + (job.lastStatus ?? '')
|
|
318
583
|
: '';
|
|
319
|
-
|
|
584
|
+
const timing = job.schedule ? job.schedule + ' (' + describeCron(job.schedule) + ')' : 'on events';
|
|
585
|
+
const also = job.schedule && job.triggerMode === 'event' ? ', clock off' : '';
|
|
586
|
+
return ('- ' + job.id.slice(0, 8) + ' "' + job.name + '": ' + timing + also +
|
|
587
|
+
(job.webhookToken ? ', webhook' : '') +
|
|
320
588
|
(job.once ? ', once' : '') + ', by ' + who + ', ' + next + last + ' - ' + clip(job.prompt, 160));
|
|
321
589
|
}
|
|
322
590
|
function validateExecution(job) {
|