@aitne/daemon 0.1.10 → 0.1.11

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.
Files changed (305) hide show
  1. package/dist/adapters/adapter-watchdog.d.ts +70 -0
  2. package/dist/adapters/adapter-watchdog.js +115 -0
  3. package/dist/adapters/discord.d.ts +17 -1
  4. package/dist/adapters/discord.js +33 -0
  5. package/dist/adapters/notification-manager.d.ts +27 -1
  6. package/dist/adapters/notification-manager.js +54 -39
  7. package/dist/adapters/slack-adapter.d.ts +26 -1
  8. package/dist/adapters/slack-adapter.js +41 -0
  9. package/dist/adapters/telegram-adapter.d.ts +18 -1
  10. package/dist/adapters/telegram-adapter.js +41 -2
  11. package/dist/adapters/types.d.ts +20 -0
  12. package/dist/adapters/whatsapp-adapter.d.ts +26 -7
  13. package/dist/adapters/whatsapp-adapter.js +74 -21
  14. package/dist/api/env-writer.js +8 -5
  15. package/dist/api/helpers/agent-errors-registry.d.ts +5 -5
  16. package/dist/api/helpers/agent-errors-registry.js +5 -5
  17. package/dist/api/routes/agent.js +33 -12
  18. package/dist/api/routes/agents/index.js +75 -16
  19. package/dist/api/routes/agents/views.d.ts +37 -2
  20. package/dist/api/routes/agents/views.js +64 -2
  21. package/dist/api/routes/background-task.d.ts +22 -0
  22. package/dist/api/routes/background-task.js +338 -0
  23. package/dist/api/routes/browser-history.js +9 -1
  24. package/dist/api/routes/context/permissions.js +3 -2
  25. package/dist/api/routes/context/snapshots.js +0 -3
  26. package/dist/api/routes/context/write.js +3 -17
  27. package/dist/api/routes/dashboard/config.js +48 -12
  28. package/dist/api/routes/dashboard/cost-approvals.js +66 -0
  29. package/dist/api/routes/dashboard/notifications.js +9 -9
  30. package/dist/api/routes/integrations/crud-patch.js +5 -1
  31. package/dist/api/routes/integrations-reconcile.js +2 -2
  32. package/dist/api/routes/notion.d.ts +1 -1
  33. package/dist/api/routes/observations.js +7 -7
  34. package/dist/api/routes/obsidian.d.ts +1 -1
  35. package/dist/api/routes/receipts.js +5 -1
  36. package/dist/api/routes/setup-migrate.js +1 -1
  37. package/dist/api/routes/setup.js +1 -1
  38. package/dist/api/routes/task-flows.d.ts +1 -1
  39. package/dist/api/routes/task-flows.js +1 -1
  40. package/dist/api/routes/tuning.d.ts +29 -0
  41. package/dist/api/routes/tuning.js +304 -0
  42. package/dist/api/server.d.ts +44 -16
  43. package/dist/api/server.js +9 -0
  44. package/dist/bootstrap/adapters.d.ts +19 -0
  45. package/dist/bootstrap/adapters.js +61 -0
  46. package/dist/bootstrap/api.d.ts +5 -3
  47. package/dist/bootstrap/api.js +45 -13
  48. package/dist/bootstrap/catchup.d.ts +1 -1
  49. package/dist/bootstrap/catchup.js +11 -11
  50. package/dist/bootstrap/event-pipeline.d.ts +11 -0
  51. package/dist/bootstrap/event-pipeline.js +245 -7
  52. package/dist/bootstrap/observers.js +9 -6
  53. package/dist/bootstrap/schedule-helpers.d.ts +104 -6
  54. package/dist/bootstrap/schedule-helpers.js +172 -19
  55. package/dist/config.js +26 -12
  56. package/dist/core/agent-core.d.ts +33 -1
  57. package/dist/core/agent-core.js +36 -1
  58. package/dist/core/agents/activity-scan-cadence.d.ts +103 -0
  59. package/dist/core/agents/activity-scan-cadence.js +127 -0
  60. package/dist/core/agents/agent-route-override.d.ts +53 -0
  61. package/dist/core/agents/agent-route-override.js +69 -0
  62. package/dist/core/agents/builtin-registry.d.ts +51 -14
  63. package/dist/core/agents/builtin-registry.js +92 -15
  64. package/dist/core/agents/config-gate-reconcile.d.ts +38 -0
  65. package/dist/core/agents/config-gate-reconcile.js +51 -0
  66. package/dist/core/agents/cron-substitute.d.ts +1 -1
  67. package/dist/core/agents/cron-substitute.js +1 -1
  68. package/dist/core/agents/custom-routine-migration.d.ts +60 -0
  69. package/dist/core/agents/custom-routine-migration.js +149 -0
  70. package/dist/core/agents/firing-blocked.d.ts +1 -1
  71. package/dist/core/agents/hourly-cadence.d.ts +102 -0
  72. package/dist/core/agents/hourly-cadence.js +126 -0
  73. package/dist/core/agents/loader-boot.js +23 -0
  74. package/dist/core/agents/loader.d.ts +19 -0
  75. package/dist/core/agents/loader.js +34 -2
  76. package/dist/core/agents/override-merge.d.ts +1 -1
  77. package/dist/core/agents/override-merge.js +9 -1
  78. package/dist/core/agents/recurrence-convert.d.ts +1 -1
  79. package/dist/core/agents/recurrence-convert.js +1 -1
  80. package/dist/core/agents/recurring-schedule-adapter.js +8 -0
  81. package/dist/core/alerts.js +6 -6
  82. package/dist/core/backends/auth-health-monitor.d.ts +2 -2
  83. package/dist/core/backends/auth-health-monitor.js +1 -1
  84. package/dist/core/backends/backend-router.d.ts +27 -1
  85. package/dist/core/backends/backend-router.js +165 -1
  86. package/dist/core/backends/claude-code-core.d.ts +71 -31
  87. package/dist/core/backends/claude-code-core.js +282 -54
  88. package/dist/core/backends/cli-quota-guards.d.ts +29 -1
  89. package/dist/core/backends/cli-quota-guards.js +40 -5
  90. package/dist/core/backends/codex-core.d.ts +6 -0
  91. package/dist/core/backends/codex-core.js +22 -6
  92. package/dist/core/backends/failure-spend.d.ts +58 -0
  93. package/dist/core/backends/failure-spend.js +137 -0
  94. package/dist/core/backends/gemini-cli-core.d.ts +6 -0
  95. package/dist/core/backends/gemini-cli-core.js +25 -6
  96. package/dist/core/backends/model-registry.d.ts +1 -1
  97. package/dist/core/backends/model-registry.js +4 -4
  98. package/dist/core/backends/opencode-core.d.ts +1 -1
  99. package/dist/core/backends/opencode-core.js +5 -5
  100. package/dist/core/backends/plan-presets.js +39 -15
  101. package/dist/core/bang-commands/commands-cost.js +3 -1
  102. package/dist/core/bang-commands/commands-report.js +4 -3
  103. package/dist/core/bang-commands/commands-research.js +4 -1
  104. package/dist/core/bang-commands/commands-revert-tuning.d.ts +18 -0
  105. package/dist/core/bang-commands/commands-revert-tuning.js +63 -0
  106. package/dist/core/bang-commands/commands-stop-start.js +3 -3
  107. package/dist/core/bang-commands/commands-task-control.d.ts +19 -0
  108. package/dist/core/bang-commands/commands-task-control.js +147 -0
  109. package/dist/core/bang-commands/commands-wiki.js +5 -5
  110. package/dist/core/bang-commands/index.d.ts +2 -0
  111. package/dist/core/bang-commands/index.js +12 -0
  112. package/dist/core/bang-commands/registry.d.ts +12 -0
  113. package/dist/core/browser-history/research-cluster-fanout.d.ts +28 -14
  114. package/dist/core/browser-history/research-cluster-fanout.js +39 -16
  115. package/dist/core/channel-timeline.d.ts +5 -1
  116. package/dist/core/channel-timeline.js +13 -0
  117. package/dist/core/context/index-reconciler.js +5 -2
  118. package/dist/core/context/policy-index-reconciler.d.ts +6 -4
  119. package/dist/core/context/policy-index-runner.js +25 -6
  120. package/dist/core/context-builder-calendar.js +10 -2
  121. package/dist/core/context-builder-conversation.d.ts +8 -1
  122. package/dist/core/context-builder-conversation.js +41 -7
  123. package/dist/core/context-builder-yesterday.js +4 -3
  124. package/dist/core/context-builder.d.ts +7 -2
  125. package/dist/core/context-builder.js +62 -20
  126. package/dist/core/context-file-serializer.d.ts +1 -1
  127. package/dist/core/context-file-serializer.js +1 -1
  128. package/dist/core/context-health.js +2 -2
  129. package/dist/core/context-paths.d.ts +1 -1
  130. package/dist/core/context-paths.js +1 -1
  131. package/dist/core/context-validation/prepare-write.js +1 -1
  132. package/dist/core/context-validation/routine-rulebook.d.ts +1 -1
  133. package/dist/core/context-vault-aliases.d.ts +0 -13
  134. package/dist/core/context-vault-aliases.js +37 -0
  135. package/dist/core/custom-routines.d.ts +99 -0
  136. package/dist/core/custom-routines.js +187 -0
  137. package/dist/core/daemon-api-cli.js +49 -0
  138. package/dist/core/day-boundary.d.ts +46 -0
  139. package/dist/core/day-boundary.js +40 -0
  140. package/dist/core/dispatcher-activity-scan.d.ts +221 -0
  141. package/dist/core/dispatcher-activity-scan.js +775 -0
  142. package/dist/core/dispatcher-error-handling.d.ts +6 -11
  143. package/dist/core/dispatcher-error-handling.js +38 -62
  144. package/dist/core/dispatcher-hourly-check.js +6 -1
  145. package/dist/core/dispatcher-message-handler.d.ts +10 -0
  146. package/dist/core/dispatcher-message-handler.js +17 -0
  147. package/dist/core/dispatcher-morning-routine.d.ts +6 -6
  148. package/dist/core/dispatcher-morning-routine.js +13 -13
  149. package/dist/core/dispatcher-result-processor.d.ts +33 -0
  150. package/dist/core/dispatcher-result-processor.js +167 -11
  151. package/dist/core/dispatcher-scheduled-background-task.d.ts +42 -0
  152. package/dist/core/dispatcher-scheduled-background-task.js +89 -0
  153. package/dist/core/dispatcher-scheduled-tasks.d.ts +63 -1
  154. package/dist/core/dispatcher-scheduled-tasks.js +213 -6
  155. package/dist/core/dispatcher-task-delivery.d.ts +105 -0
  156. package/dist/core/dispatcher-task-delivery.js +555 -0
  157. package/dist/core/dispatcher-types.d.ts +48 -9
  158. package/dist/core/dispatcher-types.js +3 -3
  159. package/dist/core/dispatcher.d.ts +112 -31
  160. package/dist/core/dispatcher.js +284 -59
  161. package/dist/core/dm-freshness-metrics.d.ts +1 -1
  162. package/dist/core/drift-effects.js +2 -2
  163. package/dist/core/feedback/consolidation-prep.js +17 -5
  164. package/dist/core/feedback/eviction-scorer.js +6 -2
  165. package/dist/core/feedback/lesson-format.js +9 -4
  166. package/dist/core/feedback/lesson-injection.d.ts +1 -1
  167. package/dist/core/feedback/lesson-injection.js +17 -2
  168. package/dist/core/feedback/lesson-store-overview.d.ts +8 -4
  169. package/dist/core/feedback/lesson-store-overview.js +8 -4
  170. package/dist/core/feedback/regeneralization-prep.js +29 -16
  171. package/dist/core/feedback/self-performance-prep.d.ts +186 -0
  172. package/dist/core/feedback/self-performance-prep.js +541 -0
  173. package/dist/core/feedback/tuning-actuator.d.ts +198 -0
  174. package/dist/core/feedback/tuning-actuator.js +432 -0
  175. package/dist/core/feedback/tuning-recommender.d.ts +247 -0
  176. package/dist/core/feedback/tuning-recommender.js +580 -0
  177. package/dist/core/feedback/tuning-revert-monitor.d.ts +90 -0
  178. package/dist/core/feedback/tuning-revert-monitor.js +213 -0
  179. package/dist/core/health-monitor.d.ts +6 -0
  180. package/dist/core/health-monitor.js +1 -1
  181. package/dist/core/injection-policy.d.ts +4 -4
  182. package/dist/core/injection-policy.js +4 -4
  183. package/dist/core/integration-main-backend.js +4 -0
  184. package/dist/core/management-md.d.ts +2 -2
  185. package/dist/core/management-md.js +51 -13
  186. package/dist/core/morning/orchestrator.d.ts +2 -2
  187. package/dist/core/morning/orchestrator.js +2 -2
  188. package/dist/core/notification-gate.d.ts +64 -0
  189. package/dist/core/notification-gate.js +51 -0
  190. package/dist/core/notification-rate-limit.d.ts +40 -0
  191. package/dist/core/notification-rate-limit.js +50 -0
  192. package/dist/core/policy-files.d.ts +1 -1
  193. package/dist/core/policy-files.js +2 -2
  194. package/dist/core/pre-pass-freshness.d.ts +4 -4
  195. package/dist/core/retention.d.ts +5 -0
  196. package/dist/core/retention.js +20 -4
  197. package/dist/core/review-context.d.ts +1 -1
  198. package/dist/core/review-context.js +10 -5
  199. package/dist/core/roadmap-write-lock.d.ts +2 -1
  200. package/dist/core/roadmap-write-lock.js +15 -10
  201. package/dist/core/routine-acquisition-plan.d.ts +47 -1
  202. package/dist/core/routine-acquisition-plan.js +78 -20
  203. package/dist/core/routine-fetch-window-retry.js +7 -4
  204. package/dist/core/routine-fetch-window-runner.d.ts +39 -3
  205. package/dist/core/routine-fetch-window-runner.js +264 -13
  206. package/dist/core/routine-windows.d.ts +2 -2
  207. package/dist/core/routine-windows.js +8 -5
  208. package/dist/core/scheduler.d.ts +175 -16
  209. package/dist/core/scheduler.js +559 -102
  210. package/dist/core/signal-detector.d.ts +12 -0
  211. package/dist/core/signal-detector.js +53 -9
  212. package/dist/core/skills-compiler-denied-tools.js +2 -2
  213. package/dist/core/skills-compiler-skill-index.d.ts +2 -2
  214. package/dist/core/skills-compiler-skill-index.js +2 -2
  215. package/dist/core/skills-compiler-variants.d.ts +1 -1
  216. package/dist/core/skills-compiler-variants.js +8 -0
  217. package/dist/core/skills-compiler.d.ts +29 -26
  218. package/dist/core/skills-compiler.js +117 -81
  219. package/dist/core/skills-manifest.d.ts +37 -0
  220. package/dist/core/skills-manifest.js +73 -2
  221. package/dist/core/sleep-inhibitor.d.ts +79 -0
  222. package/dist/core/sleep-inhibitor.js +132 -0
  223. package/dist/core/slim-system-prompt-loader.d.ts +77 -0
  224. package/dist/core/slim-system-prompt-loader.js +141 -0
  225. package/dist/core/spawn-gates.d.ts +126 -0
  226. package/dist/core/spawn-gates.js +180 -0
  227. package/dist/core/today-direct-writer.d.ts +2 -2
  228. package/dist/core/today-direct-writer.js +1 -1
  229. package/dist/core/today-write-lock.d.ts +4 -2
  230. package/dist/core/today-write-lock.js +30 -20
  231. package/dist/core/wake-detector.d.ts +55 -0
  232. package/dist/core/wake-detector.js +80 -0
  233. package/dist/core/wiki/compile-lock.d.ts +1 -1
  234. package/dist/core/wiki/compile-lock.js +1 -1
  235. package/dist/core/workdir.js +15 -6
  236. package/dist/db/activity-scan-signals.d.ts +77 -0
  237. package/dist/db/activity-scan-signals.js +378 -0
  238. package/dist/db/agents-store.d.ts +28 -0
  239. package/dist/db/agents-store.js +62 -0
  240. package/dist/db/background-task-clarifications-store.d.ts +81 -0
  241. package/dist/db/background-task-clarifications-store.js +152 -0
  242. package/dist/db/background-task-store.d.ts +207 -0
  243. package/dist/db/background-task-store.js +380 -0
  244. package/dist/db/browser-history-store.d.ts +39 -6
  245. package/dist/db/browser-history-store.js +51 -7
  246. package/dist/db/browser-task-clarifications-store.d.ts +12 -0
  247. package/dist/db/browser-task-clarifications-store.js +35 -5
  248. package/dist/db/browser-task-store.d.ts +3 -0
  249. package/dist/db/browser-task-store.js +29 -4
  250. package/dist/db/deferred-dm.d.ts +86 -0
  251. package/dist/db/deferred-dm.js +199 -0
  252. package/dist/db/migrations.js +330 -0
  253. package/dist/db/observations.d.ts +2 -2
  254. package/dist/db/observations.js +3 -3
  255. package/dist/db/schema.js +217 -16
  256. package/dist/db/voice-transcripts-store.d.ts +1 -1
  257. package/dist/index.js +86 -29
  258. package/dist/messaging/browser-task-mcp-notifier.d.ts +12 -70
  259. package/dist/messaging/browser-task-mcp-notifier.js +30 -151
  260. package/dist/messaging/browser-task-screenshot-attachment.d.ts +15 -0
  261. package/dist/messaging/browser-task-screenshot-attachment.js +63 -0
  262. package/dist/observers/delegated-sync-worker.d.ts +6 -6
  263. package/dist/observers/delegated-sync-worker.js +10 -10
  264. package/dist/observers/git-delegated-cron.d.ts +1 -1
  265. package/dist/observers/git-delegated-cron.js +2 -2
  266. package/dist/observers/github-poller-classifier.d.ts +3 -3
  267. package/dist/observers/github-poller-classifier.js +3 -3
  268. package/dist/observers/imminent-event-scheduler.d.ts +1 -1
  269. package/dist/observers/imminent-event-scheduler.js +1 -1
  270. package/dist/observers/mail-poller.d.ts +1 -0
  271. package/dist/observers/mail-poller.js +42 -3
  272. package/dist/observers/observation-summarizer/summarizer-client.d.ts +2 -2
  273. package/dist/observers/observation-summarizer/summarizer-client.js +2 -2
  274. package/dist/observers/observation-summarizer/worker.d.ts +2 -2
  275. package/dist/observers/observation-summarizer/worker.js +4 -4
  276. package/dist/observers/obsidian-watcher.d.ts +1 -1
  277. package/dist/observers/obsidian-watcher.js +1 -1
  278. package/dist/safety/agent-write-tracker.d.ts +4 -4
  279. package/dist/safety/agent-write-tracker.js +4 -4
  280. package/dist/safety/audit.d.ts +43 -5
  281. package/dist/safety/audit.js +86 -18
  282. package/dist/safety/risk-classifier.d.ts +6 -0
  283. package/dist/safety/risk-classifier.js +75 -11
  284. package/dist/scheduler/activity-scan-gate.d.ts +86 -0
  285. package/dist/scheduler/activity-scan-gate.js +132 -0
  286. package/dist/services/background-task/background-task-budget.d.ts +80 -0
  287. package/dist/services/background-task/background-task-budget.js +91 -0
  288. package/dist/services/background-task/background-task-driver.d.ts +105 -0
  289. package/dist/services/background-task/background-task-driver.js +416 -0
  290. package/dist/services/background-task/background-task-runner.d.ts +96 -0
  291. package/dist/services/background-task/background-task-runner.js +673 -0
  292. package/dist/services/background-task/background-task-tools.d.ts +84 -0
  293. package/dist/services/background-task/background-task-tools.js +247 -0
  294. package/dist/services/background-task/background-task-transition-events.d.ts +43 -0
  295. package/dist/services/background-task/background-task-transition-events.js +54 -0
  296. package/dist/services/browser-history/automation/egress-denylist.d.ts +1 -1
  297. package/dist/services/browser-history/automation/egress-denylist.js +16 -6
  298. package/dist/services/browser-history/managed-chromium/sandbox-launcher.js +0 -1
  299. package/dist/services/browser-task/browser-task-runner.js +53 -8
  300. package/dist/services/observations-batch.d.ts +1 -1
  301. package/dist/services/observations-batch.js +2 -2
  302. package/dist/settings/runtime-settings.d.ts +38 -11
  303. package/dist/settings/runtime-settings.js +203 -40
  304. package/dist/settings/settings-store.js +11 -3
  305. package/package.json +4 -4
@@ -138,6 +138,7 @@ export declare const runtimeSettingsSchema: z.ZodObject<{
138
138
  proactiveForwardChannelTimelineEnabled: z.ZodDefault<z.ZodBoolean>;
139
139
  proactiveForwardForceFreshSession: z.ZodDefault<z.ZodBoolean>;
140
140
  feedbackLearningEnabled: z.ZodDefault<z.ZodBoolean>;
141
+ selfTuningEnabled: z.ZodDefault<z.ZodBoolean>;
141
142
  feedbackPromotionThreshold: z.ZodDefault<z.ZodNumber>;
142
143
  feedbackLessonMaxBytesGlobal: z.ZodDefault<z.ZodNumber>;
143
144
  feedbackLessonMaxBytesPerAgent: z.ZodDefault<z.ZodNumber>;
@@ -152,19 +153,27 @@ export declare const runtimeSettingsSchema: z.ZodObject<{
152
153
  browserTaskPendingQueueTimeoutMinutes: z.ZodDefault<z.ZodNumber>;
153
154
  browserTaskRespectQuietHours: z.ZodDefault<z.ZodBoolean>;
154
155
  browserTaskHostnameDenylist: z.ZodDefault<z.ZodArray<z.ZodString>>;
155
- hourlyCheckEnabled: z.ZodDefault<z.ZodBoolean>;
156
- hourlyCheckIntervalMinutes: z.ZodDefault<z.ZodNumber>;
157
- hourlyCheckActiveStartHour: z.ZodDefault<z.ZodNumber>;
158
- hourlyCheckActiveEndHour: z.ZodDefault<z.ZodNumber>;
159
- hourlyCheckMinObservations: z.ZodDefault<z.ZodNumber>;
160
- hourlyCheckStage2Enabled: z.ZodDefault<z.ZodBoolean>;
161
- hourlyCheckHeartbeatHours: z.ZodDefault<z.ZodNumber>;
162
- hourlyCheckLowSignalPendingCeiling: z.ZodDefault<z.ZodNumber>;
163
- hourlyCheckPrePassFreshnessMinutes: z.ZodDefault<z.ZodNumber>;
156
+ backgroundTaskMaxConcurrent: z.ZodDefault<z.ZodNumber>;
157
+ backgroundTaskClarificationTtlMinutes: z.ZodDefault<z.ZodNumber>;
158
+ backgroundTaskPendingQueueTimeoutMinutes: z.ZodDefault<z.ZodNumber>;
159
+ backgroundTaskDigestCadenceHours: z.ZodDefault<z.ZodNumber>;
160
+ backgroundTaskDedupWindowMinutes: z.ZodDefault<z.ZodNumber>;
161
+ backgroundTaskResumeAcrossRestart: z.ZodDefault<z.ZodBoolean>;
162
+ autonomousForwardNaturalDelivery: z.ZodDefault<z.ZodBoolean>;
163
+ activityScanEnabled: z.ZodDefault<z.ZodBoolean>;
164
+ activityScanIntervalMinutes: z.ZodDefault<z.ZodNumber>;
165
+ activityScanActiveStartHour: z.ZodDefault<z.ZodNumber>;
166
+ activityScanActiveEndHour: z.ZodDefault<z.ZodNumber>;
167
+ activityScanMinObservations: z.ZodDefault<z.ZodNumber>;
168
+ activityScanStage2Enabled: z.ZodDefault<z.ZodBoolean>;
169
+ activityScanHeartbeatHours: z.ZodDefault<z.ZodNumber>;
170
+ activityScanLowSignalPendingCeiling: z.ZodDefault<z.ZodNumber>;
171
+ activityScanPrePassFreshnessMinutes: z.ZodDefault<z.ZodNumber>;
164
172
  authProbeDisabled: z.ZodDefault<z.ZodBoolean>;
165
173
  authPreflightFreshnessMs: z.ZodDefault<z.ZodNumber>;
166
174
  schedulePollIntervalSeconds: z.ZodDefault<z.ZodNumber>;
167
175
  maxBriefingDelayMinutes: z.ZodDefault<z.ZodNumber>;
176
+ ownerActivityIdleThresholdMinutes: z.ZodDefault<z.ZodNumber>;
168
177
  maxNotificationsPerHour: z.ZodDefault<z.ZodNumber>;
169
178
  maxNotificationsPerDay: z.ZodDefault<z.ZodNumber>;
170
179
  quietHoursStart: z.ZodDefault<z.ZodString>;
@@ -192,6 +201,11 @@ export declare const runtimeSettingsSchema: z.ZodObject<{
192
201
  }>>;
193
202
  opencodeBaseUrl: z.ZodDefault<z.ZodString>;
194
203
  opencodeServerUsername: z.ZodDefault<z.ZodString>;
204
+ preventSleepMode: z.ZodDefault<z.ZodEnum<{
205
+ off: "off";
206
+ ac: "ac";
207
+ always: "always";
208
+ }>>;
195
209
  obsidianDebounceSeconds: z.ZodDefault<z.ZodNumber>;
196
210
  gitPollIntervalSeconds: z.ZodDefault<z.ZodNumber>;
197
211
  gitPushOverdueMinutes: z.ZodDefault<z.ZodNumber>;
@@ -252,7 +266,7 @@ export declare const runtimeSettingsSchema: z.ZodObject<{
252
266
  mailIdleFallbackRecoveryMinutes: z.ZodDefault<z.ZodNumber>;
253
267
  mailMaxMessagesPerPoll: z.ZodDefault<z.ZodNumber>;
254
268
  mailAuthFailureRetryHours: z.ZodDefault<z.ZodNumber>;
255
- hourlyObservationCharBudget: z.ZodDefault<z.ZodNumber>;
269
+ activityScanObservationCharBudget: z.ZodDefault<z.ZodNumber>;
256
270
  prePassMaxAttemptsPerIntegration: z.ZodDefault<z.ZodNumber>;
257
271
  prePassBackoffMs: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
258
272
  prePassRetryEscalationTier: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
@@ -287,8 +301,21 @@ export declare const runtimeSettingsSchema: z.ZodObject<{
287
301
  voiceTranscriptionPrimaryLanguage: z.ZodDefault<z.ZodNullable<z.ZodString>>;
288
302
  }, z.core.$strip>;
289
303
  export type RuntimeSettings = z.infer<typeof runtimeSettingsSchema>;
290
- export declare const RUNTIME_SETTING_KEYS: readonly ["slackOwnerUserId", "telegramOwnerChatId", "discordOwnerUserId", "whatsappEnabled", "whatsappOwnerPhone", "whatsappAuthDir", "googleCalendarId", "notionDatabaseIds", "primaryVaultPath", "primaryVaultName", "externalObsidianVaultPath", "externalObsidianVaultName", "externalObsidianWatch", "gitAccounts", "advisorEnabled", "advisorModel", "enforceReadToken", "maxConcurrentSessions", "maxReactiveSessions", "delegatedProxyMaxConcurrent", "delegatedTaskModeEnabled", "delegatedTaskMaxPerDay", "delegatedTaskDefaultMaxToolCalls", "delegatedTaskDefaultMaxBudgetUsd", "delegatedTaskDefaultTimeoutMs", "delegatedTaskHeavyEnabled", "delegatedTaskStructuredOutputEnabled", "delegatedTaskSubprocessPoolEnabled", "delegatedTaskSubprocessPoolTtlSeconds", "delegatedTaskCacheEnabled", "delegatedTaskCacheTtlSeconds", "delegatedTaskCacheMaxEntries", "executeTimeoutMinutes", "sessionTimeoutDmMinutes", "sessionTimeoutChannelMinutes", "sessionTimeoutDashboardMinutes", "historyInjectionMaxMessages", "historyInjectionMaxTokens", "historyOtherSurfaceWindowMinutes", "dmStalenessStrict", "proactiveForwardChannelTimelineEnabled", "proactiveForwardForceFreshSession", "feedbackLearningEnabled", "feedbackPromotionThreshold", "feedbackLessonMaxBytesGlobal", "feedbackLessonMaxBytesPerAgent", "feedbackLessonStaleDays", "feedbackSignalRetentionDays", "agentDisplayName", "character", "timezone", "dayBoundaryHour", "monthlyReviewEnabled", "browserTaskMaxConcurrent", "browserTaskPendingQueueTimeoutMinutes", "browserTaskRespectQuietHours", "browserTaskHostnameDenylist", "hourlyCheckEnabled", "hourlyCheckIntervalMinutes", "hourlyCheckActiveStartHour", "hourlyCheckActiveEndHour", "hourlyCheckMinObservations", "hourlyCheckStage2Enabled", "hourlyCheckHeartbeatHours", "hourlyCheckLowSignalPendingCeiling", "hourlyCheckPrePassFreshnessMinutes", "authProbeDisabled", "authPreflightFreshnessMs", "schedulePollIntervalSeconds", "maxBriefingDelayMinutes", "maxNotificationsPerHour", "maxNotificationsPerDay", "quietHoursStart", "quietHoursEnd", "batchIntervalMinutes", "primaryPlatform", "defaultNotificationPlatforms", "disallowedTools", "allowedToolsOverride", "claudeExecutionPermissionMode", "codexExecutionPermissionMode", "geminiExecutionPermissionMode", "opencodeExecutionPermissionMode", "opencodeBaseUrl", "opencodeServerUsername", "obsidianDebounceSeconds", "gitPollIntervalSeconds", "gitPushOverdueMinutes", "gitProjectUpdateDebounceMinutes", "notionPollIntervalSeconds", "calendarPollIntervalSeconds", "gmailPollIntervalSeconds", "githubPollIntervalSeconds", "browserHistoryConsentAccepted", "browserHistoryBrowserOverrides", "browserHistoryCategories", "browserHistoryRetentionDays", "browserHistorySearchQueryRetentionDays", "browserHistoryLifecycle", "browserHistoryResearchDomainAllowlist", "browserHistoryResearchDomainDenylist", "mcpAutoProbeIntervalMinutes", "delegatedProbeIntervalMinutes", "enabledMailProviders", "mailPollIntervalSeconds", "mailIdleEnabled", "mailIdleInstabilityThreshold", "mailIdleFallbackRecoveryMinutes", "mailMaxMessagesPerPoll", "mailAuthFailureRetryHours", "hourlyObservationCharBudget", "prePassMaxAttemptsPerIntegration", "prePassBackoffMs", "prePassRetryEscalationTier", "prePassFanOutConcurrency", "prePassMaxBudgetUsdPerIntegration", "prePassMaxBudgetUsdPerRoutine", "prePassRetryOnPartial", "observationSummarizerEnabled", "observationSummarizerConcurrency", "observationSummarizerMaxCallsPerMinute", "observationSummarizerQueueLimit", "observationSummarizerTimeoutMs", "vipMailSenders", "outlookDeltaPageSize", "outlookGraphConcurrency", "imapReconnectBaseMs", "imapReconnectMaxMs", "autonomousDailyCostCapUsd", "autonomousMonthlyCostCapUsd", "primaryLanguage", "vaultMode", "useReviewDossiers", "useContextIndex", "voiceTranscriptionEnabled", "voiceTranscriptionPrimaryLanguage"];
304
+ export declare const RUNTIME_SETTING_KEYS: readonly ["slackOwnerUserId", "telegramOwnerChatId", "discordOwnerUserId", "whatsappEnabled", "whatsappOwnerPhone", "whatsappAuthDir", "googleCalendarId", "notionDatabaseIds", "primaryVaultPath", "primaryVaultName", "externalObsidianVaultPath", "externalObsidianVaultName", "externalObsidianWatch", "gitAccounts", "advisorEnabled", "advisorModel", "enforceReadToken", "maxConcurrentSessions", "maxReactiveSessions", "delegatedProxyMaxConcurrent", "delegatedTaskModeEnabled", "delegatedTaskMaxPerDay", "delegatedTaskDefaultMaxToolCalls", "delegatedTaskDefaultMaxBudgetUsd", "delegatedTaskDefaultTimeoutMs", "delegatedTaskHeavyEnabled", "delegatedTaskStructuredOutputEnabled", "delegatedTaskSubprocessPoolEnabled", "delegatedTaskSubprocessPoolTtlSeconds", "delegatedTaskCacheEnabled", "delegatedTaskCacheTtlSeconds", "delegatedTaskCacheMaxEntries", "executeTimeoutMinutes", "sessionTimeoutDmMinutes", "sessionTimeoutChannelMinutes", "sessionTimeoutDashboardMinutes", "historyInjectionMaxMessages", "historyInjectionMaxTokens", "historyOtherSurfaceWindowMinutes", "dmStalenessStrict", "proactiveForwardChannelTimelineEnabled", "proactiveForwardForceFreshSession", "feedbackLearningEnabled", "selfTuningEnabled", "feedbackPromotionThreshold", "feedbackLessonMaxBytesGlobal", "feedbackLessonMaxBytesPerAgent", "feedbackLessonStaleDays", "feedbackSignalRetentionDays", "agentDisplayName", "character", "timezone", "dayBoundaryHour", "monthlyReviewEnabled", "browserTaskMaxConcurrent", "browserTaskPendingQueueTimeoutMinutes", "browserTaskRespectQuietHours", "browserTaskHostnameDenylist", "backgroundTaskMaxConcurrent", "backgroundTaskClarificationTtlMinutes", "backgroundTaskPendingQueueTimeoutMinutes", "backgroundTaskDigestCadenceHours", "backgroundTaskDedupWindowMinutes", "backgroundTaskResumeAcrossRestart", "autonomousForwardNaturalDelivery", "activityScanEnabled", "activityScanIntervalMinutes", "activityScanActiveStartHour", "activityScanActiveEndHour", "activityScanMinObservations", "activityScanStage2Enabled", "activityScanHeartbeatHours", "activityScanLowSignalPendingCeiling", "activityScanPrePassFreshnessMinutes", "authProbeDisabled", "authPreflightFreshnessMs", "schedulePollIntervalSeconds", "maxBriefingDelayMinutes", "ownerActivityIdleThresholdMinutes", "maxNotificationsPerHour", "maxNotificationsPerDay", "quietHoursStart", "quietHoursEnd", "batchIntervalMinutes", "primaryPlatform", "defaultNotificationPlatforms", "disallowedTools", "allowedToolsOverride", "claudeExecutionPermissionMode", "codexExecutionPermissionMode", "geminiExecutionPermissionMode", "opencodeExecutionPermissionMode", "opencodeBaseUrl", "opencodeServerUsername", "preventSleepMode", "obsidianDebounceSeconds", "gitPollIntervalSeconds", "gitPushOverdueMinutes", "gitProjectUpdateDebounceMinutes", "notionPollIntervalSeconds", "calendarPollIntervalSeconds", "gmailPollIntervalSeconds", "githubPollIntervalSeconds", "browserHistoryConsentAccepted", "browserHistoryBrowserOverrides", "browserHistoryCategories", "browserHistoryRetentionDays", "browserHistorySearchQueryRetentionDays", "browserHistoryLifecycle", "browserHistoryResearchDomainAllowlist", "browserHistoryResearchDomainDenylist", "mcpAutoProbeIntervalMinutes", "delegatedProbeIntervalMinutes", "enabledMailProviders", "mailPollIntervalSeconds", "mailIdleEnabled", "mailIdleInstabilityThreshold", "mailIdleFallbackRecoveryMinutes", "mailMaxMessagesPerPoll", "mailAuthFailureRetryHours", "activityScanObservationCharBudget", "prePassMaxAttemptsPerIntegration", "prePassBackoffMs", "prePassRetryEscalationTier", "prePassFanOutConcurrency", "prePassMaxBudgetUsdPerIntegration", "prePassMaxBudgetUsdPerRoutine", "prePassRetryOnPartial", "observationSummarizerEnabled", "observationSummarizerConcurrency", "observationSummarizerMaxCallsPerMinute", "observationSummarizerQueueLimit", "observationSummarizerTimeoutMs", "vipMailSenders", "outlookDeltaPageSize", "outlookGraphConcurrency", "imapReconnectBaseMs", "imapReconnectMaxMs", "autonomousDailyCostCapUsd", "autonomousMonthlyCostCapUsd", "primaryLanguage", "vaultMode", "useReviewDossiers", "useContextIndex", "voiceTranscriptionEnabled", "voiceTranscriptionPrimaryLanguage"];
291
305
  export type RuntimeSettingKey = (typeof RUNTIME_SETTING_KEYS)[number];
292
306
  export declare const INTERNAL_RUNTIME_SETTING_KEYS: readonly ["enforceReadToken", "useReviewDossiers", "useContextIndex"];
293
307
  export type InternalRuntimeSettingKey = (typeof INTERNAL_RUNTIME_SETTING_KEYS)[number];
294
308
  export declare function isRuntimeSettingKey(value: string): value is RuntimeSettingKey;
309
+ /**
310
+ * v0.1.10 → v0.1.11: the "Hourly Check" agent became "Activity Scan" and its
311
+ * settings keys moved from `hourlyCheck*` / `hourlyObservationCharBudget` to
312
+ * `activityScan*`. Migration `0010-hourly-check-to-activity-scan` renames the
313
+ * persisted `settings` rows, but `loadPersistedSettings` runs BEFORE
314
+ * `runMigrations` (the merge is load-bearing for `getContextDir`, see
315
+ * bootstrap/db.ts), so on the first post-upgrade boot the rows still carry the
316
+ * legacy names when they are parsed. This map lets the settings store read
317
+ * them under the canonical key for that one boot (and tolerates DBs restored
318
+ * from old backups). Drop after a deprecation window once the migration has
319
+ * been in the wild for a few releases.
320
+ */
321
+ export declare const LEGACY_RUNTIME_SETTING_KEY_ALIASES: Readonly<Record<string, RuntimeSettingKey>>;
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { ADVISOR_ALLOWED_MODELS, DEFAULT_AGENT_DISPLAY_NAME, EXECUTION_PERMISSION_MODES, INTEGRATION_KEYS, browserHistoryBrowserOverrideSchema, browserHistoryCategorySchema, browserHistoryLifecycleConfigSchema, isAdvisorModel, isSupportedVoiceLanguage, validateAgentDisplayName, } from "@aitne/shared";
3
3
  import { NOTIFICATION_DESTINATION_PLATFORMS, isNotificationDestinationPlatform, } from "../messaging/constants.js";
4
4
  import { ALWAYS_DISALLOWED_TOOLS } from "../safety/always-disallowed.js";
5
+ import { PREVENT_SLEEP_MODES } from "../core/sleep-inhibitor.js";
5
6
  /**
6
7
  * The secret-exfiltration / credential-tampering subset of the absolute-block
7
8
  * layer now lives in `safety/always-disallowed.ts` (EXECUTION-MODE-DESIGN.md
@@ -269,6 +270,18 @@ export const runtimeSettingsSchema = z.object({
269
270
  proactiveForwardChannelTimelineEnabled: z.boolean().default(true),
270
271
  proactiveForwardForceFreshSession: z.boolean().default(false),
271
272
  feedbackLearningEnabled: z.boolean().default(true),
273
+ /**
274
+ * SELF_TUNING_REVIEW_CYCLE_DESIGN.md §6 — actuation gate for the
275
+ * self-tuning loop's Phase 3 Actuate stage. While `false` (the shipped
276
+ * default), the loop runs in shadow mode: the weekly Recommend pre-step
277
+ * still generates `<tuning_recommendations>` and `POST
278
+ * /api/tuning/verdicts` still records apply/reject/defer verdicts, but
279
+ * nothing is written through the `applyConfigUpdates` chokepoint.
280
+ * Whether this ever flips to default-true is conditional on the Phase 2
281
+ * shadow-period results — a loop that edits spend-affecting knobs
282
+ * autonomously may reasonably stay opt-in permanently (§8).
283
+ */
284
+ selfTuningEnabled: z.boolean().default(false),
272
285
  feedbackPromotionThreshold: z.number().int().min(1).max(10).default(2),
273
286
  feedbackLessonMaxBytesGlobal: z.number().int().min(1024).max(32768).default(8192),
274
287
  feedbackLessonMaxBytesPerAgent: z.number().int().min(512).max(16384).default(4096),
@@ -315,9 +328,13 @@ export const runtimeSettingsSchema = z.object({
315
328
  // poor in the current shape; the routine stays in-tree as a concept
316
329
  // pending the Mirror+Prune redesign (one trend observation + aged
317
330
  // carry-over kill/keep decisions, scoped to feed day-1-of-month
318
- // morning_routine). Re-enable by setting `PA_MONTHLY_REVIEW_ENABLED=true`
319
- // or PATCH /api/config — the scheduler reads the live flag at fire time
320
- // so the flip takes effect on the next month-end without restart.
331
+ // morning_routine).
332
+ //
333
+ // DEPRECATED (Agents-hub redesign, AGENTS_HUB_REDESIGN_PLAN.md §2): the
334
+ // monthly-review AGENT row's `enabled` is the single switch now — enable
335
+ // from /agents/monthly-review. This key stays parseable so previously
336
+ // persisted values survive (a one-time boot reconcile carries a `true`
337
+ // onto the agent row); the scheduler no longer reads it.
321
338
  monthlyReviewEnabled: z.boolean().default(false),
322
339
  /**
323
340
  * BROWSER_TASK_REDESIGN_PLAN.md §5.1 — global concurrency cap for the
@@ -381,31 +398,118 @@ export const runtimeSettingsSchema = z.object({
381
398
  .array(z.string().min(1).max(253))
382
399
  .max(500)
383
400
  .default([]),
384
- hourlyCheckEnabled: z.boolean().default(true),
401
+ /**
402
+ * BACKGROUND_TASK_RUNNER_DESIGN.md §10.3 — global concurrency cap for
403
+ * the generic background-task runner. Each worker is a fresh SDK
404
+ * session (no resident browser), so the ceiling is cost/quota driven
405
+ * rather than RAM driven. Range [1, 5], default 3.
406
+ */
407
+ backgroundTaskMaxConcurrent: z.number().int().min(1).max(5).default(3),
408
+ /**
409
+ * BACKGROUND_TASK_RUNNER_DESIGN.md §6 / §10.6 — clarification TTL. A
410
+ * parked background task waits this long for the owner's `ask_user`
411
+ * reply before the housekeeping tick transitions it to `timeout`. No
412
+ * browser resource is held while parked, so the default is far longer
413
+ * than browser-task's fixed 5 min. Range [5, 1440] minutes, default 60.
414
+ */
415
+ backgroundTaskClarificationTtlMinutes: z
416
+ .number()
417
+ .int()
418
+ .min(5)
419
+ .max(1440)
420
+ .default(60),
421
+ /**
422
+ * BACKGROUND_TASK_RUNNER_DESIGN.md §10.3 — safety valve for a task that
423
+ * sits `pending` behind the concurrency cap too long. After this many
424
+ * minutes a queued task transitions to `timeout` (fail-loud). Range
425
+ * [5, 180], default 120 (background tasks queue longer than browser
426
+ * tasks because they run longer). The reused slot-manager sweep
427
+ * (`clampPendingQueueTimeoutMinutes`) caps at 180, so the range matches.
428
+ */
429
+ backgroundTaskPendingQueueTimeoutMinutes: z
430
+ .number()
431
+ .int()
432
+ .min(5)
433
+ .max(180)
434
+ .default(120),
435
+ /**
436
+ * BACKGROUND_TASK_RUNNER_DESIGN.md §10.5 — cadence (hours) of the
437
+ * filed-results digest ("filed N background results since yesterday").
438
+ * Consumed by the Phase 3 digest surface; the setting lands here so the
439
+ * runtime schema parses it on upgrade. Range [1, 168], default 24.
440
+ */
441
+ backgroundTaskDigestCadenceHours: z
442
+ .number()
443
+ .int()
444
+ .min(1)
445
+ .max(168)
446
+ .default(24),
447
+ /**
448
+ * BACKGROUND_TASK_RUNNER_DESIGN.md §10.3 / Phase 4 — brief-dedup window
449
+ * (minutes). A `POST /api/background-task` whose `brief` + `tier` exactly
450
+ * match a still-relevant task (not a FAIL terminal) created within this
451
+ * window collapses onto that task instead of spawning a second worker —
452
+ * the runaway fan-out guard (a replayed trigger POSTing the same brief
453
+ * many times in minutes). Range [0, 1440]; `0` disables dedup. Default 10.
454
+ */
455
+ backgroundTaskDedupWindowMinutes: z
456
+ .number()
457
+ .int()
458
+ .min(0)
459
+ .max(1440)
460
+ .default(10),
461
+ /**
462
+ * BACKGROUND_TASK_RUNNER_DESIGN.md §10.2 / Phase 4 — true mid-flight
463
+ * resume across a daemon restart. When `true`, a non-terminal task that
464
+ * captured an SDK session id (`backend_session_id`) is resumed via
465
+ * `query({resume})` on boot (warm session, no re-work); resume failures
466
+ * fall back to re-dispatch-from-brief. When `false`, every non-terminal
467
+ * task is re-dispatched from its (self-contained) brief — the v1 floor.
468
+ * Default `true`.
469
+ */
470
+ backgroundTaskResumeAcrossRestart: z.boolean().default(true),
471
+ /**
472
+ * BACKGROUND_TASK_RUNNER_DESIGN.md §2.3 / §13 Decision 4 (Phase 4,
473
+ * opt-in) — when `true`, a routine autonomous forward to the owner DM is
474
+ * routed through the task-delivery gate + activity-branch machinery: an
475
+ * active owner gets a woven delivery turn (the real DM agent weaves the
476
+ * forward into the live conversation) instead of a verbatim dump; an idle
477
+ * owner gets the verbatim send (as today). Default `false` — the design
478
+ * deliberately scoped rev3 to task delivery only; this opens the same
479
+ * machinery to autonomous forwards for operators who want it.
480
+ */
481
+ autonomousForwardNaturalDelivery: z.boolean().default(false),
482
+ // DEPRECATED (Agents-hub redesign, AGENTS_HUB_REDESIGN_PLAN.md §2): the
483
+ // activity-scan AGENT row's `enabled` is the single switch now (a one-time
484
+ // boot reconcile carries a persisted `false` onto the agent row). The
485
+ // cadence keys below remain the per-field FALLBACK under the agent row's
486
+ // `runtime_window` overrides (core/agents/activity-scan-cadence.ts) — edit the
487
+ // cadence from /agents/activity-scan, not here.
488
+ activityScanEnabled: z.boolean().default(true),
385
489
  // Any positive integer in [1, 1440] minutes (1 minute up to 24 hours).
386
- // Despite the "hourly" name, the operator can dial this anywhere in that
387
- // range to balance observation latency against quota burn. The cadence
388
- // is anchored to `hourlyCheckActiveStartHour` (see
389
- // shouldFireHourlyTickAt in scheduler.ts), so the first fire of each
490
+ // The shipped default is 120 (every 2 hours); the operator can dial this
491
+ // anywhere in that range to balance observation latency against quota
492
+ // burn. The cadence is anchored to `activityScanActiveStartHour` (see
493
+ // shouldFireActivityScanTickAt in scheduler.ts), so the first fire of each
390
494
  // agent-day lands at the start of the active window. The upper bound
391
495
  // is 1440 because the modulo gate runs against minutes-since-midnight,
392
496
  // which cannot represent multi-day cadence — operators wanting weekly
393
497
  // or monthly cadence should use the dedicated review routines.
394
- hourlyCheckIntervalMinutes: z
498
+ activityScanIntervalMinutes: z
395
499
  .number()
396
500
  .int()
397
- .min(1, { message: "PA_HOURLY_CHECK_INTERVAL_MINUTES must be >= 1" })
398
- .max(1440, { message: "PA_HOURLY_CHECK_INTERVAL_MINUTES must be <= 1440 (one day)" })
399
- .default(60),
400
- hourlyCheckActiveStartHour: z.number().int().min(0).max(23).default(4),
401
- hourlyCheckActiveEndHour: z.number().int().min(1).max(24).default(24),
402
- hourlyCheckMinObservations: z.number().int().nonnegative().default(1),
501
+ .min(1, { message: "PA_ACTIVITY_SCAN_INTERVAL_MINUTES must be >= 1" })
502
+ .max(1440, { message: "PA_ACTIVITY_SCAN_INTERVAL_MINUTES must be <= 1440 (one day)" })
503
+ .default(120),
504
+ activityScanActiveStartHour: z.number().int().min(0).max(23).default(4),
505
+ activityScanActiveEndHour: z.number().int().min(1).max(24).default(24),
506
+ activityScanMinObservations: z.number().int().nonnegative().default(1),
403
507
  /**
404
508
  * cost-reduction-structural §B — flag for the optional Stage 2 lite-tier
405
509
  * triage. Default `false` so cost remains bounded to Stage 0/1 + Stage 3
406
510
  * until shadow telemetry justifies the lite triage budget.
407
511
  */
408
- hourlyCheckStage2Enabled: z.boolean().default(false),
512
+ activityScanStage2Enabled: z.boolean().default(false),
409
513
  /**
410
514
  * cost-reduction-structural §B — heartbeat window for the gate. Even on
411
515
  * a string of quiet ticks, the gate force-runs Stage 2 (or Stage 3 if
@@ -413,7 +517,7 @@ export const runtimeSettingsSchema = z.object({
413
517
  * exercised end-to-end and a signal misclassification can't trap the
414
518
  * routine in `stage0_silent` indefinitely.
415
519
  */
416
- hourlyCheckHeartbeatHours: z.number().int().min(1).max(48).default(4),
520
+ activityScanHeartbeatHours: z.number().int().min(1).max(48).default(4),
417
521
  /**
418
522
  * cost-reduction-structural §B — pending-observation ceiling under
419
523
  * which low-signal cases still route to Stage 0 silent. The default 0
@@ -421,7 +525,7 @@ export const runtimeSettingsSchema = z.object({
421
525
  * Stage 2 / Stage 3); operators who notice the gate over-escalating on
422
526
  * journal noise can dial this up.
423
527
  */
424
- hourlyCheckLowSignalPendingCeiling: z
528
+ activityScanLowSignalPendingCeiling: z
425
529
  .number()
426
530
  .int()
427
531
  .nonnegative()
@@ -430,25 +534,30 @@ export const runtimeSettingsSchema = z.object({
430
534
  /**
431
535
  * HOURLY_CHECK_GATE_REDESIGN_PLAN.md §3.4 — minimum minutes between
432
536
  * pre-pass spawns for the same integration. The `harvestForGate`
433
- * step in `HourlyCheckCoordinator.trigger` reads
537
+ * step in `ActivityScanCoordinator.trigger` reads
434
538
  * `runtime_state.pre_pass_last_run:<integrationKey>` and skips
435
539
  * pre-pass when the prior successful run is more recent than this
436
- * window. Default 30 — the cron interval is 60 min, so a 30-min
437
- * window guarantees at most one pre-pass per integration per tick
438
- * while still firing every tick under normal load.
540
+ * window. Default 30 — comfortably below the default 120-min scan
541
+ * interval, so a default install runs the pre-pass on every tick;
542
+ * the gate only bites when an operator dials the interval down or
543
+ * another routine's pre-pass ran recently.
439
544
  *
440
- * Bounded [0, 240]. `0` disables the freshness gate (pre-pass fires
545
+ * Bounded [0, 480]. `0` disables the freshness gate (pre-pass fires
441
546
  * on every tick); 240 (4h) approximates "only fire when the
442
- * heartbeat would have anyway" for cost-minimal deployments.
547
+ * heartbeat would have anyway" for cost-minimal deployments. The cap
548
+ * was widened 240 → 480 for the self-tuning R1 ladder
549
+ * (120/240/360/480 — SELF_TUNING_REVIEW_CYCLE_DESIGN.md §3.2 / D2;
550
+ * a compatible widening, every previously persisted value still
551
+ * parses). Twin bound: `env-writer.ts:NUMERIC_RANGE`.
443
552
  *
444
553
  * `forced` runs (`POST /api/agent/run-now`) bypass the gate
445
554
  * unconditionally — manual triggers explicitly want a fresh fetch.
446
555
  */
447
- hourlyCheckPrePassFreshnessMinutes: z
556
+ activityScanPrePassFreshnessMinutes: z
448
557
  .number()
449
558
  .int()
450
559
  .min(0)
451
- .max(240)
560
+ .max(480)
452
561
  .default(30),
453
562
  /**
454
563
  * Phase 4 auth health probe kill switch — corresponds to
@@ -477,6 +586,13 @@ export const runtimeSettingsSchema = z.object({
477
586
  * /api/config; tunable per user's tolerance for chatty mornings.
478
587
  */
479
588
  maxBriefingDelayMinutes: z.number().int().nonnegative().default(30),
589
+ /**
590
+ * BACKGROUND_TASK_RUNNER_DESIGN.md §2.6 — deterministic branch used by
591
+ * task.delivery to decide whether a finished task should be woven into
592
+ * an active owner conversation or sent as a standalone draft. Reads the
593
+ * most recent inbound owner DM across messaging + dashboard scopes.
594
+ */
595
+ ownerActivityIdleThresholdMinutes: z.number().int().min(1).max(60).default(5),
480
596
  maxNotificationsPerHour: z.number().int().positive().default(3),
481
597
  maxNotificationsPerDay: z.number().int().positive().default(12),
482
598
  quietHoursStart: z.string().default("22:00"),
@@ -525,6 +641,19 @@ export const runtimeSettingsSchema = z.object({
525
641
  .url()
526
642
  .default("http://127.0.0.1:4096"),
527
643
  opencodeServerUsername: z.string().min(1).default("opencode"),
644
+ /**
645
+ * Keep-awake posture while the daemon runs (macOS only; no-op elsewhere).
646
+ * Every daemon timer freezes during host sleep, so a sleeping laptop
647
+ * turns the 04:00 day-boundary flow into hours of wake-catchup replays
648
+ * riding macOS maintenance DarkWakes — with cold prompt caches making
649
+ * each replay ~10× the normal cost. `"ac"` (default) holds a
650
+ * `caffeinate -s` assertion: system sleep is inhibited only while on AC
651
+ * power, so battery drain stays impossible. `"always"` adds `-i` (idle
652
+ * sleep inhibited on battery too); `"off"` restores OS-managed sleep.
653
+ * Lid-close sleep is NOT overridden (that needs root). Read once at
654
+ * boot — see RESTART_REQUIRED_KEY_TUPLE.
655
+ */
656
+ preventSleepMode: z.enum(PREVENT_SLEEP_MODES).default("ac"),
528
657
  obsidianDebounceSeconds: z.number().positive().default(5.0),
529
658
  gitPollIntervalSeconds: z.number().int().positive().default(3600),
530
659
  /**
@@ -653,7 +782,7 @@ export const runtimeSettingsSchema = z.object({
653
782
  mailIdleFallbackRecoveryMinutes: z.number().int().positive().default(60),
654
783
  mailMaxMessagesPerPoll: z.number().int().min(1).max(100).default(20),
655
784
  mailAuthFailureRetryHours: z.number().int().positive().default(6),
656
- hourlyObservationCharBudget: z.number().int().positive().default(8000),
785
+ activityScanObservationCharBudget: z.number().int().positive().default(8000),
657
786
  /**
658
787
  * docs/design/appendices/pre-pass-fan-out.md §6 — retry and budget controls for the
659
788
  * `routine.fetch_window` fan-out coordinator. Fan-out is now the only
@@ -689,7 +818,7 @@ export const runtimeSettingsSchema = z.object({
689
818
  /**
690
819
  * cost-reduction-structural §A — observation summarizer kill switch +
691
820
  * tunables. The summarizer runs out-of-band: when disabled, observation
692
- * rows stay `summary_status='pending'` and hourly_check falls back to
821
+ * rows stay `summary_status='pending'` and activity_scan falls back to
693
822
  * the legacy fetch-on-doubt pattern (no regression in correctness; only
694
823
  * loss of cost savings).
695
824
  */
@@ -714,7 +843,7 @@ export const runtimeSettingsSchema = z.object({
714
843
  * Safety net for autonomous session cost. When set, the dispatcher skips
715
844
  * autonomous sessions whose cumulative daily cost exceeds this cap.
716
845
  * Reactive sessions (DMs, mentions) always pass through.
717
- * Degradation priority: hourly_check → roadmap_refresh → evening_review →
846
+ * Degradation priority: activity_scan → roadmap_refresh → evening_review →
718
847
  * morning_routine (last to be cut).
719
848
  * Distinct from the removed Phase 9 `maxDailyCostUsd` which blanket-blocked
720
849
  * all sessions including reactive DMs — see p9-polling-pivot.md.
@@ -779,7 +908,7 @@ export const runtimeSettingsSchema = z.object({
779
908
  * Voice transcription opt-in (see docs/design/appendices/voice-transcription.md).
780
909
  * Default `false`: inbound audio attachments pass through as file paths
781
910
  * without local Whisper inference, and no model weights are downloaded.
782
- * Flipping to `true` from `/settings/advanced` triggers a one-time model
911
+ * Flipping to `true` from `/settings/infrastructure` triggers a one-time model
783
912
  * download via `POST /api/voice/install`; the daemon auto-restarts on
784
913
  * success so the transcriber initializes with the flag observed.
785
914
  */
@@ -907,6 +1036,7 @@ export const RUNTIME_SETTING_KEYS = [
907
1036
  "proactiveForwardChannelTimelineEnabled",
908
1037
  "proactiveForwardForceFreshSession",
909
1038
  "feedbackLearningEnabled",
1039
+ "selfTuningEnabled",
910
1040
  "feedbackPromotionThreshold",
911
1041
  "feedbackLessonMaxBytesGlobal",
912
1042
  "feedbackLessonMaxBytesPerAgent",
@@ -921,19 +1051,27 @@ export const RUNTIME_SETTING_KEYS = [
921
1051
  "browserTaskPendingQueueTimeoutMinutes",
922
1052
  "browserTaskRespectQuietHours",
923
1053
  "browserTaskHostnameDenylist",
924
- "hourlyCheckEnabled",
925
- "hourlyCheckIntervalMinutes",
926
- "hourlyCheckActiveStartHour",
927
- "hourlyCheckActiveEndHour",
928
- "hourlyCheckMinObservations",
929
- "hourlyCheckStage2Enabled",
930
- "hourlyCheckHeartbeatHours",
931
- "hourlyCheckLowSignalPendingCeiling",
932
- "hourlyCheckPrePassFreshnessMinutes",
1054
+ "backgroundTaskMaxConcurrent",
1055
+ "backgroundTaskClarificationTtlMinutes",
1056
+ "backgroundTaskPendingQueueTimeoutMinutes",
1057
+ "backgroundTaskDigestCadenceHours",
1058
+ "backgroundTaskDedupWindowMinutes",
1059
+ "backgroundTaskResumeAcrossRestart",
1060
+ "autonomousForwardNaturalDelivery",
1061
+ "activityScanEnabled",
1062
+ "activityScanIntervalMinutes",
1063
+ "activityScanActiveStartHour",
1064
+ "activityScanActiveEndHour",
1065
+ "activityScanMinObservations",
1066
+ "activityScanStage2Enabled",
1067
+ "activityScanHeartbeatHours",
1068
+ "activityScanLowSignalPendingCeiling",
1069
+ "activityScanPrePassFreshnessMinutes",
933
1070
  "authProbeDisabled",
934
1071
  "authPreflightFreshnessMs",
935
1072
  "schedulePollIntervalSeconds",
936
1073
  "maxBriefingDelayMinutes",
1074
+ "ownerActivityIdleThresholdMinutes",
937
1075
  "maxNotificationsPerHour",
938
1076
  "maxNotificationsPerDay",
939
1077
  "quietHoursStart",
@@ -949,6 +1087,7 @@ export const RUNTIME_SETTING_KEYS = [
949
1087
  "opencodeExecutionPermissionMode",
950
1088
  "opencodeBaseUrl",
951
1089
  "opencodeServerUsername",
1090
+ "preventSleepMode",
952
1091
  "obsidianDebounceSeconds",
953
1092
  "gitPollIntervalSeconds",
954
1093
  "gitPushOverdueMinutes",
@@ -974,7 +1113,7 @@ export const RUNTIME_SETTING_KEYS = [
974
1113
  "mailIdleFallbackRecoveryMinutes",
975
1114
  "mailMaxMessagesPerPoll",
976
1115
  "mailAuthFailureRetryHours",
977
- "hourlyObservationCharBudget",
1116
+ "activityScanObservationCharBudget",
978
1117
  "prePassMaxAttemptsPerIntegration",
979
1118
  "prePassBackoffMs",
980
1119
  "prePassRetryEscalationTier",
@@ -1011,3 +1150,27 @@ const _assertRuntimeSettingCoverage = true;
1011
1150
  export function isRuntimeSettingKey(value) {
1012
1151
  return runtimeSettingKeySet.has(value);
1013
1152
  }
1153
+ /**
1154
+ * v0.1.10 → v0.1.11: the "Hourly Check" agent became "Activity Scan" and its
1155
+ * settings keys moved from `hourlyCheck*` / `hourlyObservationCharBudget` to
1156
+ * `activityScan*`. Migration `0010-hourly-check-to-activity-scan` renames the
1157
+ * persisted `settings` rows, but `loadPersistedSettings` runs BEFORE
1158
+ * `runMigrations` (the merge is load-bearing for `getContextDir`, see
1159
+ * bootstrap/db.ts), so on the first post-upgrade boot the rows still carry the
1160
+ * legacy names when they are parsed. This map lets the settings store read
1161
+ * them under the canonical key for that one boot (and tolerates DBs restored
1162
+ * from old backups). Drop after a deprecation window once the migration has
1163
+ * been in the wild for a few releases.
1164
+ */
1165
+ export const LEGACY_RUNTIME_SETTING_KEY_ALIASES = {
1166
+ hourlyCheckEnabled: "activityScanEnabled",
1167
+ hourlyCheckIntervalMinutes: "activityScanIntervalMinutes",
1168
+ hourlyCheckActiveStartHour: "activityScanActiveStartHour",
1169
+ hourlyCheckActiveEndHour: "activityScanActiveEndHour",
1170
+ hourlyCheckMinObservations: "activityScanMinObservations",
1171
+ hourlyCheckStage2Enabled: "activityScanStage2Enabled",
1172
+ hourlyCheckHeartbeatHours: "activityScanHeartbeatHours",
1173
+ hourlyCheckLowSignalPendingCeiling: "activityScanLowSignalPendingCeiling",
1174
+ hourlyCheckPrePassFreshnessMinutes: "activityScanPrePassFreshnessMinutes",
1175
+ hourlyObservationCharBudget: "activityScanObservationCharBudget",
1176
+ };
@@ -1,4 +1,4 @@
1
- import { RUNTIME_SETTING_KEYS, isRuntimeSettingKey, runtimeSettingsSchema, } from "./runtime-settings.js";
1
+ import { LEGACY_RUNTIME_SETTING_KEY_ALIASES, RUNTIME_SETTING_KEYS, isRuntimeSettingKey, runtimeSettingsSchema, } from "./runtime-settings.js";
2
2
  class SqliteSettingsStore {
3
3
  db;
4
4
  constructor(db) {
@@ -8,11 +8,19 @@ class SqliteSettingsStore {
8
8
  const rows = this.db.prepare("SELECT key, value_json FROM settings").all();
9
9
  const rawValues = {};
10
10
  for (const row of rows) {
11
- if (!isRuntimeSettingKey(row.key)) {
11
+ // Legacy rows (pre-rename key names) are read under their canonical
12
+ // key until migration 0010 has rewritten them — but never shadow a
13
+ // canonical row that already exists.
14
+ const aliased = LEGACY_RUNTIME_SETTING_KEY_ALIASES[row.key];
15
+ const key = aliased !== undefined ? aliased : row.key;
16
+ if (!isRuntimeSettingKey(key)) {
17
+ continue;
18
+ }
19
+ if (aliased !== undefined && key in rawValues) {
12
20
  continue;
13
21
  }
14
22
  try {
15
- rawValues[row.key] = JSON.parse(row.value_json);
23
+ rawValues[key] = JSON.parse(row.value_json);
16
24
  }
17
25
  catch {
18
26
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aitne/daemon",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Aitne daemon — long-running TypeScript service that hosts the event bus, scheduler, observers, safety layer, and HTTP API. Consumed by the `aitne` CLI; not intended for standalone use.",
5
5
  "homepage": "https://github.com/Aitne-sh/Aitne#readme",
6
6
  "bugs": {
@@ -37,7 +37,7 @@
37
37
  "@octokit/rest": "^22.0.1",
38
38
  "@opencode-ai/sdk": "1.14.50",
39
39
  "@slack/bolt": "^4.7.0",
40
- "@whiskeysockets/baileys": "7.0.0-rc.9",
40
+ "@whiskeysockets/baileys": "7.0.0-rc13",
41
41
  "ajv": "^8.20.0",
42
42
  "better-sqlite3": "^12.8.0",
43
43
  "busboy": "^1.6.0",
@@ -49,7 +49,7 @@
49
49
  "google-auth-library": "^10.6.2",
50
50
  "googleapis": "^171.4.0",
51
51
  "heap-js": "^2.7.1",
52
- "hono": "^4.12.12",
52
+ "hono": "^4.12.25",
53
53
  "html-to-text": "^9.0.5",
54
54
  "ical.js": "^2.2.1",
55
55
  "imapflow": "^1.3.1",
@@ -66,7 +66,7 @@
66
66
  "telegraf": "^4.16.3",
67
67
  "tsdav": "^2.1.8",
68
68
  "zod": "^4.3.6",
69
- "@aitne/shared": "0.1.10"
69
+ "@aitne/shared": "0.1.11"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/better-sqlite3": "^7.6.13",