@rubytech/create-sitedesk-code 0.1.386 → 0.1.388
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/__tests__/cron-heartbeat-registration.test.js +5 -0
- package/dist/cron-registration.js +1 -0
- package/dist/index.js +4 -0
- package/package.json +1 -1
- package/payload/platform/config/brand.json +3 -3
- package/payload/platform/neo4j/schema.cypher +36 -1
- package/payload/platform/plugins/.claude-plugin/marketplace.json +5 -5
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +61 -1
- package/payload/platform/plugins/docs/references/graph.md +11 -0
- package/payload/platform/plugins/docs/references/plugins-guide.md +1 -0
- package/payload/platform/plugins/docs/references/sweep-guide.md +43 -0
- package/payload/platform/plugins/memory/references/schema-estate-agent.md +34 -0
- package/payload/platform/plugins/scheduling/PLUGIN.md +17 -1
- package/payload/platform/plugins/scheduling/mcp/dist/index.js +12 -0
- package/payload/platform/plugins/scheduling/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/agent-dispatch.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/agent-dispatch.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/agent-dispatch.test.js +101 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/agent-dispatch.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/agent-dispatch.d.ts +54 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/agent-dispatch.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/agent-dispatch.js +117 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/agent-dispatch.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-classify.d.ts +7 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-classify.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-classify.js +6 -3
- package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-classify.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/agent-turn-dispatch.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/agent-turn-dispatch.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/agent-turn-dispatch.test.js +88 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/agent-turn-dispatch.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/standing-audit.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/standing-audit.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/standing-audit.test.js +77 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/standing-audit.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.d.ts +59 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.js +131 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js +62 -15
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-event-agent.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-event-agent.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-event-agent.test.js +110 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-event-agent.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-agent.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-agent.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-agent.test.js +35 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-agent.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-update-agent.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-update-agent.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-update-agent.test.js +81 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-update-agent.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.d.ts +7 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.js +21 -4
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.d.ts +4 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.js +6 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.d.ts +2 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.js +32 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.js.map +1 -1
- package/payload/platform/plugins/sweep/.claude-plugin/plugin.json +8 -0
- package/payload/platform/plugins/sweep/PLUGIN.md +15 -0
- package/payload/platform/plugins/sweep/skills/sweep-workflow/SKILL.md +113 -0
- package/payload/platform/plugins/whatsapp/PLUGIN.md +1 -1
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js +19 -4
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +9 -4
- package/payload/platform/plugins/whatsapp/skills/manage-whatsapp-config/SKILL.md +12 -0
- package/payload/platform/scripts/seed-neo4j.sh +38 -0
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts +5 -0
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/server.js +1 -1
- package/payload/platform/services/whatsapp-channel/dist/server.js.map +1 -1
- package/payload/premium-plugins/.claude-plugin/marketplace.json +0 -15
- package/payload/server/public/assets/{AdminLoginScreens-oxqHKL3C.js → AdminLoginScreens-BejIjbmU.js} +1 -1
- package/payload/server/public/assets/{AdminShell-DBD6ruS1.js → AdminShell-D2-uBSB5.js} +1 -1
- package/payload/server/public/assets/{Checkbox-yr8-ftrE.js → Checkbox-1F1tzqca.js} +1 -1
- package/payload/server/public/assets/Transcript-DkGa4CQH.js +2 -0
- package/payload/server/public/assets/{admin-CQfZnuFy.js → admin-DqQARkjy.js} +1 -1
- package/payload/server/public/assets/{browser-DbdPeDK1.js → browser-nDtEK6RC.js} +1 -1
- package/payload/server/public/assets/{calendar-CFdOhe7Q.js → calendar-CO4Bwmho.js} +1 -1
- package/payload/server/public/assets/chat-DeIge_bC.js +1 -0
- package/payload/server/public/assets/chevron-left-DhVdq0aN.js +1 -0
- package/payload/server/public/assets/data-B1GIdzHk.js +1 -0
- package/payload/server/public/assets/{graph-Bluocsf_.js → graph-DFyicKd7.js} +1 -1
- package/payload/server/public/assets/{graph-labels-BcLJmY-v.js → graph-labels-D3BQdcpD.js} +1 -1
- package/payload/server/public/assets/{operator-DjK3MBSS.js → operator-BxrjWdT9.js} +1 -1
- package/payload/server/public/assets/{page-DQNYTb2d.js → page-ByDLq_o1.js} +1 -1
- package/payload/server/public/assets/{page-zJQTRXB2.js → page-D-Ep4bXd.js} +1 -1
- package/payload/server/public/assets/{public-CHCniosp.js → public-DbdqfdYq.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-JDfwjfIL.js → rotate-ccw-BkX8HODe.js} +1 -1
- package/payload/server/public/assets/{useSubAccountSwitcher-CfI3J2IX.css → useSubAccountSwitcher-DS0iqSkP.css} +1 -1
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +5 -5
- package/payload/server/public/chat.html +8 -8
- package/payload/server/public/data.html +7 -7
- package/payload/server/public/graph.html +8 -8
- package/payload/server/public/index.html +10 -10
- package/payload/server/public/operator.html +10 -10
- package/payload/server/public/public.html +8 -8
- package/payload/server/server.js +713 -331
- package/payload/platform/plugins/sales/.claude-plugin/plugin.json +0 -8
- package/payload/platform/plugins/sales/PLUGIN.md +0 -106
- package/payload/platform/plugins/sales/references/close-tracking.md +0 -69
- package/payload/platform/plugins/sales/references/comparisons.md +0 -99
- package/payload/platform/plugins/sales/references/competitive-positioning.md +0 -51
- package/payload/platform/plugins/sales/references/faq.md +0 -73
- package/payload/platform/plugins/sales/references/objection-handling.md +0 -157
- package/payload/platform/plugins/sales/references/pricing.md +0 -101
- package/payload/premium-plugins/teaching/.claude-plugin/plugin.json +0 -8
- package/payload/premium-plugins/teaching/PLUGIN.md +0 -58
- package/payload/premium-plugins/teaching/skills/interactive-tutor/SKILL.md +0 -59
- package/payload/premium-plugins/teaching/skills/interactive-tutor/references/assessment.md +0 -70
- package/payload/premium-plugins/teaching/skills/interactive-tutor/references/classroom-conduct.md +0 -43
- package/payload/premium-plugins/teaching/skills/interactive-tutor/references/teaching-modes.md +0 -83
- package/payload/premium-plugins/teaching/skills/lesson-planner/SKILL.md +0 -48
- package/payload/premium-plugins/teaching/skills/lesson-planner/references/context-gathering.md +0 -41
- package/payload/premium-plugins/teaching/skills/lesson-planner/references/plan-structure.md +0 -94
- package/payload/premium-plugins/teaching/skills/study-pack-builder/SKILL.md +0 -52
- package/payload/premium-plugins/teaching/skills/study-pack-builder/references/disaggregation.md +0 -49
- package/payload/premium-plugins/teaching/skills/study-pack-builder/references/materials.md +0 -116
- package/payload/premium-plugins/venture-studio/.claude-plugin/plugin.json +0 -8
- package/payload/premium-plugins/venture-studio/PLUGIN.md +0 -128
- package/payload/premium-plugins/venture-studio/bin/scaffold.sh +0 -116
- package/payload/premium-plugins/venture-studio/skills/brand-pack/SKILL.md +0 -256
- package/payload/premium-plugins/venture-studio/skills/brand-pack/references/color-psychology.md +0 -118
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/SKILL.md +0 -436
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/business-plan-template.md +0 -64
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/competitive-battlecard.md +0 -37
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/competitor-analysis.md +0 -32
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/compliance-research-checklist.md +0 -53
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/data-room-structure.md +0 -88
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/deck-blueprint-template.md +0 -39
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/design-tokens-application.md +0 -79
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/html-pdf-pipeline.md +0 -236
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/internal-workings-scrub.md +0 -33
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/monetization-strategy.md +0 -35
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/pricing-strategy.md +0 -37
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/strategy-frameworks.md +0 -46
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/termsheet-template.md +0 -88
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/templates/prospectus/index.html +0 -1565
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/templates/prospectus/render-pdf.mjs +0 -91
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/templates/prospectus/term_sheet.html +0 -715
- package/payload/premium-plugins/venture-studio/skills/legal-essentials/SKILL.md +0 -65
- package/payload/premium-plugins/venture-studio/skills/office-hours/SKILL.md +0 -587
- package/payload/premium-plugins/venture-studio/skills/prototype-host/SKILL.md +0 -179
- package/payload/premium-plugins/venture-studio/skills/prototype-host/references/cloudflared-ingress-edit.md +0 -81
- package/payload/premium-plugins/venture-studio/skills/prototype-host/references/scaffold-frameworks.md +0 -60
- package/payload/premium-plugins/venture-studio/skills/prototype-host/references/systemd-user-service.md +0 -104
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/SKILL.md +0 -342
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/aarrr-metrics.md +0 -275
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/assumption-testing.md +0 -93
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/boolean-search.md +0 -308
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/build-measure-learn.md +0 -262
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/business-model-canvas.md +0 -171
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/commitment-signals.md +0 -246
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/design-thinking.md +0 -183
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/earlyvangelist.md +0 -190
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/first-principles.md +0 -58
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/fishbone.md +0 -114
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/five-whys.md +0 -43
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/ice-scoring.md +0 -237
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/innovation-accounting.md +0 -290
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/jtbd.md +0 -105
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/landing-page.md +0 -361
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/market-sizing.md +0 -58
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/market-type.md +0 -167
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/mom-test.md +0 -193
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/mvp-types.md +0 -200
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/og-images.md +0 -239
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/pareto.md +0 -103
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/persona-development.md +0 -291
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/pivot-types.md +0 -225
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/positioning-statement.md +0 -179
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/prd.md +0 -363
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/pre-mortem.md +0 -74
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/problem-validation.md +0 -253
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/product-market-fit.md +0 -256
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/research-synthesis.md +0 -276
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/strategy-red-team.md +0 -41
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/three-engines-of-growth.md +0 -248
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/validation-tests.md +0 -89
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/value-proposition-canvas.md +0 -121
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/win-loss-analysis.md +0 -242
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/workflow-mapping.md +0 -271
- package/payload/premium-plugins/writer-craft/.claude-plugin/plugin.json +0 -21
- package/payload/premium-plugins/writer-craft/PLUGIN.md +0 -134
- package/payload/premium-plugins/writer-craft/agents/writer-craft--manuscript-reviewer.md +0 -108
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.d.ts +0 -8
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.js +0 -71
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.js.map +0 -1
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/package.json +0 -7
- package/payload/premium-plugins/writer-craft/lib/mcp-spawn-tee/index.js +0 -193
- package/payload/premium-plugins/writer-craft/lib/mcp-spawn-tee/package.json +0 -3
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.d.ts +0 -51
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.js +0 -196
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.js.map +0 -1
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/package.json +0 -7
- package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.d.ts +0 -3
- package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.js +0 -58
- package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/index.d.ts +0 -3
- package/payload/premium-plugins/writer-craft/mcp/dist/index.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/index.js +0 -403
- package/payload/premium-plugins/writer-craft/mcp/dist/index.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/lib/neo4j.d.ts +0 -14
- package/payload/premium-plugins/writer-craft/mcp/dist/lib/neo4j.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/lib/neo4j.js +0 -47
- package/payload/premium-plugins/writer-craft/mcp/dist/lib/neo4j.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/lib/voice-corpus.d.ts +0 -117
- package/payload/premium-plugins/writer-craft/mcp/dist/lib/voice-corpus.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/lib/voice-corpus.js +0 -138
- package/payload/premium-plugins/writer-craft/mcp/dist/lib/voice-corpus.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-distil-profile.d.ts +0 -90
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-distil-profile.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-distil-profile.js +0 -609
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-distil-profile.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-ingest-session-text.d.ts +0 -19
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-ingest-session-text.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-ingest-session-text.js +0 -124
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-ingest-session-text.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-record-feedback.d.ts +0 -38
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-record-feedback.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-record-feedback.js +0 -93
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-record-feedback.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-retrieve-conditioning.d.ts +0 -61
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-retrieve-conditioning.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-retrieve-conditioning.js +0 -171
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-retrieve-conditioning.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-tag-content.d.ts +0 -35
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-tag-content.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-tag-content.js +0 -127
- package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-tag-content.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/package-lock.json +0 -1327
- package/payload/premium-plugins/writer-craft/mcp/package.json +0 -19
- package/payload/premium-plugins/writer-craft/mcp/scripts/smoke.mjs +0 -420
- package/payload/premium-plugins/writer-craft/mcp/src/index.ts +0 -457
- package/payload/premium-plugins/writer-craft/mcp/src/lib/neo4j.ts +0 -56
- package/payload/premium-plugins/writer-craft/mcp/src/lib/voice-corpus.ts +0 -154
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-distil-profile.ts +0 -833
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-ingest-session-text.ts +0 -153
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-record-feedback.ts +0 -148
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-retrieve-conditioning.ts +0 -270
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-tag-content.ts +0 -181
- package/payload/premium-plugins/writer-craft/mcp/tsconfig.json +0 -8
- package/payload/premium-plugins/writer-craft/skills/citation-style/SKILL.md +0 -94
- package/payload/premium-plugins/writer-craft/skills/citation-style/references/book-and-chapter-models.md +0 -77
- package/payload/premium-plugins/writer-craft/skills/citation-style/references/citation-rules.md +0 -103
- package/payload/premium-plugins/writer-craft/skills/citation-style/references/journal-article-models.md +0 -74
- package/payload/premium-plugins/writer-craft/skills/citation-style/references/other-source-models.md +0 -146
- package/payload/premium-plugins/writer-craft/skills/citation-style/references/reference-list-rules.md +0 -70
- package/payload/premium-plugins/writer-craft/skills/editorial-practice/SKILL.md +0 -108
- package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/copyediting.md +0 -73
- package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/developmental-editing.md +0 -85
- package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/genre-specific-editing.md +0 -78
- package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/line-editing.md +0 -55
- package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/self-editing.md +0 -89
- package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/SKILL.md +0 -114
- package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/audience-analysis.md +0 -73
- package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/crafting-persuasive-story.md +0 -76
- package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/persuasion-case-studies.md +0 -67
- package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/transformation-framework.md +0 -86
- package/payload/premium-plugins/writer-craft/skills/point-of-view/SKILL.md +0 -97
- package/payload/premium-plugins/writer-craft/skills/point-of-view/references/indirect-narration.md +0 -72
- package/payload/premium-plugins/writer-craft/skills/point-of-view/references/pov-types-and-voice.md +0 -91
- package/payload/premium-plugins/writer-craft/skills/point-of-view/references/protagonist-filter.md +0 -71
- package/payload/premium-plugins/writer-craft/skills/point-of-view/references/tense-and-person.md +0 -85
- package/payload/premium-plugins/writer-craft/skills/prose-craft/SKILL.md +0 -100
- package/payload/premium-plugins/writer-craft/skills/prose-craft/references/punctuation-and-grammar.md +0 -72
- package/payload/premium-plugins/writer-craft/skills/prose-craft/references/repetition.md +0 -71
- package/payload/premium-plugins/writer-craft/skills/prose-craft/references/sound-and-rhythm.md +0 -64
- package/payload/premium-plugins/writer-craft/skills/prose-craft/references/word-economy.md +0 -93
- package/payload/premium-plugins/writer-craft/skills/reader-engagement/SKILL.md +0 -100
- package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/cause-effect-setup-payoff.md +0 -79
- package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/conflict-escalation.md +0 -81
- package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/hooking-readers.md +0 -67
- package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/neurochemistry-of-engagement.md +0 -94
- package/payload/premium-plugins/writer-craft/skills/review-manuscript/SKILL.md +0 -111
- package/payload/premium-plugins/writer-craft/skills/review-manuscript/references/review-manuscript-checklist.md +0 -119
- package/payload/premium-plugins/writer-craft/skills/review-prose/SKILL.md +0 -99
- package/payload/premium-plugins/writer-craft/skills/review-prose/references/prose-review-checklist.md +0 -112
- package/payload/premium-plugins/writer-craft/skills/review-scene/SKILL.md +0 -99
- package/payload/premium-plugins/writer-craft/skills/review-scene/references/scene-analysis-framework.md +0 -95
- package/payload/premium-plugins/writer-craft/skills/story-architecture/SKILL.md +0 -106
- package/payload/premium-plugins/writer-craft/skills/story-architecture/references/blueprinting-and-scene-cards.md +0 -118
- package/payload/premium-plugins/writer-craft/skills/story-architecture/references/inner-issue-and-protagonist-goal.md +0 -66
- package/payload/premium-plugins/writer-craft/skills/story-architecture/references/misbelief-desire-worldview.md +0 -87
- package/payload/premium-plugins/writer-craft/skills/story-architecture/references/origin-scenes-and-escalation.md +0 -82
- package/payload/premium-plugins/writer-craft/skills/story-blueprint/SKILL.md +0 -133
- package/payload/premium-plugins/writer-craft/skills/story-blueprint/references/blueprinting-exercises.md +0 -118
- package/payload/premium-plugins/writer-craft/skills/story-blueprint/references/blueprinting-process.md +0 -128
- package/payload/premium-plugins/writer-craft/skills/voice-mirror/SKILL.md +0 -241
- package/payload/server/public/assets/Transcript-FX_w6no6.js +0 -2
- package/payload/server/public/assets/chat-BunxcNDk.js +0 -1
- package/payload/server/public/assets/chevron-left-Cngmu0Py.js +0 -1
- package/payload/server/public/assets/data-IqZlMSwG.js +0 -1
- /package/payload/server/public/assets/{useSubAccountSwitcher-BpQ3oKiJ.js → useSubAccountSwitcher-DMbRhLPv.js} +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { normalizeE164, phonesMatch, isValidAgentDestination, boundSubAccountFor, } from "../agent-dispatch.js";
|
|
6
|
+
function makeAccountDir(config) {
|
|
7
|
+
const dir = mkdtempSync(join(tmpdir(), "agent-dispatch-"));
|
|
8
|
+
writeFileSync(join(dir, "account.json"), JSON.stringify(config), "utf-8");
|
|
9
|
+
return dir;
|
|
10
|
+
}
|
|
11
|
+
describe("normalizeE164 / phonesMatch (replica of platform normalize.ts)", () => {
|
|
12
|
+
it("normalizes spacing, '+' and '00' prefixes to digits", () => {
|
|
13
|
+
expect(normalizeE164("+44 7504 472444")).toBe("447504472444");
|
|
14
|
+
expect(normalizeE164("00447504472444")).toBe("447504472444");
|
|
15
|
+
expect(normalizeE164("whatsapp:+447504472444")).toBe("447504472444");
|
|
16
|
+
});
|
|
17
|
+
it("returns '' for non-numeric input", () => {
|
|
18
|
+
expect(normalizeE164("not-a-phone")).toBe("");
|
|
19
|
+
});
|
|
20
|
+
it("matches a spaced '+44 7…' against a bare '447…'", () => {
|
|
21
|
+
expect(phonesMatch("+44 7504472444", "447504472444")).toBe(true);
|
|
22
|
+
expect(phonesMatch("+447504472444", "+447999999999")).toBe(false);
|
|
23
|
+
expect(phonesMatch("", "")).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe("isValidAgentDestination — whatsapp", () => {
|
|
27
|
+
let dirs = [];
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
for (const d of dirs)
|
|
30
|
+
rmSync(d, { recursive: true, force: true });
|
|
31
|
+
dirs = [];
|
|
32
|
+
});
|
|
33
|
+
it("accepts a destination present in adminPhones (phonesMatch)", () => {
|
|
34
|
+
const dir = makeAccountDir({ whatsapp: { adminPhones: ["+447504472444"] } });
|
|
35
|
+
dirs.push(dir);
|
|
36
|
+
// spaced form must still match the stored bare form
|
|
37
|
+
expect(isValidAgentDestination(dir, "whatsapp", "+44 7504 472444")).toEqual({ valid: true });
|
|
38
|
+
});
|
|
39
|
+
it("accepts a destination that is an accountManagers key", () => {
|
|
40
|
+
const dir = makeAccountDir({
|
|
41
|
+
whatsapp: { adminPhones: [], accountManagers: { "447504472444": "sub-abc" } },
|
|
42
|
+
});
|
|
43
|
+
dirs.push(dir);
|
|
44
|
+
expect(isValidAgentDestination(dir, "whatsapp", "+447504472444")).toEqual({ valid: true });
|
|
45
|
+
});
|
|
46
|
+
it("rejects a destination absent from both lists", () => {
|
|
47
|
+
const dir = makeAccountDir({ whatsapp: { adminPhones: ["+447504472444"] } });
|
|
48
|
+
dirs.push(dir);
|
|
49
|
+
expect(isValidAgentDestination(dir, "whatsapp", "+447999999999")).toEqual({
|
|
50
|
+
valid: false,
|
|
51
|
+
reason: "destination-not-admin",
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
it("rejects when there is no whatsapp config at all", () => {
|
|
55
|
+
const dir = makeAccountDir({});
|
|
56
|
+
dirs.push(dir);
|
|
57
|
+
expect(isValidAgentDestination(dir, "whatsapp", "+447504472444").valid).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe("isValidAgentDestination — telegram", () => {
|
|
61
|
+
let dirs = [];
|
|
62
|
+
afterEach(() => {
|
|
63
|
+
for (const d of dirs)
|
|
64
|
+
rmSync(d, { recursive: true, force: true });
|
|
65
|
+
dirs = [];
|
|
66
|
+
});
|
|
67
|
+
it("accepts a chat id in telegram.adminUsers", () => {
|
|
68
|
+
const dir = makeAccountDir({ telegram: { adminUsers: [12345678] } });
|
|
69
|
+
dirs.push(dir);
|
|
70
|
+
expect(isValidAgentDestination(dir, "telegram", "12345678")).toEqual({ valid: true });
|
|
71
|
+
});
|
|
72
|
+
it("rejects a chat id not in adminUsers", () => {
|
|
73
|
+
const dir = makeAccountDir({ telegram: { adminUsers: [12345678] } });
|
|
74
|
+
dirs.push(dir);
|
|
75
|
+
expect(isValidAgentDestination(dir, "telegram", "99999999")).toEqual({
|
|
76
|
+
valid: false,
|
|
77
|
+
reason: "destination-not-admin",
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe("boundSubAccountFor — whatsapp accountManagers only", () => {
|
|
82
|
+
let dirs = [];
|
|
83
|
+
afterEach(() => {
|
|
84
|
+
for (const d of dirs)
|
|
85
|
+
rmSync(d, { recursive: true, force: true });
|
|
86
|
+
dirs = [];
|
|
87
|
+
});
|
|
88
|
+
it("returns the bound sub-account for a manager destination", () => {
|
|
89
|
+
const dir = makeAccountDir({
|
|
90
|
+
whatsapp: { accountManagers: { "447504472444": "sub-abc" } },
|
|
91
|
+
});
|
|
92
|
+
dirs.push(dir);
|
|
93
|
+
expect(boundSubAccountFor(dir, "+44 7504 472444")).toBe("sub-abc");
|
|
94
|
+
});
|
|
95
|
+
it("returns null for a plain admin phone (no binding)", () => {
|
|
96
|
+
const dir = makeAccountDir({ whatsapp: { adminPhones: ["+447504472444"], accountManagers: {} } });
|
|
97
|
+
dirs.push(dir);
|
|
98
|
+
expect(boundSubAccountFor(dir, "+447504472444")).toBeNull();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=agent-dispatch.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-dispatch.test.js","sourceRoot":"","sources":["../../../src/lib/__tests__/agent-dispatch.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAc,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC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,eAAe,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAClG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type AgentChannel = "whatsapp" | "telegram";
|
|
2
|
+
export type DestinationValidity = {
|
|
3
|
+
valid: true;
|
|
4
|
+
} | {
|
|
5
|
+
valid: false;
|
|
6
|
+
reason: "destination-not-admin";
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Replica of `normalize.ts:normalizeE164` — strip whitespace/dashes/parens, a
|
|
10
|
+
* `whatsapp:` prefix, and a leading `+` or `00`; return digits-only or `''`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeE164(value: string): string;
|
|
13
|
+
/** Replica of `normalize.ts:phonesMatch` — normalized equality, non-empty. */
|
|
14
|
+
export declare function phonesMatch(a: string, b: string): boolean;
|
|
15
|
+
interface WhatsAppAdmins {
|
|
16
|
+
adminPhones: string[];
|
|
17
|
+
accountManagers: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
/** Read the channel admin config from `<accountDir>/account.json`. Missing or
|
|
20
|
+
* malformed config yields empty lists (a fail-closed default: no destination
|
|
21
|
+
* validates against empty config). */
|
|
22
|
+
export declare function readChannelAdmins(accountDir: string, channel: "whatsapp"): WhatsAppAdmins;
|
|
23
|
+
export declare function readChannelAdmins(accountDir: string, channel: "telegram"): {
|
|
24
|
+
adminUsers: number[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A destination is valid iff it is a registered admin or account-manager on
|
|
28
|
+
* that channel:
|
|
29
|
+
* - whatsapp: `phonesMatch` against any `adminPhones` entry OR any
|
|
30
|
+
* `accountManagers` key.
|
|
31
|
+
* - telegram: an integer chat id present in `telegram.adminUsers`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isValidAgentDestination(accountDir: string, channel: AgentChannel, destination: string): DestinationValidity;
|
|
34
|
+
/**
|
|
35
|
+
* Validate an `agentDispatch` at write time (shared by `schedule-event` and
|
|
36
|
+
* `schedule-update` so the two write paths cannot drift on the rule): reject an
|
|
37
|
+
* empty prompt, and reject a destination that is not a registered admin or
|
|
38
|
+
* account-manager on the channel. Throws with a caller-facing message; returns
|
|
39
|
+
* on success. `accountId` is the event's account; its `account.json` under
|
|
40
|
+
* `$PLATFORM_ROOT/../data/accounts/<accountId>` holds the channel admin config.
|
|
41
|
+
*/
|
|
42
|
+
export declare function validateAgentDispatch(accountId: string, agentDispatch: {
|
|
43
|
+
channel: AgentChannel;
|
|
44
|
+
destination: string;
|
|
45
|
+
prompt: string;
|
|
46
|
+
}): void;
|
|
47
|
+
/**
|
|
48
|
+
* The sub-account a WhatsApp manager destination is bound to, or null. Telegram
|
|
49
|
+
* has no account-manager surface (house-only, Task 1378 scope), so it always
|
|
50
|
+
* returns null. Used by the standing audit to detect a deleted sub-account.
|
|
51
|
+
*/
|
|
52
|
+
export declare function boundSubAccountFor(accountDir: string, destination: string): string | null;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=agent-dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-dispatch.d.ts","sourceRoot":"","sources":["../../src/lib/agent-dispatch.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAC3B;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GACf;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOnD;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAIzD;AAED,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED;;uCAEuC;AACvC,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,UAAU,GAClB,cAAc,CAAC;AAClB,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,UAAU,GAClB;IAAE,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AA8B5B;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,GAClB,mBAAmB,CAWrB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5E,IAAI,CAgBN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMzF"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task 1378 — agent-bearing scheduled dispatch: destination validation.
|
|
3
|
+
*
|
|
4
|
+
* The scheduling MCP cannot import `platform/ui` (plugin boundary), so this
|
|
5
|
+
* module replicates the minimal E.164 matching from
|
|
6
|
+
* `platform/ui/app/lib/whatsapp/normalize.ts` and reads the channel admin
|
|
7
|
+
* config straight out of the account's `account.json`. One implementation is
|
|
8
|
+
* shared by `schedule-event`, `schedule-update`, and the dispatcher's standing
|
|
9
|
+
* audit so the "is this destination a valid admin/manager" decision cannot
|
|
10
|
+
* drift between the write path and the audit.
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync } from "node:fs";
|
|
13
|
+
import { resolve } from "node:path";
|
|
14
|
+
/**
|
|
15
|
+
* Replica of `normalize.ts:normalizeE164` — strip whitespace/dashes/parens, a
|
|
16
|
+
* `whatsapp:` prefix, and a leading `+` or `00`; return digits-only or `''`.
|
|
17
|
+
*/
|
|
18
|
+
export function normalizeE164(value) {
|
|
19
|
+
let candidate = value.trim().replace(/[\s\-().]/g, "");
|
|
20
|
+
candidate = candidate.replace(/^whatsapp:/i, "");
|
|
21
|
+
if (candidate.startsWith("+"))
|
|
22
|
+
candidate = candidate.slice(1);
|
|
23
|
+
else if (candidate.startsWith("00"))
|
|
24
|
+
candidate = candidate.slice(2);
|
|
25
|
+
if (!/^\d+$/.test(candidate))
|
|
26
|
+
return "";
|
|
27
|
+
return candidate;
|
|
28
|
+
}
|
|
29
|
+
/** Replica of `normalize.ts:phonesMatch` — normalized equality, non-empty. */
|
|
30
|
+
export function phonesMatch(a, b) {
|
|
31
|
+
const na = normalizeE164(a);
|
|
32
|
+
const nb = normalizeE164(b);
|
|
33
|
+
return na.length > 0 && na === nb;
|
|
34
|
+
}
|
|
35
|
+
export function readChannelAdmins(accountDir, channel) {
|
|
36
|
+
let config = {};
|
|
37
|
+
try {
|
|
38
|
+
config = JSON.parse(readFileSync(resolve(accountDir, "account.json"), "utf-8"));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
config = {};
|
|
42
|
+
}
|
|
43
|
+
if (channel === "whatsapp") {
|
|
44
|
+
const wa = config.whatsapp ?? {};
|
|
45
|
+
const adminPhones = Array.isArray(wa.adminPhones)
|
|
46
|
+
? wa.adminPhones.filter((p) => typeof p === "string")
|
|
47
|
+
: [];
|
|
48
|
+
const managersRaw = wa.accountManagers ?? {};
|
|
49
|
+
const accountManagers = {};
|
|
50
|
+
for (const [k, v] of Object.entries(managersRaw)) {
|
|
51
|
+
if (typeof v === "string")
|
|
52
|
+
accountManagers[k] = v;
|
|
53
|
+
}
|
|
54
|
+
return { adminPhones, accountManagers };
|
|
55
|
+
}
|
|
56
|
+
const tg = config.telegram ?? {};
|
|
57
|
+
const adminUsers = Array.isArray(tg.adminUsers)
|
|
58
|
+
? tg.adminUsers.filter((u) => typeof u === "number")
|
|
59
|
+
: [];
|
|
60
|
+
return { adminUsers };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A destination is valid iff it is a registered admin or account-manager on
|
|
64
|
+
* that channel:
|
|
65
|
+
* - whatsapp: `phonesMatch` against any `adminPhones` entry OR any
|
|
66
|
+
* `accountManagers` key.
|
|
67
|
+
* - telegram: an integer chat id present in `telegram.adminUsers`.
|
|
68
|
+
*/
|
|
69
|
+
export function isValidAgentDestination(accountDir, channel, destination) {
|
|
70
|
+
if (channel === "whatsapp") {
|
|
71
|
+
const { adminPhones, accountManagers } = readChannelAdmins(accountDir, "whatsapp");
|
|
72
|
+
const inAdmins = adminPhones.some((p) => phonesMatch(p, destination));
|
|
73
|
+
const inManagers = Object.keys(accountManagers).some((k) => phonesMatch(k, destination));
|
|
74
|
+
return inAdmins || inManagers ? { valid: true } : { valid: false, reason: "destination-not-admin" };
|
|
75
|
+
}
|
|
76
|
+
const { adminUsers } = readChannelAdmins(accountDir, "telegram");
|
|
77
|
+
const asNumber = Number(destination);
|
|
78
|
+
const ok = Number.isInteger(asNumber) && adminUsers.includes(asNumber);
|
|
79
|
+
return ok ? { valid: true } : { valid: false, reason: "destination-not-admin" };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Validate an `agentDispatch` at write time (shared by `schedule-event` and
|
|
83
|
+
* `schedule-update` so the two write paths cannot drift on the rule): reject an
|
|
84
|
+
* empty prompt, and reject a destination that is not a registered admin or
|
|
85
|
+
* account-manager on the channel. Throws with a caller-facing message; returns
|
|
86
|
+
* on success. `accountId` is the event's account; its `account.json` under
|
|
87
|
+
* `$PLATFORM_ROOT/../data/accounts/<accountId>` holds the channel admin config.
|
|
88
|
+
*/
|
|
89
|
+
export function validateAgentDispatch(accountId, agentDispatch) {
|
|
90
|
+
const { channel, destination, prompt } = agentDispatch;
|
|
91
|
+
if (!prompt || prompt.trim().length === 0) {
|
|
92
|
+
throw new Error("agentDispatch requires a non-empty 'prompt'");
|
|
93
|
+
}
|
|
94
|
+
const platformRoot = process.env.PLATFORM_ROOT;
|
|
95
|
+
if (!platformRoot) {
|
|
96
|
+
throw new Error("PLATFORM_ROOT environment variable is required to validate the agentDispatch destination");
|
|
97
|
+
}
|
|
98
|
+
const accountDir = resolve(platformRoot, "..", "data/accounts", accountId);
|
|
99
|
+
const check = isValidAgentDestination(accountDir, channel, destination);
|
|
100
|
+
if (!check.valid) {
|
|
101
|
+
throw new Error(`agentDispatch destination "${destination}" is not a registered admin/account-manager on ${channel} — reason=${check.reason}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The sub-account a WhatsApp manager destination is bound to, or null. Telegram
|
|
106
|
+
* has no account-manager surface (house-only, Task 1378 scope), so it always
|
|
107
|
+
* returns null. Used by the standing audit to detect a deleted sub-account.
|
|
108
|
+
*/
|
|
109
|
+
export function boundSubAccountFor(accountDir, destination) {
|
|
110
|
+
const { accountManagers } = readChannelAdmins(accountDir, "whatsapp");
|
|
111
|
+
for (const [managerPhone, subAccountId] of Object.entries(accountManagers)) {
|
|
112
|
+
if (subAccountId && phonesMatch(managerPhone, destination))
|
|
113
|
+
return subAccountId;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=agent-dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-dispatch.js","sourceRoot":"","sources":["../../src/lib/agent-dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACv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AC;IACD,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAC3E,MAAM,KAAK,GAAG,uBAAuB,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACxE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,8BAA8B,WAAW,kDAAkD,OAAO,aAAa,KAAK,CAAC,MAAM,EAAE,CAC9H,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAkB,EAAE,WAAmB;IACxE,MAAM,EAAE,eAAe,EAAE,GAAG,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACtE,KAAK,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QAC3E,IAAI,YAAY,IAAI,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC;YAAE,OAAO,YAAY,CAAC;IAClF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -10,6 +10,13 @@ export interface ClassifyInput {
|
|
|
10
10
|
tool: string;
|
|
11
11
|
args?: Record<string, unknown>;
|
|
12
12
|
};
|
|
13
|
+
/** Task 1378 — an agent-bearing dispatch is a scheduler primitive, never a
|
|
14
|
+
* meeting: like `action`, its presence forces the :Event bucket. */
|
|
15
|
+
agentDispatch?: {
|
|
16
|
+
channel: "whatsapp" | "telegram";
|
|
17
|
+
destination: string;
|
|
18
|
+
prompt: string;
|
|
19
|
+
};
|
|
13
20
|
/** startDate is always present (required); endDate present means a bounded slot. */
|
|
14
21
|
endDate?: string;
|
|
15
22
|
attendees?: ScheduleAttendee[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule-classify.d.ts","sourceRoot":"","sources":["../../src/lib/schedule-classify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schedule-classify.d.ts","sourceRoot":"","sources":["../../src/lib/schedule-classify.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC1E;yEACqE;IACrE,aAAa,CAAC,EAAE;QAAE,OAAO,EAAE,UAAU,GAAG,UAAU,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1F,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAeD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CAO1E"}
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
//
|
|
9
9
|
// 1. recurrence present -> Event (recurring trigger)
|
|
10
10
|
// 2. action present -> Event (action dispatcher)
|
|
11
|
-
// 3.
|
|
12
|
-
// 4.
|
|
13
|
-
// 5.
|
|
11
|
+
// 3. agentDispatch present -> Event (agent-turn dispatcher)
|
|
12
|
+
// 4. a resolvable counterparty -> Meeting (call/appointment with someone)
|
|
13
|
+
// 5. bounded slot (endDate present) -> Meeting (a time-blocked appointment)
|
|
14
|
+
// 6. otherwise -> Event (one-time reminder)
|
|
14
15
|
//
|
|
15
16
|
// The `reason` is emitted in the observability line so a mis-bucketed write is
|
|
16
17
|
// greppable without reading the graph.
|
|
@@ -29,6 +30,8 @@ export function classifyScheduleWrite(input) {
|
|
|
29
30
|
return { label: "Event", reason: "recurrence" };
|
|
30
31
|
if (input.action)
|
|
31
32
|
return { label: "Event", reason: "action" };
|
|
33
|
+
if (input.agentDispatch)
|
|
34
|
+
return { label: "Event", reason: "agent-dispatch" };
|
|
32
35
|
if (hasResolvableCounterparty(input.attendees))
|
|
33
36
|
return { label: "Meeting", reason: "counterparty" };
|
|
34
37
|
if (input.endDate)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule-classify.js","sourceRoot":"","sources":["../../src/lib/schedule-classify.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wEAAwE;AACxE,gFAAgF;AAChF,mFAAmF;AACnF,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,EAAE;AACF,oEAAoE;AACpE,oEAAoE;AACpE,iFAAiF;AACjF,8EAA8E;AAC9E,qEAAqE;AACrE,EAAE;AACF,+EAA+E;AAC/E,uCAAuC;
|
|
1
|
+
{"version":3,"file":"schedule-classify.js","sourceRoot":"","sources":["../../src/lib/schedule-classify.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wEAAwE;AACxE,gFAAgF;AAChF,mFAAmF;AACnF,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,EAAE;AACF,oEAAoE;AACpE,oEAAoE;AACpE,yEAAyE;AACzE,iFAAiF;AACjF,8EAA8E;AAC9E,qEAAqE;AACrE,EAAE;AACF,+EAA+E;AAC/E,uCAAuC;AA0BvC;;;;;;GAMG;AACH,SAAS,yBAAyB,CAAC,SAAyC;IAC1E,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,CAC3B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAC1F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAoB;IACxD,IAAI,KAAK,CAAC,UAAU;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IACtE,IAAI,KAAK,CAAC,MAAM;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC9D,IAAI,KAAK,CAAC,aAAa;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC7E,IAAI,yBAAyB,CAAC,KAAK,CAAC,SAAS,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACpG,IAAI,KAAK,CAAC,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAClE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-turn-dispatch.test.d.ts","sourceRoot":"","sources":["../../../src/scripts/__tests__/agent-turn-dispatch.test.ts"],"names":[],"mappings":""}
|
package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/agent-turn-dispatch.test.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { chooseDispatchMode, dispatchAgentTurn } from "../agent-turn-dispatch.js";
|
|
3
|
+
describe("chooseDispatchMode", () => {
|
|
4
|
+
it("selects agent when the three agent fields are present", () => {
|
|
5
|
+
const m = chooseDispatchMode({
|
|
6
|
+
agentChannel: "whatsapp",
|
|
7
|
+
agentDestination: "+447504472444",
|
|
8
|
+
agentPrompt: "reply OK",
|
|
9
|
+
actionPlugin: null,
|
|
10
|
+
actionTool: null,
|
|
11
|
+
actionArgs: null,
|
|
12
|
+
});
|
|
13
|
+
expect(m).toEqual({ kind: "agent", channel: "whatsapp", destination: "+447504472444", prompt: "reply OK" });
|
|
14
|
+
});
|
|
15
|
+
it("selects action when action fields are present and no agent dispatch", () => {
|
|
16
|
+
const m = chooseDispatchMode({
|
|
17
|
+
agentChannel: null,
|
|
18
|
+
agentDestination: null,
|
|
19
|
+
agentPrompt: null,
|
|
20
|
+
actionPlugin: "memory",
|
|
21
|
+
actionTool: "memory-search",
|
|
22
|
+
actionArgs: null,
|
|
23
|
+
});
|
|
24
|
+
expect(m).toEqual({ kind: "action", plugin: "memory", tool: "memory-search", args: null });
|
|
25
|
+
});
|
|
26
|
+
it("selects none when neither is present", () => {
|
|
27
|
+
const m = chooseDispatchMode({
|
|
28
|
+
agentChannel: null,
|
|
29
|
+
agentDestination: null,
|
|
30
|
+
agentPrompt: null,
|
|
31
|
+
actionPlugin: null,
|
|
32
|
+
actionTool: null,
|
|
33
|
+
actionArgs: null,
|
|
34
|
+
});
|
|
35
|
+
expect(m).toEqual({ kind: "none" });
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
function fakeDriver() {
|
|
39
|
+
const runs = [];
|
|
40
|
+
return {
|
|
41
|
+
runs,
|
|
42
|
+
session: () => ({
|
|
43
|
+
run: vi.fn(async (query, params) => {
|
|
44
|
+
runs.push({ query, params });
|
|
45
|
+
return { records: [] };
|
|
46
|
+
}),
|
|
47
|
+
close: vi.fn(async () => { }),
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
describe("dispatchAgentTurn", () => {
|
|
52
|
+
const originalFetch = globalThis.fetch;
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
process.env.MAXY_UI_INTERNAL_PORT = "19200";
|
|
55
|
+
});
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
globalThis.fetch = originalFetch;
|
|
58
|
+
vi.clearAllMocks();
|
|
59
|
+
});
|
|
60
|
+
it("POSTs the inject route and records lastDispatchResult=accepted on 200", async () => {
|
|
61
|
+
const calls = [];
|
|
62
|
+
globalThis.fetch = vi.fn(async (url, init) => {
|
|
63
|
+
calls.push({ url, body: JSON.parse(init.body) });
|
|
64
|
+
return { ok: true, status: 200 };
|
|
65
|
+
});
|
|
66
|
+
const driver = fakeDriver();
|
|
67
|
+
await dispatchAgentTurn("evt-1", "whatsapp", "+447504472444", "reply OK", "acct-house", null, driver);
|
|
68
|
+
expect(calls).toHaveLength(1);
|
|
69
|
+
expect(calls[0].url).toBe("http://127.0.0.1:19200/api/channel/schedule-inject");
|
|
70
|
+
expect(calls[0].body).toEqual({
|
|
71
|
+
channel: "whatsapp",
|
|
72
|
+
accountId: "acct-house",
|
|
73
|
+
destination: "+447504472444",
|
|
74
|
+
prompt: "reply OK",
|
|
75
|
+
eventId: "evt-1",
|
|
76
|
+
});
|
|
77
|
+
const write = driver.runs.find((r) => r.query.includes("lastDispatchResult"));
|
|
78
|
+
expect(write?.params.lastDispatchResult).toBe("accepted");
|
|
79
|
+
});
|
|
80
|
+
it("records lastDispatchResult=error:404 on a non-ok response", async () => {
|
|
81
|
+
globalThis.fetch = vi.fn(async () => ({ ok: false, status: 404 }));
|
|
82
|
+
const driver = fakeDriver();
|
|
83
|
+
await dispatchAgentTurn("evt-2", "telegram", "12345678", "hello", "acct-house", null, driver);
|
|
84
|
+
const write = driver.runs.find((r) => r.query.includes("lastDispatchResult"));
|
|
85
|
+
expect(write?.params.lastDispatchResult).toBe("error:404");
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=agent-turn-dispatch.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-turn-dispatch.test.js","sourceRoot":"","sources":["../../../src/scripts/__tests__/agent-turn-dispatch.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAElF,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,CAAC,GAAG,kBAAkB,CAAC;YAC3B,YAAY,EAAE,UAAU;YACxB,gBAAgB,EAAE,eAAe;YACjC,WAAW,EAAE,UAAU;YACvB,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9G,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qEAAqE,EAAE,GAAG,EAAE;QAC7E,MAAM,CAAC,GAAG,kBAAkB,CAAC;YAC3B,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE,IAAI;YACtB,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,QAAQ;YACtB,UAAU,EAAE,eAAe;YAC3B,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7F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AK,IAAI,EAAE;QACzE,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAe,CAAA,CAA4B,CAAC;QAC1G,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAE5B,MAAM,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAe,CAAC,CAAC;QAEvG,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC9E,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/standing-audit.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standing-audit.test.d.ts","sourceRoot":"","sources":["../../../src/scripts/__tests__/standing-audit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { mkdtempSync, rmSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { runStandingAudit } from "../agent-turn-dispatch.js";
|
|
6
|
+
function driverReturning(rows) {
|
|
7
|
+
return {
|
|
8
|
+
session: () => ({
|
|
9
|
+
run: vi.fn(async () => ({
|
|
10
|
+
records: rows.map((r) => ({ get: (k) => r[k] })),
|
|
11
|
+
})),
|
|
12
|
+
close: vi.fn(async () => { }),
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
let accountsDir;
|
|
17
|
+
const HOUSE = "acct-house";
|
|
18
|
+
function seedHouse(waConfig) {
|
|
19
|
+
const dir = join(accountsDir, HOUSE);
|
|
20
|
+
mkdirSync(dir, { recursive: true });
|
|
21
|
+
writeFileSync(join(dir, "account.json"), JSON.stringify({ whatsapp: waConfig }), "utf-8");
|
|
22
|
+
}
|
|
23
|
+
let errSpy;
|
|
24
|
+
function auditLines() {
|
|
25
|
+
return errSpy.mock.calls
|
|
26
|
+
.map((c) => String(c[0]))
|
|
27
|
+
.filter((l) => l.includes("[schedule-audit]"));
|
|
28
|
+
}
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
accountsDir = mkdtempSync(join(tmpdir(), "audit-accounts-"));
|
|
31
|
+
errSpy = vi.spyOn(console, "error").mockImplementation(() => { });
|
|
32
|
+
});
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
rmSync(accountsDir, { recursive: true, force: true });
|
|
35
|
+
errSpy.mockRestore();
|
|
36
|
+
vi.clearAllMocks();
|
|
37
|
+
});
|
|
38
|
+
describe("runStandingAudit", () => {
|
|
39
|
+
it("emits destination-not-admin when the destination left adminPhones", async () => {
|
|
40
|
+
seedHouse({ adminPhones: ["+447111111111"] }); // destination not present
|
|
41
|
+
const driver = driverReturning([
|
|
42
|
+
{ eventId: "e1", accountId: HOUSE, agentChannel: "whatsapp", agentDestination: "+447504472444" },
|
|
43
|
+
]);
|
|
44
|
+
await runStandingAudit(driver, [HOUSE], accountsDir);
|
|
45
|
+
expect(auditLines()).toEqual([
|
|
46
|
+
expect.stringContaining("op=stale-dispatch eventId=e1 reason=destination-not-admin"),
|
|
47
|
+
]);
|
|
48
|
+
});
|
|
49
|
+
it("emits sub-account-missing when a manager binding points at a deleted sub-account", async () => {
|
|
50
|
+
seedHouse({ accountManagers: { "447504472444": "sub-gone" } }); // sub dir never created
|
|
51
|
+
const driver = driverReturning([
|
|
52
|
+
{ eventId: "e2", accountId: HOUSE, agentChannel: "whatsapp", agentDestination: "+447504472444" },
|
|
53
|
+
]);
|
|
54
|
+
await runStandingAudit(driver, [HOUSE], accountsDir);
|
|
55
|
+
expect(auditLines()).toEqual([
|
|
56
|
+
expect.stringContaining("op=stale-dispatch eventId=e2 reason=sub-account-missing"),
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
it("emits nothing for a healthy binding (manager + present sub-account)", async () => {
|
|
60
|
+
seedHouse({ accountManagers: { "447504472444": "sub-ok" } });
|
|
61
|
+
mkdirSync(join(accountsDir, "sub-ok"), { recursive: true });
|
|
62
|
+
const driver = driverReturning([
|
|
63
|
+
{ eventId: "e3", accountId: HOUSE, agentChannel: "whatsapp", agentDestination: "+447504472444" },
|
|
64
|
+
]);
|
|
65
|
+
await runStandingAudit(driver, [HOUSE], accountsDir);
|
|
66
|
+
expect(auditLines()).toEqual([]);
|
|
67
|
+
});
|
|
68
|
+
it("emits nothing for a healthy plain admin destination", async () => {
|
|
69
|
+
seedHouse({ adminPhones: ["+447504472444"] });
|
|
70
|
+
const driver = driverReturning([
|
|
71
|
+
{ eventId: "e4", accountId: HOUSE, agentChannel: "whatsapp", agentDestination: "+447504472444" },
|
|
72
|
+
]);
|
|
73
|
+
await runStandingAudit(driver, [HOUSE], accountsDir);
|
|
74
|
+
expect(auditLines()).toEqual([]);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=standing-audit.test.js.map
|
package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/standing-audit.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standing-audit.test.js","sourceRoot":"","sources":["../../../src/scripts/__tests__/standing-audit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,E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CAAC;YAC7B,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE;SACjG,CAAC,CAAC;QACH,MAAM,gBAAgB,CAAC,MAAe,EAAE,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC;QAC9D,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task 1378 — agent-bearing scheduled dispatch.
|
|
3
|
+
*
|
|
4
|
+
* When a due `:Event` carries an agent dispatch (`agentChannel`/
|
|
5
|
+
* `agentDestination`/`agentPrompt`) instead of a tool-only `action`, the
|
|
6
|
+
* heartbeat POSTs the prompt to the UI server's loopback inject route rather
|
|
7
|
+
* than spawning an MCP tool. The route builds a synthetic admin inbound so the
|
|
8
|
+
* normal channel spawn/resume/reply machine runs the turn. This module owns the
|
|
9
|
+
* routing decision and the POST + node-recording, kept out of the script's
|
|
10
|
+
* `main()` so it is unit-testable without executing the heartbeat.
|
|
11
|
+
*/
|
|
12
|
+
import { type Driver } from "neo4j-driver";
|
|
13
|
+
export type DispatchMode = {
|
|
14
|
+
kind: "agent";
|
|
15
|
+
channel: string;
|
|
16
|
+
destination: string;
|
|
17
|
+
prompt: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "action";
|
|
20
|
+
plugin: string;
|
|
21
|
+
tool: string;
|
|
22
|
+
args: string | null;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "none";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Decide how a due event dispatches from its selected node fields. An event
|
|
28
|
+
* carries at most one mode (enforced at write); agent dispatch takes precedence
|
|
29
|
+
* so a malformed both-set node still routes deterministically.
|
|
30
|
+
*/
|
|
31
|
+
export declare function chooseDispatchMode(fields: {
|
|
32
|
+
agentChannel: string | null;
|
|
33
|
+
agentDestination: string | null;
|
|
34
|
+
agentPrompt: string | null;
|
|
35
|
+
actionPlugin: string | null;
|
|
36
|
+
actionTool: string | null;
|
|
37
|
+
actionArgs: string | null;
|
|
38
|
+
}): DispatchMode;
|
|
39
|
+
/**
|
|
40
|
+
* Fire an agent-bearing dispatch: POST the prompt to the UI server's loopback
|
|
41
|
+
* inject route and record the outcome on the `:Event` node exactly as
|
|
42
|
+
* `dispatchAction` does (`lastDispatchResult`/`lastDispatchAt` + a note). On the
|
|
43
|
+
* recurring path `nextRun` has already been advanced by the caller; it is
|
|
44
|
+
* passed here only for the log line. Never throws — a POST/Neo4j failure is
|
|
45
|
+
* recorded, not propagated, so one event never aborts the sweep.
|
|
46
|
+
*/
|
|
47
|
+
export declare function dispatchAgentTurn(eventId: string, channel: string, destination: string, prompt: string, eventAccountId: string, nextRun: string | null, driver: Driver): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* The no-event detector. Each heartbeat tick, over every agent-dispatch event
|
|
50
|
+
* for a local account, re-checks the destination binding against the current
|
|
51
|
+
* channel config so a destination removed from `adminPhones`/`accountManagers`
|
|
52
|
+
* out of band — or a manager whose sub-account was deleted — is surfaced before
|
|
53
|
+
* the next fire silently mis-dispatches. Independent of any inbound: it reads
|
|
54
|
+
* the node and the on-disk config, nothing else. Emits one
|
|
55
|
+
* `[schedule-audit] op=stale-dispatch` line per invalid binding; a healthy
|
|
56
|
+
* binding emits nothing.
|
|
57
|
+
*/
|
|
58
|
+
export declare function runStandingAudit(driver: Driver, localAccountIds: string[], accountsDir: string): Promise<void>;
|
|
59
|
+
//# sourceMappingURL=agent-turn-dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-turn-dispatch.d.ts","sourceRoot":"","sources":["../../src/scripts/agent-turn-dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAA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