@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.
- package/dist/adapters/adapter-watchdog.d.ts +70 -0
- package/dist/adapters/adapter-watchdog.js +115 -0
- package/dist/adapters/discord.d.ts +17 -1
- package/dist/adapters/discord.js +33 -0
- package/dist/adapters/notification-manager.d.ts +27 -1
- package/dist/adapters/notification-manager.js +54 -39
- package/dist/adapters/slack-adapter.d.ts +26 -1
- package/dist/adapters/slack-adapter.js +41 -0
- package/dist/adapters/telegram-adapter.d.ts +18 -1
- package/dist/adapters/telegram-adapter.js +41 -2
- package/dist/adapters/types.d.ts +20 -0
- package/dist/adapters/whatsapp-adapter.d.ts +26 -7
- package/dist/adapters/whatsapp-adapter.js +74 -21
- package/dist/api/env-writer.js +8 -5
- package/dist/api/helpers/agent-errors-registry.d.ts +5 -5
- package/dist/api/helpers/agent-errors-registry.js +5 -5
- package/dist/api/routes/agent.js +33 -12
- package/dist/api/routes/agents/index.js +75 -16
- package/dist/api/routes/agents/views.d.ts +37 -2
- package/dist/api/routes/agents/views.js +64 -2
- package/dist/api/routes/background-task.d.ts +22 -0
- package/dist/api/routes/background-task.js +338 -0
- package/dist/api/routes/browser-history.js +9 -1
- package/dist/api/routes/context/permissions.js +3 -2
- package/dist/api/routes/context/snapshots.js +0 -3
- package/dist/api/routes/context/write.js +3 -17
- package/dist/api/routes/dashboard/config.js +48 -12
- package/dist/api/routes/dashboard/cost-approvals.js +66 -0
- package/dist/api/routes/dashboard/notifications.js +9 -9
- package/dist/api/routes/integrations/crud-patch.js +5 -1
- package/dist/api/routes/integrations-reconcile.js +2 -2
- package/dist/api/routes/notion.d.ts +1 -1
- package/dist/api/routes/observations.js +7 -7
- package/dist/api/routes/obsidian.d.ts +1 -1
- package/dist/api/routes/receipts.js +5 -1
- package/dist/api/routes/setup-migrate.js +1 -1
- package/dist/api/routes/setup.js +1 -1
- package/dist/api/routes/task-flows.d.ts +1 -1
- package/dist/api/routes/task-flows.js +1 -1
- package/dist/api/routes/tuning.d.ts +29 -0
- package/dist/api/routes/tuning.js +304 -0
- package/dist/api/server.d.ts +44 -16
- package/dist/api/server.js +9 -0
- package/dist/bootstrap/adapters.d.ts +19 -0
- package/dist/bootstrap/adapters.js +61 -0
- package/dist/bootstrap/api.d.ts +5 -3
- package/dist/bootstrap/api.js +45 -13
- package/dist/bootstrap/catchup.d.ts +1 -1
- package/dist/bootstrap/catchup.js +11 -11
- package/dist/bootstrap/event-pipeline.d.ts +11 -0
- package/dist/bootstrap/event-pipeline.js +245 -7
- package/dist/bootstrap/observers.js +9 -6
- package/dist/bootstrap/schedule-helpers.d.ts +104 -6
- package/dist/bootstrap/schedule-helpers.js +172 -19
- package/dist/config.js +26 -12
- package/dist/core/agent-core.d.ts +33 -1
- package/dist/core/agent-core.js +36 -1
- package/dist/core/agents/activity-scan-cadence.d.ts +103 -0
- package/dist/core/agents/activity-scan-cadence.js +127 -0
- package/dist/core/agents/agent-route-override.d.ts +53 -0
- package/dist/core/agents/agent-route-override.js +69 -0
- package/dist/core/agents/builtin-registry.d.ts +51 -14
- package/dist/core/agents/builtin-registry.js +92 -15
- package/dist/core/agents/config-gate-reconcile.d.ts +38 -0
- package/dist/core/agents/config-gate-reconcile.js +51 -0
- package/dist/core/agents/cron-substitute.d.ts +1 -1
- package/dist/core/agents/cron-substitute.js +1 -1
- package/dist/core/agents/custom-routine-migration.d.ts +60 -0
- package/dist/core/agents/custom-routine-migration.js +149 -0
- package/dist/core/agents/firing-blocked.d.ts +1 -1
- package/dist/core/agents/hourly-cadence.d.ts +102 -0
- package/dist/core/agents/hourly-cadence.js +126 -0
- package/dist/core/agents/loader-boot.js +23 -0
- package/dist/core/agents/loader.d.ts +19 -0
- package/dist/core/agents/loader.js +34 -2
- package/dist/core/agents/override-merge.d.ts +1 -1
- package/dist/core/agents/override-merge.js +9 -1
- package/dist/core/agents/recurrence-convert.d.ts +1 -1
- package/dist/core/agents/recurrence-convert.js +1 -1
- package/dist/core/agents/recurring-schedule-adapter.js +8 -0
- package/dist/core/alerts.js +6 -6
- package/dist/core/backends/auth-health-monitor.d.ts +2 -2
- package/dist/core/backends/auth-health-monitor.js +1 -1
- package/dist/core/backends/backend-router.d.ts +27 -1
- package/dist/core/backends/backend-router.js +165 -1
- package/dist/core/backends/claude-code-core.d.ts +71 -31
- package/dist/core/backends/claude-code-core.js +282 -54
- package/dist/core/backends/cli-quota-guards.d.ts +29 -1
- package/dist/core/backends/cli-quota-guards.js +40 -5
- package/dist/core/backends/codex-core.d.ts +6 -0
- package/dist/core/backends/codex-core.js +22 -6
- package/dist/core/backends/failure-spend.d.ts +58 -0
- package/dist/core/backends/failure-spend.js +137 -0
- package/dist/core/backends/gemini-cli-core.d.ts +6 -0
- package/dist/core/backends/gemini-cli-core.js +25 -6
- package/dist/core/backends/model-registry.d.ts +1 -1
- package/dist/core/backends/model-registry.js +4 -4
- package/dist/core/backends/opencode-core.d.ts +1 -1
- package/dist/core/backends/opencode-core.js +5 -5
- package/dist/core/backends/plan-presets.js +39 -15
- package/dist/core/bang-commands/commands-cost.js +3 -1
- package/dist/core/bang-commands/commands-report.js +4 -3
- package/dist/core/bang-commands/commands-research.js +4 -1
- package/dist/core/bang-commands/commands-revert-tuning.d.ts +18 -0
- package/dist/core/bang-commands/commands-revert-tuning.js +63 -0
- package/dist/core/bang-commands/commands-stop-start.js +3 -3
- package/dist/core/bang-commands/commands-task-control.d.ts +19 -0
- package/dist/core/bang-commands/commands-task-control.js +147 -0
- package/dist/core/bang-commands/commands-wiki.js +5 -5
- package/dist/core/bang-commands/index.d.ts +2 -0
- package/dist/core/bang-commands/index.js +12 -0
- package/dist/core/bang-commands/registry.d.ts +12 -0
- package/dist/core/browser-history/research-cluster-fanout.d.ts +28 -14
- package/dist/core/browser-history/research-cluster-fanout.js +39 -16
- package/dist/core/channel-timeline.d.ts +5 -1
- package/dist/core/channel-timeline.js +13 -0
- package/dist/core/context/index-reconciler.js +5 -2
- package/dist/core/context/policy-index-reconciler.d.ts +6 -4
- package/dist/core/context/policy-index-runner.js +25 -6
- package/dist/core/context-builder-calendar.js +10 -2
- package/dist/core/context-builder-conversation.d.ts +8 -1
- package/dist/core/context-builder-conversation.js +41 -7
- package/dist/core/context-builder-yesterday.js +4 -3
- package/dist/core/context-builder.d.ts +7 -2
- package/dist/core/context-builder.js +62 -20
- package/dist/core/context-file-serializer.d.ts +1 -1
- package/dist/core/context-file-serializer.js +1 -1
- package/dist/core/context-health.js +2 -2
- package/dist/core/context-paths.d.ts +1 -1
- package/dist/core/context-paths.js +1 -1
- package/dist/core/context-validation/prepare-write.js +1 -1
- package/dist/core/context-validation/routine-rulebook.d.ts +1 -1
- package/dist/core/context-vault-aliases.d.ts +0 -13
- package/dist/core/context-vault-aliases.js +37 -0
- package/dist/core/custom-routines.d.ts +99 -0
- package/dist/core/custom-routines.js +187 -0
- package/dist/core/daemon-api-cli.js +49 -0
- package/dist/core/day-boundary.d.ts +46 -0
- package/dist/core/day-boundary.js +40 -0
- package/dist/core/dispatcher-activity-scan.d.ts +221 -0
- package/dist/core/dispatcher-activity-scan.js +775 -0
- package/dist/core/dispatcher-error-handling.d.ts +6 -11
- package/dist/core/dispatcher-error-handling.js +38 -62
- package/dist/core/dispatcher-hourly-check.js +6 -1
- package/dist/core/dispatcher-message-handler.d.ts +10 -0
- package/dist/core/dispatcher-message-handler.js +17 -0
- package/dist/core/dispatcher-morning-routine.d.ts +6 -6
- package/dist/core/dispatcher-morning-routine.js +13 -13
- package/dist/core/dispatcher-result-processor.d.ts +33 -0
- package/dist/core/dispatcher-result-processor.js +167 -11
- package/dist/core/dispatcher-scheduled-background-task.d.ts +42 -0
- package/dist/core/dispatcher-scheduled-background-task.js +89 -0
- package/dist/core/dispatcher-scheduled-tasks.d.ts +63 -1
- package/dist/core/dispatcher-scheduled-tasks.js +213 -6
- package/dist/core/dispatcher-task-delivery.d.ts +105 -0
- package/dist/core/dispatcher-task-delivery.js +555 -0
- package/dist/core/dispatcher-types.d.ts +48 -9
- package/dist/core/dispatcher-types.js +3 -3
- package/dist/core/dispatcher.d.ts +112 -31
- package/dist/core/dispatcher.js +284 -59
- package/dist/core/dm-freshness-metrics.d.ts +1 -1
- package/dist/core/drift-effects.js +2 -2
- package/dist/core/feedback/consolidation-prep.js +17 -5
- package/dist/core/feedback/eviction-scorer.js +6 -2
- package/dist/core/feedback/lesson-format.js +9 -4
- package/dist/core/feedback/lesson-injection.d.ts +1 -1
- package/dist/core/feedback/lesson-injection.js +17 -2
- package/dist/core/feedback/lesson-store-overview.d.ts +8 -4
- package/dist/core/feedback/lesson-store-overview.js +8 -4
- package/dist/core/feedback/regeneralization-prep.js +29 -16
- package/dist/core/feedback/self-performance-prep.d.ts +186 -0
- package/dist/core/feedback/self-performance-prep.js +541 -0
- package/dist/core/feedback/tuning-actuator.d.ts +198 -0
- package/dist/core/feedback/tuning-actuator.js +432 -0
- package/dist/core/feedback/tuning-recommender.d.ts +247 -0
- package/dist/core/feedback/tuning-recommender.js +580 -0
- package/dist/core/feedback/tuning-revert-monitor.d.ts +90 -0
- package/dist/core/feedback/tuning-revert-monitor.js +213 -0
- package/dist/core/health-monitor.d.ts +6 -0
- package/dist/core/health-monitor.js +1 -1
- package/dist/core/injection-policy.d.ts +4 -4
- package/dist/core/injection-policy.js +4 -4
- package/dist/core/integration-main-backend.js +4 -0
- package/dist/core/management-md.d.ts +2 -2
- package/dist/core/management-md.js +51 -13
- package/dist/core/morning/orchestrator.d.ts +2 -2
- package/dist/core/morning/orchestrator.js +2 -2
- package/dist/core/notification-gate.d.ts +64 -0
- package/dist/core/notification-gate.js +51 -0
- package/dist/core/notification-rate-limit.d.ts +40 -0
- package/dist/core/notification-rate-limit.js +50 -0
- package/dist/core/policy-files.d.ts +1 -1
- package/dist/core/policy-files.js +2 -2
- package/dist/core/pre-pass-freshness.d.ts +4 -4
- package/dist/core/retention.d.ts +5 -0
- package/dist/core/retention.js +20 -4
- package/dist/core/review-context.d.ts +1 -1
- package/dist/core/review-context.js +10 -5
- package/dist/core/roadmap-write-lock.d.ts +2 -1
- package/dist/core/roadmap-write-lock.js +15 -10
- package/dist/core/routine-acquisition-plan.d.ts +47 -1
- package/dist/core/routine-acquisition-plan.js +78 -20
- package/dist/core/routine-fetch-window-retry.js +7 -4
- package/dist/core/routine-fetch-window-runner.d.ts +39 -3
- package/dist/core/routine-fetch-window-runner.js +264 -13
- package/dist/core/routine-windows.d.ts +2 -2
- package/dist/core/routine-windows.js +8 -5
- package/dist/core/scheduler.d.ts +175 -16
- package/dist/core/scheduler.js +559 -102
- package/dist/core/signal-detector.d.ts +12 -0
- package/dist/core/signal-detector.js +53 -9
- package/dist/core/skills-compiler-denied-tools.js +2 -2
- package/dist/core/skills-compiler-skill-index.d.ts +2 -2
- package/dist/core/skills-compiler-skill-index.js +2 -2
- package/dist/core/skills-compiler-variants.d.ts +1 -1
- package/dist/core/skills-compiler-variants.js +8 -0
- package/dist/core/skills-compiler.d.ts +29 -26
- package/dist/core/skills-compiler.js +117 -81
- package/dist/core/skills-manifest.d.ts +37 -0
- package/dist/core/skills-manifest.js +73 -2
- package/dist/core/sleep-inhibitor.d.ts +79 -0
- package/dist/core/sleep-inhibitor.js +132 -0
- package/dist/core/slim-system-prompt-loader.d.ts +77 -0
- package/dist/core/slim-system-prompt-loader.js +141 -0
- package/dist/core/spawn-gates.d.ts +126 -0
- package/dist/core/spawn-gates.js +180 -0
- package/dist/core/today-direct-writer.d.ts +2 -2
- package/dist/core/today-direct-writer.js +1 -1
- package/dist/core/today-write-lock.d.ts +4 -2
- package/dist/core/today-write-lock.js +30 -20
- package/dist/core/wake-detector.d.ts +55 -0
- package/dist/core/wake-detector.js +80 -0
- package/dist/core/wiki/compile-lock.d.ts +1 -1
- package/dist/core/wiki/compile-lock.js +1 -1
- package/dist/core/workdir.js +15 -6
- package/dist/db/activity-scan-signals.d.ts +77 -0
- package/dist/db/activity-scan-signals.js +378 -0
- package/dist/db/agents-store.d.ts +28 -0
- package/dist/db/agents-store.js +62 -0
- package/dist/db/background-task-clarifications-store.d.ts +81 -0
- package/dist/db/background-task-clarifications-store.js +152 -0
- package/dist/db/background-task-store.d.ts +207 -0
- package/dist/db/background-task-store.js +380 -0
- package/dist/db/browser-history-store.d.ts +39 -6
- package/dist/db/browser-history-store.js +51 -7
- package/dist/db/browser-task-clarifications-store.d.ts +12 -0
- package/dist/db/browser-task-clarifications-store.js +35 -5
- package/dist/db/browser-task-store.d.ts +3 -0
- package/dist/db/browser-task-store.js +29 -4
- package/dist/db/deferred-dm.d.ts +86 -0
- package/dist/db/deferred-dm.js +199 -0
- package/dist/db/migrations.js +330 -0
- package/dist/db/observations.d.ts +2 -2
- package/dist/db/observations.js +3 -3
- package/dist/db/schema.js +217 -16
- package/dist/db/voice-transcripts-store.d.ts +1 -1
- package/dist/index.js +86 -29
- package/dist/messaging/browser-task-mcp-notifier.d.ts +12 -70
- package/dist/messaging/browser-task-mcp-notifier.js +30 -151
- package/dist/messaging/browser-task-screenshot-attachment.d.ts +15 -0
- package/dist/messaging/browser-task-screenshot-attachment.js +63 -0
- package/dist/observers/delegated-sync-worker.d.ts +6 -6
- package/dist/observers/delegated-sync-worker.js +10 -10
- package/dist/observers/git-delegated-cron.d.ts +1 -1
- package/dist/observers/git-delegated-cron.js +2 -2
- package/dist/observers/github-poller-classifier.d.ts +3 -3
- package/dist/observers/github-poller-classifier.js +3 -3
- package/dist/observers/imminent-event-scheduler.d.ts +1 -1
- package/dist/observers/imminent-event-scheduler.js +1 -1
- package/dist/observers/mail-poller.d.ts +1 -0
- package/dist/observers/mail-poller.js +42 -3
- package/dist/observers/observation-summarizer/summarizer-client.d.ts +2 -2
- package/dist/observers/observation-summarizer/summarizer-client.js +2 -2
- package/dist/observers/observation-summarizer/worker.d.ts +2 -2
- package/dist/observers/observation-summarizer/worker.js +4 -4
- package/dist/observers/obsidian-watcher.d.ts +1 -1
- package/dist/observers/obsidian-watcher.js +1 -1
- package/dist/safety/agent-write-tracker.d.ts +4 -4
- package/dist/safety/agent-write-tracker.js +4 -4
- package/dist/safety/audit.d.ts +43 -5
- package/dist/safety/audit.js +86 -18
- package/dist/safety/risk-classifier.d.ts +6 -0
- package/dist/safety/risk-classifier.js +75 -11
- package/dist/scheduler/activity-scan-gate.d.ts +86 -0
- package/dist/scheduler/activity-scan-gate.js +132 -0
- package/dist/services/background-task/background-task-budget.d.ts +80 -0
- package/dist/services/background-task/background-task-budget.js +91 -0
- package/dist/services/background-task/background-task-driver.d.ts +105 -0
- package/dist/services/background-task/background-task-driver.js +416 -0
- package/dist/services/background-task/background-task-runner.d.ts +96 -0
- package/dist/services/background-task/background-task-runner.js +673 -0
- package/dist/services/background-task/background-task-tools.d.ts +84 -0
- package/dist/services/background-task/background-task-tools.js +247 -0
- package/dist/services/background-task/background-task-transition-events.d.ts +43 -0
- package/dist/services/background-task/background-task-transition-events.js +54 -0
- package/dist/services/browser-history/automation/egress-denylist.d.ts +1 -1
- package/dist/services/browser-history/automation/egress-denylist.js +16 -6
- package/dist/services/browser-history/managed-chromium/sandbox-launcher.js +0 -1
- package/dist/services/browser-task/browser-task-runner.js +53 -8
- package/dist/services/observations-batch.d.ts +1 -1
- package/dist/services/observations-batch.js +2 -2
- package/dist/settings/runtime-settings.d.ts +38 -11
- package/dist/settings/runtime-settings.js +203 -40
- package/dist/settings/settings-store.js +11 -3
- package/package.json +4 -4
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* the daemon — adapter / service interfaces (`IDashboardStream`,
|
|
6
6
|
* `INotificationManager`, `ISessionManager`, `IMessageRecorder`,
|
|
7
7
|
* `IContextBuilder`, `IAuditLogger`), the `GetTaskFlow` callback, and the
|
|
8
|
-
* value types used at API boundaries (`
|
|
9
|
-
* `
|
|
8
|
+
* value types used at API boundaries (`TriggerActivityScanOptions`,
|
|
9
|
+
* `TriggerActivityScanResult`, `InFlightExecutionInfo`, `SetupMode`,
|
|
10
10
|
* `BangCommandDetail`, `ReplyActivityHandle`). It also hosts two pure
|
|
11
11
|
* helpers that have no dependence on dispatcher instance state:
|
|
12
12
|
* `buildLogErrorContext` (recovers backend/quota failure metadata from a
|
|
13
|
-
* thrown error) and `parseStage2Verdict` (extracts the Stage 2
|
|
13
|
+
* thrown error) and `parseStage2Verdict` (extracts the Stage 2 activity-scan
|
|
14
14
|
* triage JSON verdict from an LLM response).
|
|
15
15
|
*
|
|
16
16
|
* The dispatcher re-exports the public-surface members of this file so that
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import type Database from "better-sqlite3";
|
|
2
2
|
import type { Event } from "@aitne/shared";
|
|
3
|
+
import { type TaskDeliveryAsset } from "@aitne/shared";
|
|
3
4
|
import type { AgentConfig } from "../config.js";
|
|
4
5
|
import type { DocsCitationLookup } from "./docs/citation-validator.js";
|
|
5
6
|
import type { SignalDetector } from "./signal-detector.js";
|
|
6
7
|
import type { ServiceRegistry } from "../services/service-registry.js";
|
|
7
8
|
import { EventBus } from "./event-bus.js";
|
|
9
|
+
import { SessionGateRegistry } from "./session-gate.js";
|
|
8
10
|
import type { IAgentRouter } from "./backends/backend-router.js";
|
|
9
11
|
import type { TodayWriteLockManager } from "./today-write-lock.js";
|
|
10
12
|
import type { RoadmapWriteLockManager } from "./roadmap-write-lock.js";
|
|
11
13
|
import type { AgentWriteTracker } from "../safety/agent-write-tracker.js";
|
|
12
14
|
import type { AttachmentStore } from "../services/attachments/store.js";
|
|
15
|
+
import type { OutboundAttachmentRef } from "../adapters/types.js";
|
|
13
16
|
import type { VoiceTranscriber } from "../services/voice/transcriber.js";
|
|
14
17
|
import type { AgentExecutionTracker } from "./agents/agent-execution-tracker.js";
|
|
15
18
|
export type { IAgentCore, StreamCallbacks } from "./agent-core.js";
|
|
16
19
|
export type { IAgentRouter } from "./backends/backend-router.js";
|
|
17
|
-
import { parseStage2Verdict, type ReplyActivityHandle, type IDashboardStream, type IContextBuilder, type GetTaskFlow, type INotificationManager, type ISessionManager, type IMessageRecorder, type IAuditLogger, type BangCommandDetail, type DailyWriteAuditDetail, type
|
|
20
|
+
import { parseStage2Verdict, type ReplyActivityHandle, type IDashboardStream, type IContextBuilder, type GetTaskFlow, type INotificationManager, type ISessionManager, type IMessageRecorder, type IAuditLogger, type BangCommandDetail, type DailyWriteAuditDetail, type TriggerActivityScanSkipReason, type SetupMode, type TriggerActivityScanOptions, type TriggerActivityScanResult, type InFlightExecutionInfo } from "./dispatcher-types.js";
|
|
18
21
|
export { parseStage2Verdict, };
|
|
19
|
-
export type { ReplyActivityHandle, IDashboardStream, IContextBuilder, GetTaskFlow, INotificationManager, ISessionManager, IMessageRecorder, IAuditLogger, BangCommandDetail, DailyWriteAuditDetail,
|
|
20
|
-
import type { QueueMorningRoutineWake } from "./dispatcher-
|
|
22
|
+
export type { ReplyActivityHandle, IDashboardStream, IContextBuilder, GetTaskFlow, INotificationManager, ISessionManager, IMessageRecorder, IAuditLogger, BangCommandDetail, DailyWriteAuditDetail, TriggerActivityScanSkipReason, SetupMode, TriggerActivityScanOptions, TriggerActivityScanResult, InFlightExecutionInfo, };
|
|
23
|
+
import type { QueueMorningRoutineWake } from "./dispatcher-activity-scan.js";
|
|
21
24
|
import { SKILL_CURATION_OPTIMIZER_ALLOWED_TOOLS } from "./dispatcher-scheduled-tasks.js";
|
|
22
25
|
export { SKILL_CURATION_OPTIMIZER_ALLOWED_TOOLS };
|
|
23
26
|
export declare class EventDispatcher {
|
|
@@ -101,6 +104,14 @@ export declare class EventDispatcher {
|
|
|
101
104
|
* instead of leaving the row silently flipped to `failed` in the DB.
|
|
102
105
|
*/
|
|
103
106
|
private browserTaskTerminalNotifier;
|
|
107
|
+
/**
|
|
108
|
+
* BACKGROUND_TASK_RUNNER_DESIGN.md §4.2 — the dispatcher routes
|
|
109
|
+
* `scheduled.background_task` events to this runner. Wired at startup
|
|
110
|
+
* from `bootstrap/event-pipeline.ts` via `setBackgroundTaskRunner`.
|
|
111
|
+
* Null when the runner factory has not landed — the dispatch branch
|
|
112
|
+
* flips the row to `failed (runner_unavailable)` so it doesn't park.
|
|
113
|
+
*/
|
|
114
|
+
private backgroundTaskRunner;
|
|
104
115
|
/**
|
|
105
116
|
* Current setup mode — scope-agnostic flag that survives internal
|
|
106
117
|
* direct-message session refresh (day boundary, stale flag, etc). Previously this
|
|
@@ -130,38 +141,38 @@ export declare class EventDispatcher {
|
|
|
130
141
|
/** Dedup guard: timestamp of the last roadmap_refresh emission */
|
|
131
142
|
private lastRoadmapRefreshEmitMs;
|
|
132
143
|
private morningRoutineInProgress;
|
|
133
|
-
private
|
|
144
|
+
private activityScanInProgress;
|
|
134
145
|
/**
|
|
135
146
|
* Wall-clock timestamp (ms since epoch) of the most recent flip of
|
|
136
|
-
* `
|
|
147
|
+
* `activityScanInProgress` to `true`, or `null` when the flag is false.
|
|
137
148
|
*
|
|
138
|
-
* Paired with `
|
|
149
|
+
* Paired with `ACTIVITY_SCAN_FLAG_MAX_AGE_MS` to break the silent-stall
|
|
139
150
|
* pattern where the flag is set true at enqueue time but the matching
|
|
140
151
|
* `dispatchSafe` finally never runs — currently possible when the
|
|
141
152
|
* EventBus evicts/drops the queued routine event under `put()` pressure
|
|
142
153
|
* (heap-js drops the lowest-priority entry silently when `heap.size() >=
|
|
143
154
|
* maxSize=1000`). Without the timestamp the flag stays `true` until
|
|
144
155
|
* process restart and every subsequent hourly tick short-circuits with
|
|
145
|
-
* `
|
|
156
|
+
* `activity_scan_in_progress`.
|
|
146
157
|
*
|
|
147
|
-
* Read side (`
|
|
158
|
+
* Read side (`isActivityScanInProgress` callback below) checks the age
|
|
148
159
|
* and auto-clears when it exceeds the bound, surfacing the recovery via
|
|
149
160
|
* a warn log so the operator sees the EventBus pressure event.
|
|
150
161
|
*/
|
|
151
|
-
private
|
|
162
|
+
private activityScanInProgressAt;
|
|
152
163
|
/**
|
|
153
|
-
* Upper bound for how long `
|
|
164
|
+
* Upper bound for how long `activityScanInProgress=true` can plausibly
|
|
154
165
|
* be valid before we treat it as stuck and force-clear.
|
|
155
166
|
*
|
|
156
|
-
* Sized generously above the realistic Stage-3
|
|
157
|
-
* (fetch_window pre-pass ~30–60 s + Sonnet
|
|
167
|
+
* Sized generously above the realistic Stage-3 activity_scan ceiling
|
|
168
|
+
* (fetch_window pre-pass ~30–60 s + Sonnet activity_scan session
|
|
158
169
|
* ~1–3 min) so a slow but normal run is never falsely cleared. Sized
|
|
159
170
|
* well below an entire agent-day so a stuck flag recovers within a
|
|
160
171
|
* single hourly cron cycle's worst case (default cadence 60 min).
|
|
161
172
|
* The 30-minute window is comfortably outside any plausible "still
|
|
162
173
|
* running" interpretation and inside one full hourly slot.
|
|
163
174
|
*/
|
|
164
|
-
private static readonly
|
|
175
|
+
private static readonly ACTIVITY_SCAN_FLAG_MAX_AGE_MS;
|
|
165
176
|
/**
|
|
166
177
|
* P22 §3.4 — wired by `index.ts` after the daemon's data dir + skills root
|
|
167
178
|
* are known. Returns a `{runId, runToken, workdirPath, targetSkills}` tuple
|
|
@@ -194,12 +205,19 @@ export declare class EventDispatcher {
|
|
|
194
205
|
* and older code paths that don't wire the store. When null, the
|
|
195
206
|
* dispatcher skips attachment staging + outbound collection. */
|
|
196
207
|
private attachmentStore;
|
|
208
|
+
/** Injected lazily via `setTaskDeliveryAssetResolver` — optional.
|
|
209
|
+
* Resolves a task's deliverable assets (browser-task screenshots +
|
|
210
|
+
* worker-written files) to outbound attachments for the `task.delivery`
|
|
211
|
+
* idle + active branches (the ingest hook is constructed after this
|
|
212
|
+
* dispatcher, so it is wired post-construction like the attachment
|
|
213
|
+
* store). When null, task-delivery DMs are text-only. */
|
|
214
|
+
private taskDeliveryAssetResolver;
|
|
197
215
|
/** Injected lazily via `setDelegatedSyncRefresh` — optional. When null,
|
|
198
|
-
*
|
|
216
|
+
* activity scan fires without first refreshing delegated-mode snapshots,
|
|
199
217
|
* matching the pre-Phase-9 behaviour. Wired in production when at
|
|
200
218
|
* least one integration is in delegated mode. See
|
|
201
219
|
* `docs/design/appendices/delegated-sync-opt-in.md` and the worker's
|
|
202
|
-
* `
|
|
220
|
+
* `runDisabledCadencesForActivityScan` method. */
|
|
203
221
|
private delegatedSyncRefresh;
|
|
204
222
|
/**
|
|
205
223
|
* Injected lazily via `setQueueMorningRoutineWake` (wired in `index.ts`
|
|
@@ -218,7 +236,7 @@ export declare class EventDispatcher {
|
|
|
218
236
|
* Injected lazily via `setEventBroadcaster` — optional. When wired, the
|
|
219
237
|
* dispatcher emits `routine_started` / `routine_completed` SSE events at
|
|
220
238
|
* the `dispatchSafe` chokepoint so the dashboard can render real-time
|
|
221
|
-
* progress for autonomous routines (morning_routine,
|
|
239
|
+
* progress for autonomous routines (morning_routine, activity_scan,
|
|
222
240
|
* roadmap_refresh, evening/weekly/monthly reviews, etc.).
|
|
223
241
|
*
|
|
224
242
|
* Failure to broadcast is non-fatal: the throw is swallowed and logged
|
|
@@ -295,21 +313,38 @@ export declare class EventDispatcher {
|
|
|
295
313
|
*/
|
|
296
314
|
private readonly resultProcessor;
|
|
297
315
|
/**
|
|
298
|
-
* Phase D-2 coordinator: owns `
|
|
316
|
+
* Phase D-2 coordinator: owns `triggerActivityScan` and the
|
|
299
317
|
* cost-reduction-structural §B three-stage gate. Borrows live
|
|
300
|
-
* accessors for the dispatcher's `
|
|
318
|
+
* accessors for the dispatcher's `activityScanInProgress` flag so the
|
|
301
319
|
* pre-existing C1 atomic check-and-set semantics survive the split.
|
|
302
320
|
*/
|
|
303
321
|
/**
|
|
304
322
|
* docs/design/appendices/routine-data-acquisition.md Phase 4 / D1 — shared pre-pass
|
|
305
|
-
* runner for `routine.fetch_window`. Injected into
|
|
323
|
+
* runner for `routine.fetch_window`. Injected into ActivityScanCoordinator
|
|
306
324
|
* (D3), MorningRoutineRunner (D2), and ScheduledTaskRunner (D4) so
|
|
307
325
|
* every routine that has rows in `ROUTINE_WINDOWS` gets the same
|
|
308
326
|
* fetcher session ahead of its parent dispatch. Pure helper, no
|
|
309
327
|
* mutable state of its own.
|
|
310
328
|
*/
|
|
311
329
|
private readonly fetchWindowRunner;
|
|
312
|
-
|
|
330
|
+
/**
|
|
331
|
+
* PREPASS_COST_REDUCTION_PLAN.md N2 — offline (backend-API-host DNS) +
|
|
332
|
+
* cached-auth spawn gate for autonomous sessions. Shared with the
|
|
333
|
+
* pre-pass fan-out runner so both layers reuse one DNS verdict cache.
|
|
334
|
+
*/
|
|
335
|
+
private readonly spawnGate;
|
|
336
|
+
/**
|
|
337
|
+
* Last spawn-gate skip *audit write* per (schedule-or-type, reason) —
|
|
338
|
+
* ms epoch. A released schedule row is re-claimed by the
|
|
339
|
+
* ScheduleWatcher every poll tick (default 5s), so an hours-long
|
|
340
|
+
* offline window would otherwise INSERT thousands of identical
|
|
341
|
+
* `result='skipped'` rows. The DB row release/claim churn is bounded
|
|
342
|
+
* (UPDATEs to one row); the audit INSERT is what must be throttled.
|
|
343
|
+
* In-memory on purpose: worst case after a restart is one extra row.
|
|
344
|
+
*/
|
|
345
|
+
private readonly spawnGateSkipAuditAt;
|
|
346
|
+
private static readonly SPAWN_GATE_SKIP_AUDIT_THROTTLE_MS;
|
|
347
|
+
private readonly activityScan;
|
|
313
348
|
/**
|
|
314
349
|
* Phase D-2 coordinator: owns morning-routine execution end-to-end
|
|
315
350
|
* (lock acquisition, prompt-variant selection, retry chain, today.md
|
|
@@ -341,7 +376,7 @@ export declare class EventDispatcher {
|
|
|
341
376
|
* thin shims that forward into this handler.
|
|
342
377
|
*/
|
|
343
378
|
private readonly messageHandler;
|
|
344
|
-
constructor(eventBus: EventBus, agentRouter: IAgentRouter, contextBuilder: IContextBuilder, getTaskFlow: GetTaskFlow, notificationMgr: INotificationManager, sessionMgr: ISessionManager, messageRecorder: IMessageRecorder, audit: IAuditLogger, db: Database.Database, config: AgentConfig, todayWriteLock?: TodayWriteLockManager | undefined, services?: ServiceRegistry | undefined, roadmapWriteLock?: RoadmapWriteLockManager | undefined, writeTracker?: AgentWriteTracker | undefined);
|
|
379
|
+
constructor(eventBus: EventBus, agentRouter: IAgentRouter, contextBuilder: IContextBuilder, getTaskFlow: GetTaskFlow, notificationMgr: INotificationManager, sessionMgr: ISessionManager, messageRecorder: IMessageRecorder, audit: IAuditLogger, db: Database.Database, config: AgentConfig, todayWriteLock?: TodayWriteLockManager | undefined, services?: ServiceRegistry | undefined, roadmapWriteLock?: RoadmapWriteLockManager | undefined, writeTracker?: AgentWriteTracker | undefined, sessionGates?: SessionGateRegistry);
|
|
345
380
|
private loadPersistedSetupMode;
|
|
346
381
|
/** Set the SignalDetector for implicit feedback collection from user messages. */
|
|
347
382
|
setSignalDetector(detector: SignalDetector): void;
|
|
@@ -373,6 +408,13 @@ export declare class EventDispatcher {
|
|
|
373
408
|
*/
|
|
374
409
|
setBrowserTaskRunner(runner: import("../services/browser-task/browser-task-runner.js").BrowserTaskRunner | null): void;
|
|
375
410
|
getBrowserTaskRunner(): import("../services/browser-task/browser-task-runner.js").BrowserTaskRunner | null;
|
|
411
|
+
/**
|
|
412
|
+
* BACKGROUND_TASK_RUNNER_DESIGN.md §4.2 — wire the generic
|
|
413
|
+
* background-task runner so the `scheduled.background_task` dispatch
|
|
414
|
+
* branch can hand fire-time events to it. Pairs with the
|
|
415
|
+
* `event-pipeline.ts` `createBackgroundTaskRunner` factory call.
|
|
416
|
+
*/
|
|
417
|
+
setBackgroundTaskRunner(runner: import("../services/background-task/background-task-runner.js").BackgroundTaskRunner | null): void;
|
|
376
418
|
/**
|
|
377
419
|
* BROWSER_TASK_REDESIGN_PLAN.md §7 — wire the terminal-state DM
|
|
378
420
|
* emitter used by the `scheduled.browser_task` failure paths (see
|
|
@@ -394,13 +436,19 @@ export declare class EventDispatcher {
|
|
|
394
436
|
setDocsCitationLookup(lookup: DocsCitationLookup): void;
|
|
395
437
|
/** Chat-attachments Phase 1 — inject the shared AttachmentStore. */
|
|
396
438
|
setAttachmentStore(store: AttachmentStore): void;
|
|
439
|
+
/** BACKGROUND_TASK_RUNNER_DESIGN.md Phase 1 (delivery assets) — inject the
|
|
440
|
+
* asset resolver used by the `task.delivery` idle + active branches to
|
|
441
|
+
* attach a task's deliverable files (screenshots, PDF/PPTX/PNG/docs)
|
|
442
|
+
* inline. Wired post-construction because the underlying
|
|
443
|
+
* dashboard-ingest hook is built after this dispatcher. */
|
|
444
|
+
setTaskDeliveryAssetResolver(resolver: (platform: string, assets: readonly TaskDeliveryAsset[]) => Promise<readonly OutboundAttachmentRef[]>): void;
|
|
397
445
|
/** Inject the local-Whisper voice transcriber. Optional — when unset,
|
|
398
446
|
* inbound audio attachments are passed to the backend with a path-only
|
|
399
447
|
* reference (the pre-feature behaviour). */
|
|
400
448
|
setVoiceTranscriber(transcriber: VoiceTranscriber): void;
|
|
401
449
|
/**
|
|
402
450
|
* Inject the delegated-sync refresh callback. Called from
|
|
403
|
-
* `
|
|
451
|
+
* `triggerActivityScan` before the gate decision so any cadence the
|
|
404
452
|
* operator left opted-OUT (post-Phase-9 default) populates fresh
|
|
405
453
|
* Gmail / Notion observations the agent can then consume.
|
|
406
454
|
*
|
|
@@ -410,13 +458,13 @@ export declare class EventDispatcher {
|
|
|
410
458
|
* dispatcher holding a stale reference.
|
|
411
459
|
*
|
|
412
460
|
* Pass `null` to detach (e.g. when no delegated integration exists).
|
|
413
|
-
* The
|
|
461
|
+
* The activity scan then proceeds without a refresh — equivalent to the
|
|
414
462
|
* pre-injection behaviour.
|
|
415
463
|
*/
|
|
416
464
|
setDelegatedSyncRefresh(fn: (() => Promise<void>) | null): void;
|
|
417
465
|
/**
|
|
418
466
|
* Wire the scheduler's `queueMorningRoutineWake` so the pre-routine
|
|
419
|
-
* gate (
|
|
467
|
+
* gate (activity_scan + evening/weekly/monthly review) can self-recover
|
|
420
468
|
* after a missed 04:00 cron fire. Wired once in `index.ts` after both
|
|
421
469
|
* the dispatcher and scheduler are constructed; passing `null` detaches.
|
|
422
470
|
* When unset, the gate logs a warning and still skips the dependent
|
|
@@ -439,6 +487,14 @@ export declare class EventDispatcher {
|
|
|
439
487
|
* behaves exactly as before. Set once at boot from the event-pipeline factory.
|
|
440
488
|
*/
|
|
441
489
|
setAgentExecutionTracker(tracker: AgentExecutionTracker): void;
|
|
490
|
+
/**
|
|
491
|
+
* Resolve the user-Agent slug owning an in-flight firing, for stamping
|
|
492
|
+
* `agent_id` into quiet-hours-deferred DM rows (QUIET_HOURS_HARDENING_PLAN
|
|
493
|
+
* Phase 1 — the `/api/notify` gate coalesces per Agent so an hourly Agent
|
|
494
|
+
* firing five times overnight yields one combined DM). `null` when no
|
|
495
|
+
* tracker is wired or no execution is active for the correlation id.
|
|
496
|
+
*/
|
|
497
|
+
agentIdForCorrelation(correlationId: string): string | null;
|
|
442
498
|
/**
|
|
443
499
|
* Open an execution row for an agent-resolvable firing (§8.1), called from
|
|
444
500
|
* `dispatchSafe` after the setup / cost gates pass so a skipped firing never
|
|
@@ -507,7 +563,7 @@ export declare class EventDispatcher {
|
|
|
507
563
|
/**
|
|
508
564
|
* Enter setup mode. Called from `POST /setup/start` so the warm gate
|
|
509
565
|
* engages the moment the user opens the dashboard setup flow — before any
|
|
510
|
-
* agent turn runs — so concurrent
|
|
566
|
+
* agent turn runs — so concurrent activity_scan / morning routine / scheduled
|
|
511
567
|
* wake work cannot race with the setup conversation. Persisted to
|
|
512
568
|
* `runtime_state` so the flag survives daemon restart.
|
|
513
569
|
*/
|
|
@@ -526,7 +582,7 @@ export declare class EventDispatcher {
|
|
|
526
582
|
*/
|
|
527
583
|
getInFlightExecutions(): InFlightExecutionInfo[];
|
|
528
584
|
/**
|
|
529
|
-
* Gate for autonomous background work (cron routines,
|
|
585
|
+
* Gate for autonomous background work (cron routines, activity_scan,
|
|
530
586
|
* scheduled wake tasks, startup catchup, calendar-poller reactive events).
|
|
531
587
|
*
|
|
532
588
|
* Two layers:
|
|
@@ -558,21 +614,29 @@ export declare class EventDispatcher {
|
|
|
558
614
|
/**
|
|
559
615
|
* Check whether this autonomous event should be skipped because the daily
|
|
560
616
|
* autonomous cost cap has been exceeded. Uses priority-based degradation:
|
|
561
|
-
*
|
|
617
|
+
* activity_scan (lowest priority, skipped first) → roadmap_refresh →
|
|
562
618
|
* evening_review → morning_routine (highest, last to be cut).
|
|
563
619
|
*
|
|
564
620
|
* Lower-priority events are skipped at 100% of cap; higher-priority events
|
|
565
621
|
* only at 150%+, giving headroom for the morning briefing.
|
|
566
622
|
*/
|
|
567
623
|
private shouldSkipForCostCap;
|
|
624
|
+
/**
|
|
625
|
+
* Resolve the candidate backends for an autonomous event and run the
|
|
626
|
+
* N2 spawn gates against them. Fail-open on every internal error
|
|
627
|
+
* (binding resolution included) — the gate exists to save sessions
|
|
628
|
+
* that would deterministically fail, never to block live ones.
|
|
629
|
+
* Returns `null` when the gate could not be evaluated.
|
|
630
|
+
*/
|
|
631
|
+
private evaluateAutonomousSpawnGate;
|
|
568
632
|
private handleEvent;
|
|
569
633
|
private handleEventInner;
|
|
570
634
|
/**
|
|
571
|
-
* Public entry point. Delegates to the
|
|
635
|
+
* Public entry point. Delegates to the ActivityScanCoordinator.
|
|
572
636
|
* The dispatcher keeps the wrapper because tests + the cron entry
|
|
573
|
-
* call `dispatcher.
|
|
637
|
+
* call `dispatcher.triggerActivityScan(source, opts)` directly.
|
|
574
638
|
*/
|
|
575
|
-
|
|
639
|
+
triggerActivityScan(source: string, options?: TriggerActivityScanOptions): Promise<TriggerActivityScanResult>;
|
|
576
640
|
/**
|
|
577
641
|
* Advisory check: is a morning routine execution or retry currently in
|
|
578
642
|
* progress? Synchronous (no async) so callers can atomically gate other
|
|
@@ -586,7 +650,7 @@ export declare class EventDispatcher {
|
|
|
586
650
|
*
|
|
587
651
|
* Public (not private) because Phase 4's `AuthHealthMonitor.checkAll()`
|
|
588
652
|
* shares the same skip-while-morning-routine-active invariant as the
|
|
589
|
-
*
|
|
653
|
+
* activity scan, and injects this method as an option so a probe tick
|
|
590
654
|
* running concurrently with morning routine can no-op cleanly. See
|
|
591
655
|
* `docs/design/09-safety-cost.md` §9.5.4.
|
|
592
656
|
*/
|
|
@@ -608,8 +672,25 @@ export declare class EventDispatcher {
|
|
|
608
672
|
* non-scheduled events or already-terminal rows.
|
|
609
673
|
*/
|
|
610
674
|
private releaseClaimedSchedule;
|
|
675
|
+
/**
|
|
676
|
+
* Throttle for spawn-gate skip audit rows. A released schedule row is
|
|
677
|
+
* due immediately, so the watcher re-claims it every poll tick (5s
|
|
678
|
+
* default) for the whole outage — without this, one offline day per
|
|
679
|
+
* pending row writes ~17k identical agent_actions rows. Keyed by
|
|
680
|
+
* (schedule id | event type) × reason so distinct routines and
|
|
681
|
+
* distinct reasons each still get their own first row, and a reason
|
|
682
|
+
* flip (offline → auth_unhealthy) is recorded promptly.
|
|
683
|
+
*/
|
|
684
|
+
private shouldWriteSpawnGateSkipAudit;
|
|
611
685
|
private dispatchSafe;
|
|
612
686
|
private dispatch;
|
|
687
|
+
/**
|
|
688
|
+
* BACKGROUND_TASK_RUNNER_DESIGN.md §4.2 — dispatch branch for
|
|
689
|
+
* `scheduled.background_task`. Defers to `handleScheduledBackgroundTask`
|
|
690
|
+
* (validation + row creation + runner handoff) and translates the
|
|
691
|
+
* outcome into the `agent_schedule.status` write.
|
|
692
|
+
*/
|
|
693
|
+
private handleScheduledBackgroundTaskDispatch;
|
|
613
694
|
/**
|
|
614
695
|
* BROWSER_TASK_REDESIGN_PLAN.md §6.2 + §7 — dispatch branch for
|
|
615
696
|
* `scheduled.browser_task`. Defers the heavy lifting to
|