@aitne/daemon 0.1.6 → 0.1.8
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/dashboard-adapter.d.ts +18 -2
- package/dist/adapters/dashboard-adapter.d.ts.map +1 -1
- package/dist/adapters/dashboard-adapter.js +101 -51
- package/dist/adapters/dashboard-adapter.js.map +1 -1
- package/dist/adapters/discord.d.ts +8 -0
- package/dist/adapters/discord.d.ts.map +1 -1
- package/dist/adapters/discord.js +100 -21
- package/dist/adapters/discord.js.map +1 -1
- package/dist/adapters/message-hub.d.ts.map +1 -1
- package/dist/adapters/message-hub.js +7 -1
- package/dist/adapters/message-hub.js.map +1 -1
- package/dist/adapters/notification-manager.d.ts +102 -2
- package/dist/adapters/notification-manager.d.ts.map +1 -1
- package/dist/adapters/notification-manager.js +228 -8
- package/dist/adapters/notification-manager.js.map +1 -1
- package/dist/adapters/outbound-text.d.ts +16 -0
- package/dist/adapters/outbound-text.d.ts.map +1 -1
- package/dist/adapters/outbound-text.js +118 -1
- package/dist/adapters/outbound-text.js.map +1 -1
- package/dist/adapters/primary-platform-resolver.d.ts +69 -0
- package/dist/adapters/primary-platform-resolver.d.ts.map +1 -0
- package/dist/adapters/primary-platform-resolver.js +55 -0
- package/dist/adapters/primary-platform-resolver.js.map +1 -0
- package/dist/adapters/slack-adapter.d.ts +28 -0
- package/dist/adapters/slack-adapter.d.ts.map +1 -1
- package/dist/adapters/slack-adapter.js +134 -35
- package/dist/adapters/slack-adapter.js.map +1 -1
- package/dist/adapters/telegram-adapter.d.ts +7 -1
- package/dist/adapters/telegram-adapter.d.ts.map +1 -1
- package/dist/adapters/telegram-adapter.js +49 -18
- package/dist/adapters/telegram-adapter.js.map +1 -1
- package/dist/adapters/whatsapp-adapter.d.ts +33 -0
- package/dist/adapters/whatsapp-adapter.d.ts.map +1 -1
- package/dist/adapters/whatsapp-adapter.js +84 -0
- package/dist/adapters/whatsapp-adapter.js.map +1 -1
- package/dist/api/directory-picker.d.ts.map +1 -1
- package/dist/api/directory-picker.js +14 -0
- package/dist/api/directory-picker.js.map +1 -1
- package/dist/api/env-writer.d.ts.map +1 -1
- package/dist/api/env-writer.js +6 -1
- package/dist/api/env-writer.js.map +1 -1
- package/dist/api/helpers/agent-errors.d.ts +2600 -0
- package/dist/api/helpers/agent-errors.d.ts.map +1 -0
- package/dist/api/helpers/agent-errors.js +2506 -0
- package/dist/api/helpers/agent-errors.js.map +1 -0
- package/dist/api/integration-route-gate.d.ts.map +1 -1
- package/dist/api/integration-route-gate.js +10 -3
- package/dist/api/integration-route-gate.js.map +1 -1
- package/dist/api/routes/agent-schedule-plan-match.d.ts +5 -0
- package/dist/api/routes/agent-schedule-plan-match.d.ts.map +1 -0
- package/dist/api/routes/agent-schedule-plan-match.js +101 -0
- package/dist/api/routes/agent-schedule-plan-match.js.map +1 -0
- package/dist/api/routes/agent-schedule.d.ts +4 -0
- package/dist/api/routes/agent-schedule.d.ts.map +1 -0
- package/dist/api/routes/agent-schedule.js +750 -0
- package/dist/api/routes/agent-schedule.js.map +1 -0
- package/dist/api/routes/agent.d.ts.map +1 -1
- package/dist/api/routes/agent.js +209 -366
- package/dist/api/routes/agent.js.map +1 -1
- package/dist/api/routes/apple-calendar.d.ts.map +1 -1
- package/dist/api/routes/apple-calendar.js +109 -27
- package/dist/api/routes/apple-calendar.js.map +1 -1
- package/dist/api/routes/attachments.d.ts.map +1 -1
- package/dist/api/routes/attachments.js +113 -21
- package/dist/api/routes/attachments.js.map +1 -1
- package/dist/api/routes/backends.d.ts.map +1 -1
- package/dist/api/routes/backends.js +100 -4
- package/dist/api/routes/backends.js.map +1 -1
- package/dist/api/routes/books.d.ts.map +1 -1
- package/dist/api/routes/books.js +58 -18
- package/dist/api/routes/books.js.map +1 -1
- package/dist/api/routes/calendar.d.ts +3 -2
- package/dist/api/routes/calendar.d.ts.map +1 -1
- package/dist/api/routes/calendar.js +330 -55
- package/dist/api/routes/calendar.js.map +1 -1
- package/dist/api/routes/commands.d.ts.map +1 -1
- package/dist/api/routes/commands.js +20 -1
- package/dist/api/routes/commands.js.map +1 -1
- package/dist/api/routes/context/index.d.ts +33 -0
- package/dist/api/routes/context/index.d.ts.map +1 -0
- package/dist/api/routes/context/index.js +193 -0
- package/dist/api/routes/context/index.js.map +1 -0
- package/dist/api/routes/context/locks.d.ts +4 -0
- package/dist/api/routes/context/locks.d.ts.map +1 -0
- package/dist/api/routes/context/locks.js +136 -0
- package/dist/api/routes/context/locks.js.map +1 -0
- package/dist/api/routes/context/path-resolve.d.ts +15 -0
- package/dist/api/routes/context/path-resolve.d.ts.map +1 -0
- package/dist/api/routes/context/path-resolve.js +109 -0
- package/dist/api/routes/context/path-resolve.js.map +1 -0
- package/dist/api/routes/context/permissions.d.ts +35 -0
- package/dist/api/routes/context/permissions.d.ts.map +1 -0
- package/dist/api/routes/context/permissions.js +192 -0
- package/dist/api/routes/context/permissions.js.map +1 -0
- package/dist/api/routes/context/read.d.ts +4 -0
- package/dist/api/routes/context/read.d.ts.map +1 -0
- package/dist/api/routes/context/read.js +295 -0
- package/dist/api/routes/context/read.js.map +1 -0
- package/dist/api/routes/context/repair.d.ts +4 -0
- package/dist/api/routes/context/repair.d.ts.map +1 -0
- package/dist/api/routes/context/repair.js +114 -0
- package/dist/api/routes/context/repair.js.map +1 -0
- package/dist/api/routes/context/snapshots.d.ts +4 -0
- package/dist/api/routes/context/snapshots.d.ts.map +1 -0
- package/dist/api/routes/context/snapshots.js +177 -0
- package/dist/api/routes/context/snapshots.js.map +1 -0
- package/dist/api/routes/context/write.d.ts +4 -0
- package/dist/api/routes/context/write.d.ts.map +1 -0
- package/dist/api/routes/context/write.js +570 -0
- package/dist/api/routes/context/write.js.map +1 -0
- package/dist/api/routes/context.d.ts +2 -43
- package/dist/api/routes/context.d.ts.map +1 -1
- package/dist/api/routes/context.js +415 -558
- package/dist/api/routes/context.js.map +1 -1
- package/dist/api/routes/dashboard/config.d.ts +4 -0
- package/dist/api/routes/dashboard/config.d.ts.map +1 -0
- package/dist/api/routes/dashboard/config.js +499 -0
- package/dist/api/routes/dashboard/config.js.map +1 -0
- package/dist/api/routes/dashboard/conversations.d.ts +4 -0
- package/dist/api/routes/dashboard/conversations.d.ts.map +1 -0
- package/dist/api/routes/dashboard/conversations.js +309 -0
- package/dist/api/routes/dashboard/conversations.js.map +1 -0
- package/dist/api/routes/dashboard/cost-approvals.d.ts +29 -0
- package/dist/api/routes/dashboard/cost-approvals.d.ts.map +1 -0
- package/dist/api/routes/dashboard/cost-approvals.js +259 -0
- package/dist/api/routes/dashboard/cost-approvals.js.map +1 -0
- package/dist/api/routes/dashboard/index.d.ts +27 -0
- package/dist/api/routes/dashboard/index.d.ts.map +1 -0
- package/dist/api/routes/dashboard/index.js +47 -0
- package/dist/api/routes/dashboard/index.js.map +1 -0
- package/dist/api/routes/dashboard/messaging.d.ts +4 -0
- package/dist/api/routes/dashboard/messaging.d.ts.map +1 -0
- package/dist/api/routes/dashboard/messaging.js +351 -0
- package/dist/api/routes/dashboard/messaging.js.map +1 -0
- package/dist/api/routes/dashboard/notifications.d.ts +4 -0
- package/dist/api/routes/dashboard/notifications.d.ts.map +1 -0
- package/dist/api/routes/dashboard/notifications.js +109 -0
- package/dist/api/routes/dashboard/notifications.js.map +1 -0
- package/dist/api/routes/dashboard/oauth-google.d.ts +4 -0
- package/dist/api/routes/dashboard/oauth-google.d.ts.map +1 -0
- package/dist/api/routes/dashboard/oauth-google.js +293 -0
- package/dist/api/routes/dashboard/oauth-google.js.map +1 -0
- package/dist/api/routes/dashboard/schedule-readonly.d.ts +4 -0
- package/dist/api/routes/dashboard/schedule-readonly.d.ts.map +1 -0
- package/dist/api/routes/dashboard/schedule-readonly.js +46 -0
- package/dist/api/routes/dashboard/schedule-readonly.js.map +1 -0
- package/dist/api/routes/dashboard/secrets.d.ts +24 -0
- package/dist/api/routes/dashboard/secrets.d.ts.map +1 -0
- package/dist/api/routes/dashboard/secrets.js +307 -0
- package/dist/api/routes/dashboard/secrets.js.map +1 -0
- package/dist/api/routes/dashboard/snapshots.d.ts +4 -0
- package/dist/api/routes/dashboard/snapshots.d.ts.map +1 -0
- package/dist/api/routes/dashboard/snapshots.js +33 -0
- package/dist/api/routes/dashboard/snapshots.js.map +1 -0
- package/dist/api/routes/dashboard.d.ts.map +1 -1
- package/dist/api/routes/dashboard.js +20 -12
- package/dist/api/routes/dashboard.js.map +1 -1
- package/dist/api/routes/delegated.d.ts +5 -4
- package/dist/api/routes/delegated.d.ts.map +1 -1
- package/dist/api/routes/delegated.js +6 -5
- package/dist/api/routes/delegated.js.map +1 -1
- package/dist/api/routes/docs.d.ts.map +1 -1
- package/dist/api/routes/docs.js +72 -9
- package/dist/api/routes/docs.js.map +1 -1
- package/dist/api/routes/entities.d.ts.map +1 -1
- package/dist/api/routes/entities.js +112 -43
- package/dist/api/routes/entities.js.map +1 -1
- package/dist/api/routes/fs.d.ts.map +1 -1
- package/dist/api/routes/fs.js +27 -12
- package/dist/api/routes/fs.js.map +1 -1
- package/dist/api/routes/git-templates.d.ts.map +1 -1
- package/dist/api/routes/git-templates.js +107 -27
- package/dist/api/routes/git-templates.js.map +1 -1
- package/dist/api/routes/git.d.ts.map +1 -1
- package/dist/api/routes/git.js +55 -11
- package/dist/api/routes/git.js.map +1 -1
- package/dist/api/routes/github.d.ts.map +1 -1
- package/dist/api/routes/github.js +110 -17
- package/dist/api/routes/github.js.map +1 -1
- package/dist/api/routes/integrations/crud-patch.d.ts +17 -0
- package/dist/api/routes/integrations/crud-patch.d.ts.map +1 -0
- package/dist/api/routes/integrations/crud-patch.js +600 -0
- package/dist/api/routes/integrations/crud-patch.js.map +1 -0
- package/dist/api/routes/integrations/crud.d.ts +16 -0
- package/dist/api/routes/integrations/crud.d.ts.map +1 -0
- package/dist/api/routes/integrations/crud.js +158 -0
- package/dist/api/routes/integrations/crud.js.map +1 -0
- package/dist/api/routes/integrations/exec.d.ts +23 -0
- package/dist/api/routes/integrations/exec.d.ts.map +1 -0
- package/dist/api/routes/integrations/exec.js +356 -0
- package/dist/api/routes/integrations/exec.js.map +1 -0
- package/dist/api/routes/integrations/index.d.ts +62 -0
- package/dist/api/routes/integrations/index.d.ts.map +1 -0
- package/dist/api/routes/integrations/index.js +70 -0
- package/dist/api/routes/integrations/index.js.map +1 -0
- package/dist/api/routes/integrations/integrations/crud.d.ts +16 -0
- package/dist/api/routes/integrations/integrations/crud.d.ts.map +1 -0
- package/dist/api/routes/integrations/integrations/crud.js +158 -0
- package/dist/api/routes/integrations/integrations/crud.js.map +1 -0
- package/dist/api/routes/integrations/integrations/index.d.ts +55 -0
- package/dist/api/routes/integrations/integrations/index.d.ts.map +1 -0
- package/dist/api/routes/integrations/integrations/index.js +65 -0
- package/dist/api/routes/integrations/integrations/index.js.map +1 -0
- package/dist/api/routes/integrations/integrations/invoke.d.ts +38 -0
- package/dist/api/routes/integrations/integrations/invoke.d.ts.map +1 -0
- package/dist/api/routes/integrations/integrations/invoke.js +320 -0
- package/dist/api/routes/integrations/integrations/invoke.js.map +1 -0
- package/dist/api/routes/integrations/integrations/probe.d.ts +21 -0
- package/dist/api/routes/integrations/integrations/probe.d.ts.map +1 -0
- package/dist/api/routes/integrations/integrations/probe.js +247 -0
- package/dist/api/routes/integrations/integrations/probe.js.map +1 -0
- package/dist/api/routes/integrations/invoke.d.ts +38 -0
- package/dist/api/routes/integrations/invoke.d.ts.map +1 -0
- package/dist/api/routes/integrations/invoke.js +320 -0
- package/dist/api/routes/integrations/invoke.js.map +1 -0
- package/dist/api/routes/integrations/probe.d.ts +21 -0
- package/dist/api/routes/integrations/probe.d.ts.map +1 -0
- package/dist/api/routes/integrations/probe.js +247 -0
- package/dist/api/routes/integrations/probe.js.map +1 -0
- package/dist/api/routes/integrations.d.ts.map +1 -1
- package/dist/api/routes/integrations.js +65 -13
- package/dist/api/routes/integrations.js.map +1 -1
- package/dist/api/routes/knowledge.d.ts.map +1 -1
- package/dist/api/routes/knowledge.js +13 -2
- package/dist/api/routes/knowledge.js.map +1 -1
- package/dist/api/routes/mail/_pa_wip_mail/app-password.d.ts +4 -0
- package/dist/api/routes/mail/_pa_wip_mail/app-password.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/app-password.js +192 -0
- package/dist/api/routes/mail/_pa_wip_mail/app-password.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/body-helpers.d.ts +55 -0
- package/dist/api/routes/mail/_pa_wip_mail/body-helpers.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/body-helpers.js +91 -0
- package/dist/api/routes/mail/_pa_wip_mail/body-helpers.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/dependencies.d.ts +36 -0
- package/dist/api/routes/mail/_pa_wip_mail/dependencies.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/dependencies.js +2 -0
- package/dist/api/routes/mail/_pa_wip_mail/dependencies.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/gating.d.ts +45 -0
- package/dist/api/routes/mail/_pa_wip_mail/gating.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/gating.js +98 -0
- package/dist/api/routes/mail/_pa_wip_mail/gating.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/accounts.d.ts +4 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/accounts.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/accounts.js +289 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/accounts.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/app-password.d.ts +4 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/app-password.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/app-password.js +192 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/app-password.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/body-helpers.d.ts +55 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/body-helpers.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/body-helpers.js +91 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/body-helpers.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/dependencies.d.ts +36 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/dependencies.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/dependencies.js +2 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/dependencies.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/drafts.d.ts +5 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/drafts.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/drafts.js +139 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/drafts.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/gating.d.ts +45 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/gating.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/gating.js +98 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/gating.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/index.d.ts +18 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/index.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/index.js +40 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/index.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/messages.d.ts +15 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/messages.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/messages.js +239 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/messages.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/outlook-config.d.ts +4 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/outlook-config.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/outlook-config.js +73 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/outlook-config.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/provider-resolver.d.ts +64 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/provider-resolver.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/provider-resolver.js +286 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/provider-resolver.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/providers.d.ts +4 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/providers.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/providers.js +73 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/providers.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/tags-folders.d.ts +5 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/tags-folders.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/tags-folders.js +35 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/tags-folders.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/validators.d.ts +23 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/validators.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/validators.js +131 -0
- package/dist/api/routes/mail/_pa_wip_mail/mail/validators.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/provider-resolver.d.ts +64 -0
- package/dist/api/routes/mail/_pa_wip_mail/provider-resolver.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/provider-resolver.js +286 -0
- package/dist/api/routes/mail/_pa_wip_mail/provider-resolver.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/search-health.d.ts +4 -0
- package/dist/api/routes/mail/_pa_wip_mail/search-health.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/search-health.js +131 -0
- package/dist/api/routes/mail/_pa_wip_mail/search-health.js.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/validators.d.ts +23 -0
- package/dist/api/routes/mail/_pa_wip_mail/validators.d.ts.map +1 -0
- package/dist/api/routes/mail/_pa_wip_mail/validators.js +131 -0
- package/dist/api/routes/mail/_pa_wip_mail/validators.js.map +1 -0
- package/dist/api/routes/mail/accounts.d.ts +4 -0
- package/dist/api/routes/mail/accounts.d.ts.map +1 -0
- package/dist/api/routes/mail/accounts.js +289 -0
- package/dist/api/routes/mail/accounts.js.map +1 -0
- package/dist/api/routes/mail/app-password.d.ts +4 -0
- package/dist/api/routes/mail/app-password.d.ts.map +1 -0
- package/dist/api/routes/mail/app-password.js +192 -0
- package/dist/api/routes/mail/app-password.js.map +1 -0
- package/dist/api/routes/mail/body-helpers.d.ts +56 -0
- package/dist/api/routes/mail/body-helpers.d.ts.map +1 -0
- package/dist/api/routes/mail/body-helpers.js +91 -0
- package/dist/api/routes/mail/body-helpers.js.map +1 -0
- package/dist/api/routes/mail/dependencies.d.ts +36 -0
- package/dist/api/routes/mail/dependencies.d.ts.map +1 -0
- package/dist/api/routes/mail/dependencies.js +2 -0
- package/dist/api/routes/mail/dependencies.js.map +1 -0
- package/dist/api/routes/mail/drafts.d.ts +5 -0
- package/dist/api/routes/mail/drafts.d.ts.map +1 -0
- package/dist/api/routes/mail/drafts.js +139 -0
- package/dist/api/routes/mail/drafts.js.map +1 -0
- package/dist/api/routes/mail/gating.d.ts +45 -0
- package/dist/api/routes/mail/gating.d.ts.map +1 -0
- package/dist/api/routes/mail/gating.js +99 -0
- package/dist/api/routes/mail/gating.js.map +1 -0
- package/dist/api/routes/mail/index.d.ts +18 -0
- package/dist/api/routes/mail/index.d.ts.map +1 -0
- package/dist/api/routes/mail/index.js +40 -0
- package/dist/api/routes/mail/index.js.map +1 -0
- package/dist/api/routes/mail/messages.d.ts +15 -0
- package/dist/api/routes/mail/messages.d.ts.map +1 -0
- package/dist/api/routes/mail/messages.js +239 -0
- package/dist/api/routes/mail/messages.js.map +1 -0
- package/dist/api/routes/mail/outlook-config.d.ts +4 -0
- package/dist/api/routes/mail/outlook-config.d.ts.map +1 -0
- package/dist/api/routes/mail/outlook-config.js +73 -0
- package/dist/api/routes/mail/outlook-config.js.map +1 -0
- package/dist/api/routes/mail/provider-resolver.d.ts +64 -0
- package/dist/api/routes/mail/provider-resolver.d.ts.map +1 -0
- package/dist/api/routes/mail/provider-resolver.js +286 -0
- package/dist/api/routes/mail/provider-resolver.js.map +1 -0
- package/dist/api/routes/mail/providers.d.ts +4 -0
- package/dist/api/routes/mail/providers.d.ts.map +1 -0
- package/dist/api/routes/mail/providers.js +73 -0
- package/dist/api/routes/mail/providers.js.map +1 -0
- package/dist/api/routes/mail/search-health.d.ts +4 -0
- package/dist/api/routes/mail/search-health.d.ts.map +1 -0
- package/dist/api/routes/mail/search-health.js +131 -0
- package/dist/api/routes/mail/search-health.js.map +1 -0
- package/dist/api/routes/mail/tags-folders.d.ts +5 -0
- package/dist/api/routes/mail/tags-folders.d.ts.map +1 -0
- package/dist/api/routes/mail/tags-folders.js +35 -0
- package/dist/api/routes/mail/tags-folders.js.map +1 -0
- package/dist/api/routes/mail/validators.d.ts +23 -0
- package/dist/api/routes/mail/validators.d.ts.map +1 -0
- package/dist/api/routes/mail/validators.js +131 -0
- package/dist/api/routes/mail/validators.js.map +1 -0
- package/dist/api/routes/mail.d.ts.map +1 -1
- package/dist/api/routes/mail.js +259 -67
- package/dist/api/routes/mail.js.map +1 -1
- package/dist/api/routes/managed-tasks.d.ts.map +1 -1
- package/dist/api/routes/managed-tasks.js +142 -54
- package/dist/api/routes/managed-tasks.js.map +1 -1
- package/dist/api/routes/mcp.d.ts.map +1 -1
- package/dist/api/routes/mcp.js +115 -47
- package/dist/api/routes/mcp.js.map +1 -1
- package/dist/api/routes/metrics.d.ts +1 -1
- package/dist/api/routes/metrics.js +2 -2
- package/dist/api/routes/notion.d.ts.map +1 -1
- package/dist/api/routes/notion.js +230 -54
- package/dist/api/routes/notion.js.map +1 -1
- package/dist/api/routes/observations.d.ts.map +1 -1
- package/dist/api/routes/observations.js +40 -169
- package/dist/api/routes/observations.js.map +1 -1
- package/dist/api/routes/obsidian.d.ts.map +1 -1
- package/dist/api/routes/obsidian.js +193 -32
- package/dist/api/routes/obsidian.js.map +1 -1
- package/dist/api/routes/profile-questions.d.ts.map +1 -1
- package/dist/api/routes/profile-questions.js +19 -3
- package/dist/api/routes/profile-questions.js.map +1 -1
- package/dist/api/routes/receipts.d.ts.map +1 -1
- package/dist/api/routes/receipts.js +64 -24
- package/dist/api/routes/receipts.js.map +1 -1
- package/dist/api/routes/recurring-schedules.d.ts.map +1 -1
- package/dist/api/routes/recurring-schedules.js +243 -13
- package/dist/api/routes/recurring-schedules.js.map +1 -1
- package/dist/api/routes/repositories.d.ts.map +1 -1
- package/dist/api/routes/repositories.js +278 -104
- package/dist/api/routes/repositories.js.map +1 -1
- package/dist/api/routes/schedule-model-resolver.d.ts +153 -0
- package/dist/api/routes/schedule-model-resolver.d.ts.map +1 -0
- package/dist/api/routes/schedule-model-resolver.js +282 -0
- package/dist/api/routes/schedule-model-resolver.js.map +1 -0
- package/dist/api/routes/schedule-options.d.ts +25 -0
- package/dist/api/routes/schedule-options.d.ts.map +1 -0
- package/dist/api/routes/schedule-options.js +77 -0
- package/dist/api/routes/schedule-options.js.map +1 -0
- package/dist/api/routes/schedule-validation.d.ts +146 -0
- package/dist/api/routes/schedule-validation.d.ts.map +1 -0
- package/dist/api/routes/schedule-validation.js +153 -0
- package/dist/api/routes/schedule-validation.js.map +1 -0
- package/dist/api/routes/setup.d.ts.map +1 -1
- package/dist/api/routes/setup.js +100 -26
- package/dist/api/routes/setup.js.map +1 -1
- package/dist/api/routes/skills.d.ts.map +1 -1
- package/dist/api/routes/skills.js +81 -30
- package/dist/api/routes/skills.js.map +1 -1
- package/dist/api/routes/sot-bindings.d.ts.map +1 -1
- package/dist/api/routes/sot-bindings.js +46 -11
- package/dist/api/routes/sot-bindings.js.map +1 -1
- package/dist/api/routes/sse.d.ts.map +1 -1
- package/dist/api/routes/sse.js +6 -1
- package/dist/api/routes/sse.js.map +1 -1
- package/dist/api/routes/system.d.ts.map +1 -1
- package/dist/api/routes/system.js +15 -2
- package/dist/api/routes/system.js.map +1 -1
- package/dist/api/routes/travel-bookings.d.ts.map +1 -1
- package/dist/api/routes/travel-bookings.js +26 -9
- package/dist/api/routes/travel-bookings.js.map +1 -1
- package/dist/api/routes/travel-time.d.ts.map +1 -1
- package/dist/api/routes/travel-time.js +50 -10
- package/dist/api/routes/travel-time.js.map +1 -1
- package/dist/api/routes/wiki.d.ts.map +1 -1
- package/dist/api/routes/wiki.js +49 -8
- package/dist/api/routes/wiki.js.map +1 -1
- package/dist/api/server.d.ts +15 -3
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +32 -10
- package/dist/api/server.js.map +1 -1
- package/dist/bootstrap/adapters.d.ts.map +1 -1
- package/dist/bootstrap/adapters.js +7 -4
- package/dist/bootstrap/adapters.js.map +1 -1
- package/dist/bootstrap/api.d.ts +205 -0
- package/dist/bootstrap/api.d.ts.map +1 -0
- package/dist/bootstrap/api.js +443 -0
- package/dist/bootstrap/api.js.map +1 -0
- package/dist/bootstrap/db.d.ts +119 -0
- package/dist/bootstrap/db.d.ts.map +1 -0
- package/dist/bootstrap/db.js +294 -0
- package/dist/bootstrap/db.js.map +1 -0
- package/dist/bootstrap/event-pipeline.d.ts +308 -0
- package/dist/bootstrap/event-pipeline.d.ts.map +1 -0
- package/dist/bootstrap/event-pipeline.js +704 -0
- package/dist/bootstrap/event-pipeline.js.map +1 -0
- package/dist/bootstrap/observers.d.ts +148 -0
- package/dist/bootstrap/observers.d.ts.map +1 -0
- package/dist/bootstrap/observers.js +558 -0
- package/dist/bootstrap/observers.js.map +1 -0
- package/dist/bootstrap/schedule-helpers.d.ts +122 -0
- package/dist/bootstrap/schedule-helpers.d.ts.map +1 -1
- package/dist/bootstrap/schedule-helpers.js +202 -4
- package/dist/bootstrap/schedule-helpers.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +20 -3
- package/dist/config.js.map +1 -1
- package/dist/core/abort-utils.d.ts +14 -0
- package/dist/core/abort-utils.d.ts.map +1 -0
- package/dist/core/abort-utils.js +36 -0
- package/dist/core/abort-utils.js.map +1 -0
- package/dist/core/agent-core.d.ts +22 -3
- package/dist/core/agent-core.d.ts.map +1 -1
- package/dist/core/agent-core.js +3 -1
- package/dist/core/agent-core.js.map +1 -1
- package/dist/core/backends/auth-health-monitor.js +2 -3
- package/dist/core/backends/auth-health-monitor.js.map +1 -1
- package/dist/core/backends/backend-router.d.ts +11 -1
- package/dist/core/backends/backend-router.d.ts.map +1 -1
- package/dist/core/backends/backend-router.js +97 -2
- package/dist/core/backends/backend-router.js.map +1 -1
- package/dist/core/backends/claude-code-core.d.ts +51 -0
- package/dist/core/backends/claude-code-core.d.ts.map +1 -1
- package/dist/core/backends/claude-code-core.js +134 -11
- package/dist/core/backends/claude-code-core.js.map +1 -1
- package/dist/core/backends/claude-tool-collection.js +1 -1
- package/dist/core/backends/codex-core.d.ts +13 -1
- package/dist/core/backends/codex-core.d.ts.map +1 -1
- package/dist/core/backends/codex-core.js +436 -22
- package/dist/core/backends/codex-core.js.map +1 -1
- package/dist/core/backends/gemini-cli-core.d.ts +5 -1
- package/dist/core/backends/gemini-cli-core.d.ts.map +1 -1
- package/dist/core/backends/gemini-cli-core.js +298 -15
- package/dist/core/backends/gemini-cli-core.js.map +1 -1
- package/dist/core/backends/install-methods.d.ts.map +1 -1
- package/dist/core/backends/install-methods.js +22 -0
- package/dist/core/backends/install-methods.js.map +1 -1
- package/dist/core/backends/model-registry.d.ts +9 -4
- package/dist/core/backends/model-registry.d.ts.map +1 -1
- package/dist/core/backends/model-registry.js +153 -23
- package/dist/core/backends/model-registry.js.map +1 -1
- package/dist/core/backends/native-skill-discovery-probe.d.ts +80 -0
- package/dist/core/backends/native-skill-discovery-probe.d.ts.map +1 -0
- package/dist/core/backends/native-skill-discovery-probe.js +175 -0
- package/dist/core/backends/native-skill-discovery-probe.js.map +1 -0
- package/dist/core/backends/opencode-basic-auth-fetch.d.ts +27 -0
- package/dist/core/backends/opencode-basic-auth-fetch.d.ts.map +1 -0
- package/dist/core/backends/opencode-basic-auth-fetch.js +40 -0
- package/dist/core/backends/opencode-basic-auth-fetch.js.map +1 -0
- package/dist/core/backends/opencode-config-builder.d.ts +86 -0
- package/dist/core/backends/opencode-config-builder.d.ts.map +1 -0
- package/dist/core/backends/opencode-config-builder.js +172 -0
- package/dist/core/backends/opencode-config-builder.js.map +1 -0
- package/dist/core/backends/opencode-core.d.ts +316 -0
- package/dist/core/backends/opencode-core.d.ts.map +1 -0
- package/dist/core/backends/opencode-core.js +1502 -0
- package/dist/core/backends/opencode-core.js.map +1 -0
- package/dist/core/backends/opencode-event-mapper.d.ts +133 -0
- package/dist/core/backends/opencode-event-mapper.d.ts.map +1 -0
- package/dist/core/backends/opencode-event-mapper.js +198 -0
- package/dist/core/backends/opencode-event-mapper.js.map +1 -0
- package/dist/core/backends/opencode-mcp.d.ts +82 -0
- package/dist/core/backends/opencode-mcp.d.ts.map +1 -0
- package/dist/core/backends/opencode-mcp.js +165 -0
- package/dist/core/backends/opencode-mcp.js.map +1 -0
- package/dist/core/backends/opencode-server-manager.d.ts +114 -0
- package/dist/core/backends/opencode-server-manager.d.ts.map +1 -0
- package/dist/core/backends/opencode-server-manager.js +222 -0
- package/dist/core/backends/opencode-server-manager.js.map +1 -0
- package/dist/core/backends/opencode-types.d.ts +46 -0
- package/dist/core/backends/opencode-types.d.ts.map +1 -0
- package/dist/core/backends/opencode-types.js +14 -0
- package/dist/core/backends/opencode-types.js.map +1 -0
- package/dist/core/backends/plan-presets.d.ts +18 -5
- package/dist/core/backends/plan-presets.d.ts.map +1 -1
- package/dist/core/backends/plan-presets.js +144 -23
- package/dist/core/backends/plan-presets.js.map +1 -1
- package/dist/core/backends/process-config-cascade.d.ts +35 -0
- package/dist/core/backends/process-config-cascade.d.ts.map +1 -1
- package/dist/core/backends/process-config-cascade.js +35 -1
- package/dist/core/backends/process-config-cascade.js.map +1 -1
- package/dist/core/backends/prompt-utils.d.ts.map +1 -1
- package/dist/core/backends/prompt-utils.js +0 -2
- package/dist/core/backends/prompt-utils.js.map +1 -1
- package/dist/core/backends/quota-reset-hints.d.ts +44 -0
- package/dist/core/backends/quota-reset-hints.d.ts.map +1 -0
- package/dist/core/backends/quota-reset-hints.js +117 -0
- package/dist/core/backends/quota-reset-hints.js.map +1 -0
- package/dist/core/bang-commands/commands-close.d.ts +24 -0
- package/dist/core/bang-commands/commands-close.d.ts.map +1 -0
- package/dist/core/bang-commands/commands-close.js +24 -0
- package/dist/core/bang-commands/commands-close.js.map +1 -0
- package/dist/core/bang-commands/commands-cost.d.ts.map +1 -1
- package/dist/core/bang-commands/commands-cost.js +13 -0
- package/dist/core/bang-commands/commands-cost.js.map +1 -1
- package/dist/core/bang-commands/commands-help.d.ts.map +1 -1
- package/dist/core/bang-commands/commands-help.js +44 -5
- package/dist/core/bang-commands/commands-help.js.map +1 -1
- package/dist/core/bang-commands/commands-report.d.ts.map +1 -1
- package/dist/core/bang-commands/commands-report.js +1 -0
- package/dist/core/bang-commands/commands-report.js.map +1 -1
- package/dist/core/bang-commands/commands-stop-start.d.ts.map +1 -1
- package/dist/core/bang-commands/commands-stop-start.js +2 -0
- package/dist/core/bang-commands/commands-stop-start.js.map +1 -1
- package/dist/core/bang-commands/commands-wiki.d.ts.map +1 -1
- package/dist/core/bang-commands/commands-wiki.js +12 -1
- package/dist/core/bang-commands/commands-wiki.js.map +1 -1
- package/dist/core/bang-commands/format-utils.d.ts +13 -1
- package/dist/core/bang-commands/format-utils.d.ts.map +1 -1
- package/dist/core/bang-commands/format-utils.js +21 -2
- package/dist/core/bang-commands/format-utils.js.map +1 -1
- package/dist/core/bang-commands/index.d.ts +1 -0
- package/dist/core/bang-commands/index.d.ts.map +1 -1
- package/dist/core/bang-commands/index.js +3 -0
- package/dist/core/bang-commands/index.js.map +1 -1
- package/dist/core/bang-commands/registry.d.ts +50 -0
- package/dist/core/bang-commands/registry.d.ts.map +1 -1
- package/dist/core/bang-commands/registry.js +164 -19
- package/dist/core/bang-commands/registry.js.map +1 -1
- package/dist/core/channel-timeline.d.ts +18 -1
- package/dist/core/channel-timeline.d.ts.map +1 -1
- package/dist/core/channel-timeline.js +44 -0
- package/dist/core/channel-timeline.js.map +1 -1
- package/dist/core/context/activity-view-runner.js +9 -1
- package/dist/core/context/activity-view-runner.js.map +1 -1
- package/dist/core/context/default-schedules-runner.js +44 -4
- package/dist/core/context/default-schedules-runner.js.map +1 -1
- package/dist/core/context/domain-index-runner.js +9 -1
- package/dist/core/context/domain-index-runner.js.map +1 -1
- package/dist/core/context/entity-source-rename.d.ts.map +1 -1
- package/dist/core/context/entity-source-rename.js +9 -1
- package/dist/core/context/entity-source-rename.js.map +1 -1
- package/dist/core/context/policy-index-runner.js +9 -1
- package/dist/core/context/policy-index-runner.js.map +1 -1
- package/dist/core/context/reconciler-runner.js +9 -1
- package/dist/core/context/reconciler-runner.js.map +1 -1
- package/dist/core/context-builder.d.ts +97 -2
- package/dist/core/context-builder.d.ts.map +1 -1
- package/dist/core/context-builder.js +303 -30
- package/dist/core/context-builder.js.map +1 -1
- package/dist/core/context-frontmatter.d.ts +6 -0
- package/dist/core/context-frontmatter.d.ts.map +1 -1
- package/dist/core/context-frontmatter.js +120 -8
- package/dist/core/context-frontmatter.js.map +1 -1
- package/dist/core/context-health.js +21 -9
- package/dist/core/context-health.js.map +1 -1
- package/dist/core/context-validation/_pa_wip_context_validation/index.d.ts +19 -0
- package/dist/core/context-validation/_pa_wip_context_validation/index.d.ts.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/index.js +19 -0
- package/dist/core/context-validation/_pa_wip_context_validation/index.js.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/prepare-write.d.ts +94 -0
- package/dist/core/context-validation/_pa_wip_context_validation/prepare-write.d.ts.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/prepare-write.js +130 -0
- package/dist/core/context-validation/_pa_wip_context_validation/prepare-write.js.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/routine-rulebook.d.ts +60 -0
- package/dist/core/context-validation/_pa_wip_context_validation/routine-rulebook.d.ts.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/routine-rulebook.js +156 -0
- package/dist/core/context-validation/_pa_wip_context_validation/routine-rulebook.js.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/section.d.ts +41 -0
- package/dist/core/context-validation/_pa_wip_context_validation/section.d.ts.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/section.js +82 -0
- package/dist/core/context-validation/_pa_wip_context_validation/section.js.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/snapshot-debounce.d.ts +52 -0
- package/dist/core/context-validation/_pa_wip_context_validation/snapshot-debounce.d.ts.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/snapshot-debounce.js +110 -0
- package/dist/core/context-validation/_pa_wip_context_validation/snapshot-debounce.js.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/today.d.ts +85 -0
- package/dist/core/context-validation/_pa_wip_context_validation/today.d.ts.map +1 -0
- package/dist/core/context-validation/_pa_wip_context_validation/today.js +162 -0
- package/dist/core/context-validation/_pa_wip_context_validation/today.js.map +1 -0
- package/dist/core/context-validation/index.d.ts +19 -0
- package/dist/core/context-validation/index.d.ts.map +1 -0
- package/dist/core/context-validation/index.js +19 -0
- package/dist/core/context-validation/index.js.map +1 -0
- package/dist/core/context-validation/prepare-write.d.ts +95 -0
- package/dist/core/context-validation/prepare-write.d.ts.map +1 -0
- package/dist/core/context-validation/prepare-write.js +135 -0
- package/dist/core/context-validation/prepare-write.js.map +1 -0
- package/dist/core/context-validation/routine-rulebook.d.ts +60 -0
- package/dist/core/context-validation/routine-rulebook.d.ts.map +1 -0
- package/dist/core/context-validation/routine-rulebook.js +156 -0
- package/dist/core/context-validation/routine-rulebook.js.map +1 -0
- package/dist/core/context-validation/section.d.ts +41 -0
- package/dist/core/context-validation/section.d.ts.map +1 -0
- package/dist/core/context-validation/section.js +82 -0
- package/dist/core/context-validation/section.js.map +1 -0
- package/dist/core/context-validation/snapshot-debounce.d.ts +52 -0
- package/dist/core/context-validation/snapshot-debounce.d.ts.map +1 -0
- package/dist/core/context-validation/snapshot-debounce.js +110 -0
- package/dist/core/context-validation/snapshot-debounce.js.map +1 -0
- package/dist/core/context-validation/today.d.ts +85 -0
- package/dist/core/context-validation/today.d.ts.map +1 -0
- package/dist/core/context-validation/today.js +168 -0
- package/dist/core/context-validation/today.js.map +1 -0
- package/dist/core/daemon-api-cli.d.ts +6 -5
- package/dist/core/daemon-api-cli.d.ts.map +1 -1
- package/dist/core/daemon-api-cli.js +73 -32
- package/dist/core/daemon-api-cli.js.map +1 -1
- package/dist/core/dispatcher-error-handling.d.ts +13 -0
- package/dist/core/dispatcher-error-handling.d.ts.map +1 -1
- package/dist/core/dispatcher-error-handling.js +69 -0
- package/dist/core/dispatcher-error-handling.js.map +1 -1
- package/dist/core/dispatcher-hourly-check.d.ts +73 -1
- package/dist/core/dispatcher-hourly-check.d.ts.map +1 -1
- package/dist/core/dispatcher-hourly-check.js +249 -151
- package/dist/core/dispatcher-hourly-check.js.map +1 -1
- package/dist/core/dispatcher-message-handler.d.ts +11 -1
- package/dist/core/dispatcher-message-handler.d.ts.map +1 -1
- package/dist/core/dispatcher-message-handler.js +165 -47
- package/dist/core/dispatcher-message-handler.js.map +1 -1
- package/dist/core/dispatcher-morning-routine.d.ts +38 -30
- package/dist/core/dispatcher-morning-routine.d.ts.map +1 -1
- package/dist/core/dispatcher-morning-routine.js +162 -104
- package/dist/core/dispatcher-morning-routine.js.map +1 -1
- package/dist/core/dispatcher-prompt.d.ts +4 -1
- package/dist/core/dispatcher-prompt.d.ts.map +1 -1
- package/dist/core/dispatcher-prompt.js +18 -2
- package/dist/core/dispatcher-prompt.js.map +1 -1
- package/dist/core/dispatcher-repository-helpers.d.ts.map +1 -1
- package/dist/core/dispatcher-repository-helpers.js +5 -1
- package/dist/core/dispatcher-repository-helpers.js.map +1 -1
- package/dist/core/dispatcher-result-processor.d.ts.map +1 -1
- package/dist/core/dispatcher-result-processor.js +9 -4
- package/dist/core/dispatcher-result-processor.js.map +1 -1
- package/dist/core/dispatcher-scheduled-tasks.d.ts +1 -1
- package/dist/core/dispatcher-scheduled-tasks.d.ts.map +1 -1
- package/dist/core/dispatcher-scheduled-tasks.js +79 -16
- package/dist/core/dispatcher-scheduled-tasks.js.map +1 -1
- package/dist/core/dispatcher-types.d.ts +84 -12
- package/dist/core/dispatcher-types.d.ts.map +1 -1
- package/dist/core/dispatcher-types.js.map +1 -1
- package/dist/core/dispatcher.d.ts +50 -1
- package/dist/core/dispatcher.d.ts.map +1 -1
- package/dist/core/dispatcher.js +143 -8
- package/dist/core/dispatcher.js.map +1 -1
- package/dist/core/dm-freshness-metrics.d.ts +6 -5
- package/dist/core/dm-freshness-metrics.d.ts.map +1 -1
- package/dist/core/dm-freshness-metrics.js +7 -6
- package/dist/core/dm-freshness-metrics.js.map +1 -1
- package/dist/core/evening-review-verify.d.ts +164 -0
- package/dist/core/evening-review-verify.d.ts.map +1 -0
- package/dist/core/evening-review-verify.js +637 -0
- package/dist/core/evening-review-verify.js.map +1 -0
- package/dist/core/fetch-window-prompt-loader.d.ts +47 -0
- package/dist/core/fetch-window-prompt-loader.d.ts.map +1 -0
- package/dist/core/fetch-window-prompt-loader.js +72 -0
- package/dist/core/fetch-window-prompt-loader.js.map +1 -0
- package/dist/core/management-md.d.ts.map +1 -1
- package/dist/core/management-md.js +23 -9
- package/dist/core/management-md.js.map +1 -1
- package/dist/core/management-registry.d.ts +13 -21
- package/dist/core/management-registry.d.ts.map +1 -1
- package/dist/core/management-registry.js +27 -48
- package/dist/core/management-registry.js.map +1 -1
- package/dist/core/metrics.d.ts +88 -1
- package/dist/core/metrics.d.ts.map +1 -1
- package/dist/core/metrics.js +78 -2
- package/dist/core/metrics.js.map +1 -1
- package/dist/core/morning/agent-journal-appender.d.ts +197 -0
- package/dist/core/morning/agent-journal-appender.d.ts.map +1 -0
- package/dist/core/morning/agent-journal-appender.js +458 -0
- package/dist/core/morning/agent-journal-appender.js.map +1 -0
- package/dist/core/morning/handoff-parser.d.ts +45 -0
- package/dist/core/morning/handoff-parser.d.ts.map +1 -0
- package/dist/core/morning/handoff-parser.js +117 -0
- package/dist/core/morning/handoff-parser.js.map +1 -0
- package/dist/core/morning/journal-skeleton-builder.d.ts +157 -0
- package/dist/core/morning/journal-skeleton-builder.d.ts.map +1 -0
- package/dist/core/morning/journal-skeleton-builder.js +303 -0
- package/dist/core/morning/journal-skeleton-builder.js.map +1 -0
- package/dist/core/morning/orchestrator.d.ts +312 -0
- package/dist/core/morning/orchestrator.d.ts.map +1 -0
- package/dist/core/morning/orchestrator.js +827 -0
- package/dist/core/morning/orchestrator.js.map +1 -0
- package/dist/core/morning/parent-audit-emitter.d.ts +82 -0
- package/dist/core/morning/parent-audit-emitter.d.ts.map +1 -0
- package/dist/core/morning/parent-audit-emitter.js +120 -0
- package/dist/core/morning/parent-audit-emitter.js.map +1 -0
- package/dist/core/morning/roadmap-skeleton-builder.d.ts +159 -0
- package/dist/core/morning/roadmap-skeleton-builder.d.ts.map +1 -0
- package/dist/core/morning/roadmap-skeleton-builder.js +338 -0
- package/dist/core/morning/roadmap-skeleton-builder.js.map +1 -0
- package/dist/core/output-language-policy.js +1 -1
- package/dist/core/output-language-policy.js.map +1 -1
- package/dist/core/policy-files.d.ts +19 -2
- package/dist/core/policy-files.d.ts.map +1 -1
- package/dist/core/policy-files.js +65 -7
- package/dist/core/policy-files.js.map +1 -1
- package/dist/core/pre-pass-freshness.d.ts +28 -0
- package/dist/core/pre-pass-freshness.d.ts.map +1 -0
- package/dist/core/pre-pass-freshness.js +10 -0
- package/dist/core/pre-pass-freshness.js.map +1 -0
- package/dist/core/previous-week-digest.d.ts +130 -0
- package/dist/core/previous-week-digest.d.ts.map +1 -0
- package/dist/core/previous-week-digest.js +257 -0
- package/dist/core/previous-week-digest.js.map +1 -0
- package/dist/core/prompts.js +3 -3
- package/dist/core/prompts.js.map +1 -1
- package/dist/core/quiet-hours-sync.d.ts.map +1 -1
- package/dist/core/quiet-hours-sync.js +7 -0
- package/dist/core/quiet-hours-sync.js.map +1 -1
- package/dist/core/recurrence.d.ts +13 -0
- package/dist/core/recurrence.d.ts.map +1 -1
- package/dist/core/recurrence.js +108 -13
- package/dist/core/recurrence.js.map +1 -1
- package/dist/core/release-assets.d.ts +21 -1
- package/dist/core/release-assets.d.ts.map +1 -1
- package/dist/core/release-assets.js +58 -3
- package/dist/core/release-assets.js.map +1 -1
- package/dist/core/repository-management-docs.d.ts.map +1 -1
- package/dist/core/repository-management-docs.js +14 -4
- package/dist/core/repository-management-docs.js.map +1 -1
- package/dist/core/review-context.d.ts.map +1 -1
- package/dist/core/review-context.js +29 -1
- package/dist/core/review-context.js.map +1 -1
- package/dist/core/roadmap-maintenance.d.ts +213 -0
- package/dist/core/roadmap-maintenance.d.ts.map +1 -0
- package/dist/core/roadmap-maintenance.js +706 -0
- package/dist/core/roadmap-maintenance.js.map +1 -0
- package/dist/core/roadmap-validate.d.ts +5 -0
- package/dist/core/roadmap-validate.d.ts.map +1 -1
- package/dist/core/roadmap-validate.js +6 -69
- package/dist/core/roadmap-validate.js.map +1 -1
- package/dist/core/routine-acquisition-plan.d.ts +43 -7
- package/dist/core/routine-acquisition-plan.d.ts.map +1 -1
- package/dist/core/routine-acquisition-plan.js +99 -8
- package/dist/core/routine-acquisition-plan.js.map +1 -1
- package/dist/core/routine-fetch-window-retry.d.ts +41 -2
- package/dist/core/routine-fetch-window-retry.d.ts.map +1 -1
- package/dist/core/routine-fetch-window-retry.js +91 -8
- package/dist/core/routine-fetch-window-retry.js.map +1 -1
- package/dist/core/routine-fetch-window-runner.d.ts +55 -21
- package/dist/core/routine-fetch-window-runner.d.ts.map +1 -1
- package/dist/core/routine-fetch-window-runner.js +258 -35
- package/dist/core/routine-fetch-window-runner.js.map +1 -1
- package/dist/core/routine-windows.d.ts +17 -13
- package/dist/core/routine-windows.d.ts.map +1 -1
- package/dist/core/routine-windows.js +78 -36
- package/dist/core/routine-windows.js.map +1 -1
- package/dist/core/scheduler.d.ts +121 -37
- package/dist/core/scheduler.d.ts.map +1 -1
- package/dist/core/scheduler.js +359 -80
- package/dist/core/scheduler.js.map +1 -1
- package/dist/core/session-manager.d.ts +25 -6
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +32 -15
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/skeleton.d.ts.map +1 -1
- package/dist/core/skeleton.js +23 -23
- package/dist/core/skeleton.js.map +1 -1
- package/dist/core/skills-compiler.d.ts +275 -25
- package/dist/core/skills-compiler.d.ts.map +1 -1
- package/dist/core/skills-compiler.js +844 -205
- package/dist/core/skills-compiler.js.map +1 -1
- package/dist/core/skills-manifest.d.ts +104 -0
- package/dist/core/skills-manifest.d.ts.map +1 -1
- package/dist/core/skills-manifest.js +350 -39
- package/dist/core/skills-manifest.js.map +1 -1
- package/dist/core/wiki/git-precompile.d.ts +9 -0
- package/dist/core/wiki/git-precompile.d.ts.map +1 -1
- package/dist/core/wiki/git-precompile.js +7 -1
- package/dist/core/wiki/git-precompile.js.map +1 -1
- package/dist/core/workdir.d.ts +30 -1
- package/dist/core/workdir.d.ts.map +1 -1
- package/dist/core/workdir.js +140 -15
- package/dist/core/workdir.js.map +1 -1
- package/dist/db/entities-store.d.ts +5 -5
- package/dist/db/entities-store.js +5 -5
- package/dist/db/hourly-check-signals.d.ts.map +1 -1
- package/dist/db/hourly-check-signals.js +121 -35
- package/dist/db/hourly-check-signals.js.map +1 -1
- package/dist/db/observations.d.ts +1 -1
- package/dist/db/observations.js +1 -1
- package/dist/db/observations.js.map +1 -1
- package/dist/db/recurring-schedules.d.ts +32 -1
- package/dist/db/recurring-schedules.d.ts.map +1 -1
- package/dist/db/recurring-schedules.js +29 -10
- package/dist/db/recurring-schedules.js.map +1 -1
- package/dist/db/repositories-store.d.ts +2 -1
- package/dist/db/repositories-store.d.ts.map +1 -1
- package/dist/db/repositories-store.js +38 -3
- package/dist/db/repositories-store.js.map +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +157 -51
- package/dist/db/schema.js.map +1 -1
- package/dist/db/wiki-store.d.ts.map +1 -1
- package/dist/db/wiki-store.js +3 -0
- package/dist/db/wiki-store.js.map +1 -1
- package/dist/index.js +308 -1473
- package/dist/index.js.map +1 -1
- package/dist/messaging/magic-phrase.d.ts +16 -0
- package/dist/messaging/magic-phrase.d.ts.map +1 -1
- package/dist/messaging/magic-phrase.js +53 -0
- package/dist/messaging/magic-phrase.js.map +1 -1
- package/dist/messaging/owner-channels.d.ts +24 -0
- package/dist/messaging/owner-channels.d.ts.map +1 -1
- package/dist/messaging/owner-channels.js +38 -0
- package/dist/messaging/owner-channels.js.map +1 -1
- package/dist/messaging/setup-welcome-dm.d.ts +30 -0
- package/dist/messaging/setup-welcome-dm.d.ts.map +1 -0
- package/dist/messaging/setup-welcome-dm.js +86 -0
- package/dist/messaging/setup-welcome-dm.js.map +1 -0
- package/dist/observers/calendar-poller.d.ts +2 -0
- package/dist/observers/calendar-poller.d.ts.map +1 -1
- package/dist/observers/calendar-poller.js +76 -54
- package/dist/observers/calendar-poller.js.map +1 -1
- package/dist/observers/delegated-sync-worker.d.ts +62 -0
- package/dist/observers/delegated-sync-worker.d.ts.map +1 -1
- package/dist/observers/delegated-sync-worker.js +128 -1
- package/dist/observers/delegated-sync-worker.js.map +1 -1
- package/dist/observers/git-watcher.d.ts +22 -0
- package/dist/observers/git-watcher.d.ts.map +1 -1
- package/dist/observers/git-watcher.js +31 -7
- package/dist/observers/git-watcher.js.map +1 -1
- package/dist/observers/imminent-event-scheduler.d.ts +2 -0
- package/dist/observers/imminent-event-scheduler.d.ts.map +1 -1
- package/dist/observers/imminent-event-scheduler.js +29 -0
- package/dist/observers/imminent-event-scheduler.js.map +1 -1
- package/dist/observers/notion-poller.d.ts +2 -0
- package/dist/observers/notion-poller.d.ts.map +1 -1
- package/dist/observers/notion-poller.js +44 -6
- package/dist/observers/notion-poller.js.map +1 -1
- package/dist/observers/poll-guard.d.ts +63 -0
- package/dist/observers/poll-guard.d.ts.map +1 -0
- package/dist/observers/poll-guard.js +89 -0
- package/dist/observers/poll-guard.js.map +1 -0
- package/dist/safety/absolute-block-audit.d.ts +17 -0
- package/dist/safety/absolute-block-audit.d.ts.map +1 -1
- package/dist/safety/absolute-block-audit.js +28 -2
- package/dist/safety/absolute-block-audit.js.map +1 -1
- package/dist/safety/agent-write-tracker.d.ts +42 -1
- package/dist/safety/agent-write-tracker.d.ts.map +1 -1
- package/dist/safety/agent-write-tracker.js +81 -1
- package/dist/safety/agent-write-tracker.js.map +1 -1
- package/dist/safety/always-disallowed.d.ts +34 -0
- package/dist/safety/always-disallowed.d.ts.map +1 -1
- package/dist/safety/always-disallowed.js +114 -7
- package/dist/safety/always-disallowed.js.map +1 -1
- package/dist/safety/audit.d.ts +20 -0
- package/dist/safety/audit.d.ts.map +1 -1
- package/dist/safety/audit.js +126 -0
- package/dist/safety/audit.js.map +1 -1
- package/dist/safety/risk-classifier.d.ts +17 -1
- package/dist/safety/risk-classifier.d.ts.map +1 -1
- package/dist/safety/risk-classifier.js +75 -7
- package/dist/safety/risk-classifier.js.map +1 -1
- package/dist/safety/subprocess-block-scanner.d.ts +89 -0
- package/dist/safety/subprocess-block-scanner.d.ts.map +1 -0
- package/dist/safety/subprocess-block-scanner.js +177 -0
- package/dist/safety/subprocess-block-scanner.js.map +1 -0
- package/dist/scheduler/hourly-check-gate.d.ts +23 -9
- package/dist/scheduler/hourly-check-gate.d.ts.map +1 -1
- package/dist/scheduler/hourly-check-gate.js +11 -6
- package/dist/scheduler/hourly-check-gate.js.map +1 -1
- package/dist/secrets/backend-api-key-env.d.ts.map +1 -1
- package/dist/secrets/backend-api-key-env.js +1 -0
- package/dist/secrets/backend-api-key-env.js.map +1 -1
- package/dist/services/delegated-backend-invoker.d.ts.map +1 -1
- package/dist/services/delegated-backend-invoker.js +8 -1
- package/dist/services/delegated-backend-invoker.js.map +1 -1
- package/dist/services/delegated-invoker-audit.d.ts.map +1 -1
- package/dist/services/delegated-invoker-audit.js +5 -1
- package/dist/services/delegated-invoker-audit.js.map +1 -1
- package/dist/services/delegated-proxy-config.d.ts +3 -2
- package/dist/services/delegated-proxy-config.d.ts.map +1 -1
- package/dist/services/delegated-proxy-config.js.map +1 -1
- package/dist/services/integrations/extract-write-item-id.d.ts +5 -2
- package/dist/services/integrations/extract-write-item-id.d.ts.map +1 -1
- package/dist/services/integrations/extract-write-item-id.js.map +1 -1
- package/dist/services/mcp/generators/index.d.ts +1 -0
- package/dist/services/mcp/generators/index.d.ts.map +1 -1
- package/dist/services/mcp/generators/index.js +3 -0
- package/dist/services/mcp/generators/index.js.map +1 -1
- package/dist/services/mcp/sdk-observations-server.d.ts +60 -0
- package/dist/services/mcp/sdk-observations-server.d.ts.map +1 -0
- package/dist/services/mcp/sdk-observations-server.js +161 -0
- package/dist/services/mcp/sdk-observations-server.js.map +1 -0
- package/dist/services/mcp/session-materializer.d.ts.map +1 -1
- package/dist/services/mcp/session-materializer.js +13 -9
- package/dist/services/mcp/session-materializer.js.map +1 -1
- package/dist/services/mcp/types.d.ts +1 -0
- package/dist/services/mcp/types.d.ts.map +1 -1
- package/dist/services/notion.d.ts +19 -1
- package/dist/services/notion.d.ts.map +1 -1
- package/dist/services/notion.js +41 -2
- package/dist/services/notion.js.map +1 -1
- package/dist/services/observations-batch.d.ts +100 -0
- package/dist/services/observations-batch.d.ts.map +1 -0
- package/dist/services/observations-batch.js +258 -0
- package/dist/services/observations-batch.js.map +1 -0
- package/dist/services/voice/transcriber.d.ts +23 -0
- package/dist/services/voice/transcriber.d.ts.map +1 -1
- package/dist/services/voice/transcriber.js +55 -0
- package/dist/services/voice/transcriber.js.map +1 -1
- package/dist/settings/runtime-settings.d.ts +9 -6
- package/dist/settings/runtime-settings.d.ts.map +1 -1
- package/dist/settings/runtime-settings.js +50 -17
- package/dist/settings/runtime-settings.js.map +1 -1
- package/package.json +3 -2
- package/dist/api/delegated-proxy-helper.d.ts +0 -33
- package/dist/api/delegated-proxy-helper.d.ts.map +0 -1
- package/dist/api/delegated-proxy-helper.js +0 -54
- package/dist/api/delegated-proxy-helper.js.map +0 -1
- package/dist/core/roadmap-merge.d.ts +0 -7
- package/dist/core/roadmap-merge.d.ts.map +0 -1
- package/dist/core/roadmap-merge.js +0 -187
- package/dist/core/roadmap-merge.js.map +0 -1
- package/dist/db/test-schemas.d.ts +0 -23
- package/dist/db/test-schemas.d.ts.map +0 -1
- package/dist/db/test-schemas.js +0 -111
- package/dist/db/test-schemas.js.map +0 -1
|
@@ -2,23 +2,23 @@ import { Hono } from "hono";
|
|
|
2
2
|
import { readFileSync, existsSync, statSync, readdirSync, unlinkSync, realpathSync, lstatSync, readlinkSync, } from "node:fs";
|
|
3
3
|
import { basename, join, dirname, resolve, relative, isAbsolute } from "node:path";
|
|
4
4
|
import { writeFileAtomically } from "../../core/atomic-write.js";
|
|
5
|
-
import { contextPutSchema, contextPatchSchema, getAgentDayDateStr, localDateStr,
|
|
5
|
+
import { contextPutSchema, contextPatchSchema, getAgentDayDateStr, localDateStr, } from "@aitne/shared";
|
|
6
6
|
import { getContextDir } from "../../config.js";
|
|
7
7
|
import { getDegradedMode } from "../../db/runtime-state.js";
|
|
8
8
|
import { InMemoryTodayWriteLockManager, getTodayWriteLockTimeoutMs, } from "../../core/today-write-lock.js";
|
|
9
9
|
import { InMemoryRoadmapWriteLockManager, getRoadmapWriteLockTimeoutMs, } from "../../core/roadmap-write-lock.js";
|
|
10
10
|
import { CONTEXT_BASE_FILE_STEMS, CONTEXT_FILE_EXTENSIONS, } from "../../core/context-paths.js";
|
|
11
11
|
import { REPAIRABLE_STUB_TARGETS, buildContextHealthReport, normalizeRepairStubPath, } from "../../core/context-health.js";
|
|
12
|
-
import {
|
|
12
|
+
import { validateDailySkeletonFrontmatter } from "../../core/context-frontmatter.js";
|
|
13
13
|
import { classifyContextWriteStaleness } from "../../core/context-staleness.js";
|
|
14
14
|
import { resolveTemplatesRoot } from "../../core/skeleton.js";
|
|
15
|
-
import { parseCustomRoutineSpec, } from "../../core/custom-routine-scheduler.js";
|
|
16
|
-
import { normalizeRoadmapForWrite, validateRoadmap, validateRoadmapTransition, } from "../../core/roadmap-validate.js";
|
|
17
15
|
import { isValidYmd, } from "../../core/roadmap-horizon.js";
|
|
18
16
|
import { extractRoadmapIds, generateRoadmapId, RoadmapIdGenerationError, } from "../../core/roadmap-ids.js";
|
|
19
17
|
import { buildTodayAgentPlanMetadata, extractTodayAgentPlanRows, extractTodayDate, readTodayAgentPlanMetadata, } from "../../core/today-agent-plan.js";
|
|
18
|
+
import { SNAPSHOT_DEBOUNCE_MS, clearEntriesBefore, findSection, getAvailableSections, isLegacyTodayContent, prepareContextContentForWrite, toTodayScheduleCandidate, trimBulletEntries, validateContextContent, validateTodayContent, } from "../../core/context-validation/index.js";
|
|
20
19
|
import { createLogger } from "../../logging.js";
|
|
21
20
|
import { readJsonBody } from "../json-body.js";
|
|
21
|
+
import { composeIssue, respondWithAgentError, } from "../helpers/agent-errors.js";
|
|
22
22
|
const logger = createLogger("context-api");
|
|
23
23
|
const CONTEXT_BASE_FILE_STEM_SET = new Set(CONTEXT_BASE_FILE_STEMS);
|
|
24
24
|
function resolveContextTarget(userPath) {
|
|
@@ -311,140 +311,6 @@ function notifyPromptContextChanged(deps, path, reason, input) {
|
|
|
311
311
|
logger.warn({ err, path, method: input.method }, "Failed to record context_write agent_actions row (Stage C metrics)");
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
/**
|
|
315
|
-
* Normalize a section name for matching:
|
|
316
|
-
* lowercase, spaces → underscores, strip leading ##
|
|
317
|
-
*/
|
|
318
|
-
function normalizeSection(name) {
|
|
319
|
-
return name
|
|
320
|
-
.replace(/^#+\s*/, "")
|
|
321
|
-
.toLowerCase()
|
|
322
|
-
.replace(/\s+/g, "_");
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Find a section in markdown content and return its boundaries.
|
|
326
|
-
* Returns [startOfBody, endOfBody] where body is between this ## and next ##.
|
|
327
|
-
*/
|
|
328
|
-
function findSection(content, sectionName) {
|
|
329
|
-
const normalized = normalizeSection(sectionName);
|
|
330
|
-
const lines = content.split("\n");
|
|
331
|
-
let sectionStart = -1;
|
|
332
|
-
let headerEnd = -1;
|
|
333
|
-
for (let i = 0; i < lines.length; i++) {
|
|
334
|
-
if (lines[i].startsWith("## ")) {
|
|
335
|
-
const lineNormalized = normalizeSection(lines[i]);
|
|
336
|
-
if (lineNormalized === normalized) {
|
|
337
|
-
sectionStart = i;
|
|
338
|
-
const lineStart = sumLength(lines, i);
|
|
339
|
-
const nlPos = content.indexOf("\n", lineStart);
|
|
340
|
-
// Handle file ending without trailing newline
|
|
341
|
-
headerEnd = nlPos === -1 ? content.length : nlPos + 1;
|
|
342
|
-
break;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
if (sectionStart === -1)
|
|
347
|
-
return null;
|
|
348
|
-
// Find end: next ## header or EOF
|
|
349
|
-
let sectionEnd = content.length;
|
|
350
|
-
for (let i = sectionStart + 1; i < lines.length; i++) {
|
|
351
|
-
if (lines[i].startsWith("## ")) {
|
|
352
|
-
sectionEnd = sumLength(lines, i);
|
|
353
|
-
break;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return { start: headerEnd, end: sectionEnd, headerEnd };
|
|
357
|
-
}
|
|
358
|
-
function sumLength(lines, upToIndex) {
|
|
359
|
-
let len = 0;
|
|
360
|
-
for (let i = 0; i < upToIndex; i++) {
|
|
361
|
-
len += lines[i].length + 1; // +1 for \n
|
|
362
|
-
}
|
|
363
|
-
return len;
|
|
364
|
-
}
|
|
365
|
-
function getAvailableSections(content) {
|
|
366
|
-
return content
|
|
367
|
-
.split("\n")
|
|
368
|
-
.filter((l) => l.startsWith("## "))
|
|
369
|
-
.map((l) => normalizeSection(l));
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Parse a timestamp from a bullet entry like `- [2026-04-10 02:32:59] ...`
|
|
373
|
-
* Returns the timestamp string or null if the line doesn't match.
|
|
374
|
-
*/
|
|
375
|
-
const ENTRY_TIMESTAMP_RE = /^- \[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\]/;
|
|
376
|
-
function parseEntryTimestamp(line) {
|
|
377
|
-
const match = ENTRY_TIMESTAMP_RE.exec(line);
|
|
378
|
-
return match ? match[1] : null;
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Remove entries whose `- [YYYY-MM-DD HH:MM:SS]` timestamp is ≤ cutoff.
|
|
382
|
-
* Non-matching lines (blank lines, continuation lines) are preserved.
|
|
383
|
-
* Returns the remaining section body and the count of removed entries.
|
|
384
|
-
*/
|
|
385
|
-
function clearEntriesBefore(sectionBody, cutoff) {
|
|
386
|
-
const lines = sectionBody.split("\n");
|
|
387
|
-
const kept = [];
|
|
388
|
-
let removedCount = 0;
|
|
389
|
-
let skipContinuation = false;
|
|
390
|
-
for (const line of lines) {
|
|
391
|
-
const ts = parseEntryTimestamp(line);
|
|
392
|
-
if (ts !== null) {
|
|
393
|
-
// This is a timestamped entry
|
|
394
|
-
if (ts <= cutoff) {
|
|
395
|
-
removedCount++;
|
|
396
|
-
skipContinuation = true;
|
|
397
|
-
continue;
|
|
398
|
-
}
|
|
399
|
-
skipContinuation = false;
|
|
400
|
-
kept.push(line);
|
|
401
|
-
}
|
|
402
|
-
else if (skipContinuation && (line.startsWith(" ") || line.trim() === "")) {
|
|
403
|
-
// Continuation or trailing blank line of a removed entry
|
|
404
|
-
continue;
|
|
405
|
-
}
|
|
406
|
-
else {
|
|
407
|
-
skipContinuation = false;
|
|
408
|
-
kept.push(line);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
return { remaining: kept.join("\n"), removedCount };
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Trim oldest bullet entries (`- ...` lines) from the top of a section
|
|
415
|
-
* body to keep at most `maxEntries` entries. Non-bullet lines (blank
|
|
416
|
-
* lines, non-`- ` prefixed lines) are preserved.
|
|
417
|
-
*/
|
|
418
|
-
function trimBulletEntries(body, maxEntries) {
|
|
419
|
-
const lines = body.split("\n");
|
|
420
|
-
// Collect indices of bullet entry start lines
|
|
421
|
-
const bulletIndices = [];
|
|
422
|
-
for (let i = 0; i < lines.length; i++) {
|
|
423
|
-
if (lines[i].startsWith("- ")) {
|
|
424
|
-
bulletIndices.push(i);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
const excess = bulletIndices.length - maxEntries;
|
|
428
|
-
if (excess <= 0) {
|
|
429
|
-
return { body, trimmed: 0 };
|
|
430
|
-
}
|
|
431
|
-
// Remove the oldest (topmost) `excess` entries and their continuations.
|
|
432
|
-
// Also remove blank lines between consecutive removed entries to avoid
|
|
433
|
-
// orphaned whitespace accumulating over many trim cycles.
|
|
434
|
-
const removeSet = new Set();
|
|
435
|
-
for (let i = 0; i < excess; i++) {
|
|
436
|
-
const start = bulletIndices[i];
|
|
437
|
-
const end = i + 1 < bulletIndices.length ? bulletIndices[i + 1] : lines.length;
|
|
438
|
-
for (let j = start; j < end; j++) {
|
|
439
|
-
if (j === start || lines[j].startsWith(" ") || lines[j].trim() === "") {
|
|
440
|
-
removeSet.add(j);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
const kept = lines.filter((_, i) => !removeSet.has(i));
|
|
445
|
-
return { body: kept.join("\n"), trimmed: excess };
|
|
446
|
-
}
|
|
447
|
-
const SNAPSHOT_DEBOUNCE_MS = 5 * 60 * 1000; // 5 minutes
|
|
448
314
|
/**
|
|
449
315
|
* Cap on the JSON body accepted by the Context PUT/PATCH endpoints.
|
|
450
316
|
*
|
|
@@ -494,12 +360,18 @@ export function createContextRoutes(deps) {
|
|
|
494
360
|
app.use("/context/*", async (c, next) => {
|
|
495
361
|
const state = getDegradedMode(db);
|
|
496
362
|
if (state) {
|
|
497
|
-
return c
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
363
|
+
return respondWithAgentError(c, 503, [
|
|
364
|
+
composeIssue("context.vault_unreachable", {
|
|
365
|
+
field: "primaryVault",
|
|
366
|
+
received: { reason: state.reason, path: state.path, since: state.since },
|
|
367
|
+
}),
|
|
368
|
+
], {
|
|
369
|
+
legacyFields: {
|
|
370
|
+
reason: state.reason,
|
|
371
|
+
path: state.path,
|
|
372
|
+
since: state.since,
|
|
373
|
+
},
|
|
374
|
+
});
|
|
503
375
|
}
|
|
504
376
|
// Phase 2 — global context-write gate engaged during a
|
|
505
377
|
// /api/setup/migrate-context run. Refuses WRITES (not reads)
|
|
@@ -508,11 +380,17 @@ export function createContextRoutes(deps) {
|
|
|
508
380
|
const writeMethods = new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
509
381
|
if (deps.contextWriteGate?.isEngaged() && writeMethods.has(c.req.method)) {
|
|
510
382
|
const gateState = deps.contextWriteGate.getState();
|
|
511
|
-
return c
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
383
|
+
return respondWithAgentError(c, 503, [
|
|
384
|
+
composeIssue("context.migration_in_progress", {
|
|
385
|
+
field: "method",
|
|
386
|
+
received: { method: c.req.method, reason: gateState.reason, since: gateState.since },
|
|
387
|
+
}),
|
|
388
|
+
], {
|
|
389
|
+
legacyFields: {
|
|
390
|
+
reason: gateState.reason,
|
|
391
|
+
since: gateState.since,
|
|
392
|
+
},
|
|
393
|
+
});
|
|
516
394
|
}
|
|
517
395
|
await next();
|
|
518
396
|
});
|
|
@@ -581,10 +459,12 @@ export function createContextRoutes(deps) {
|
|
|
581
459
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
582
460
|
return {
|
|
583
461
|
ok: false,
|
|
584
|
-
response: c
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
462
|
+
response: respondWithAgentError(c, 400, [
|
|
463
|
+
composeIssue("context.body_not_object", {
|
|
464
|
+
field: "body",
|
|
465
|
+
received: parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed,
|
|
466
|
+
}),
|
|
467
|
+
]),
|
|
588
468
|
};
|
|
589
469
|
}
|
|
590
470
|
return { ok: true, body: parsed };
|
|
@@ -594,7 +474,12 @@ export function createContextRoutes(deps) {
|
|
|
594
474
|
logger.warn({ path: c.req.path, method: c.req.method, detail }, "Request rejected — body is not valid JSON");
|
|
595
475
|
return {
|
|
596
476
|
ok: false,
|
|
597
|
-
response: c
|
|
477
|
+
response: respondWithAgentError(c, 400, [
|
|
478
|
+
composeIssue("context.invalid_json_body", {
|
|
479
|
+
field: "body",
|
|
480
|
+
received: detail,
|
|
481
|
+
}),
|
|
482
|
+
]),
|
|
598
483
|
};
|
|
599
484
|
}
|
|
600
485
|
}
|
|
@@ -603,7 +488,12 @@ export function createContextRoutes(deps) {
|
|
|
603
488
|
app.post("/context/lock/morning-routine", (c) => {
|
|
604
489
|
const result = morningRoutineLock.acquire();
|
|
605
490
|
if (!result.ok) {
|
|
606
|
-
return c
|
|
491
|
+
return respondWithAgentError(c, 409, [
|
|
492
|
+
composeIssue("context.lock_held", {
|
|
493
|
+
field: "morningRoutineLock",
|
|
494
|
+
received: { holder: result.holder },
|
|
495
|
+
}),
|
|
496
|
+
]);
|
|
607
497
|
}
|
|
608
498
|
return c.json({ status: "acquired", lockId: result.lockId });
|
|
609
499
|
});
|
|
@@ -614,7 +504,12 @@ export function createContextRoutes(deps) {
|
|
|
614
504
|
if (lockId && morningRoutineLock.release(lockId)) {
|
|
615
505
|
return c.json({ status: "released" });
|
|
616
506
|
}
|
|
617
|
-
return c
|
|
507
|
+
return respondWithAgentError(c, 400, [
|
|
508
|
+
composeIssue("context.lock_not_held", {
|
|
509
|
+
field: "lockId",
|
|
510
|
+
received: lockId ?? "<missing>",
|
|
511
|
+
}),
|
|
512
|
+
]);
|
|
618
513
|
});
|
|
619
514
|
// POST /context/lock/roadmap — Acquire exclusive roadmap write lock
|
|
620
515
|
// Dispatcher auto-acquires this for `routine.roadmap_refresh`; other
|
|
@@ -623,7 +518,12 @@ export function createContextRoutes(deps) {
|
|
|
623
518
|
app.post("/context/lock/roadmap", (c) => {
|
|
624
519
|
const result = roadmapWriteLock.acquire();
|
|
625
520
|
if (!result.ok) {
|
|
626
|
-
return c
|
|
521
|
+
return respondWithAgentError(c, 409, [
|
|
522
|
+
composeIssue("context.roadmap_write_lock_held", {
|
|
523
|
+
field: "roadmapWriteLock",
|
|
524
|
+
received: { holder: result.holder },
|
|
525
|
+
}),
|
|
526
|
+
]);
|
|
627
527
|
}
|
|
628
528
|
return c.json({ status: "acquired", lockId: result.lockId });
|
|
629
529
|
});
|
|
@@ -634,7 +534,12 @@ export function createContextRoutes(deps) {
|
|
|
634
534
|
if (lockId && roadmapWriteLock.release(lockId)) {
|
|
635
535
|
return c.json({ status: "released" });
|
|
636
536
|
}
|
|
637
|
-
return c
|
|
537
|
+
return respondWithAgentError(c, 400, [
|
|
538
|
+
composeIssue("context.lock_not_held", {
|
|
539
|
+
field: "lockId",
|
|
540
|
+
received: lockId ?? "<missing>",
|
|
541
|
+
}),
|
|
542
|
+
]);
|
|
638
543
|
});
|
|
639
544
|
// POST /context/roadmap/id — Mint a stable daemon-owned roadmap entry id.
|
|
640
545
|
app.post("/context/roadmap/id", async (c) => {
|
|
@@ -642,7 +547,12 @@ export function createContextRoutes(deps) {
|
|
|
642
547
|
const lockId = c.req.header("X-Lock-Id");
|
|
643
548
|
if (!roadmapWriteLock.isHeldBy(lockId)) {
|
|
644
549
|
logger.info({ path: "roadmap" }, "Roadmap id mint rejected — roadmap write lock held");
|
|
645
|
-
return c
|
|
550
|
+
return respondWithAgentError(c, 409, [
|
|
551
|
+
composeIssue("context.roadmap_write_lock_held", {
|
|
552
|
+
field: "X-Lock-Id",
|
|
553
|
+
received: lockId ?? "<missing>",
|
|
554
|
+
}),
|
|
555
|
+
]);
|
|
646
556
|
}
|
|
647
557
|
}
|
|
648
558
|
const parsedBody = await readOptionalJsonBody(c);
|
|
@@ -653,16 +563,23 @@ export function createContextRoutes(deps) {
|
|
|
653
563
|
? requestedDate
|
|
654
564
|
: localDateStr(new Date(), config.timezone || undefined);
|
|
655
565
|
if (!isValidYmd(creationDate)) {
|
|
656
|
-
return c
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
566
|
+
return respondWithAgentError(c, 400, [
|
|
567
|
+
composeIssue("context.creation_date_invalid", {
|
|
568
|
+
field: "creationDate",
|
|
569
|
+
received: creationDate,
|
|
570
|
+
}),
|
|
571
|
+
]);
|
|
660
572
|
}
|
|
661
573
|
return withWriteLock(() => {
|
|
662
574
|
const contextDir = getCurrentContextDir();
|
|
663
575
|
const fullPath = safePath(contextDir, "roadmap");
|
|
664
576
|
if (!fullPath) {
|
|
665
|
-
return c
|
|
577
|
+
return respondWithAgentError(c, 400, [
|
|
578
|
+
composeIssue("context.path_invalid", {
|
|
579
|
+
field: "path",
|
|
580
|
+
received: "roadmap",
|
|
581
|
+
}),
|
|
582
|
+
]);
|
|
666
583
|
}
|
|
667
584
|
const content = existsSync(fullPath)
|
|
668
585
|
? readFileSync(fullPath, "utf-8")
|
|
@@ -679,7 +596,12 @@ export function createContextRoutes(deps) {
|
|
|
679
596
|
}
|
|
680
597
|
catch (err) {
|
|
681
598
|
if (err instanceof RoadmapIdGenerationError) {
|
|
682
|
-
return c
|
|
599
|
+
return respondWithAgentError(c, 503, [
|
|
600
|
+
composeIssue("context.roadmap_id_generation_failed", {
|
|
601
|
+
field: "id",
|
|
602
|
+
received: { existingIdCount: existingIds.length, creationDate },
|
|
603
|
+
}),
|
|
604
|
+
]);
|
|
683
605
|
}
|
|
684
606
|
throw err;
|
|
685
607
|
}
|
|
@@ -697,7 +619,12 @@ export function createContextRoutes(deps) {
|
|
|
697
619
|
const contextDir = getCurrentContextDir();
|
|
698
620
|
const todayPath = join(contextDir, "today.md");
|
|
699
621
|
if (!existsSync(todayPath)) {
|
|
700
|
-
return c
|
|
622
|
+
return respondWithAgentError(c, 404, [
|
|
623
|
+
composeIssue("context.path_not_found", {
|
|
624
|
+
field: "path",
|
|
625
|
+
received: "today",
|
|
626
|
+
}),
|
|
627
|
+
]);
|
|
701
628
|
}
|
|
702
629
|
const content = readFileSync(todayPath, "utf-8");
|
|
703
630
|
const dateStr = content.match(/^#.*(\d{4}-\d{2}-\d{2})/)?.[1] ??
|
|
@@ -720,46 +647,87 @@ export function createContextRoutes(deps) {
|
|
|
720
647
|
// row back onto disk. The current on-disk file (if any) is snapshotted
|
|
721
648
|
// first so the restore itself is reversible from the Knowledge page.
|
|
722
649
|
app.post("/context/restore-snapshot/:id", (c) => {
|
|
723
|
-
const
|
|
650
|
+
const idRaw = c.req.param("id");
|
|
651
|
+
const id = Number(idRaw);
|
|
724
652
|
if (!Number.isSafeInteger(id) || id <= 0) {
|
|
725
|
-
return c
|
|
653
|
+
return respondWithAgentError(c, 400, [
|
|
654
|
+
composeIssue("context.snapshot_id_invalid", {
|
|
655
|
+
field: "id",
|
|
656
|
+
received: idRaw,
|
|
657
|
+
}),
|
|
658
|
+
]);
|
|
726
659
|
}
|
|
727
660
|
const row = db
|
|
728
661
|
.prepare("SELECT id, file_path, content FROM md_file_snapshots WHERE id = ?")
|
|
729
662
|
.get(id);
|
|
730
663
|
if (!row) {
|
|
731
|
-
return c
|
|
664
|
+
return respondWithAgentError(c, 404, [
|
|
665
|
+
composeIssue("context.snapshot_not_found", {
|
|
666
|
+
field: "id",
|
|
667
|
+
received: id,
|
|
668
|
+
}),
|
|
669
|
+
]);
|
|
732
670
|
}
|
|
733
671
|
const target = resolveContextTarget(row.file_path);
|
|
734
672
|
const path = target.base;
|
|
735
673
|
const contextDir = getCurrentContextDir();
|
|
736
674
|
const fullPath = safePath(contextDir, row.file_path);
|
|
737
675
|
if (!fullPath) {
|
|
738
|
-
return c
|
|
676
|
+
return respondWithAgentError(c, 400, [
|
|
677
|
+
composeIssue("context.path_invalid", {
|
|
678
|
+
field: "path",
|
|
679
|
+
received: path,
|
|
680
|
+
}),
|
|
681
|
+
]);
|
|
739
682
|
}
|
|
740
683
|
if (!isWriteAllowed(path, "PUT") && !isWriteAllowed(path, "PATCH")) {
|
|
741
684
|
logger.warn({ path, method: "RESTORE" }, "Snapshot restore forbidden");
|
|
742
|
-
return c
|
|
685
|
+
return respondWithAgentError(c, 403, [
|
|
686
|
+
composeIssue("context.write_forbidden", {
|
|
687
|
+
field: "path",
|
|
688
|
+
received: { path, method: "RESTORE" },
|
|
689
|
+
}),
|
|
690
|
+
]);
|
|
743
691
|
}
|
|
744
692
|
if (morningRoutineLock.getHolder() && path === "today") {
|
|
745
693
|
const lockId = c.req.header("X-Lock-Id");
|
|
746
694
|
if (!morningRoutineLock.isHeldBy(lockId)) {
|
|
747
695
|
logger.info({ path }, "Snapshot restore rejected — morning routine lock held");
|
|
748
|
-
return c
|
|
696
|
+
return respondWithAgentError(c, 409, [
|
|
697
|
+
composeIssue("context.morning_routine_lock_held", {
|
|
698
|
+
field: "X-Lock-Id",
|
|
699
|
+
received: lockId ?? "<missing>",
|
|
700
|
+
}),
|
|
701
|
+
]);
|
|
749
702
|
}
|
|
750
703
|
}
|
|
751
704
|
if (roadmapWriteLock.getHolder() && path === "roadmap") {
|
|
752
705
|
const lockId = c.req.header("X-Lock-Id");
|
|
753
706
|
if (!roadmapWriteLock.isHeldBy(lockId)) {
|
|
754
707
|
logger.info({ path }, "Snapshot restore rejected — roadmap write lock held");
|
|
755
|
-
return c
|
|
708
|
+
return respondWithAgentError(c, 409, [
|
|
709
|
+
composeIssue("context.roadmap_write_lock_held", {
|
|
710
|
+
field: "X-Lock-Id",
|
|
711
|
+
received: lockId ?? "<missing>",
|
|
712
|
+
}),
|
|
713
|
+
]);
|
|
756
714
|
}
|
|
757
715
|
}
|
|
758
716
|
const contentError = validateContextContent(target, row.content, {
|
|
759
717
|
skipFrontmatterValidation: true,
|
|
760
718
|
});
|
|
761
719
|
if (contentError) {
|
|
762
|
-
return c
|
|
720
|
+
return respondWithAgentError(c, contentError.status, [
|
|
721
|
+
composeIssue("context.content_validation_failed", {
|
|
722
|
+
field: contentError.path ?? "content",
|
|
723
|
+
received: contentError.message,
|
|
724
|
+
}),
|
|
725
|
+
], {
|
|
726
|
+
legacyFields: {
|
|
727
|
+
message: contentError.message,
|
|
728
|
+
path: contentError.path,
|
|
729
|
+
},
|
|
730
|
+
});
|
|
763
731
|
}
|
|
764
732
|
return withWriteLock(() => {
|
|
765
733
|
let backupSnapshotId = null;
|
|
@@ -811,7 +779,12 @@ export function createContextRoutes(deps) {
|
|
|
811
779
|
"inbox",
|
|
812
780
|
];
|
|
813
781
|
if (!allowedDirs.includes(dir)) {
|
|
814
|
-
return c
|
|
782
|
+
return respondWithAgentError(c, 400, [
|
|
783
|
+
composeIssue("context.directory_invalid", {
|
|
784
|
+
field: "dir",
|
|
785
|
+
received: { dir, allowed: allowedDirs },
|
|
786
|
+
}),
|
|
787
|
+
]);
|
|
815
788
|
}
|
|
816
789
|
const contextDir = getCurrentContextDir();
|
|
817
790
|
const dirPath = join(contextDir, dir);
|
|
@@ -908,10 +881,20 @@ export function createContextRoutes(deps) {
|
|
|
908
881
|
const contextDir = getCurrentContextDir();
|
|
909
882
|
const fullPath = safePath(contextDir, "today");
|
|
910
883
|
if (!fullPath) {
|
|
911
|
-
return c
|
|
884
|
+
return respondWithAgentError(c, 400, [
|
|
885
|
+
composeIssue("context.path_invalid", {
|
|
886
|
+
field: "path",
|
|
887
|
+
received: "today",
|
|
888
|
+
}),
|
|
889
|
+
]);
|
|
912
890
|
}
|
|
913
891
|
if (!existsSync(fullPath)) {
|
|
914
|
-
return c
|
|
892
|
+
return respondWithAgentError(c, 404, [
|
|
893
|
+
composeIssue("context.path_not_found", {
|
|
894
|
+
field: "path",
|
|
895
|
+
received: "today",
|
|
896
|
+
}),
|
|
897
|
+
]);
|
|
915
898
|
}
|
|
916
899
|
const content = readFileSync(fullPath, "utf-8");
|
|
917
900
|
const validationError = validateTodayContent(content);
|
|
@@ -1006,41 +989,57 @@ export function createContextRoutes(deps) {
|
|
|
1006
989
|
return parsedBody.response;
|
|
1007
990
|
const rawPath = parsedBody.body.path;
|
|
1008
991
|
if (typeof rawPath !== "string") {
|
|
1009
|
-
return c
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
992
|
+
return respondWithAgentError(c, 400, [
|
|
993
|
+
composeIssue("context.path_required", {
|
|
994
|
+
field: "path",
|
|
995
|
+
received: typeof rawPath,
|
|
996
|
+
}),
|
|
997
|
+
], {
|
|
998
|
+
// repair-stub previously returned `error: "validation_error"` for
|
|
999
|
+
// the missing-path branch (not `"path_required"`); preserve that
|
|
1000
|
+
// legacy alias so dashboard / older tests don't break.
|
|
1001
|
+
legacyErrorCode: "validation_error",
|
|
1002
|
+
});
|
|
1013
1003
|
}
|
|
1014
1004
|
const normalizedPath = normalizeRepairStubPath(rawPath);
|
|
1015
1005
|
if (!normalizedPath || !REPAIRABLE_STUB_TARGETS.has(normalizedPath)) {
|
|
1016
|
-
return c
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1006
|
+
return respondWithAgentError(c, 400, [
|
|
1007
|
+
composeIssue("context.stub_target_unsupported", {
|
|
1008
|
+
field: "path",
|
|
1009
|
+
received: { path: rawPath, allowed: Array.from(REPAIRABLE_STUB_TARGETS) },
|
|
1010
|
+
}),
|
|
1011
|
+
]);
|
|
1021
1012
|
}
|
|
1022
1013
|
const templatesRoot = resolveTemplatesRoot(config.workspaceDir);
|
|
1023
1014
|
/* c8 ignore next 9 — resolveTemplatesRoot always succeeds via import.meta.url
|
|
1024
1015
|
* fallback in tests; the 503 branch requires a broken install where the
|
|
1025
1016
|
* agent-assets directory is absent from every candidate path. */
|
|
1026
1017
|
if (!templatesRoot) {
|
|
1027
|
-
return c
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1018
|
+
return respondWithAgentError(c, 503, [
|
|
1019
|
+
composeIssue("context.template_unavailable", {
|
|
1020
|
+
field: "templatesRoot",
|
|
1021
|
+
received: "<unresolved>",
|
|
1022
|
+
}),
|
|
1023
|
+
]);
|
|
1031
1024
|
}
|
|
1032
1025
|
const templatePath = join(templatesRoot, normalizedPath);
|
|
1033
1026
|
if (!existsSync(templatePath)) {
|
|
1034
|
-
return c
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1027
|
+
return respondWithAgentError(c, 404, [
|
|
1028
|
+
composeIssue("context.template_not_found", {
|
|
1029
|
+
field: "path",
|
|
1030
|
+
received: { path: normalizedPath, templatePath },
|
|
1031
|
+
}),
|
|
1032
|
+
]);
|
|
1039
1033
|
}
|
|
1040
1034
|
const contextDir = getCurrentContextDir();
|
|
1041
1035
|
const fullPath = safePath(contextDir, normalizedPath);
|
|
1042
1036
|
if (!fullPath) {
|
|
1043
|
-
return c
|
|
1037
|
+
return respondWithAgentError(c, 400, [
|
|
1038
|
+
composeIssue("context.path_invalid", {
|
|
1039
|
+
field: "path",
|
|
1040
|
+
received: normalizedPath,
|
|
1041
|
+
}),
|
|
1042
|
+
]);
|
|
1044
1043
|
}
|
|
1045
1044
|
return withWriteLock(() => {
|
|
1046
1045
|
if (existsSync(fullPath)) {
|
|
@@ -1077,16 +1076,31 @@ export function createContextRoutes(deps) {
|
|
|
1077
1076
|
app.get("/context/*", (c) => {
|
|
1078
1077
|
const rawPath = c.req.path.replace("/api/context/", "");
|
|
1079
1078
|
if (!rawPath || rawPath === "list") {
|
|
1080
|
-
return c
|
|
1079
|
+
return respondWithAgentError(c, 400, [
|
|
1080
|
+
composeIssue("context.path_required", {
|
|
1081
|
+
field: "path",
|
|
1082
|
+
received: rawPath === "list" ? "list (route ambiguous with /list/:dir)" : "<empty>",
|
|
1083
|
+
}),
|
|
1084
|
+
]);
|
|
1081
1085
|
}
|
|
1082
1086
|
const path = normalizeContextPath(rawPath);
|
|
1083
1087
|
const contextDir = getCurrentContextDir();
|
|
1084
1088
|
const fullPath = safePath(contextDir, rawPath);
|
|
1085
1089
|
if (!fullPath) {
|
|
1086
|
-
return c
|
|
1090
|
+
return respondWithAgentError(c, 400, [
|
|
1091
|
+
composeIssue("context.path_invalid", {
|
|
1092
|
+
field: "path",
|
|
1093
|
+
received: path,
|
|
1094
|
+
}),
|
|
1095
|
+
]);
|
|
1087
1096
|
}
|
|
1088
1097
|
if (!existsSync(fullPath)) {
|
|
1089
|
-
return c
|
|
1098
|
+
return respondWithAgentError(c, 404, [
|
|
1099
|
+
composeIssue("context.path_not_found", {
|
|
1100
|
+
field: "path",
|
|
1101
|
+
received: path,
|
|
1102
|
+
}),
|
|
1103
|
+
]);
|
|
1090
1104
|
}
|
|
1091
1105
|
const content = readFileSync(fullPath, "utf-8");
|
|
1092
1106
|
const stat = statSync(fullPath);
|
|
@@ -1123,18 +1137,33 @@ export function createContextRoutes(deps) {
|
|
|
1123
1137
|
const contextDir = getCurrentContextDir();
|
|
1124
1138
|
const fullPath = safePath(contextDir, rawPath);
|
|
1125
1139
|
if (!fullPath) {
|
|
1126
|
-
return c
|
|
1140
|
+
return respondWithAgentError(c, 400, [
|
|
1141
|
+
composeIssue("context.path_invalid", {
|
|
1142
|
+
field: "path",
|
|
1143
|
+
received: path,
|
|
1144
|
+
}),
|
|
1145
|
+
]);
|
|
1127
1146
|
}
|
|
1128
1147
|
if (!isWriteAllowed(path, "PUT")) {
|
|
1129
1148
|
logger.warn({ path, method: "PUT" }, "Context write forbidden");
|
|
1130
|
-
return c
|
|
1149
|
+
return respondWithAgentError(c, 403, [
|
|
1150
|
+
composeIssue("context.write_forbidden", {
|
|
1151
|
+
field: "path",
|
|
1152
|
+
received: { path, method: "PUT" },
|
|
1153
|
+
}),
|
|
1154
|
+
]);
|
|
1131
1155
|
}
|
|
1132
1156
|
// Morning Routine lock: reject writes to today while lock is held
|
|
1133
1157
|
if (morningRoutineLock.getHolder() && path === "today") {
|
|
1134
1158
|
const lockId = c.req.header("X-Lock-Id");
|
|
1135
1159
|
if (!morningRoutineLock.isHeldBy(lockId)) {
|
|
1136
1160
|
logger.info({ path }, "Context PUT rejected — morning routine lock held");
|
|
1137
|
-
return c
|
|
1161
|
+
return respondWithAgentError(c, 409, [
|
|
1162
|
+
composeIssue("context.morning_routine_lock_held", {
|
|
1163
|
+
field: "X-Lock-Id",
|
|
1164
|
+
received: lockId ?? "<missing>",
|
|
1165
|
+
}),
|
|
1166
|
+
]);
|
|
1138
1167
|
}
|
|
1139
1168
|
}
|
|
1140
1169
|
// Roadmap write lock: reject writes to roadmap while another session holds it
|
|
@@ -1142,7 +1171,12 @@ export function createContextRoutes(deps) {
|
|
|
1142
1171
|
const lockId = c.req.header("X-Lock-Id");
|
|
1143
1172
|
if (!roadmapWriteLock.isHeldBy(lockId)) {
|
|
1144
1173
|
logger.info({ path }, "Context PUT rejected — roadmap write lock held");
|
|
1145
|
-
return c
|
|
1174
|
+
return respondWithAgentError(c, 409, [
|
|
1175
|
+
composeIssue("context.roadmap_write_lock_held", {
|
|
1176
|
+
field: "X-Lock-Id",
|
|
1177
|
+
received: lockId ?? "<missing>",
|
|
1178
|
+
}),
|
|
1179
|
+
]);
|
|
1146
1180
|
}
|
|
1147
1181
|
}
|
|
1148
1182
|
const parsedBody = await readJsonBody(c, { maxBytes: CONTEXT_BODY_MAX_BYTES });
|
|
@@ -1151,7 +1185,12 @@ export function createContextRoutes(deps) {
|
|
|
1151
1185
|
const body = parsedBody.body;
|
|
1152
1186
|
const parsed = contextPutSchema.safeParse(body);
|
|
1153
1187
|
if (!parsed.success) {
|
|
1154
|
-
return c
|
|
1188
|
+
return respondWithAgentError(c, 400, [
|
|
1189
|
+
composeIssue("context.body_not_object", {
|
|
1190
|
+
field: "body",
|
|
1191
|
+
received: parsed.error.issues.map((i) => i.message).join("; "),
|
|
1192
|
+
}),
|
|
1193
|
+
]);
|
|
1155
1194
|
}
|
|
1156
1195
|
const roadmapValidationOff = isRoadmapValidationDisabled(path, c.req.header("X-Roadmap-Validation"));
|
|
1157
1196
|
if (roadmapValidationOff) {
|
|
@@ -1167,11 +1206,37 @@ export function createContextRoutes(deps) {
|
|
|
1167
1206
|
expectedAgentDay,
|
|
1168
1207
|
});
|
|
1169
1208
|
if (!preflight.ok) {
|
|
1170
|
-
return c.
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1209
|
+
return respondWithAgentError(c, preflight.status, [
|
|
1210
|
+
composeIssue("context.content_validation_failed", {
|
|
1211
|
+
field: preflight.path ?? "content",
|
|
1212
|
+
received: preflight.message,
|
|
1213
|
+
}),
|
|
1214
|
+
], {
|
|
1215
|
+
legacyFields: {
|
|
1216
|
+
message: preflight.message,
|
|
1217
|
+
path: preflight.path,
|
|
1218
|
+
},
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
// morning-routine-optimization.md §"PUT /api/context/daily/<date>
|
|
1222
|
+
// skeleton-preservation validator" — only runs once generic
|
|
1223
|
+
// frontmatter validation (type/owner/updated/H1) has passed.
|
|
1224
|
+
// Returns per-field structured drift errors for the five
|
|
1225
|
+
// skeleton-owned frontmatter fields (date, weekday,
|
|
1226
|
+
// agent_generated, calendar_events, messages_handled) so Stage B
|
|
1227
|
+
// can fix every missing/malformed field in a single retry rather
|
|
1228
|
+
// than discovering them one at a time. Body is NOT validated —
|
|
1229
|
+
// Stage B authors body per rules/journal-format.md.
|
|
1230
|
+
if (target.base.startsWith("daily/")) {
|
|
1231
|
+
const dailyRelativePath = `${target.base}${target.ext}`;
|
|
1232
|
+
const driftErrors = validateDailySkeletonFrontmatter(preflight.content, dailyRelativePath);
|
|
1233
|
+
if (driftErrors.length > 0) {
|
|
1234
|
+
return respondWithAgentError(c, 422, driftErrors.map((drift) => composeIssue("context.daily_skeleton_field_drift", {
|
|
1235
|
+
field: drift.field,
|
|
1236
|
+
received: drift.received ?? "<missing>",
|
|
1237
|
+
expected: drift.expected,
|
|
1238
|
+
})));
|
|
1239
|
+
}
|
|
1175
1240
|
}
|
|
1176
1241
|
const sessionId = c.req.header("X-Session-Id");
|
|
1177
1242
|
return withWriteLock(() => {
|
|
@@ -1182,11 +1247,12 @@ export function createContextRoutes(deps) {
|
|
|
1182
1247
|
// outer existsSync check and then sequentially overwrite.
|
|
1183
1248
|
if (CREATE_ONLY_PUT.has(path) && existsSync(fullPath)) {
|
|
1184
1249
|
logger.warn({ path }, "Context PUT rejected — file exists, use PATCH to append");
|
|
1185
|
-
return c
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1250
|
+
return respondWithAgentError(c, 409, [
|
|
1251
|
+
composeIssue("context.append_only_violation", {
|
|
1252
|
+
field: "path",
|
|
1253
|
+
received: { path, hint: `Use PATCH to append new sections to ${path}.` },
|
|
1254
|
+
}),
|
|
1255
|
+
]);
|
|
1190
1256
|
}
|
|
1191
1257
|
// Optimistic concurrency check: if client supplied expectedMtime,
|
|
1192
1258
|
// compare against the current file. On mismatch, return 409 with
|
|
@@ -1202,7 +1268,16 @@ export function createContextRoutes(deps) {
|
|
|
1202
1268
|
parsed.data.expectedMtime !== currentMtime) {
|
|
1203
1269
|
logger.info({ path, expectedMtime: parsed.data.expectedMtime, currentMtime }, "Context PUT conflict");
|
|
1204
1270
|
return c.json({
|
|
1271
|
+
ok: false,
|
|
1205
1272
|
error: "conflict",
|
|
1273
|
+
summary: `PUT conflict on ${path}: expectedMtime ${parsed.data.expectedMtime} did not match current ${currentMtime}. GET the file, replay your change, and retry.`,
|
|
1274
|
+
errors: [
|
|
1275
|
+
composeIssue("context.write_conflict", {
|
|
1276
|
+
field: "expectedMtime",
|
|
1277
|
+
received: { expectedMtime: parsed.data.expectedMtime, currentMtime },
|
|
1278
|
+
}),
|
|
1279
|
+
],
|
|
1280
|
+
retryable: true,
|
|
1206
1281
|
currentMtime,
|
|
1207
1282
|
currentContent: existing,
|
|
1208
1283
|
}, 409);
|
|
@@ -1216,11 +1291,17 @@ export function createContextRoutes(deps) {
|
|
|
1216
1291
|
expectedAgentDay,
|
|
1217
1292
|
});
|
|
1218
1293
|
if (!prepared.ok) {
|
|
1219
|
-
return c.
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1294
|
+
return respondWithAgentError(c, prepared.status, [
|
|
1295
|
+
composeIssue("context.content_validation_failed", {
|
|
1296
|
+
field: prepared.path ?? "content",
|
|
1297
|
+
received: prepared.message,
|
|
1298
|
+
}),
|
|
1299
|
+
], {
|
|
1300
|
+
legacyFields: {
|
|
1301
|
+
message: prepared.message,
|
|
1302
|
+
path: prepared.path,
|
|
1303
|
+
},
|
|
1304
|
+
});
|
|
1224
1305
|
}
|
|
1225
1306
|
contentToWrite = prepared.content;
|
|
1226
1307
|
snapshotId = saveSnapshot(path, existing, "api_put", true, sessionId);
|
|
@@ -1228,7 +1309,16 @@ export function createContextRoutes(deps) {
|
|
|
1228
1309
|
else if (parsed.data.expectedMtime !== undefined) {
|
|
1229
1310
|
// Client expected a specific mtime but the file is gone
|
|
1230
1311
|
return c.json({
|
|
1312
|
+
ok: false,
|
|
1231
1313
|
error: "conflict",
|
|
1314
|
+
summary: `PUT conflict on ${path}: expectedMtime ${parsed.data.expectedMtime} but file no longer exists.`,
|
|
1315
|
+
errors: [
|
|
1316
|
+
composeIssue("context.write_conflict", {
|
|
1317
|
+
field: "expectedMtime",
|
|
1318
|
+
received: { expectedMtime: parsed.data.expectedMtime, currentMtime: "" },
|
|
1319
|
+
}),
|
|
1320
|
+
],
|
|
1321
|
+
retryable: true,
|
|
1232
1322
|
currentMtime: "",
|
|
1233
1323
|
currentContent: "",
|
|
1234
1324
|
}, 409);
|
|
@@ -1261,18 +1351,33 @@ export function createContextRoutes(deps) {
|
|
|
1261
1351
|
const contextDir = getCurrentContextDir();
|
|
1262
1352
|
const fullPath = safePath(contextDir, rawPath);
|
|
1263
1353
|
if (!fullPath) {
|
|
1264
|
-
return c
|
|
1354
|
+
return respondWithAgentError(c, 400, [
|
|
1355
|
+
composeIssue("context.path_invalid", {
|
|
1356
|
+
field: "path",
|
|
1357
|
+
received: path,
|
|
1358
|
+
}),
|
|
1359
|
+
]);
|
|
1265
1360
|
}
|
|
1266
1361
|
if (!isWriteAllowed(path, "PATCH")) {
|
|
1267
1362
|
logger.warn({ path, method: "PATCH" }, "Context write forbidden");
|
|
1268
|
-
return c
|
|
1363
|
+
return respondWithAgentError(c, 403, [
|
|
1364
|
+
composeIssue("context.write_forbidden", {
|
|
1365
|
+
field: "path",
|
|
1366
|
+
received: { path, method: "PATCH" },
|
|
1367
|
+
}),
|
|
1368
|
+
]);
|
|
1269
1369
|
}
|
|
1270
1370
|
// Morning Routine lock: reject writes to today while lock is held
|
|
1271
1371
|
if (morningRoutineLock.getHolder() && path === "today") {
|
|
1272
1372
|
const lockId = c.req.header("X-Lock-Id");
|
|
1273
1373
|
if (!morningRoutineLock.isHeldBy(lockId)) {
|
|
1274
1374
|
logger.info({ path }, "Context PATCH rejected — morning routine lock held");
|
|
1275
|
-
return c
|
|
1375
|
+
return respondWithAgentError(c, 409, [
|
|
1376
|
+
composeIssue("context.morning_routine_lock_held", {
|
|
1377
|
+
field: "X-Lock-Id",
|
|
1378
|
+
received: lockId ?? "<missing>",
|
|
1379
|
+
}),
|
|
1380
|
+
]);
|
|
1276
1381
|
}
|
|
1277
1382
|
}
|
|
1278
1383
|
// Roadmap write lock: reject writes to roadmap while another session holds it
|
|
@@ -1280,7 +1385,12 @@ export function createContextRoutes(deps) {
|
|
|
1280
1385
|
const lockId = c.req.header("X-Lock-Id");
|
|
1281
1386
|
if (!roadmapWriteLock.isHeldBy(lockId)) {
|
|
1282
1387
|
logger.info({ path }, "Context PATCH rejected — roadmap write lock held");
|
|
1283
|
-
return c
|
|
1388
|
+
return respondWithAgentError(c, 409, [
|
|
1389
|
+
composeIssue("context.roadmap_write_lock_held", {
|
|
1390
|
+
field: "X-Lock-Id",
|
|
1391
|
+
received: lockId ?? "<missing>",
|
|
1392
|
+
}),
|
|
1393
|
+
]);
|
|
1284
1394
|
}
|
|
1285
1395
|
}
|
|
1286
1396
|
const parsedBody = await readJsonBody(c, { maxBytes: CONTEXT_BODY_MAX_BYTES });
|
|
@@ -1289,13 +1399,20 @@ export function createContextRoutes(deps) {
|
|
|
1289
1399
|
const body = parsedBody.body;
|
|
1290
1400
|
const parsed = contextPatchSchema.safeParse(body);
|
|
1291
1401
|
if (!parsed.success) {
|
|
1292
|
-
return c
|
|
1402
|
+
return respondWithAgentError(c, 400, [
|
|
1403
|
+
composeIssue("context.body_not_object", {
|
|
1404
|
+
field: "body",
|
|
1405
|
+
received: parsed.error.issues.map((i) => i.message).join("; "),
|
|
1406
|
+
}),
|
|
1407
|
+
]);
|
|
1293
1408
|
}
|
|
1294
1409
|
if (target.ext === ".base") {
|
|
1295
|
-
return c
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1410
|
+
return respondWithAgentError(c, 400, [
|
|
1411
|
+
composeIssue("context.unsupported_operation", {
|
|
1412
|
+
field: "method",
|
|
1413
|
+
received: { method: "PATCH", ext: ".base", hint: "Use PUT to replace .base files." },
|
|
1414
|
+
}),
|
|
1415
|
+
]);
|
|
1299
1416
|
}
|
|
1300
1417
|
const { section, mode, content: newContent, cutoff, maxEntries } = parsed.data;
|
|
1301
1418
|
const sessionId = c.req.header("X-Session-Id");
|
|
@@ -1308,7 +1425,12 @@ export function createContextRoutes(deps) {
|
|
|
1308
1425
|
: undefined;
|
|
1309
1426
|
return withWriteLock(() => {
|
|
1310
1427
|
if (!existsSync(fullPath)) {
|
|
1311
|
-
return c
|
|
1428
|
+
return respondWithAgentError(c, 404, [
|
|
1429
|
+
composeIssue("context.path_not_found", {
|
|
1430
|
+
field: "path",
|
|
1431
|
+
received: path,
|
|
1432
|
+
}),
|
|
1433
|
+
]);
|
|
1312
1434
|
}
|
|
1313
1435
|
const fileContent = readFileSync(fullPath, "utf-8");
|
|
1314
1436
|
// ── append_to_file: append content to end of file (no section lookup) ──
|
|
@@ -1329,11 +1451,17 @@ export function createContextRoutes(deps) {
|
|
|
1329
1451
|
expectedAgentDay,
|
|
1330
1452
|
});
|
|
1331
1453
|
if (!prepared.ok) {
|
|
1332
|
-
return c.
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1454
|
+
return respondWithAgentError(c, prepared.status, [
|
|
1455
|
+
composeIssue("context.content_validation_failed", {
|
|
1456
|
+
field: prepared.path ?? "content",
|
|
1457
|
+
received: prepared.message,
|
|
1458
|
+
}),
|
|
1459
|
+
], {
|
|
1460
|
+
legacyFields: {
|
|
1461
|
+
message: prepared.message,
|
|
1462
|
+
path: prepared.path,
|
|
1463
|
+
},
|
|
1464
|
+
});
|
|
1337
1465
|
}
|
|
1338
1466
|
saveSnapshot(path, fileContent, "api_patch", false, sessionId);
|
|
1339
1467
|
writeFileAtomically(fullPath, prepared.content);
|
|
@@ -1358,11 +1486,18 @@ export function createContextRoutes(deps) {
|
|
|
1358
1486
|
// ── Section-based modes: require section lookup ──
|
|
1359
1487
|
const sectionBounds = findSection(fileContent, section);
|
|
1360
1488
|
if (!sectionBounds) {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1489
|
+
const availableSections = getAvailableSections(fileContent);
|
|
1490
|
+
return respondWithAgentError(c, 400, [
|
|
1491
|
+
composeIssue("context.section_not_found", {
|
|
1492
|
+
field: "section",
|
|
1493
|
+
received: { section, availableSections },
|
|
1494
|
+
}),
|
|
1495
|
+
], {
|
|
1496
|
+
legacyFields: {
|
|
1497
|
+
section,
|
|
1498
|
+
availableSections,
|
|
1499
|
+
},
|
|
1500
|
+
});
|
|
1366
1501
|
}
|
|
1367
1502
|
let updated;
|
|
1368
1503
|
const before = fileContent.slice(0, sectionBounds.start);
|
|
@@ -1394,10 +1529,13 @@ export function createContextRoutes(deps) {
|
|
|
1394
1529
|
// Schema refinements validate format, but defense-in-depth for
|
|
1395
1530
|
// direct API callers that bypass schema validation.
|
|
1396
1531
|
if (!cutoff || !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(cutoff)) {
|
|
1397
|
-
return c
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1532
|
+
return respondWithAgentError(c, 400, [
|
|
1533
|
+
composeIssue("context.cutoff_required", {
|
|
1534
|
+
field: "cutoff",
|
|
1535
|
+
received: cutoff ?? "<missing>",
|
|
1536
|
+
expected: "'YYYY-MM-DD HH:MM:SS' format (zero-padded)",
|
|
1537
|
+
}),
|
|
1538
|
+
]);
|
|
1401
1539
|
}
|
|
1402
1540
|
const clearResult = clearEntriesBefore(currentBody, cutoff);
|
|
1403
1541
|
updated = before + clearResult.remaining + after;
|
|
@@ -1415,11 +1553,17 @@ export function createContextRoutes(deps) {
|
|
|
1415
1553
|
expectedAgentDay,
|
|
1416
1554
|
});
|
|
1417
1555
|
if (!prepared.ok) {
|
|
1418
|
-
return c.
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1556
|
+
return respondWithAgentError(c, prepared.status, [
|
|
1557
|
+
composeIssue("context.content_validation_failed", {
|
|
1558
|
+
field: prepared.path ?? "content",
|
|
1559
|
+
received: prepared.message,
|
|
1560
|
+
}),
|
|
1561
|
+
], {
|
|
1562
|
+
legacyFields: {
|
|
1563
|
+
message: prepared.message,
|
|
1564
|
+
path: prepared.path,
|
|
1565
|
+
},
|
|
1566
|
+
});
|
|
1423
1567
|
}
|
|
1424
1568
|
// Force snapshot on replace (bypass debounce) to ensure recovery
|
|
1425
1569
|
// from accidental overwrites. Other modes use normal debounce.
|
|
@@ -1455,15 +1599,30 @@ export function createContextRoutes(deps) {
|
|
|
1455
1599
|
const contextDir = getCurrentContextDir();
|
|
1456
1600
|
const fullPath = safePath(contextDir, path);
|
|
1457
1601
|
if (!fullPath) {
|
|
1458
|
-
return c
|
|
1602
|
+
return respondWithAgentError(c, 400, [
|
|
1603
|
+
composeIssue("context.path_invalid", {
|
|
1604
|
+
field: "path",
|
|
1605
|
+
received: path,
|
|
1606
|
+
}),
|
|
1607
|
+
]);
|
|
1459
1608
|
}
|
|
1460
1609
|
if (!isWriteAllowed(path, "DELETE")) {
|
|
1461
1610
|
logger.warn({ path, method: "DELETE" }, "Context delete forbidden");
|
|
1462
|
-
return c
|
|
1611
|
+
return respondWithAgentError(c, 403, [
|
|
1612
|
+
composeIssue("context.write_forbidden", {
|
|
1613
|
+
field: "path",
|
|
1614
|
+
received: { path, method: "DELETE" },
|
|
1615
|
+
}),
|
|
1616
|
+
]);
|
|
1463
1617
|
}
|
|
1464
1618
|
return withWriteLock(() => {
|
|
1465
1619
|
if (!existsSync(fullPath)) {
|
|
1466
|
-
return c
|
|
1620
|
+
return respondWithAgentError(c, 404, [
|
|
1621
|
+
composeIssue("context.path_not_found", {
|
|
1622
|
+
field: "path",
|
|
1623
|
+
received: path,
|
|
1624
|
+
}),
|
|
1625
|
+
]);
|
|
1467
1626
|
}
|
|
1468
1627
|
const existing = readFileSync(fullPath, "utf-8");
|
|
1469
1628
|
const snapshotId = saveSnapshot(path, existing, "api_delete", true);
|
|
@@ -1478,311 +1637,9 @@ export function createContextRoutes(deps) {
|
|
|
1478
1637
|
});
|
|
1479
1638
|
return app;
|
|
1480
1639
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
});
|
|
1487
|
-
return message ? { message, status: 400 } : null;
|
|
1488
|
-
}
|
|
1489
|
-
if (target.base === "roadmap") {
|
|
1490
|
-
const result = validateRoadmap(content);
|
|
1491
|
-
if (!result.ok && result.error) {
|
|
1492
|
-
return {
|
|
1493
|
-
message: formatRoadmapValidationError(result.error),
|
|
1494
|
-
status: 400,
|
|
1495
|
-
path: result.error.path,
|
|
1496
|
-
};
|
|
1497
|
-
}
|
|
1498
|
-
return null;
|
|
1499
|
-
}
|
|
1500
|
-
if (target.base.startsWith("routines/custom/")) {
|
|
1501
|
-
const slug = target.base.slice("routines/custom/".length);
|
|
1502
|
-
const result = parseCustomRoutineSpec(slug, content);
|
|
1503
|
-
if (!result.ok) {
|
|
1504
|
-
return {
|
|
1505
|
-
message: explainCustomRoutineValidationError(result.error),
|
|
1506
|
-
status: 400,
|
|
1507
|
-
};
|
|
1508
|
-
}
|
|
1509
|
-
return null;
|
|
1510
|
-
}
|
|
1511
|
-
if (target.base.startsWith("routines/") && target.base !== "routines/_index") {
|
|
1512
|
-
const message = validateBuiltInRoutineRulebook(target.base, content);
|
|
1513
|
-
return message ? { message, status: 400 } : null;
|
|
1514
|
-
}
|
|
1515
|
-
const relativePath = `${target.base}${target.ext}`;
|
|
1516
|
-
if (!options?.skipFrontmatterValidation) {
|
|
1517
|
-
const frontmatterError = validateContextFileFrontmatter(content, relativePath);
|
|
1518
|
-
if (frontmatterError) {
|
|
1519
|
-
return { message: frontmatterError.message, status: 422 };
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
if (target.ext !== ".base")
|
|
1523
|
-
return null;
|
|
1524
|
-
const message = validateBaseYamlSyntax(content);
|
|
1525
|
-
return message ? { message, status: 400 } : null;
|
|
1526
|
-
}
|
|
1527
|
-
const TODAY_REQUIRED_SECTIONS = [
|
|
1528
|
-
"User Schedule",
|
|
1529
|
-
"User Tasks",
|
|
1530
|
-
"Agent Plan",
|
|
1531
|
-
"Agent Notes",
|
|
1532
|
-
"Agent Log",
|
|
1533
|
-
"Handoff",
|
|
1534
|
-
];
|
|
1535
|
-
const TODAY_H1_RE = /^# \d{4}-\d{2}-\d{2}(?: \([^)]+\))?$/;
|
|
1536
|
-
const TODAY_DAY_TYPE_RE = /^> Day type: (Weekday|Weekend) \| Work focus: (on|off) \| Study focus: (on|off) \| Personal focus: (on|off)$/;
|
|
1537
|
-
function isLegacyTodayContent(content) {
|
|
1538
|
-
const lines = content.split(/\r?\n/);
|
|
1539
|
-
return (lines[0] ?? "").trim() === "# Today";
|
|
1540
|
-
}
|
|
1541
|
-
function validateTodayContent(content, options = {}) {
|
|
1542
|
-
if (options.allowLegacyToday && isLegacyTodayContent(content))
|
|
1543
|
-
return null;
|
|
1544
|
-
const lines = content.split(/\r?\n/);
|
|
1545
|
-
const firstLine = (lines[0] ?? "").trim();
|
|
1546
|
-
if (!TODAY_H1_RE.test(firstLine)) {
|
|
1547
|
-
return ("today.md line 1 must be `# YYYY-MM-DD (day-of-week)`. " +
|
|
1548
|
-
"The date and dashes are ASCII English; only the weekday inside " +
|
|
1549
|
-
"`(...)` may be localized. Do NOT translate the literal `# ` prefix " +
|
|
1550
|
-
"or change the date separator. See the today skill for the full " +
|
|
1551
|
-
"skeleton contract.");
|
|
1552
|
-
}
|
|
1553
|
-
if (!TODAY_DAY_TYPE_RE.test((lines[1] ?? "").trim())) {
|
|
1554
|
-
return ("today.md line 2 must be `> Day type: Weekday|Weekend | Work focus: on|off | Study focus: on|off | Personal focus: on|off`. " +
|
|
1555
|
-
"This line is parsed by every downstream event handler — keep it " +
|
|
1556
|
-
"exact English ASCII with the casing, pipe separators (` | `), and " +
|
|
1557
|
-
"leading `> ` shown above. Do NOT translate `Day type` / `Weekday` / " +
|
|
1558
|
-
"`Work focus` / `on` / `off` etc. into the user's primary_language; " +
|
|
1559
|
-
"the `<output_language_policy>` skeleton-precedence rule covers this " +
|
|
1560
|
-
"line. Example: " +
|
|
1561
|
-
"`> Day type: Weekday | Work focus: on | Study focus: on | Personal focus: on`.");
|
|
1562
|
-
}
|
|
1563
|
-
// Agent-day-date check — rejects wrong-date H1 with a clear error echoing
|
|
1564
|
-
// both values. Without this, a wrong-date PUT silently succeeds (regex
|
|
1565
|
-
// passes) and the dispatcher's post-run hasCurrentAgentDayTodayMd() check
|
|
1566
|
-
// schedules a retry while the same session still has the prompt context
|
|
1567
|
-
// loaded, wasting a heavy-tier turn cycle. With this guard the agent gets
|
|
1568
|
-
// immediate feedback and corrects in-session.
|
|
1569
|
-
if (options.expectedAgentDay) {
|
|
1570
|
-
// TODAY_H1_RE already matched, so the YYYY-MM-DD capture is guaranteed.
|
|
1571
|
-
// No optional-chain — the regex precondition guarantees `[1]` is set.
|
|
1572
|
-
const writtenDate = firstLine.match(/^# (\d{4}-\d{2}-\d{2})/)[1];
|
|
1573
|
-
if (writtenDate !== options.expectedAgentDay) {
|
|
1574
|
-
return (`today.md line 1 date '${writtenDate}' does not match the current ` +
|
|
1575
|
-
`agent-day date '${options.expectedAgentDay}'. ` +
|
|
1576
|
-
`Use the date from <current_agent_day date="..."> in your prompt context — ` +
|
|
1577
|
-
`the agent-day differs from calendar today before the day-boundary hour.`);
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
let previousSectionIndex = 1;
|
|
1581
|
-
for (const section of TODAY_REQUIRED_SECTIONS) {
|
|
1582
|
-
const index = lines.findIndex((line, lineIndex) => lineIndex > previousSectionIndex && line.trim() === `## ${section}`);
|
|
1583
|
-
if (index < 0) {
|
|
1584
|
-
return `today.md requires \`## ${section}\` in canonical order.`;
|
|
1585
|
-
}
|
|
1586
|
-
previousSectionIndex = index;
|
|
1587
|
-
}
|
|
1588
|
-
const parsed = extractTodayAgentPlanRows(content);
|
|
1589
|
-
if (parsed.invalidRows.length > 0) {
|
|
1590
|
-
const first = parsed.invalidRows[0];
|
|
1591
|
-
return (`today.md Agent Plan line ${first.line} must match ` +
|
|
1592
|
-
`\`- [ ] HH:MM <action> [work|study|personal|home] →DM|→notify|→check-in|→wake\`. ` +
|
|
1593
|
-
`Got: ${JSON.stringify(first.raw)}`);
|
|
1594
|
-
}
|
|
1595
|
-
return null;
|
|
1596
|
-
}
|
|
1597
|
-
function toTodayScheduleCandidate(row, timezone) {
|
|
1598
|
-
const scheduledAt = parseScheduleDate(row.scheduled_for);
|
|
1599
|
-
if (Number.isNaN(scheduledAt.getTime()))
|
|
1600
|
-
return null;
|
|
1601
|
-
const local = nowInTimezone(timezone, scheduledAt);
|
|
1602
|
-
const localDate = `${local.year}-${String(local.month).padStart(2, "0")}-${String(local.day).padStart(2, "0")}`;
|
|
1603
|
-
const localTime = `${String(local.hours).padStart(2, "0")}:${String(local.minutes).padStart(2, "0")}`;
|
|
1604
|
-
return {
|
|
1605
|
-
id: row.id,
|
|
1606
|
-
scheduledFor: row.scheduled_for,
|
|
1607
|
-
localDate,
|
|
1608
|
-
localTime,
|
|
1609
|
-
taskType: row.task_type,
|
|
1610
|
-
status: row.status,
|
|
1611
|
-
description: row.task_description,
|
|
1612
|
-
taskContext: parseJsonObject(row.task_context),
|
|
1613
|
-
};
|
|
1614
|
-
}
|
|
1615
|
-
function parseScheduleDate(value) {
|
|
1616
|
-
return new Date(value.includes("T") ? value : value.replace(" ", "T") + "Z");
|
|
1617
|
-
}
|
|
1618
|
-
function parseJsonObject(raw) {
|
|
1619
|
-
if (!raw)
|
|
1620
|
-
return {};
|
|
1621
|
-
try {
|
|
1622
|
-
const parsed = JSON.parse(raw);
|
|
1623
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
1624
|
-
return parsed;
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
catch {
|
|
1628
|
-
// Ignore corrupt metadata for reconciliation diagnostics.
|
|
1629
|
-
}
|
|
1630
|
-
return {};
|
|
1631
|
-
}
|
|
1632
|
-
function prepareContextContentForWrite(target, content, options) {
|
|
1633
|
-
if (target.base !== "roadmap") {
|
|
1634
|
-
const contentError = validateContextContent(target, content, {
|
|
1635
|
-
allowLegacyToday: options?.allowLegacyToday,
|
|
1636
|
-
expectedAgentDay: options?.expectedAgentDay,
|
|
1637
|
-
});
|
|
1638
|
-
if (contentError) {
|
|
1639
|
-
return {
|
|
1640
|
-
ok: false,
|
|
1641
|
-
message: contentError.message,
|
|
1642
|
-
status: contentError.status,
|
|
1643
|
-
path: contentError.path,
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
return { ok: true, content };
|
|
1647
|
-
}
|
|
1648
|
-
if (options?.disableRoadmapValidation) {
|
|
1649
|
-
return { ok: true, content };
|
|
1650
|
-
}
|
|
1651
|
-
const normalized = normalizeRoadmapForWrite(content, {
|
|
1652
|
-
timezone: options?.timezone,
|
|
1653
|
-
defaultLongTermPlanSource: options?.defaultLongTermPlanSource ?? "manual",
|
|
1654
|
-
});
|
|
1655
|
-
const result = validateRoadmap(normalized.content);
|
|
1656
|
-
if (!result.ok && result.error) {
|
|
1657
|
-
return {
|
|
1658
|
-
ok: false,
|
|
1659
|
-
message: formatRoadmapValidationError(result.error),
|
|
1660
|
-
status: 400,
|
|
1661
|
-
path: result.error.path,
|
|
1662
|
-
};
|
|
1663
|
-
}
|
|
1664
|
-
if (options?.previousRoadmapContent !== undefined) {
|
|
1665
|
-
const transition = validateRoadmapTransition(options.previousRoadmapContent, normalized.content, {
|
|
1666
|
-
today: options.today,
|
|
1667
|
-
timezone: options.timezone,
|
|
1668
|
-
});
|
|
1669
|
-
if (!transition.ok && transition.error) {
|
|
1670
|
-
return {
|
|
1671
|
-
ok: false,
|
|
1672
|
-
message: formatRoadmapValidationError(transition.error),
|
|
1673
|
-
status: 400,
|
|
1674
|
-
path: transition.error.path,
|
|
1675
|
-
};
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
return { ok: true, content: normalized.content };
|
|
1679
|
-
}
|
|
1680
|
-
function formatRoadmapValidationError(error) {
|
|
1681
|
-
const line = error.line ? `line ${error.line}: ` : "";
|
|
1682
|
-
return `${line}${error.message}`;
|
|
1683
|
-
}
|
|
1684
|
-
function validateBuiltInRoutineRulebook(path, content) {
|
|
1685
|
-
const frontmatter = extractRoutineFrontmatter(content);
|
|
1686
|
-
if (frontmatter === null) {
|
|
1687
|
-
return "Routine rulebooks require YAML frontmatter.";
|
|
1688
|
-
}
|
|
1689
|
-
const expectedSlug = path.slice("routines/".length);
|
|
1690
|
-
const typeRaw = readRoutineFrontmatterScalar(frontmatter, "type");
|
|
1691
|
-
if (!typeRaw) {
|
|
1692
|
-
return "Routine rulebooks require `type: rule` in frontmatter.";
|
|
1693
|
-
}
|
|
1694
|
-
if (typeRaw !== "rule") {
|
|
1695
|
-
return "Routine rulebooks must declare `type: rule`.";
|
|
1696
|
-
}
|
|
1697
|
-
const slugRaw = readRoutineFrontmatterScalar(frontmatter, "slug");
|
|
1698
|
-
if (!slugRaw) {
|
|
1699
|
-
return "Routine rulebooks require a `slug` frontmatter field.";
|
|
1700
|
-
}
|
|
1701
|
-
if (slugRaw !== expectedSlug) {
|
|
1702
|
-
return `Routine rulebook slug must match the filename (${expectedSlug}).`;
|
|
1703
|
-
}
|
|
1704
|
-
if (!/^##\s+Checks\s*$/m.test(content)) {
|
|
1705
|
-
return "Routine rulebooks require a `## Checks` section.";
|
|
1706
|
-
}
|
|
1707
|
-
return null;
|
|
1708
|
-
}
|
|
1709
|
-
function explainCustomRoutineValidationError(error) {
|
|
1710
|
-
switch (error.kind) {
|
|
1711
|
-
case "missing_field":
|
|
1712
|
-
return `Custom routine files require \`${error.field}\` in frontmatter.`;
|
|
1713
|
-
case "invalid_cron":
|
|
1714
|
-
return `Invalid cron expression: \`${error.value}\`.`;
|
|
1715
|
-
case "invalid_slug":
|
|
1716
|
-
return `Custom routine slug is invalid or does not match the filename: \`${error.value}\`.`;
|
|
1717
|
-
case "invalid_type":
|
|
1718
|
-
return `Custom routines must declare \`type: rule\`, got \`${error.value}\`.`;
|
|
1719
|
-
case "invalid_process_key":
|
|
1720
|
-
return `Custom routine \`process_key\` must match the filename-derived key, got \`${error.value}\`.`;
|
|
1721
|
-
case "invalid_enabled":
|
|
1722
|
-
return `Custom routine \`enabled\` must be \`true\` or \`false\`, got \`${error.value}\`.`;
|
|
1723
|
-
case "invalid_tier":
|
|
1724
|
-
return `Custom routine \`backend_tier\` must be \`light\` or \`heavy\`, got \`${error.value}\`.`;
|
|
1725
|
-
case "invalid_budget":
|
|
1726
|
-
return `Custom routine \`max_budget_usd\` must be a positive number, got \`${error.value}\`.`;
|
|
1727
|
-
case "missing_checks_section":
|
|
1728
|
-
return "Custom routines require a `## Checks` section.";
|
|
1729
|
-
case "no_frontmatter":
|
|
1730
|
-
return "Custom routines require YAML frontmatter.";
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
function extractRoutineFrontmatter(content) {
|
|
1734
|
-
if (!content.startsWith("---\n") && !content.startsWith("---\r\n")) {
|
|
1735
|
-
return null;
|
|
1736
|
-
}
|
|
1737
|
-
const afterOpen = content.startsWith("---\r\n") ? 5 : 4;
|
|
1738
|
-
const endIdx = content.indexOf("\n---", afterOpen - 1);
|
|
1739
|
-
if (endIdx < 0)
|
|
1740
|
-
return null;
|
|
1741
|
-
return content.slice(afterOpen, endIdx);
|
|
1742
|
-
}
|
|
1743
|
-
function readRoutineFrontmatterScalar(frontmatter, field) {
|
|
1744
|
-
const re = new RegExp(`^${field}\\s*:\\s*(.+?)\\s*$`, "m");
|
|
1745
|
-
const match = frontmatter.match(re);
|
|
1746
|
-
if (!match)
|
|
1747
|
-
return null;
|
|
1748
|
-
let value = match[1].trim();
|
|
1749
|
-
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
1750
|
-
(value.startsWith("'") && value.endsWith("'"))) {
|
|
1751
|
-
value = value.slice(1, -1);
|
|
1752
|
-
}
|
|
1753
|
-
return value;
|
|
1754
|
-
}
|
|
1755
|
-
function validateBaseYamlSyntax(content) {
|
|
1756
|
-
if (content.trim().length === 0) {
|
|
1757
|
-
return ".base files must not be empty.";
|
|
1758
|
-
}
|
|
1759
|
-
const lines = content.split("\n");
|
|
1760
|
-
let sawMeaningfulLine = false;
|
|
1761
|
-
for (let index = 0; index < lines.length; index++) {
|
|
1762
|
-
const raw = lines[index];
|
|
1763
|
-
const lineNo = index + 1;
|
|
1764
|
-
if (raw.includes("\t")) {
|
|
1765
|
-
return `.base YAML may not contain tab indentation (line ${lineNo}).`;
|
|
1766
|
-
}
|
|
1767
|
-
const trimmed = raw.trim();
|
|
1768
|
-
if (!trimmed || trimmed.startsWith("#"))
|
|
1769
|
-
continue;
|
|
1770
|
-
sawMeaningfulLine = true;
|
|
1771
|
-
const indent = raw.length - raw.trimStart().length;
|
|
1772
|
-
if (indent % 2 !== 0) {
|
|
1773
|
-
return `.base YAML uses 2-space indentation (line ${lineNo}).`;
|
|
1774
|
-
}
|
|
1775
|
-
const isListItem = /^-\s+\S/.test(trimmed);
|
|
1776
|
-
const isMapping = /^[^:#][^:]*:\s*(?:.*)?$/.test(trimmed);
|
|
1777
|
-
if (!isListItem && !isMapping) {
|
|
1778
|
-
return `Invalid .base YAML structure on line ${lineNo}.`;
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
if (!sawMeaningfulLine) {
|
|
1782
|
-
return ".base files must contain at least one mapping entry.";
|
|
1783
|
-
}
|
|
1784
|
-
return null;
|
|
1785
|
-
}
|
|
1786
|
-
// Export for testing
|
|
1787
|
-
export { normalizeSection, findSection, isWriteAllowed, safePath, resolveContextTarget, validateBaseYamlSyntax, validateTodayContent, clearEntriesBefore, trimBulletEntries, parseEntryTimestamp, };
|
|
1640
|
+
// Path/permission helpers stay test-exported until PR 4 moves them into
|
|
1641
|
+
// `routes/context/{path-resolve,permissions}.ts`. The validator surface
|
|
1642
|
+
// previously exported here now lives in `core/context-validation/` and
|
|
1643
|
+
// is tested at its source.
|
|
1644
|
+
export { isWriteAllowed, safePath, resolveContextTarget };
|
|
1788
1645
|
//# sourceMappingURL=context.js.map
|