@aitne/daemon 0.1.3 → 0.1.6
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/notification-manager.d.ts +12 -0
- package/dist/adapters/notification-manager.d.ts.map +1 -1
- package/dist/adapters/notification-manager.js +39 -1
- package/dist/adapters/notification-manager.js.map +1 -1
- package/dist/adapters/whatsapp-adapter.d.ts.map +1 -1
- package/dist/adapters/whatsapp-adapter.js +0 -1
- package/dist/adapters/whatsapp-adapter.js.map +1 -1
- package/dist/api/integration-route-gate.d.ts +15 -11
- package/dist/api/integration-route-gate.d.ts.map +1 -1
- package/dist/api/integration-route-gate.js +60 -23
- package/dist/api/integration-route-gate.js.map +1 -1
- package/dist/api/json-body.d.ts +22 -7
- package/dist/api/json-body.d.ts.map +1 -1
- package/dist/api/json-body.js +27 -8
- package/dist/api/json-body.js.map +1 -1
- package/dist/api/routes/agent.d.ts.map +1 -1
- package/dist/api/routes/agent.js +25 -0
- package/dist/api/routes/agent.js.map +1 -1
- package/dist/api/routes/backends.d.ts.map +1 -1
- package/dist/api/routes/backends.js +96 -1
- package/dist/api/routes/backends.js.map +1 -1
- package/dist/api/routes/books.js +1 -1
- package/dist/api/routes/books.js.map +1 -1
- package/dist/api/routes/commands.d.ts.map +1 -1
- package/dist/api/routes/commands.js +16 -13
- package/dist/api/routes/commands.js.map +1 -1
- package/dist/api/routes/context.d.ts.map +1 -1
- package/dist/api/routes/context.js +26 -3
- package/dist/api/routes/context.js.map +1 -1
- package/dist/api/routes/dashboard.d.ts.map +1 -1
- package/dist/api/routes/dashboard.js +103 -5
- package/dist/api/routes/dashboard.js.map +1 -1
- package/dist/api/routes/fs.d.ts +23 -0
- package/dist/api/routes/fs.d.ts.map +1 -0
- package/dist/api/routes/fs.js +156 -0
- package/dist/api/routes/fs.js.map +1 -0
- package/dist/api/routes/fs.logic.d.ts +62 -0
- package/dist/api/routes/fs.logic.d.ts.map +1 -0
- package/dist/api/routes/fs.logic.js +137 -0
- package/dist/api/routes/fs.logic.js.map +1 -0
- package/dist/api/routes/github.d.ts.map +1 -1
- package/dist/api/routes/github.js +38 -5
- package/dist/api/routes/github.js.map +1 -1
- package/dist/api/routes/health.d.ts.map +1 -1
- package/dist/api/routes/health.js +4 -2
- package/dist/api/routes/health.js.map +1 -1
- package/dist/api/routes/integrations.d.ts +35 -6
- package/dist/api/routes/integrations.d.ts.map +1 -1
- package/dist/api/routes/integrations.js +192 -15
- package/dist/api/routes/integrations.js.map +1 -1
- package/dist/api/routes/mail.d.ts.map +1 -1
- package/dist/api/routes/mail.js +112 -46
- package/dist/api/routes/mail.js.map +1 -1
- package/dist/api/routes/metrics.d.ts +1 -0
- package/dist/api/routes/metrics.d.ts.map +1 -1
- package/dist/api/routes/metrics.js +24 -0
- package/dist/api/routes/metrics.js.map +1 -1
- package/dist/api/routes/observations.d.ts.map +1 -1
- package/dist/api/routes/observations.js +696 -30
- package/dist/api/routes/observations.js.map +1 -1
- package/dist/api/routes/setup-migrate.d.ts +9 -1
- package/dist/api/routes/setup-migrate.d.ts.map +1 -1
- package/dist/api/routes/setup-migrate.js +4 -2
- package/dist/api/routes/setup-migrate.js.map +1 -1
- package/dist/api/routes/skills.d.ts +9 -1
- package/dist/api/routes/skills.d.ts.map +1 -1
- package/dist/api/routes/skills.js +77 -17
- package/dist/api/routes/skills.js.map +1 -1
- package/dist/api/routes/voice.d.ts.map +1 -1
- package/dist/api/routes/voice.js +62 -4
- package/dist/api/routes/voice.js.map +1 -1
- package/dist/api/routes/wiki.d.ts +4 -0
- package/dist/api/routes/wiki.d.ts.map +1 -0
- package/dist/api/routes/wiki.js +1075 -0
- package/dist/api/routes/wiki.js.map +1 -0
- package/dist/api/server.d.ts +13 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +27 -1
- package/dist/api/server.js.map +1 -1
- package/dist/bootstrap/adapters.d.ts +109 -0
- package/dist/bootstrap/adapters.d.ts.map +1 -0
- package/dist/bootstrap/adapters.js +237 -0
- package/dist/bootstrap/adapters.js.map +1 -0
- package/dist/bootstrap/catchup.d.ts +23 -0
- package/dist/bootstrap/catchup.d.ts.map +1 -0
- package/dist/bootstrap/catchup.js +124 -0
- package/dist/bootstrap/catchup.js.map +1 -0
- package/dist/bootstrap/schedule-helpers.d.ts +18 -0
- package/dist/bootstrap/schedule-helpers.d.ts.map +1 -0
- package/dist/bootstrap/schedule-helpers.js +96 -0
- package/dist/bootstrap/schedule-helpers.js.map +1 -0
- package/dist/bootstrap/services.d.ts +60 -0
- package/dist/bootstrap/services.d.ts.map +1 -0
- package/dist/bootstrap/services.js +209 -0
- package/dist/bootstrap/services.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-core.d.ts +25 -0
- package/dist/core/agent-core.d.ts.map +1 -1
- package/dist/core/agent-core.js.map +1 -1
- package/dist/core/backends/backend-router.d.ts +28 -1
- package/dist/core/backends/backend-router.d.ts.map +1 -1
- package/dist/core/backends/backend-router.js +58 -4
- package/dist/core/backends/backend-router.js.map +1 -1
- package/dist/core/backends/claude-auth.d.ts +70 -0
- package/dist/core/backends/claude-auth.d.ts.map +1 -0
- package/dist/core/backends/claude-auth.js +198 -0
- package/dist/core/backends/claude-auth.js.map +1 -0
- package/dist/core/backends/claude-code-core.d.ts +47 -119
- package/dist/core/backends/claude-code-core.d.ts.map +1 -1
- package/dist/core/backends/claude-code-core.js +166 -1561
- package/dist/core/backends/claude-code-core.js.map +1 -1
- package/dist/core/backends/claude-delegated.d.ts +86 -0
- package/dist/core/backends/claude-delegated.d.ts.map +1 -0
- package/dist/core/backends/claude-delegated.js +801 -0
- package/dist/core/backends/claude-delegated.js.map +1 -0
- package/dist/core/backends/claude-errors.d.ts +39 -0
- package/dist/core/backends/claude-errors.d.ts.map +1 -0
- package/dist/core/backends/claude-errors.js +71 -0
- package/dist/core/backends/claude-errors.js.map +1 -0
- package/dist/core/backends/claude-probe.d.ts +103 -0
- package/dist/core/backends/claude-probe.d.ts.map +1 -0
- package/dist/core/backends/claude-probe.js +336 -0
- package/dist/core/backends/claude-probe.js.map +1 -0
- package/dist/core/backends/claude-tool-collection.d.ts +135 -0
- package/dist/core/backends/claude-tool-collection.d.ts.map +1 -0
- package/dist/core/backends/claude-tool-collection.js +1093 -0
- package/dist/core/backends/claude-tool-collection.js.map +1 -0
- package/dist/core/backends/codex-core.d.ts.map +1 -1
- package/dist/core/backends/codex-core.js +36 -0
- package/dist/core/backends/codex-core.js.map +1 -1
- package/dist/core/backends/gemini-cli-core.d.ts +45 -5
- package/dist/core/backends/gemini-cli-core.d.ts.map +1 -1
- package/dist/core/backends/gemini-cli-core.js +146 -36
- package/dist/core/backends/gemini-cli-core.js.map +1 -1
- package/dist/core/backends/plan-presets.d.ts +3 -1
- package/dist/core/backends/plan-presets.d.ts.map +1 -1
- package/dist/core/backends/plan-presets.js +42 -2
- package/dist/core/backends/plan-presets.js.map +1 -1
- package/dist/core/backends/prompt-utils.d.ts +1 -0
- package/dist/core/backends/prompt-utils.d.ts.map +1 -1
- package/dist/core/backends/prompt-utils.js +60 -3
- package/dist/core/backends/prompt-utils.js.map +1 -1
- package/dist/core/bang-commands/commands-help.d.ts +5 -0
- package/dist/core/bang-commands/commands-help.d.ts.map +1 -0
- package/dist/core/bang-commands/commands-help.js +69 -0
- package/dist/core/bang-commands/commands-help.js.map +1 -0
- package/dist/core/bang-commands/commands-wiki.d.ts +75 -0
- package/dist/core/bang-commands/commands-wiki.d.ts.map +1 -0
- package/dist/core/bang-commands/commands-wiki.js +574 -0
- package/dist/core/bang-commands/commands-wiki.js.map +1 -0
- package/dist/core/bang-commands/index.d.ts +4 -2
- package/dist/core/bang-commands/index.d.ts.map +1 -1
- package/dist/core/bang-commands/index.js +15 -1
- package/dist/core/bang-commands/index.js.map +1 -1
- package/dist/core/bang-commands/registry.d.ts +47 -4
- package/dist/core/bang-commands/registry.d.ts.map +1 -1
- package/dist/core/bang-commands/registry.js +85 -15
- package/dist/core/bang-commands/registry.js.map +1 -1
- package/dist/core/context-builder.d.ts +53 -12
- package/dist/core/context-builder.d.ts.map +1 -1
- package/dist/core/context-builder.js +240 -92
- package/dist/core/context-builder.js.map +1 -1
- package/dist/core/daemon-api-cli.d.ts.map +1 -1
- package/dist/core/daemon-api-cli.js +50 -2
- package/dist/core/daemon-api-cli.js.map +1 -1
- package/dist/core/dispatcher-date-utils.d.ts +49 -0
- package/dist/core/dispatcher-date-utils.d.ts.map +1 -0
- package/dist/core/dispatcher-date-utils.js +132 -0
- package/dist/core/dispatcher-date-utils.js.map +1 -0
- package/dist/core/dispatcher-error-handling.d.ts +159 -0
- package/dist/core/dispatcher-error-handling.d.ts.map +1 -0
- package/dist/core/dispatcher-error-handling.js +393 -0
- package/dist/core/dispatcher-error-handling.js.map +1 -0
- package/dist/core/dispatcher-hourly-check.d.ts +150 -0
- package/dist/core/dispatcher-hourly-check.d.ts.map +1 -0
- package/dist/core/dispatcher-hourly-check.js +665 -0
- package/dist/core/dispatcher-hourly-check.js.map +1 -0
- package/dist/core/dispatcher-message-handler.d.ts +170 -0
- package/dist/core/dispatcher-message-handler.d.ts.map +1 -0
- package/dist/core/dispatcher-message-handler.js +1064 -0
- package/dist/core/dispatcher-message-handler.js.map +1 -0
- package/dist/core/dispatcher-morning-routine.d.ts +169 -0
- package/dist/core/dispatcher-morning-routine.d.ts.map +1 -0
- package/dist/core/dispatcher-morning-routine.js +449 -0
- package/dist/core/dispatcher-morning-routine.js.map +1 -0
- package/dist/core/dispatcher-prompt.d.ts +107 -0
- package/dist/core/dispatcher-prompt.d.ts.map +1 -0
- package/dist/core/dispatcher-prompt.js +227 -0
- package/dist/core/dispatcher-prompt.js.map +1 -0
- package/dist/core/dispatcher-repository-helpers.d.ts +39 -0
- package/dist/core/dispatcher-repository-helpers.d.ts.map +1 -0
- package/dist/core/dispatcher-repository-helpers.js +86 -0
- package/dist/core/dispatcher-repository-helpers.js.map +1 -0
- package/dist/core/dispatcher-result-processor.d.ts +168 -0
- package/dist/core/dispatcher-result-processor.d.ts.map +1 -0
- package/dist/core/dispatcher-result-processor.js +533 -0
- package/dist/core/dispatcher-result-processor.js.map +1 -0
- package/dist/core/dispatcher-scheduled-tasks.d.ts +406 -0
- package/dist/core/dispatcher-scheduled-tasks.d.ts.map +1 -0
- package/dist/core/dispatcher-scheduled-tasks.js +1032 -0
- package/dist/core/dispatcher-scheduled-tasks.js.map +1 -0
- package/dist/core/dispatcher-types.d.ts +411 -0
- package/dist/core/dispatcher-types.d.ts.map +1 -0
- package/dist/core/dispatcher-types.js +106 -0
- package/dist/core/dispatcher-types.js.map +1 -0
- package/dist/core/dispatcher.d.ts +122 -610
- package/dist/core/dispatcher.d.ts.map +1 -1
- package/dist/core/dispatcher.js +365 -3521
- package/dist/core/dispatcher.js.map +1 -1
- package/dist/core/integration-health.d.ts +18 -10
- package/dist/core/integration-health.d.ts.map +1 -1
- package/dist/core/integration-health.js +31 -1
- package/dist/core/integration-health.js.map +1 -1
- package/dist/core/integration-lifecycle.d.ts +65 -0
- package/dist/core/integration-lifecycle.d.ts.map +1 -1
- package/dist/core/integration-lifecycle.js +163 -14
- package/dist/core/integration-lifecycle.js.map +1 -1
- package/dist/core/integration-main-backend.d.ts +40 -0
- package/dist/core/integration-main-backend.d.ts.map +1 -1
- package/dist/core/integration-main-backend.js +89 -2
- package/dist/core/integration-main-backend.js.map +1 -1
- package/dist/core/management-md.d.ts +51 -17
- package/dist/core/management-md.d.ts.map +1 -1
- package/dist/core/management-md.js +233 -56
- package/dist/core/management-md.js.map +1 -1
- package/dist/core/metrics.d.ts +127 -0
- package/dist/core/metrics.d.ts.map +1 -1
- package/dist/core/metrics.js +256 -1
- package/dist/core/metrics.js.map +1 -1
- package/dist/core/output-language-policy.d.ts +74 -0
- package/dist/core/output-language-policy.d.ts.map +1 -0
- package/dist/core/output-language-policy.js +194 -0
- package/dist/core/output-language-policy.js.map +1 -0
- package/dist/core/prompts.d.ts +3 -1
- package/dist/core/prompts.d.ts.map +1 -1
- package/dist/core/prompts.js +161 -3
- package/dist/core/prompts.js.map +1 -1
- package/dist/core/repository-management-docs.d.ts +24 -0
- package/dist/core/repository-management-docs.d.ts.map +1 -1
- package/dist/core/repository-management-docs.js +210 -26
- package/dist/core/repository-management-docs.js.map +1 -1
- package/dist/core/roadmap-validate.js +13 -1
- package/dist/core/roadmap-validate.js.map +1 -1
- package/dist/core/routine-acquisition-plan.d.ts +182 -0
- package/dist/core/routine-acquisition-plan.d.ts.map +1 -0
- package/dist/core/routine-acquisition-plan.js +367 -0
- package/dist/core/routine-acquisition-plan.js.map +1 -0
- package/dist/core/routine-fetch-window-retry.d.ts +109 -0
- package/dist/core/routine-fetch-window-retry.d.ts.map +1 -0
- package/dist/core/routine-fetch-window-retry.js +210 -0
- package/dist/core/routine-fetch-window-retry.js.map +1 -0
- package/dist/core/routine-fetch-window-runner.d.ts +427 -0
- package/dist/core/routine-fetch-window-runner.d.ts.map +1 -0
- package/dist/core/routine-fetch-window-runner.js +1591 -0
- package/dist/core/routine-fetch-window-runner.js.map +1 -0
- package/dist/core/routine-windows.d.ts +171 -0
- package/dist/core/routine-windows.d.ts.map +1 -0
- package/dist/core/routine-windows.js +377 -0
- package/dist/core/routine-windows.js.map +1 -0
- package/dist/core/scheduler.d.ts +50 -2
- package/dist/core/scheduler.d.ts.map +1 -1
- package/dist/core/scheduler.js +88 -7
- package/dist/core/scheduler.js.map +1 -1
- package/dist/core/skill-curation/declarations.d.ts.map +1 -1
- package/dist/core/skill-curation/declarations.js +11 -12
- package/dist/core/skill-curation/declarations.js.map +1 -1
- package/dist/core/skill-source-paths.d.ts +14 -0
- package/dist/core/skill-source-paths.d.ts.map +1 -0
- package/dist/core/skill-source-paths.js +82 -0
- package/dist/core/skill-source-paths.js.map +1 -0
- package/dist/core/skills-compiler.d.ts +29 -0
- package/dist/core/skills-compiler.d.ts.map +1 -1
- package/dist/core/skills-compiler.js +166 -30
- package/dist/core/skills-compiler.js.map +1 -1
- package/dist/core/skills-manifest.d.ts.map +1 -1
- package/dist/core/skills-manifest.js +72 -0
- package/dist/core/skills-manifest.js.map +1 -1
- package/dist/core/system-reset.d.ts +25 -0
- package/dist/core/system-reset.d.ts.map +1 -1
- package/dist/core/system-reset.js +72 -2
- package/dist/core/system-reset.js.map +1 -1
- package/dist/core/wiki/approval-queue.d.ts +31 -0
- package/dist/core/wiki/approval-queue.d.ts.map +1 -0
- package/dist/core/wiki/approval-queue.js +44 -0
- package/dist/core/wiki/approval-queue.js.map +1 -0
- package/dist/core/wiki/bridge.d.ts +74 -0
- package/dist/core/wiki/bridge.d.ts.map +1 -0
- package/dist/core/wiki/bridge.js +405 -0
- package/dist/core/wiki/bridge.js.map +1 -0
- package/dist/core/wiki/compile-lock.d.ts +42 -0
- package/dist/core/wiki/compile-lock.d.ts.map +1 -0
- package/dist/core/wiki/compile-lock.js +55 -0
- package/dist/core/wiki/compile-lock.js.map +1 -0
- package/dist/core/wiki/compile-preview.d.ts +8 -0
- package/dist/core/wiki/compile-preview.d.ts.map +1 -0
- package/dist/core/wiki/compile-preview.js +200 -0
- package/dist/core/wiki/compile-preview.js.map +1 -0
- package/dist/core/wiki/cost-estimate.d.ts +30 -0
- package/dist/core/wiki/cost-estimate.d.ts.map +1 -0
- package/dist/core/wiki/cost-estimate.js +243 -0
- package/dist/core/wiki/cost-estimate.js.map +1 -0
- package/dist/core/wiki/dispatcher.d.ts +48 -0
- package/dist/core/wiki/dispatcher.d.ts.map +1 -0
- package/dist/core/wiki/dispatcher.js +92 -0
- package/dist/core/wiki/dispatcher.js.map +1 -0
- package/dist/core/wiki/git-precompile.d.ts +86 -0
- package/dist/core/wiki/git-precompile.d.ts.map +1 -0
- package/dist/core/wiki/git-precompile.js +96 -0
- package/dist/core/wiki/git-precompile.js.map +1 -0
- package/dist/core/wiki/import-migrate.d.ts +38 -0
- package/dist/core/wiki/import-migrate.d.ts.map +1 -0
- package/dist/core/wiki/import-migrate.js +310 -0
- package/dist/core/wiki/import-migrate.js.map +1 -0
- package/dist/core/wiki/import-probe.d.ts +76 -0
- package/dist/core/wiki/import-probe.d.ts.map +1 -0
- package/dist/core/wiki/import-probe.js +245 -0
- package/dist/core/wiki/import-probe.js.map +1 -0
- package/dist/core/wiki/index-cache.d.ts +39 -0
- package/dist/core/wiki/index-cache.d.ts.map +1 -0
- package/dist/core/wiki/index-cache.js +152 -0
- package/dist/core/wiki/index-cache.js.map +1 -0
- package/dist/core/wiki/multi-url-dispatch.d.ts +52 -0
- package/dist/core/wiki/multi-url-dispatch.d.ts.map +1 -0
- package/dist/core/wiki/multi-url-dispatch.js +72 -0
- package/dist/core/wiki/multi-url-dispatch.js.map +1 -0
- package/dist/core/wiki/wiki-fts.d.ts +75 -0
- package/dist/core/wiki/wiki-fts.d.ts.map +1 -0
- package/dist/core/wiki/wiki-fts.js +265 -0
- package/dist/core/wiki/wiki-fts.js.map +1 -0
- package/dist/core/wiki/workspaces.d.ts +101 -0
- package/dist/core/wiki/workspaces.d.ts.map +1 -0
- package/dist/core/wiki/workspaces.js +352 -0
- package/dist/core/wiki/workspaces.js.map +1 -0
- package/dist/core/wiki/write-strategy.d.ts +70 -0
- package/dist/core/wiki/write-strategy.d.ts.map +1 -0
- package/dist/core/wiki/write-strategy.js +112 -0
- package/dist/core/wiki/write-strategy.js.map +1 -0
- package/dist/core/workdir.d.ts +8 -1
- package/dist/core/workdir.d.ts.map +1 -1
- package/dist/core/workdir.js +4 -1
- package/dist/core/workdir.js.map +1 -1
- package/dist/db/observations.d.ts +45 -2
- package/dist/db/observations.d.ts.map +1 -1
- package/dist/db/observations.js +112 -14
- package/dist/db/observations.js.map +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +135 -25
- package/dist/db/schema.js.map +1 -1
- package/dist/db/wiki-store.d.ts +3 -0
- package/dist/db/wiki-store.d.ts.map +1 -0
- package/dist/db/wiki-store.js +7 -0
- package/dist/db/wiki-store.js.map +1 -0
- package/dist/index.js +159 -610
- package/dist/index.js.map +1 -1
- package/dist/messaging/url-extract.d.ts +8 -0
- package/dist/messaging/url-extract.d.ts.map +1 -0
- package/dist/messaging/url-extract.js +41 -0
- package/dist/messaging/url-extract.js.map +1 -0
- package/dist/observers/delegated-sync-worker.d.ts +52 -1
- package/dist/observers/delegated-sync-worker.d.ts.map +1 -1
- package/dist/observers/delegated-sync-worker.js +75 -18
- package/dist/observers/delegated-sync-worker.js.map +1 -1
- package/dist/observers/imminent-event-scheduler.d.ts +20 -7
- package/dist/observers/imminent-event-scheduler.d.ts.map +1 -1
- package/dist/observers/imminent-event-scheduler.js +134 -29
- package/dist/observers/imminent-event-scheduler.js.map +1 -1
- package/dist/observers/mail-poller.d.ts +12 -5
- package/dist/observers/mail-poller.d.ts.map +1 -1
- package/dist/observers/mail-poller.js +36 -14
- package/dist/observers/mail-poller.js.map +1 -1
- package/dist/observers/manager.d.ts +37 -5
- package/dist/observers/manager.d.ts.map +1 -1
- package/dist/observers/manager.js +28 -10
- package/dist/observers/manager.js.map +1 -1
- package/dist/safety/always-disallowed.d.ts +65 -0
- package/dist/safety/always-disallowed.d.ts.map +1 -1
- package/dist/safety/always-disallowed.js +106 -10
- package/dist/safety/always-disallowed.js.map +1 -1
- package/dist/safety/audit.d.ts +46 -1
- package/dist/safety/audit.d.ts.map +1 -1
- package/dist/safety/audit.js +79 -16
- package/dist/safety/audit.js.map +1 -1
- package/dist/safety/risk-classifier.d.ts.map +1 -1
- package/dist/safety/risk-classifier.js +29 -0
- package/dist/safety/risk-classifier.js.map +1 -1
- package/dist/services/delegated-backend-invoker.d.ts +1 -51
- package/dist/services/delegated-backend-invoker.d.ts.map +1 -1
- package/dist/services/delegated-backend-invoker.js +41 -480
- package/dist/services/delegated-backend-invoker.js.map +1 -1
- package/dist/services/delegated-invoker-audit.d.ts +94 -0
- package/dist/services/delegated-invoker-audit.d.ts.map +1 -0
- package/dist/services/delegated-invoker-audit.js +238 -0
- package/dist/services/delegated-invoker-audit.js.map +1 -0
- package/dist/services/delegated-invoker-cache-hits.d.ts +34 -0
- package/dist/services/delegated-invoker-cache-hits.d.ts.map +1 -0
- package/dist/services/delegated-invoker-cache-hits.js +104 -0
- package/dist/services/delegated-invoker-cache-hits.js.map +1 -0
- package/dist/services/delegated-invoker-janitors.d.ts +28 -0
- package/dist/services/delegated-invoker-janitors.d.ts.map +1 -0
- package/dist/services/delegated-invoker-janitors.js +104 -0
- package/dist/services/delegated-invoker-janitors.js.map +1 -0
- package/dist/services/delegated-invoker-utils.d.ts +42 -0
- package/dist/services/delegated-invoker-utils.d.ts.map +1 -0
- package/dist/services/delegated-invoker-utils.js +100 -0
- package/dist/services/delegated-invoker-utils.js.map +1 -0
- package/dist/services/delegated-task-runtime.d.ts +1 -1
- package/dist/services/delegated-task-runtime.js +1 -1
- package/dist/services/integrations/snapshot-partitions.d.ts +5 -0
- package/dist/services/integrations/snapshot-partitions.d.ts.map +1 -1
- package/dist/services/integrations/snapshot-partitions.js +12 -0
- package/dist/services/integrations/snapshot-partitions.js.map +1 -1
- package/dist/services/voice/transcriber-impl.d.ts.map +1 -1
- package/dist/services/voice/transcriber-impl.js +7 -8
- package/dist/services/voice/transcriber-impl.js.map +1 -1
- package/dist/settings/runtime-settings.d.ts +12 -1
- package/dist/settings/runtime-settings.d.ts.map +1 -1
- package/dist/settings/runtime-settings.js +59 -1
- package/dist/settings/runtime-settings.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { estimateFullCompileCost } from "./cost-estimate.js";
|
|
4
|
+
/**
|
|
5
|
+
* WIKI_BUILDER_DESIGN.md §P4.B — pure-JS preview producer for
|
|
6
|
+
* `!compile --preview` (and `--dry-run` aliases). Surfaces what
|
|
7
|
+
* `wiki.compile` would touch before any agent session runs, so the
|
|
8
|
+
* operator can approve / reject from a DM reply or the dashboard.
|
|
9
|
+
*
|
|
10
|
+
* The compiler itself is an LLM session — its page-graph determination
|
|
11
|
+
* is opaque to pure code. The preview approximates the touch set with
|
|
12
|
+
* the only signal we have without running it:
|
|
13
|
+
*
|
|
14
|
+
* - Raw note `10_raw/<slug>.md` whose mtime is newer than the workspace
|
|
15
|
+
* `last_compile_at` is "pending"; older is "stale" (would be skipped
|
|
16
|
+
* in incremental mode, re-processed in full mode).
|
|
17
|
+
* - A pending raw whose stem matches an existing `20_wiki/<slug>.md` is
|
|
18
|
+
* "modified" (compiler likely updates the wiki page).
|
|
19
|
+
* - A pending raw with no matching wiki page is "added".
|
|
20
|
+
* - In full mode, every raw is pending and reuses the same classifier.
|
|
21
|
+
*
|
|
22
|
+
* This is intentionally fuzzy: the actual compile is allowed to override
|
|
23
|
+
* the classification (e.g. merge two raws into one wiki page). The
|
|
24
|
+
* preview's contract is "no surprises larger than this set", not "exactly
|
|
25
|
+
* this set". The §P4.B copy in WIKI_BUILDER_DESIGN.md states the same
|
|
26
|
+
* caveat — the dry-run is an upper-bound courtesy, not a commitment.
|
|
27
|
+
*
|
|
28
|
+
* Duration: estimated from the token total and a per-MTok throughput
|
|
29
|
+
* constant (`SECONDS_PER_MTOK_INPUT`). Sonnet at peak streams ~1.2k
|
|
30
|
+
* tokens/sec but compile sessions are tool-loop-bounded; the constant
|
|
31
|
+
* undershoots so the dashboard ETA isn't optimistic.
|
|
32
|
+
*/
|
|
33
|
+
// Sonnet 4.6 tool-loop steady-state in compile sessions runs ~5–8 minutes
|
|
34
|
+
// per million input tokens once the tool fan-out overhead is folded in.
|
|
35
|
+
// Stay on the pessimistic side so a "10-minute compile" never surprises
|
|
36
|
+
// the operator by taking 25.
|
|
37
|
+
const SECONDS_PER_MTOK_INPUT = 480;
|
|
38
|
+
export function buildCompilePreview(input) {
|
|
39
|
+
const rawDir = join(input.workspace.root_path, "10_raw");
|
|
40
|
+
const wikiDir = join(input.workspace.root_path, "20_wiki");
|
|
41
|
+
const rawFiles = listRawSlugs(rawDir);
|
|
42
|
+
const wikiSlugs = new Set(listWikiSlugs(wikiDir));
|
|
43
|
+
const lastCompileEpoch = parseEpoch(input.workspace.last_compile_at);
|
|
44
|
+
const added = [];
|
|
45
|
+
const modified = [];
|
|
46
|
+
const unchanged = [];
|
|
47
|
+
for (const raw of rawFiles) {
|
|
48
|
+
const isPending = input.mode === "full" ||
|
|
49
|
+
lastCompileEpoch === null ||
|
|
50
|
+
raw.mtimeEpoch > lastCompileEpoch;
|
|
51
|
+
if (!isPending) {
|
|
52
|
+
unchanged.push(`10_raw/${raw.relPath}`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (wikiSlugs.has(raw.slug)) {
|
|
56
|
+
modified.push(`20_wiki/${raw.slug}.md`);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
added.push(`20_wiki/${raw.slug}.md`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Wiki pages without a corresponding pending raw are reported under
|
|
63
|
+
// `unchanged` so the dashboard can render a "pages that will keep their
|
|
64
|
+
// current content" count next to "pages that will change".
|
|
65
|
+
const touchedSlugs = new Set();
|
|
66
|
+
for (const path of [...added, ...modified]) {
|
|
67
|
+
const m = path.match(/^20_wiki\/(.+)\.md$/);
|
|
68
|
+
if (m)
|
|
69
|
+
touchedSlugs.add(m[1]);
|
|
70
|
+
}
|
|
71
|
+
for (const slug of wikiSlugs) {
|
|
72
|
+
if (touchedSlugs.has(slug))
|
|
73
|
+
continue;
|
|
74
|
+
unchanged.push(`20_wiki/${slug}.md`);
|
|
75
|
+
}
|
|
76
|
+
// Reuse the canonical estimator so the preview, the dashboard banner,
|
|
77
|
+
// and the !compile-full approval gate quote identical numbers.
|
|
78
|
+
const estimate = estimateFullCompileCost(input.workspace);
|
|
79
|
+
// For incremental mode, scale the estimate to the pending-raw subset
|
|
80
|
+
// so the preview cost isn't full-rebuild cost. The 0.5×/2× brackets in
|
|
81
|
+
// `WikiCostEstimate` keep their meaning at the scaled magnitude.
|
|
82
|
+
const pendingCount = added.length + modified.length;
|
|
83
|
+
const scaledEstimate = input.mode === "full" || estimate.rawCount === 0
|
|
84
|
+
? estimate
|
|
85
|
+
: scaleEstimate(estimate, pendingCount);
|
|
86
|
+
const estimatedDurationSeconds = Math.ceil((scaledEstimate.estimatedInputTokens / 1_000_000) * SECONDS_PER_MTOK_INPUT);
|
|
87
|
+
return {
|
|
88
|
+
workspace: input.workspace.name,
|
|
89
|
+
mode: input.mode,
|
|
90
|
+
added: added.sort(),
|
|
91
|
+
modified: modified.sort(),
|
|
92
|
+
unchanged: unchanged.sort(),
|
|
93
|
+
estimate: scaledEstimate,
|
|
94
|
+
estimatedDurationSeconds,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function scaleEstimate(estimate, pendingCount) {
|
|
98
|
+
if (estimate.rawCount === 0)
|
|
99
|
+
return estimate;
|
|
100
|
+
const ratio = pendingCount / estimate.rawCount;
|
|
101
|
+
const scaledTokens = Math.round(estimate.estimatedInputTokens * ratio);
|
|
102
|
+
const expectedUsd = (scaledTokens / 1_000) * estimate.unitCostUsdPerKToken;
|
|
103
|
+
return {
|
|
104
|
+
...estimate,
|
|
105
|
+
rawCount: pendingCount,
|
|
106
|
+
estimatedInputTokens: scaledTokens,
|
|
107
|
+
optimisticUsd: round(expectedUsd * 0.5),
|
|
108
|
+
expectedUsd: round(expectedUsd),
|
|
109
|
+
pessimisticUsd: round(expectedUsd * 2),
|
|
110
|
+
exceedsThreshold: expectedUsd * 2 > estimate.thresholdUsd,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function listRawSlugs(rawDir) {
|
|
114
|
+
if (!existsSync(rawDir))
|
|
115
|
+
return [];
|
|
116
|
+
const out = [];
|
|
117
|
+
for (const entry of readdirSync(rawDir, { withFileTypes: true })) {
|
|
118
|
+
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
119
|
+
try {
|
|
120
|
+
const stat = statSync(join(rawDir, entry.name));
|
|
121
|
+
out.push({
|
|
122
|
+
relPath: entry.name,
|
|
123
|
+
slug: entry.name.slice(0, -3),
|
|
124
|
+
mtimeEpoch: stat.mtimeMs,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
/* skip */
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (entry.isDirectory() && entry.name === "images")
|
|
133
|
+
continue;
|
|
134
|
+
// Imported vaults may keep type-subdirs under 10_raw until migration;
|
|
135
|
+
// walk them so the preview is still useful pre-flatten. Slugs collide
|
|
136
|
+
// across subdirs are tolerated because the compiler treats each raw
|
|
137
|
+
// file independently — the rare duplicate is reported as `modified`
|
|
138
|
+
// twice, which is correct intent for the operator.
|
|
139
|
+
if (entry.isDirectory()) {
|
|
140
|
+
walkSubdir(join(rawDir, entry.name), entry.name, out);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
function walkSubdir(absDir, prefix, out) {
|
|
146
|
+
try {
|
|
147
|
+
for (const entry of readdirSync(absDir, { withFileTypes: true })) {
|
|
148
|
+
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
149
|
+
try {
|
|
150
|
+
const stat = statSync(join(absDir, entry.name));
|
|
151
|
+
out.push({
|
|
152
|
+
relPath: `${prefix}/${entry.name}`,
|
|
153
|
+
slug: entry.name.slice(0, -3),
|
|
154
|
+
mtimeEpoch: stat.mtimeMs,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
/* skip */
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (entry.isDirectory()) {
|
|
162
|
+
walkSubdir(join(absDir, entry.name), `${prefix}/${entry.name}`, out);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
/* skip unreadable directory */
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function listWikiSlugs(wikiDir) {
|
|
171
|
+
if (!existsSync(wikiDir))
|
|
172
|
+
return [];
|
|
173
|
+
const out = [];
|
|
174
|
+
for (const entry of readdirSync(wikiDir, { withFileTypes: true })) {
|
|
175
|
+
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
176
|
+
continue;
|
|
177
|
+
const slug = entry.name.slice(0, -3);
|
|
178
|
+
if (slug === "_index")
|
|
179
|
+
continue;
|
|
180
|
+
out.push(slug);
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
function parseEpoch(timestamp) {
|
|
185
|
+
if (!timestamp)
|
|
186
|
+
return null;
|
|
187
|
+
// SQLite emits `YYYY-MM-DD HH:MM:SS` from CURRENT_TIMESTAMP, which
|
|
188
|
+
// `new Date(...)` reads as local time in Node — but the value is UTC.
|
|
189
|
+
// Treat the space-separator shape explicitly so the comparison against
|
|
190
|
+
// `mtimeMs` (always UTC epoch) stays correct across operator timezones.
|
|
191
|
+
const isoCandidate = /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(timestamp)
|
|
192
|
+
? `${timestamp.replace(" ", "T")}Z`
|
|
193
|
+
: timestamp;
|
|
194
|
+
const epoch = Date.parse(isoCandidate);
|
|
195
|
+
return Number.isNaN(epoch) ? null : epoch;
|
|
196
|
+
}
|
|
197
|
+
function round(value) {
|
|
198
|
+
return Math.round(value * 1_000_000) / 1_000_000;
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=compile-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-preview.js","sourceRoot":"","sources":["../../../src/core/wiki/compile-preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;;;;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CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG;QACnC,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5C,CAAC;AAED,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { WikiCostEstimate } from "@aitne/shared";
|
|
2
|
+
import type { WikiWorkspaceRow } from "./workspaces.js";
|
|
3
|
+
export interface EstimateCompileOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Legacy override (P2.E): use a flat `avgInputTokensPerRaw` instead of
|
|
6
|
+
* the per-file char-based count. Retained for the dashboard's
|
|
7
|
+
* deterministic banner copy and the existing test suite. When set,
|
|
8
|
+
* disk reads are skipped — only the file count matters.
|
|
9
|
+
*/
|
|
10
|
+
avgInputTokensPerRaw?: number;
|
|
11
|
+
/** Override the per-1k-token cost the estimator uses. */
|
|
12
|
+
unitCostUsdPerKToken?: number;
|
|
13
|
+
/** Inject a raw count instead of scanning disk. */
|
|
14
|
+
rawCountOverride?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Cap the per-file breakdown list. The aggregate cost is unaffected.
|
|
17
|
+
* Default {@link PER_FILE_BREAKDOWN_LIMIT}; set 0 to omit the list.
|
|
18
|
+
*/
|
|
19
|
+
perFileBreakdownLimit?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function estimateFullCompileCost(workspace: Pick<WikiWorkspaceRow, "root_path" | "full_compile_approval_threshold_usd">, options?: EstimateCompileOptions): WikiCostEstimate;
|
|
22
|
+
/**
|
|
23
|
+
* Approximate token count from a Markdown body. Script-aware: majority-CJK
|
|
24
|
+
* content uses a denser divisor than Latin scripts because BPE merges
|
|
25
|
+
* fewer multi-byte sequences. The PER_FILE_MIN_TOKENS floor models the
|
|
26
|
+
* fixed per-call overhead the actual compile session pays regardless of
|
|
27
|
+
* input size (system prompt, skills bundle, tool descriptions).
|
|
28
|
+
*/
|
|
29
|
+
export declare function approxTokenCount(content: string): number;
|
|
30
|
+
//# sourceMappingURL=cost-estimate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-estimate.d.ts","sourceRoot":"","sources":["../../../src/core/wiki/cost-estimate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAqDxD,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yDAAyD;IACzD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,IAAI,CACb,gBAAgB,EAChB,WAAW,GAAG,qCAAqC,CACpD,EACD,OAAO,GAAE,sBAA2B,GACnC,gBAAgB,CAqFlB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAWxD"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Wiki compile cost estimator — WIKI_BUILDER_DESIGN.md §5.5, §P2.E, §P4.C.
|
|
5
|
+
*
|
|
6
|
+
* Pure JS (no agent session, no SDK call). The estimator opens each raw
|
|
7
|
+
* note, approximates its token count from on-disk content, then multiplies
|
|
8
|
+
* the total by the tier unit cost and brackets with 0.5×/2× multipliers.
|
|
9
|
+
* The dashboard banner and the bang-handler approval gate both read from
|
|
10
|
+
* this single source so the numbers cannot drift between UI and runtime.
|
|
11
|
+
*
|
|
12
|
+
* P2 originally shipped a flat-per-file heuristic (`rawCount × 1500`),
|
|
13
|
+
* which under-counted on long ingested articles and over-counted on
|
|
14
|
+
* one-line stubs. P4.C upgrades to a per-file char→token approximation
|
|
15
|
+
* (§P4.C in WIKI_BUILDER_DESIGN.md):
|
|
16
|
+
*
|
|
17
|
+
* - English / Latin scripts: ~4 chars per token (the well-known
|
|
18
|
+
* OpenAI rule-of-thumb; matches Anthropic's tokenizer within ±15%
|
|
19
|
+
* for prose; confirmed against the gpt-tokenizer dist).
|
|
20
|
+
* - CJK content: ~1.5 chars per token (BPE merges short CJK runs but
|
|
21
|
+
* not as aggressively as Latin word fragments).
|
|
22
|
+
*
|
|
23
|
+
* The classifier counts Unicode code points whose script is one of
|
|
24
|
+
* Han, Hiragana, Katakana, Hangul, Bopomofo. If the document is
|
|
25
|
+
* majority-CJK we apply the CJK divisor to the entire file; otherwise
|
|
26
|
+
* Latin. A per-script split would be more accurate but adds 30% code
|
|
27
|
+
* for a sub-percent gain on typical mixed-script files.
|
|
28
|
+
*
|
|
29
|
+
* Why not invoke `@huggingface/transformers`: loading the tokenizer
|
|
30
|
+
* model downloads ~50MB on first call and adds ~200ms to a route the
|
|
31
|
+
* dashboard polls. The 4-chars-per-token heuristic is within 10–20% of
|
|
32
|
+
* the true Anthropic count on prose and within 5% on CJK — well under
|
|
33
|
+
* the 0.5×/2× bracket the design already exposes. Keep the gate cheap.
|
|
34
|
+
*
|
|
35
|
+
* Why pure JS, not an agent pre-pass: spawning a separate session to
|
|
36
|
+
* compute the estimate would itself burn budget — and the estimate's
|
|
37
|
+
* purpose is to decide whether spawning the *real* session is okay.
|
|
38
|
+
*/
|
|
39
|
+
const DEFAULT_AVG_INPUT_TOKENS_PER_RAW = 1_500;
|
|
40
|
+
const DEFAULT_UNIT_COST_USD_PER_KTOKEN = 0.003; // Sonnet 4.6 input ~ $3 per Mtoken.
|
|
41
|
+
const LATIN_CHARS_PER_TOKEN = 4;
|
|
42
|
+
const CJK_CHARS_PER_TOKEN = 1.5;
|
|
43
|
+
// Heuristic floor — empty / one-line raw files still cost the per-call
|
|
44
|
+
// fixed overhead (system prompt, skills bundle, tool docs). 200 input
|
|
45
|
+
// tokens is the rough minimum a compile session needs even for a stub.
|
|
46
|
+
const PER_FILE_MIN_TOKENS = 200;
|
|
47
|
+
// Cap on per-file breakdown rows returned to the dashboard so a vault
|
|
48
|
+
// with thousands of raw files does not balloon the response payload.
|
|
49
|
+
const PER_FILE_BREAKDOWN_LIMIT = 20;
|
|
50
|
+
const OPTIMISTIC_MULT = 0.5;
|
|
51
|
+
const PESSIMISTIC_MULT = 2.0;
|
|
52
|
+
export function estimateFullCompileCost(workspace, options = {}) {
|
|
53
|
+
const unitCost = options.unitCostUsdPerKToken ?? DEFAULT_UNIT_COST_USD_PER_KTOKEN;
|
|
54
|
+
const threshold = workspace.full_compile_approval_threshold_usd;
|
|
55
|
+
// Legacy flat-heuristic branch — preserved for existing P2 tests and
|
|
56
|
+
// any caller that explicitly opts into the cheap mode.
|
|
57
|
+
if (options.avgInputTokensPerRaw !== undefined) {
|
|
58
|
+
const rawCount = options.rawCountOverride ?? countRawNotes(join(workspace.root_path, "10_raw"));
|
|
59
|
+
const estimatedInputTokens = Math.max(0, rawCount * options.avgInputTokensPerRaw);
|
|
60
|
+
const expectedUsd = (estimatedInputTokens / 1_000) * unitCost;
|
|
61
|
+
return {
|
|
62
|
+
rawCount,
|
|
63
|
+
estimatedInputTokens,
|
|
64
|
+
unitCostUsdPerKToken: unitCost,
|
|
65
|
+
optimisticUsd: round(expectedUsd * OPTIMISTIC_MULT),
|
|
66
|
+
expectedUsd: round(expectedUsd),
|
|
67
|
+
pessimisticUsd: round(expectedUsd * PESSIMISTIC_MULT),
|
|
68
|
+
thresholdUsd: threshold,
|
|
69
|
+
exceedsThreshold: expectedUsd * PESSIMISTIC_MULT > threshold,
|
|
70
|
+
method: "flat-heuristic",
|
|
71
|
+
perFile: [],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// P4.C — per-file token estimate. Walk the raw layer, sum tokens.
|
|
75
|
+
const breakdownLimit = options.perFileBreakdownLimit ?? PER_FILE_BREAKDOWN_LIMIT;
|
|
76
|
+
const rawDir = join(workspace.root_path, "10_raw");
|
|
77
|
+
let estimatedInputTokens = 0;
|
|
78
|
+
let rawCount = 0;
|
|
79
|
+
const perFile = [];
|
|
80
|
+
if (existsSync(rawDir)) {
|
|
81
|
+
for (const rel of walkRawLayer(rawDir)) {
|
|
82
|
+
const full = join(rawDir, rel);
|
|
83
|
+
let charCount = 0;
|
|
84
|
+
let tokenCount = PER_FILE_MIN_TOKENS;
|
|
85
|
+
try {
|
|
86
|
+
const stat = statSync(full);
|
|
87
|
+
if (!stat.isFile())
|
|
88
|
+
continue;
|
|
89
|
+
const content = readFileSync(full, "utf-8");
|
|
90
|
+
charCount = content.length;
|
|
91
|
+
tokenCount = approxTokenCount(content);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Unreadable file — still account for fixed-overhead minimum so the
|
|
95
|
+
// estimate is not silently 0.
|
|
96
|
+
}
|
|
97
|
+
rawCount += 1;
|
|
98
|
+
estimatedInputTokens += tokenCount;
|
|
99
|
+
perFile.push({ path: `10_raw/${rel}`, charCount, estimatedTokens: tokenCount });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Honour `rawCountOverride` for the deterministic test path. The
|
|
103
|
+
// override semantically asks "what would the estimate look like for N
|
|
104
|
+
// files?" so we also override the token total — keeping the per-file
|
|
105
|
+
// breakdown produces an incoherent answer where `rawCount` doesn't
|
|
106
|
+
// match the breakdown length. Callers that want disk-accurate numbers
|
|
107
|
+
// simply omit the override.
|
|
108
|
+
if (options.rawCountOverride !== undefined) {
|
|
109
|
+
rawCount = options.rawCountOverride;
|
|
110
|
+
estimatedInputTokens = rawCount * DEFAULT_AVG_INPUT_TOKENS_PER_RAW;
|
|
111
|
+
perFile.length = 0;
|
|
112
|
+
}
|
|
113
|
+
// Sort breakdown by descending cost contribution so the dashboard shows
|
|
114
|
+
// the biggest files first (where the operator's attention should land).
|
|
115
|
+
perFile.sort((a, b) => b.estimatedTokens - a.estimatedTokens);
|
|
116
|
+
const trimmedPerFile = breakdownLimit > 0 ? perFile.slice(0, breakdownLimit) : [];
|
|
117
|
+
const expectedUsd = (estimatedInputTokens / 1_000) * unitCost;
|
|
118
|
+
const optimisticUsd = expectedUsd * OPTIMISTIC_MULT;
|
|
119
|
+
const pessimisticUsd = expectedUsd * PESSIMISTIC_MULT;
|
|
120
|
+
return {
|
|
121
|
+
rawCount,
|
|
122
|
+
estimatedInputTokens,
|
|
123
|
+
unitCostUsdPerKToken: unitCost,
|
|
124
|
+
optimisticUsd: round(optimisticUsd),
|
|
125
|
+
expectedUsd: round(expectedUsd),
|
|
126
|
+
pessimisticUsd: round(pessimisticUsd),
|
|
127
|
+
thresholdUsd: threshold,
|
|
128
|
+
exceedsThreshold: pessimisticUsd > threshold,
|
|
129
|
+
method: "per-file-chars",
|
|
130
|
+
perFile: trimmedPerFile,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Approximate token count from a Markdown body. Script-aware: majority-CJK
|
|
135
|
+
* content uses a denser divisor than Latin scripts because BPE merges
|
|
136
|
+
* fewer multi-byte sequences. The PER_FILE_MIN_TOKENS floor models the
|
|
137
|
+
* fixed per-call overhead the actual compile session pays regardless of
|
|
138
|
+
* input size (system prompt, skills bundle, tool descriptions).
|
|
139
|
+
*/
|
|
140
|
+
export function approxTokenCount(content) {
|
|
141
|
+
if (content.length === 0)
|
|
142
|
+
return PER_FILE_MIN_TOKENS;
|
|
143
|
+
let cjkChars = 0;
|
|
144
|
+
for (const ch of content) {
|
|
145
|
+
if (isCjkChar(ch))
|
|
146
|
+
cjkChars += 1;
|
|
147
|
+
}
|
|
148
|
+
const totalCodepoints = [...content].length;
|
|
149
|
+
const cjkRatio = totalCodepoints === 0 ? 0 : cjkChars / totalCodepoints;
|
|
150
|
+
const divisor = cjkRatio > 0.5 ? CJK_CHARS_PER_TOKEN : LATIN_CHARS_PER_TOKEN;
|
|
151
|
+
const tokens = Math.ceil(content.length / divisor);
|
|
152
|
+
return Math.max(PER_FILE_MIN_TOKENS, tokens);
|
|
153
|
+
}
|
|
154
|
+
function isCjkChar(ch) {
|
|
155
|
+
const cp = ch.codePointAt(0);
|
|
156
|
+
if (cp === undefined)
|
|
157
|
+
return false;
|
|
158
|
+
// U+3040–U+309F Hiragana, U+30A0–U+30FF Katakana,
|
|
159
|
+
// U+3400–U+4DBF / U+4E00–U+9FFF Han (CJK Unified Ideographs),
|
|
160
|
+
// U+AC00–U+D7AF Hangul Syllables, U+3100–U+312F Bopomofo.
|
|
161
|
+
return ((cp >= 0x3040 && cp <= 0x30ff) ||
|
|
162
|
+
(cp >= 0x3400 && cp <= 0x4dbf) ||
|
|
163
|
+
(cp >= 0x4e00 && cp <= 0x9fff) ||
|
|
164
|
+
(cp >= 0xac00 && cp <= 0xd7af) ||
|
|
165
|
+
(cp >= 0x3100 && cp <= 0x312f));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Walk `10_raw/` returning markdown leaves (root + recursive fallback for
|
|
169
|
+
* not-yet-flattened imported vaults — see {@link countRawNotes}). The
|
|
170
|
+
* `images/` subtree is skipped per §2.4 invariant.
|
|
171
|
+
*/
|
|
172
|
+
function walkRawLayer(rawDir) {
|
|
173
|
+
const out = [];
|
|
174
|
+
for (const entry of readdirSync(rawDir, { withFileTypes: true })) {
|
|
175
|
+
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
176
|
+
out.push(entry.name);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (entry.isDirectory() && entry.name === "images")
|
|
180
|
+
continue;
|
|
181
|
+
if (entry.isDirectory()) {
|
|
182
|
+
walkDirInto(join(rawDir, entry.name), entry.name, out);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
function walkDirInto(absDir, relPrefix, out) {
|
|
188
|
+
try {
|
|
189
|
+
for (const entry of readdirSync(absDir, { withFileTypes: true })) {
|
|
190
|
+
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
191
|
+
out.push(`${relPrefix}/${entry.name}`);
|
|
192
|
+
}
|
|
193
|
+
else if (entry.isDirectory()) {
|
|
194
|
+
walkDirInto(join(absDir, entry.name), `${relPrefix}/${entry.name}`, out);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
/* skip unreadable directory */
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function countRawNotes(rawDir) {
|
|
203
|
+
if (!existsSync(rawDir))
|
|
204
|
+
return 0;
|
|
205
|
+
let count = 0;
|
|
206
|
+
for (const entry of readdirSync(rawDir, { withFileTypes: true })) {
|
|
207
|
+
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
208
|
+
count += 1;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (entry.isDirectory() && entry.name === "images")
|
|
212
|
+
continue;
|
|
213
|
+
if (entry.isDirectory()) {
|
|
214
|
+
const full = join(rawDir, entry.name);
|
|
215
|
+
try {
|
|
216
|
+
const stat = statSync(full);
|
|
217
|
+
if (stat.isDirectory()) {
|
|
218
|
+
count += countMarkdownRecursive(full);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
/* skip unreadable directory */
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return count;
|
|
227
|
+
}
|
|
228
|
+
function countMarkdownRecursive(dir) {
|
|
229
|
+
let count = 0;
|
|
230
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
231
|
+
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
232
|
+
count += 1;
|
|
233
|
+
}
|
|
234
|
+
else if (entry.isDirectory()) {
|
|
235
|
+
count += countMarkdownRecursive(join(dir, entry.name));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return count;
|
|
239
|
+
}
|
|
240
|
+
function round(value) {
|
|
241
|
+
return Math.round(value * 1_000_000) / 1_000_000;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=cost-estimate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-estimate.js","sourceRoot":"","sources":["../../../src/core/wiki/cost-estimate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAC/C,MAAM,gCAAgC,GAAG,KAAK,CAAC,CAAC,oCAAoC;AACpF,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,uEAAuE;AACvE,sEAAsE;AACtE,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,sEAAsE;AACtE,qEAAqE;AACrE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAqB7B,MAAM,UAAU,uBAAuB,CACrC,SAGC,EACD,UAAkC,EAAE;IAEpC,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,IAAI,gCAAgC,CAAC;IAClF,MAAM,SAAS,GAAG,SA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,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC5B,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACvB,KAAK,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,+BAA+B;YACjC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAW;IACzC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC9D,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,KAAK,IAAI,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/B,KAAK,IAAI,sBAAsB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Event, type WikiReplyTarget } from "@aitne/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Every wiki-tier process key the daemon dispatches. Kept ordered by
|
|
4
|
+
* Phase (P1 ingest/compile/ask, P3 operational triad lint/trace/connect)
|
|
5
|
+
* so a quick visual scan tells you which surfaces ship in which phase.
|
|
6
|
+
*/
|
|
7
|
+
export declare const WIKI_PROCESS_KEYS: readonly ["wiki.ingest_url", "wiki.compile", "wiki.ask", "wiki.lint", "wiki.trace", "wiki.connect"];
|
|
8
|
+
/** Back-compat alias for the P1 surface. Prefer {@link WIKI_PROCESS_KEYS}. */
|
|
9
|
+
export declare const WIKI_P1_PROCESS_KEYS: readonly ["wiki.ingest_url", "wiki.compile", "wiki.ask", "wiki.lint", "wiki.trace", "wiki.connect"];
|
|
10
|
+
export type WikiProcessKey = (typeof WIKI_PROCESS_KEYS)[number];
|
|
11
|
+
/** @deprecated use {@link WikiProcessKey}. */
|
|
12
|
+
export type WikiP1ProcessKey = WikiProcessKey;
|
|
13
|
+
export declare function isWikiProcessKey(value: string): value is WikiProcessKey;
|
|
14
|
+
export interface WikiCommandEventInput {
|
|
15
|
+
processKey: WikiProcessKey;
|
|
16
|
+
workspace: string;
|
|
17
|
+
sourceEvent?: Event;
|
|
18
|
+
batchId?: string;
|
|
19
|
+
data?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createWikiCommandEvent(input: WikiCommandEventInput): Event;
|
|
22
|
+
/**
|
|
23
|
+
* Pure helper — read the reply-routing tuple stored on `event.data.reply_target`.
|
|
24
|
+
*
|
|
25
|
+
* Despite the `WikiReplyTarget` type name (kept for historical reasons —
|
|
26
|
+
* the schema first shipped with the wiki subsystem), the helper is
|
|
27
|
+
* type-agnostic: it reads the same `data.reply_target` field that
|
|
28
|
+
* `createWikiCommandEvent` puts on wiki.* events AND that `scheduler.ts`
|
|
29
|
+
* lifts onto `scheduled.task` events from approval rows
|
|
30
|
+
* (WIKI_BUILDER_DESIGN.md §3.4-bis). Callers in `ResultProcessor` use it
|
|
31
|
+
* to decide between direct reply (`NotificationManager.send({ replyTo })`)
|
|
32
|
+
* and proactive fan-out to the user's primary destinations.
|
|
33
|
+
*
|
|
34
|
+
* Returns null when:
|
|
35
|
+
* - the event has no `data.reply_target` field (cron/routine event,
|
|
36
|
+
* or wiki event minted without a sourceEvent), or
|
|
37
|
+
* - the field shape is corrupt (defensive — a daemon downgrade reading
|
|
38
|
+
* a payload from a future schema version).
|
|
39
|
+
*
|
|
40
|
+
* `readWikiReplyTarget` is exported as a back-compat alias so older
|
|
41
|
+
* external consumers keep working; new code should prefer
|
|
42
|
+
* `readEventReplyTarget`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readEventReplyTarget(event: Event): WikiReplyTarget | null;
|
|
45
|
+
/** @deprecated Renamed to {@link readEventReplyTarget} — kept as an
|
|
46
|
+
* alias to avoid breaking external callers during the rename window. */
|
|
47
|
+
export declare const readWikiReplyTarget: typeof readEventReplyTarget;
|
|
48
|
+
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../../src/core/wiki/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACV,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,qGAOpB,CAAC;AAEX,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,qGAAoB,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,8CAA8C;AAC9C,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE9C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAEvE;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,cAAc,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,KAAK,CAwC1E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAKzE;AAED;yEACyE;AACzE,eAAO,MAAM,mBAAmB,6BAAuB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { EventPriority, createEvent, isMessageEvent, wikiReplyTargetSchema, } from "@aitne/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Every wiki-tier process key the daemon dispatches. Kept ordered by
|
|
4
|
+
* Phase (P1 ingest/compile/ask, P3 operational triad lint/trace/connect)
|
|
5
|
+
* so a quick visual scan tells you which surfaces ship in which phase.
|
|
6
|
+
*/
|
|
7
|
+
export const WIKI_PROCESS_KEYS = [
|
|
8
|
+
"wiki.ingest_url",
|
|
9
|
+
"wiki.compile",
|
|
10
|
+
"wiki.ask",
|
|
11
|
+
"wiki.lint",
|
|
12
|
+
"wiki.trace",
|
|
13
|
+
"wiki.connect",
|
|
14
|
+
];
|
|
15
|
+
/** Back-compat alias for the P1 surface. Prefer {@link WIKI_PROCESS_KEYS}. */
|
|
16
|
+
export const WIKI_P1_PROCESS_KEYS = WIKI_PROCESS_KEYS;
|
|
17
|
+
export function isWikiProcessKey(value) {
|
|
18
|
+
return WIKI_PROCESS_KEYS.includes(value);
|
|
19
|
+
}
|
|
20
|
+
export function createWikiCommandEvent(input) {
|
|
21
|
+
// WIKI_BUILDER_DESIGN.md §3.4 — derive the reply routing tuple from the
|
|
22
|
+
// originating MessageEvent so the per-URL completion DMs from
|
|
23
|
+
// wiki.ingest_url (and the answer/report/log DMs from the other wiki
|
|
24
|
+
// process keys) land back on the same channel the operator used to
|
|
25
|
+
// run the bang command. When the source is not a MessageEvent
|
|
26
|
+
// (currently unreachable — wiki events spawn only from `!ingest` /
|
|
27
|
+
// `!compile` / `!ask` / ... which are all DMs — but future routine
|
|
28
|
+
// entry points might exist), `reply_target` is omitted and the
|
|
29
|
+
// ResultProcessor falls back to the user's configured destinations
|
|
30
|
+
// via `MessageHub.sendToUser`.
|
|
31
|
+
const replyTarget = input.sourceEvent && isMessageEvent(input.sourceEvent)
|
|
32
|
+
? {
|
|
33
|
+
platform: input.sourceEvent.platform,
|
|
34
|
+
channel: input.sourceEvent.channel,
|
|
35
|
+
threadId: input.sourceEvent.threadId,
|
|
36
|
+
sender: input.sourceEvent.sender,
|
|
37
|
+
}
|
|
38
|
+
: undefined;
|
|
39
|
+
// Spread order matters: `input.data` is caller-supplied (the bang
|
|
40
|
+
// handler's per-key payload like `{ url }` for ingest_url or
|
|
41
|
+
// `{ topic }` for trace) and MUST NOT be allowed to override
|
|
42
|
+
// daemon-controlled routing/audit fields. A bang handler that
|
|
43
|
+
// accidentally (or maliciously, in a future plugin surface) put
|
|
44
|
+
// `reply_target` or `batch_id` in `data` would otherwise hijack the
|
|
45
|
+
// event. Daemon fields therefore come AFTER `input.data` so they
|
|
46
|
+
// win the spread conflict.
|
|
47
|
+
return createEvent({
|
|
48
|
+
type: input.processKey,
|
|
49
|
+
source: "wiki.bang",
|
|
50
|
+
priority: EventPriority.HIGH,
|
|
51
|
+
data: {
|
|
52
|
+
...(input.data ?? {}),
|
|
53
|
+
workspace: input.workspace,
|
|
54
|
+
...(input.batchId ? { batch_id: input.batchId } : {}),
|
|
55
|
+
...(input.sourceEvent ? { parent_correlation_id: input.sourceEvent.correlationId } : {}),
|
|
56
|
+
...(replyTarget ? { reply_target: replyTarget } : {}),
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Pure helper — read the reply-routing tuple stored on `event.data.reply_target`.
|
|
62
|
+
*
|
|
63
|
+
* Despite the `WikiReplyTarget` type name (kept for historical reasons —
|
|
64
|
+
* the schema first shipped with the wiki subsystem), the helper is
|
|
65
|
+
* type-agnostic: it reads the same `data.reply_target` field that
|
|
66
|
+
* `createWikiCommandEvent` puts on wiki.* events AND that `scheduler.ts`
|
|
67
|
+
* lifts onto `scheduled.task` events from approval rows
|
|
68
|
+
* (WIKI_BUILDER_DESIGN.md §3.4-bis). Callers in `ResultProcessor` use it
|
|
69
|
+
* to decide between direct reply (`NotificationManager.send({ replyTo })`)
|
|
70
|
+
* and proactive fan-out to the user's primary destinations.
|
|
71
|
+
*
|
|
72
|
+
* Returns null when:
|
|
73
|
+
* - the event has no `data.reply_target` field (cron/routine event,
|
|
74
|
+
* or wiki event minted without a sourceEvent), or
|
|
75
|
+
* - the field shape is corrupt (defensive — a daemon downgrade reading
|
|
76
|
+
* a payload from a future schema version).
|
|
77
|
+
*
|
|
78
|
+
* `readWikiReplyTarget` is exported as a back-compat alias so older
|
|
79
|
+
* external consumers keep working; new code should prefer
|
|
80
|
+
* `readEventReplyTarget`.
|
|
81
|
+
*/
|
|
82
|
+
export function readEventReplyTarget(event) {
|
|
83
|
+
const raw = event.data?.reply_target;
|
|
84
|
+
if (!raw)
|
|
85
|
+
return null;
|
|
86
|
+
const parsed = wikiReplyTargetSchema.safeParse(raw);
|
|
87
|
+
return parsed.success ? parsed.data : null;
|
|
88
|
+
}
|
|
89
|
+
/** @deprecated Renamed to {@link readEventReplyTarget} — kept as an
|
|
90
|
+
* alias to avoid breaking external callers during the rename window. */
|
|
91
|
+
export const readWikiReplyTarget = readEventReplyTarget;
|
|
92
|
+
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../../src/core/wiki/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,cAAc,EACd,qBAAqB,GAGtB,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,iBAAiB;IACjB,cAAc;IACd,UAAU;IACV,WAAW;IACX,YAAY;IACZ,cAAc;CACN,CAAC;AAEX,8EAA8E;AAC9E,MAAM,CAAC,MAAM,oBAAoB,G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