@rubytech/create-sitedesk-code 0.1.446 → 0.1.448
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/package.json +1 -1
- package/payload/platform/lib/graph-style/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/graph-style/dist/index.js +6 -0
- package/payload/platform/lib/graph-style/dist/index.js.map +1 -1
- package/payload/platform/lib/graph-style/src/index.ts +7 -0
- package/payload/platform/neo4j/schema.cypher +35 -1
- package/payload/platform/plugins/.claude-plugin/marketplace.json +5 -0
- package/payload/platform/plugins/admin/hooks/lib/maxy-mcp-plugins.txt +1 -0
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +42 -5
- package/payload/platform/plugins/docs/references/calendar-booking.md +18 -1
- package/payload/platform/plugins/docs/references/claudeai-connectors.md +15 -0
- package/payload/platform/plugins/docs/references/outlook-guide.md +8 -3
- package/payload/platform/plugins/email/skills/email-composition/SKILL.md +4 -4
- package/payload/platform/plugins/memory/references/schema-construction.md +7 -2
- package/payload/platform/plugins/outlook/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/outlook/PLUGIN.md +23 -5
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.js +70 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/html-to-text.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/html-to-text.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/html-to-text.test.js +22 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/html-to-text.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-delete.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-delete.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-delete.test.js +60 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-delete.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-fetch-body.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-fetch-body.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-fetch-body.test.js +80 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-fetch-body.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-otp-extract.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-otp-extract.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-otp-extract.test.js +90 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-otp-extract.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-reply.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-reply.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-reply.test.js +194 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-reply.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/otp.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/otp.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/otp.test.js +16 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/otp.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/outbound-attachments.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/outbound-attachments.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/outbound-attachments.test.js +103 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/outbound-attachments.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/index.js +88 -0
- package/payload/platform/plugins/outlook/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/outlook/mcp/dist/lib/html-to-text.d.ts +9 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/html-to-text.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/html-to-text.js +24 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/html-to-text.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/otp.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/otp.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/otp.js +49 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/otp.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.d.ts +58 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.js +127 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.d.ts +28 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.js +54 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.d.ts +21 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.js +38 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-delete.d.ts +14 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-delete.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-delete.js +39 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-delete.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-fetch-body.d.ts +23 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-fetch-body.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-fetch-body.js +44 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-fetch-body.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-otp-extract.d.ts +22 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-otp-extract.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-otp-extract.js +90 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-otp-extract.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.d.ts +27 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.js +75 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.js.map +1 -0
- package/payload/platform/plugins/outlook/references/graph-surfaces.md +57 -1
- package/payload/platform/plugins/outlook/skills/outlook/SKILL.md +15 -4
- package/payload/platform/plugins/scheduling/PLUGIN.md +15 -0
- package/payload/platform/plugins/scheduling/mcp/dist/index.js +29 -1
- package/payload/platform/plugins/scheduling/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js +53 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts +21 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js +80 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.d.ts +4 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js +68 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.js +75 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.d.ts +31 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.js +41 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/.claude-plugin/plugin.json +21 -0
- package/payload/platform/plugins/voice-mirror/PLUGIN.md +72 -0
- package/payload/platform/plugins/voice-mirror/lib/mcp-spawn-tee/index.js +193 -0
- package/payload/platform/plugins/voice-mirror/lib/mcp-spawn-tee/package.json +3 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/index.d.ts +3 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/index.d.ts.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/index.js +403 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/index.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/lib/neo4j.d.ts +14 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/lib/neo4j.d.ts.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/lib/neo4j.js +47 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/lib/neo4j.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/lib/voice-corpus.d.ts +117 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/lib/voice-corpus.d.ts.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/lib/voice-corpus.js +138 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/lib/voice-corpus.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-distil-profile.d.ts +90 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-distil-profile.d.ts.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-distil-profile.js +609 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-distil-profile.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-ingest-session-text.d.ts +19 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-ingest-session-text.d.ts.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-ingest-session-text.js +124 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-ingest-session-text.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-record-feedback.d.ts +38 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-record-feedback.d.ts.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-record-feedback.js +93 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-record-feedback.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-retrieve-conditioning.d.ts +61 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-retrieve-conditioning.d.ts.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-retrieve-conditioning.js +171 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-retrieve-conditioning.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-tag-content.d.ts +35 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-tag-content.d.ts.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-tag-content.js +127 -0
- package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-tag-content.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/mcp/package-lock.json +1327 -0
- package/payload/platform/plugins/voice-mirror/mcp/package.json +19 -0
- package/payload/platform/plugins/voice-mirror/mcp/scripts/smoke.mjs +420 -0
- package/payload/platform/plugins/voice-mirror/skills/voice-mirror/SKILL.md +241 -0
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +12 -0
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/templates/agents/admin/AGENTS.md +1 -1
- package/payload/platform/templates/specialists/agents/content-producer.md +1 -1
- package/payload/platform/templates/specialists/agents/personal-assistant.md +6 -2
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/PLUGIN.md +15 -9
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/index.js +2 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/index.js.map +1 -1
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/lib/neo4j.d.ts +5 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/lib/neo4j.d.ts.map +1 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/lib/neo4j.js +41 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/lib/neo4j.js.map +1 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/tools/note-capture.d.ts +25 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/tools/note-capture.d.ts.map +1 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/tools/note-capture.js +114 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/dist/tools/note-capture.js.map +1 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/package-lock.json +137 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/package.json +1 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/src/index.ts +2 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/src/lib/__tests__/note-capture.test.ts +55 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/src/lib/neo4j.ts +51 -0
- package/payload/premium-plugins/sitedesk/plugins/sitedesk-job/mcp/src/tools/note-capture.ts +153 -0
- package/payload/server/public/assets/{AdminLoginScreens-D9L-CuWi.js → AdminLoginScreens-Bvf4HKmq.js} +1 -1
- package/payload/server/public/assets/AdminShell-CaGc8ODG.js +2 -0
- package/payload/server/public/assets/{Checkbox-CFdt8ljo.js → Checkbox-2SswiICc.js} +1 -1
- package/payload/server/public/assets/admin-B7GPCzpr.js +1 -0
- package/payload/server/public/assets/browser-CodHC_MO.js +1 -0
- package/payload/server/public/assets/calendar-DH7cyXKF.js +1 -0
- package/payload/server/public/assets/chat-BQyPAEMv.js +1 -0
- package/payload/server/public/assets/chevron-left-Cmev0R9v.js +1 -0
- package/payload/server/public/assets/data-DWxZzMfL.js +1 -0
- package/payload/server/public/assets/{graph-DrE7KupQ.js → graph-BToB78LG.js} +2 -2
- package/payload/server/public/assets/graph-labels-JRGrstzM.js +1 -0
- package/payload/server/public/assets/maximize-2-CEQRv64B.js +1 -0
- package/payload/server/public/assets/operator-Cx8cq2wf.js +1 -0
- package/payload/server/public/assets/page-D6kzsk18.js +32 -0
- package/payload/server/public/assets/page-TCsQy4eP.js +1 -0
- package/payload/server/public/assets/public-B61xcmAr.js +1 -0
- package/payload/server/public/assets/{rotate-ccw-Cqp4oqHV.js → rotate-ccw-7_3ol0Z4.js} +1 -1
- package/payload/server/public/assets/{tasks-bQKOhMga.js → tasks-BY9ajKXf.js} +1 -1
- package/payload/server/public/assets/{time-entry-format-BIL4ZaDK.js → time-entry-format-DmNhIJnM.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-C5-GOl5l.js +1 -0
- package/payload/server/public/assets/useSelectionMode-UOUVnP9B.js +1 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-CVHKTSst.css → useSubAccountSwitcher-DgM1ergs.css} +1 -1
- package/payload/server/public/assets/useVoiceRecorder-BAP3yGxs.js +2 -0
- package/payload/server/public/browser.html +5 -5
- package/payload/server/public/calendar.html +6 -6
- package/payload/server/public/chat.html +12 -12
- package/payload/server/public/data.html +10 -10
- package/payload/server/public/graph.html +11 -11
- package/payload/server/public/index.html +13 -13
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +12 -12
- package/payload/server/public/tasks.html +5 -5
- package/payload/server/server.js +349 -171
- package/payload/server/public/assets/AdminShell-DSQrvZXq.js +0 -2
- package/payload/server/public/assets/admin-Ch4n-G0j.js +0 -1
- package/payload/server/public/assets/browser-B2AIxiuk.js +0 -1
- package/payload/server/public/assets/calendar-BvItH3B0.js +0 -1
- package/payload/server/public/assets/chat-eQFMaX9y.js +0 -1
- package/payload/server/public/assets/chevron-left-D2AnCEyE.js +0 -1
- package/payload/server/public/assets/data-BzOmbHoe.js +0 -1
- package/payload/server/public/assets/file-download-CK9j_Jx2.js +0 -1
- package/payload/server/public/assets/graph-labels-CwEtvIRV.js +0 -1
- package/payload/server/public/assets/maximize-2-CuzEom3K.js +0 -1
- package/payload/server/public/assets/operator-DlboYPPu.js +0 -1
- package/payload/server/public/assets/page-BuWH5gNK.js +0 -1
- package/payload/server/public/assets/page-Co9E8U5x.js +0 -32
- package/payload/server/public/assets/public-DtFpPMTG.js +0 -1
- package/payload/server/public/assets/useCopyFeedback-rB8QuqyH.js +0 -1
- package/payload/server/public/assets/useVoiceRecorder-Ctny8qWx.js +0 -2
- /package/payload/server/public/assets/{useSubAccountSwitcher-CHEt_m6q.js → useSubAccountSwitcher-DF6bohQA.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-bookings.d.ts","sourceRoot":"","sources":["../../src/scripts/reconcile-bookings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"reconcile-bookings.d.ts","sourceRoot":"","sources":["../../src/scripts/reconcile-bookings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* calendar, links the booker as a :Person, and notifies the admin. Marks each
|
|
8
8
|
* row swept so it reconciles exactly once. Ends with the standing audit.
|
|
9
9
|
*
|
|
10
|
+
* Task 1654 — for each booking-site account it also create-only provisions the
|
|
11
|
+
* recurring connector-sync :Event (the admin turn that reads the calendar connector
|
|
12
|
+
* and reflects busy blocks into availability).
|
|
13
|
+
*
|
|
10
14
|
* The Pi has no running periodic surface today (the legacy cron was removed and
|
|
11
15
|
* the desktop-scheduled-task replacement is not wired), so this binary is armed
|
|
12
16
|
* by the always-running platform/ui server on an interval. A PID lock prevents
|
|
@@ -22,7 +26,7 @@ import { spawnSync } from "node:child_process";
|
|
|
22
26
|
import { readFileSync, writeFileSync, existsSync, unlinkSync, mkdirSync, readdirSync } from "node:fs";
|
|
23
27
|
import { resolve, join } from "node:path";
|
|
24
28
|
import { homedir } from "node:os";
|
|
25
|
-
import { reconcileOne, auditCounts } from "../lib/booking-reconcile.js";
|
|
29
|
+
import { reconcileOne, auditCounts, ensureConnectorSyncEvent, countPublishedConflicts } from "../lib/booking-reconcile.js";
|
|
26
30
|
import { notifyBooking } from "../lib/booking-notify.js";
|
|
27
31
|
import { buildD1Command } from "../lib/d1-command.js";
|
|
28
32
|
function resolveConfigDir() {
|
|
@@ -98,6 +102,18 @@ function readEnvFile(path) {
|
|
|
98
102
|
}
|
|
99
103
|
return out;
|
|
100
104
|
}
|
|
105
|
+
/** First registered admin WhatsApp phone for this account, or null. Provisioning
|
|
106
|
+
* skips (observably) when no admin destination exists to dispatch the sync to. */
|
|
107
|
+
function readAdminPhone(accountDir) {
|
|
108
|
+
try {
|
|
109
|
+
const cfg = JSON.parse(readFileSync(join(accountDir, "account.json"), "utf-8"));
|
|
110
|
+
const phones = Array.isArray(cfg.adminPhones) ? cfg.adminPhones : [];
|
|
111
|
+
return typeof phones[0] === "string" && phones[0].length > 0 ? phones[0] : null;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
101
117
|
/** Run a D1 SQL statement via wrangler with the per-scope token. Returns parsed rows. */
|
|
102
118
|
function d1Query(dbName, sql, env) {
|
|
103
119
|
const { command, args } = buildD1Command(dbName, sql);
|
|
@@ -163,6 +179,26 @@ async function reconcileAccount(driver, accountId, accountDir, houseToken, house
|
|
|
163
179
|
console.error(`[calendar-reconcile] account=${accountId} skip reason=no-booking-db`);
|
|
164
180
|
return;
|
|
165
181
|
}
|
|
182
|
+
// Task 1654 — provision the recurring connector-sync turn for this booking-site
|
|
183
|
+
// account. Create-only; the admin session it spawns is the only seat that can
|
|
184
|
+
// read the calendar connector. Skips observably when no admin destination exists.
|
|
185
|
+
const syncSession = driver.session();
|
|
186
|
+
try {
|
|
187
|
+
const adminPhone = readAdminPhone(accountDir);
|
|
188
|
+
if (!adminPhone) {
|
|
189
|
+
console.error(`[calendar-availability] op=cal-sync-provision account=${accountId} result=skipped reason=no-admin-destination`);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const outcome = await ensureConnectorSyncEvent(syncSession, accountId, adminPhone);
|
|
193
|
+
console.error(`[calendar-availability] op=cal-sync-provision account=${accountId} result=${outcome}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
console.error(`[calendar-availability] op=cal-sync-provision account=${accountId} result=error reason=${JSON.stringify(err.message)}`);
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
await syncSession.close();
|
|
201
|
+
}
|
|
166
202
|
// Task 1631 — house code uses the house-only Cloudflare credential, never a
|
|
167
203
|
// per-account token. The account-wide token no longer lives in a sub-account
|
|
168
204
|
// secrets file; the booking DB is still targeted by its per-account name.
|
|
@@ -240,6 +276,37 @@ async function reconcileAccount(driver, accountId, accountDir, houseToken, house
|
|
|
240
276
|
finally {
|
|
241
277
|
await auditSession.close();
|
|
242
278
|
}
|
|
279
|
+
// Task 1654 — standing connector-drift audit. Independent of any booking: it
|
|
280
|
+
// reconciles the PUBLISHED open slots against the current connector-busy set,
|
|
281
|
+
// so a booking page offering a slot the connector shows busy is surfaced before
|
|
282
|
+
// a customer hits it. connector-busy read from the graph, published slots from D1.
|
|
283
|
+
const driftSession = driver.session();
|
|
284
|
+
try {
|
|
285
|
+
let publishedSlots = [];
|
|
286
|
+
try {
|
|
287
|
+
const rows = d1Query(dbName, "SELECT payload FROM availability_snapshot WHERE id=1", wranglerEnv);
|
|
288
|
+
const payload = rows[0]?.payload;
|
|
289
|
+
if (typeof payload === "string") {
|
|
290
|
+
const parsed = JSON.parse(payload);
|
|
291
|
+
if (Array.isArray(parsed.slots))
|
|
292
|
+
publishedSlots = parsed.slots;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
/* no snapshot yet (booking site never published) — audit degrades to 0 */
|
|
297
|
+
}
|
|
298
|
+
const busyRes = await driftSession.run(`MATCH (b:ConnectorBusy {accountId: $accountId})
|
|
299
|
+
RETURN toString(b.startsAt) AS start, toString(b.endsAt) AS end`, { accountId });
|
|
300
|
+
const busy = busyRes.records.map((r) => ({ start: r.get("start"), end: r.get("end") }));
|
|
301
|
+
const conflicts = countPublishedConflicts(publishedSlots, busy);
|
|
302
|
+
console.error(`[calendar-availability] op=cal-drift account=${accountId} conflicts=${conflicts}`);
|
|
303
|
+
}
|
|
304
|
+
catch (err) {
|
|
305
|
+
console.error(`[calendar-availability] op=cal-drift account=${accountId} result=error reason=${JSON.stringify(err.message)}`);
|
|
306
|
+
}
|
|
307
|
+
finally {
|
|
308
|
+
await driftSession.close();
|
|
309
|
+
}
|
|
243
310
|
}
|
|
244
311
|
async function main() {
|
|
245
312
|
if (!acquireLock()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-bookings.js","sourceRoot":"","sources":["../../src/scripts/reconcile-bookings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAoC,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAmB,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAE,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,SAAS,gBAAgB;IACvB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC/C,IAAI,CAAC,YAAY;QAAE,MAAM,IAAI,KAAK,CA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AC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,mCAAmC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtG,WAAW,EAAE,CAAC;IACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-connector-busy-sync.test.d.ts","sourceRoot":"","sources":["../../../src/tools/__tests__/schedule-connector-busy-sync.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { syncConnectorBusy } from "../schedule-connector-busy-sync.js";
|
|
3
|
+
// The mock records every tx.run and asserts the whole replace happens inside a
|
|
4
|
+
// single executeWrite — the atomicity the tool depends on so a concurrent
|
|
5
|
+
// free-busy read never sees the transient empty set (delete + inserts commit
|
|
6
|
+
// together).
|
|
7
|
+
function mockSession() {
|
|
8
|
+
const calls = [];
|
|
9
|
+
let writeTxCount = 0;
|
|
10
|
+
const tx = {
|
|
11
|
+
run: vi.fn(async (cypher, params) => {
|
|
12
|
+
calls.push({ cypher, params });
|
|
13
|
+
return { records: [] };
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
const session = {
|
|
17
|
+
executeWrite: vi.fn(async (work) => {
|
|
18
|
+
writeTxCount++;
|
|
19
|
+
return work(tx);
|
|
20
|
+
}),
|
|
21
|
+
close: vi.fn(async () => { }),
|
|
22
|
+
};
|
|
23
|
+
return { session: session, calls, txRun: tx.run, writeTx: () => writeTxCount };
|
|
24
|
+
}
|
|
25
|
+
describe("syncConnectorBusy", () => {
|
|
26
|
+
it("wholesale-deletes then reflects each valid busy interval in one write transaction", async () => {
|
|
27
|
+
const { session, calls, writeTx } = mockSession();
|
|
28
|
+
const res = await syncConnectorBusy(session, "acct-1", {
|
|
29
|
+
connector: "google",
|
|
30
|
+
busy: [
|
|
31
|
+
{ start: "2026-06-22T10:00:00Z", end: "2026-06-22T11:00:00Z" },
|
|
32
|
+
{ start: "2026-06-22T14:00:00Z", end: "2026-06-22T15:00:00Z" },
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
expect(res).toEqual({ connector: "google", busyBlocks: 2, reflected: 2 });
|
|
36
|
+
// The entire replace runs inside exactly one executeWrite — delete and
|
|
37
|
+
// insert commit together, so no reader observes a transient empty set.
|
|
38
|
+
expect(writeTx()).toBe(1);
|
|
39
|
+
// First statement clears the account's existing connector-busy nodes.
|
|
40
|
+
expect(calls[0].cypher).toMatch(/DELETE/);
|
|
41
|
+
expect(calls[0].cypher).toMatch(/ConnectorBusy/);
|
|
42
|
+
expect(calls[0].params.accountId).toBe("acct-1");
|
|
43
|
+
// A single UNWIND insert carries both valid intervals with the connector tag.
|
|
44
|
+
const insert = calls.find((c) => /CREATE/.test(c.cypher));
|
|
45
|
+
expect(insert).toBeTruthy();
|
|
46
|
+
expect(insert.cypher).toMatch(/UNWIND/);
|
|
47
|
+
expect(insert.params.connector).toBe("google");
|
|
48
|
+
expect(insert.params.busy).toHaveLength(2);
|
|
49
|
+
});
|
|
50
|
+
it("skips an interval whose start is not before its end and does not count it reflected", async () => {
|
|
51
|
+
const { session, calls } = mockSession();
|
|
52
|
+
const res = await syncConnectorBusy(session, "acct-1", {
|
|
53
|
+
connector: "m365",
|
|
54
|
+
busy: [
|
|
55
|
+
{ start: "2026-06-22T11:00:00Z", end: "2026-06-22T10:00:00Z" }, // invalid
|
|
56
|
+
{ start: "2026-06-22T14:00:00Z", end: "2026-06-22T15:00:00Z" }, // valid
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
expect(res).toEqual({ connector: "m365", busyBlocks: 2, reflected: 1 });
|
|
60
|
+
// Only the one valid interval is unwound into the insert.
|
|
61
|
+
const insert = calls.find((c) => /CREATE/.test(c.cypher));
|
|
62
|
+
expect(insert.params.busy).toHaveLength(1);
|
|
63
|
+
});
|
|
64
|
+
it("connector=none clears connector-busy and reflects nothing", async () => {
|
|
65
|
+
const { session, calls, writeTx } = mockSession();
|
|
66
|
+
const res = await syncConnectorBusy(session, "acct-1", { connector: "none", busy: [] });
|
|
67
|
+
expect(res).toEqual({ connector: "none", busyBlocks: 0, reflected: 0 });
|
|
68
|
+
// Still clears inside the transaction, so a deauthorised connector's stale
|
|
69
|
+
// blocks disappear; with nothing valid there is no insert statement.
|
|
70
|
+
expect(writeTx()).toBe(1);
|
|
71
|
+
expect(calls[0].cypher).toMatch(/DELETE/);
|
|
72
|
+
expect(calls.some((c) => /CREATE/.test(c.cypher))).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=schedule-connector-busy-sync.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-connector-busy-sync.test.js","sourceRoot":"","sources":["../../../src/tools/__tests__/schedule-connector-busy-sync.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,+EAA+E;AAC/E,0EAA0E;AAC1E,6EAA6E;AAC7E,aAAa;AACb,SAAS,WAAW;IAClB,MAAM,KAAK,GAA0D,EAAE,CAAC;IACxE,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG;QACT,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,MAAc,EAAE,MAA+B,EAAE,EAAE;YACnE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAC/B,OAAO,EAAE,OAAO,EAAE,EAAE,E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| "none";
|
|
3
|
+
export interface BusyInterval {
|
|
4
|
+
start: string;
|
|
5
|
+
end: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ConnectorBusyInput {
|
|
8
|
+
connector: ConnectorKind;
|
|
9
|
+
busy: BusyInterval[];
|
|
10
|
+
}
|
|
11
|
+
export interface SyncResult {
|
|
12
|
+
connector: ConnectorKind;
|
|
13
|
+
busyBlocks: number;
|
|
14
|
+
reflected: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Wholesale-replace the account's :ConnectorBusy nodes with the busy intervals
|
|
18
|
+
* the admin turn read from its calendar connector. Delete-then-insert so an
|
|
19
|
+
* upstream-deleted connector event stops blocking on the next sync, and a
|
|
20
|
+
* deauthorised connector (connector='none', busy=[]) clears all blocks.
|
|
21
|
+
*
|
|
22
|
+
* The delete and every insert run in ONE write transaction so the replace is
|
|
23
|
+
* all-or-nothing: a concurrent /api/calendar/free-busy read never observes the
|
|
24
|
+
* transient empty set between clear and re-insert (which would publish a real
|
|
25
|
+
* busy time as an open slot), and a mid-write failure rolls back to the prior
|
|
26
|
+
* complete set rather than leaving a partial one.
|
|
27
|
+
*
|
|
28
|
+
* The LLM read the connector; this write and the counts are deterministic.
|
|
29
|
+
*/
|
|
30
|
+
export declare function syncConnectorBusy(session: Session, accountId: string, input: ConnectorBusyInput): Promise<SyncResult>;
|
|
31
|
+
//# sourceMappingURL=schedule-connector-busy-sync.d.ts.map
|
package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-connector-busy-sync.d.ts","sourceRoot":"","sources":["../../src/tools/schedule-connector-busy-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,aAAa,CAAC;IACzB,IAAI,EAAE,YAAY,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AASD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,UAAU,CAAC,CAsBrB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** A busy interval is valid iff both ends parse as ISO and start < end. */
|
|
2
|
+
function isValidInterval(iv) {
|
|
3
|
+
const s = Date.parse(iv.start);
|
|
4
|
+
const e = Date.parse(iv.end);
|
|
5
|
+
return !Number.isNaN(s) && !Number.isNaN(e) && s < e;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wholesale-replace the account's :ConnectorBusy nodes with the busy intervals
|
|
9
|
+
* the admin turn read from its calendar connector. Delete-then-insert so an
|
|
10
|
+
* upstream-deleted connector event stops blocking on the next sync, and a
|
|
11
|
+
* deauthorised connector (connector='none', busy=[]) clears all blocks.
|
|
12
|
+
*
|
|
13
|
+
* The delete and every insert run in ONE write transaction so the replace is
|
|
14
|
+
* all-or-nothing: a concurrent /api/calendar/free-busy read never observes the
|
|
15
|
+
* transient empty set between clear and re-insert (which would publish a real
|
|
16
|
+
* busy time as an open slot), and a mid-write failure rolls back to the prior
|
|
17
|
+
* complete set rather than leaving a partial one.
|
|
18
|
+
*
|
|
19
|
+
* The LLM read the connector; this write and the counts are deterministic.
|
|
20
|
+
*/
|
|
21
|
+
export async function syncConnectorBusy(session, accountId, input) {
|
|
22
|
+
const now = new Date().toISOString();
|
|
23
|
+
// Invalid intervals are skipped and not counted reflected, so the caller's
|
|
24
|
+
// op=cal-sync line proves what actually landed.
|
|
25
|
+
const valid = input.busy.filter(isValidInterval).map((iv) => ({ start: iv.start, end: iv.end }));
|
|
26
|
+
await session.executeWrite(async (tx) => {
|
|
27
|
+
await tx.run(`MATCH (b:ConnectorBusy {accountId: $accountId}) DELETE b`, { accountId });
|
|
28
|
+
if (valid.length > 0) {
|
|
29
|
+
await tx.run(`UNWIND $busy AS iv
|
|
30
|
+
CREATE (b:ConnectorBusy {
|
|
31
|
+
accountId: $accountId,
|
|
32
|
+
startsAt: datetime(iv.start),
|
|
33
|
+
endsAt: datetime(iv.end),
|
|
34
|
+
connector: $connector,
|
|
35
|
+
syncedAt: datetime($now)
|
|
36
|
+
})`, { accountId, busy: valid, connector: input.connector, now });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return { connector: input.connector, busyBlocks: input.busy.length, reflected: valid.length };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=schedule-connector-busy-sync.js.map
|
package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-connector-busy-sync.js","sourceRoot":"","sources":["../../src/tools/schedule-connector-busy-sync.ts"],"names":[],"mappings":"AAoBA,2EAA2E;AAC3E,SAAS,eAAe,CAAC,EAAgB;IACvC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAgB,EAChB,SAAiB,EACjB,KAAyB;IAEzB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,2EAA2E;IAC3E,gDAAgD;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACjG,MAAM,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACtC,MAAM,EAAE,CAAC,GAAG,CAAC,0DAA0D,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QACxF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,EAAE,CAAC,GAAG,CACV;;;;;;;YAOI,EACJ,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AAChG,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "voice-mirror",
|
|
3
|
+
"description": "Authorial-voice capture and application. Captures the operator's voice from their own writing (the `human-only` corpus) and conditions agent drafts on it. Five tools: tag historical content (operator supplies `format`), distil a per-format style card, retrieve conditioning for a drafting brief (requires `brief.format`), record operator edits as feedback, and capture the current session's turns on demand. Other drafting skills (email composition, property-brochure, prospectus) call it transparently — opt out via `voiceMirror: false` in the calling skill's frontmatter. A core plugin: present on every brand, no premium bundle required.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Rubytech LLC"
|
|
7
|
+
},
|
|
8
|
+
"mcpServers": {
|
|
9
|
+
"voice-mirror": {
|
|
10
|
+
"type": "stdio",
|
|
11
|
+
"command": "node",
|
|
12
|
+
"args": [
|
|
13
|
+
"${CLAUDE_PLUGIN_ROOT}/lib/mcp-spawn-tee/index.js",
|
|
14
|
+
"${CLAUDE_PLUGIN_ROOT}/mcp/dist/index.js"
|
|
15
|
+
],
|
|
16
|
+
"env": {
|
|
17
|
+
"MCP_SPAWN_TEE_NAME": "voice-mirror"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
mcp-manifest: auto
|
|
3
|
+
name: voice-mirror
|
|
4
|
+
description: "Authorial-voice capture and application. Captures the operator's voice from their own writing (the `human-only` corpus) and conditions agent drafts on it. Five tools: tag historical content (operator supplies `format`), distil a per-format style card, retrieve conditioning for a drafting brief (requires `brief.format`), record operator edits as feedback, and capture the current session's turns on demand. Other drafting skills (email composition, property-brochure, prospectus) call it transparently — opt out via `voiceMirror: false` in the calling skill's frontmatter. A core plugin: present on every brand, no premium bundle required."
|
|
5
|
+
icon: 🪞
|
|
6
|
+
tools:
|
|
7
|
+
- name: voice-tag-content
|
|
8
|
+
publicAllowlist: false
|
|
9
|
+
adminAllowlist: true
|
|
10
|
+
- name: voice-distil-profile
|
|
11
|
+
publicAllowlist: false
|
|
12
|
+
adminAllowlist: true
|
|
13
|
+
- name: voice-retrieve-conditioning
|
|
14
|
+
publicAllowlist: false
|
|
15
|
+
adminAllowlist: false
|
|
16
|
+
- name: voice-record-feedback
|
|
17
|
+
publicAllowlist: false
|
|
18
|
+
adminAllowlist: true
|
|
19
|
+
- name: voice-ingest-session-text
|
|
20
|
+
publicAllowlist: false
|
|
21
|
+
adminAllowlist: true
|
|
22
|
+
mcp:
|
|
23
|
+
command: node
|
|
24
|
+
args:
|
|
25
|
+
- ${PLATFORM_ROOT}/lib/mcp-spawn-tee/dist/index.js
|
|
26
|
+
- ${PLATFORM_ROOT}/plugins/voice-mirror/mcp/dist/index.js
|
|
27
|
+
env:
|
|
28
|
+
MCP_SPAWN_TEE_NAME: voice-mirror
|
|
29
|
+
LOG_DIR: ${LOG_DIR}
|
|
30
|
+
PLATFORM_ROOT: ${PLATFORM_ROOT}
|
|
31
|
+
ACCOUNT_ID: ${ACCOUNT_ID}
|
|
32
|
+
ADMIN_USER_ID: ${ADMIN_USER_ID}
|
|
33
|
+
SESSION_ID: ${SESSION_ID}
|
|
34
|
+
NEO4J_URI: ${NEO4J_URI}
|
|
35
|
+
NEO4J_USER: ${NEO4J_USER}
|
|
36
|
+
NEO4J_PASSWORD: ${NEO4J_PASSWORD}
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
# Voice Mirror
|
|
40
|
+
|
|
41
|
+
Capture the operator's authorial voice from their own writing (the `human-only` corpus) and condition agent drafts on it. A core plugin — present on every brand.
|
|
42
|
+
|
|
43
|
+
The `voice-mirror` skill drives the operator-facing flow (backfill tagging, distillation, session capture). Other drafting skills call `voice-retrieve-conditioning` transparently before composing, so prose that goes out under the operator's name is conditioned on their style card, not a neutral register.
|
|
44
|
+
|
|
45
|
+
## When to Activate
|
|
46
|
+
|
|
47
|
+
The operator is:
|
|
48
|
+
- Building or refreshing their writing-voice profile from their own historical content
|
|
49
|
+
- Asking to capture the current session's voice
|
|
50
|
+
- Drafting anything that goes out under their name (email, social post, article, marketing copy, note) — the drafting skill retrieves conditioning automatically
|
|
51
|
+
|
|
52
|
+
## Skill
|
|
53
|
+
|
|
54
|
+
| Skill | Purpose |
|
|
55
|
+
|-------|---------|
|
|
56
|
+
| `voice-mirror` | Capture the operator's voice from their own writing (`human-only` corpus) and condition agent drafts on it. Five tools: tag historical content (operator supplies `format`), distil a per-format style card, retrieve conditioning for a drafting brief (requires `brief.format`), record operator edits as feedback, and capture the current session's turns on demand. Other drafting skills (email composition, property-brochure, prospectus) call it transparently — opt out via `voiceMirror: false` in the calling skill's frontmatter. |
|
|
57
|
+
|
|
58
|
+
## Tools
|
|
59
|
+
|
|
60
|
+
Voice mirror introduces five deterministic plugin tools. They route writes through `memory-write` so the graph-write gate stamps provenance on every node.
|
|
61
|
+
|
|
62
|
+
| Tool | Purpose |
|
|
63
|
+
|------|---------|
|
|
64
|
+
| `voice-tag-content` | Stamp `authorshipMode ∈ {human-only, human-led-agent-assisted, agent-led-human-reviewed, agent-only, unknown}`, `format ∈ {text, email, social-post, article, note, marketing-copy}`, and `voiceAuthor` on one or many `:KnowledgeDocument | :Message | :SocialPost` nodes (email threads live as `:KnowledgeDocument {source:'email'}`). Bulk-mode for backfill batches. `format` is required. `author` is optional — omit to attribute to the tagging operator. |
|
|
65
|
+
| `voice-distil-profile` | Three modes, scope-aware (`scope='personal'` default walks one author; `scope='org'` walks the whole account onto the business). `mode='sample'` (default) walks the `human-only` corpus for the given `format`/`scope` and returns exemplars + recent edit intents for the agent to compose a style card; cadence-guarded (≥20% growth or ≥30 days). `mode='amend'` reads only `nodeIds` plus the existing `:VoiceProfile.styleCard` so the agent can decide whether named documents move the profile — operator-initiated, no cadence guard. `mode='write'` persists the YAML card; supply `amendedFromNodeIds` to attribute the write to specific documents (bypasses cadence + corpus walk). Trashed nodes are excluded from every walk. Omit `format` on `'sample'` to enumerate all formats in that scope's corpus and distil each. |
|
|
66
|
+
| `voice-retrieve-conditioning` | Return `{styleCard, exemplars[], status}` for a drafting brief. Requires `brief.format` (one of the six corpus formats). `brief.scope` (default `personal`) picks personal vs org voice; a personal request with no personal profile falls back to the org profile (`status='fallback-org'`). K=5 short-form (`brief.length:'short'`), K=15 long-form (`brief.length:'long'`). Token-budget bounded. `status ∈ {ok, fallback-org, no-data, error}`. |
|
|
67
|
+
| `voice-record-feedback` | Capture an operator edit on an agent draft as a `:VoiceEdit {format, scope}` with a Haiku-summarised `intent`, linked back to the scoped per-format `:VoiceProfile` via `:FEEDBACK_FOR` (org edits → org profile; editor preserved via `:AUTHORED`). Requires `format`. |
|
|
68
|
+
| `voice-ingest-session-text` | Write operator turns from the current session as `:Message {format:'text', authorshipMode:'human-only'}` corpus nodes. The agent reads its own operator turns from context and passes them as `turns`. Deduplicates via SHA256 `contentHash`. Invoked on demand by the voice-mirror skill when the operator asks to capture this session's voice. |
|
|
69
|
+
|
|
70
|
+
## References
|
|
71
|
+
|
|
72
|
+
No external references; the skill body defines the five tool contracts. Developer notes in `maxy-code/.docs/voice-mirror.md`.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* MCP spawn-tee — in-process stderr capture + lifecycle observability.
|
|
5
|
+
*
|
|
6
|
+
* Claude Code spawns each MCP server itself; the platform never holds a
|
|
7
|
+
* ChildProcess handle. This shim sits between Claude Code and the real MCP
|
|
8
|
+
* server: Claude Code runs `node <this> <real-entry>`, and the shim runs the
|
|
9
|
+
* real entry IN ITS OWN PROCESS via dynamic import() — one node runtime, not
|
|
10
|
+
* two. Before importing, it replaces process.stderr.write with a tee so every
|
|
11
|
+
* stderr byte the server writes is mirrored to the log sinks; stdin and stdout
|
|
12
|
+
* (the JSON-RPC channel) are never touched.
|
|
13
|
+
*
|
|
14
|
+
* Claude Code CLI → shim (this file) = node running <real-entry> in-process
|
|
15
|
+
* stdin/stdout : untouched (JSON-RPC channel)
|
|
16
|
+
* stderr : process.stderr.write teed → per-date + per-session + passthrough
|
|
17
|
+
*
|
|
18
|
+
* Destinations (Task 706) — unchanged:
|
|
19
|
+
* - `${LOG_DIR}/mcp-<name>-stderr-<date>.log` — per-date raw (back-compat;
|
|
20
|
+
* the in-process mcp-stderr-tee and the [mcp-init-error] probe read it).
|
|
21
|
+
* - `${LOG_DIR}/mcp-<name>-<SESSION_ID>.log` — per-session raw + lifecycle
|
|
22
|
+
* lines. Authoritative sink. Absent when SESSION_ID is unset (enumeration
|
|
23
|
+
* spawn) — then the per-date file is the fallback.
|
|
24
|
+
* - `server.log` via the loopback log-ingest route — best-effort mirror of
|
|
25
|
+
* the [mcp-helper] lifecycle lines.
|
|
26
|
+
*
|
|
27
|
+
* Lifecycle lines, correlation key `session=<id8> server=<name>` — unchanged:
|
|
28
|
+
* [mcp-helper] op=spawn ... pid= entry=
|
|
29
|
+
* [mcp-helper] op=boot ... head=<first stderr bytes>
|
|
30
|
+
* [mcp-helper] op=exit ... code= signal= lifetimeMs= stderr-tail=
|
|
31
|
+
*
|
|
32
|
+
* Process model (Task 989): the shim IS the server's process. op=exit fires
|
|
33
|
+
* from process.on("exit"), so it covers a normal exit, a non-zero exit, an
|
|
34
|
+
* uncaught throw (code 1), and a catchable-signal exit (SIGTERM/SIGINT/SIGHUP,
|
|
35
|
+
* whose handlers record the signal name). An external SIGKILL is uncatchable
|
|
36
|
+
* and leaves no op=exit line — the per-session stderr tail already on disk and
|
|
37
|
+
* Claude Code's own transport-drop are the evidence for that death mode.
|
|
38
|
+
*
|
|
39
|
+
* The shim never writes to fd 1 (stdout) — that is the JSON-RPC channel.
|
|
40
|
+
*/
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
const node_fs_1 = require("node:fs");
|
|
43
|
+
const node_path_1 = require("node:path");
|
|
44
|
+
const node_url_1 = require("node:url");
|
|
45
|
+
const SERVER_NAME = process.env.MCP_SPAWN_TEE_NAME ?? "unknown";
|
|
46
|
+
const LOG_DIR = process.env.LOG_DIR;
|
|
47
|
+
const SESSION_ID = process.env.SESSION_ID;
|
|
48
|
+
const PLATFORM_PORT = process.env.PLATFORM_PORT;
|
|
49
|
+
const ENTRY = process.argv[2];
|
|
50
|
+
const SESSION_ID8 = SESSION_ID ? SESSION_ID.slice(0, 8) : "—";
|
|
51
|
+
const spawnStamp = Date.now();
|
|
52
|
+
// Per-session raw + lifecycle log (Task 706). Empty SESSION_ID (enumeration
|
|
53
|
+
// spawn) → undefined, and the per-date file is the fallback.
|
|
54
|
+
const perSessionPath = LOG_DIR && SESSION_ID
|
|
55
|
+
? (0, node_path_1.resolve)(LOG_DIR, `mcp-${SERVER_NAME}-${SESSION_ID}.log`)
|
|
56
|
+
: undefined;
|
|
57
|
+
const perDatePath = LOG_DIR
|
|
58
|
+
? (0, node_path_1.resolve)(LOG_DIR, `mcp-${SERVER_NAME}-stderr-${new Date(spawnStamp).toISOString().slice(0, 10)}.log`)
|
|
59
|
+
: undefined;
|
|
60
|
+
// Rolling tail of entry stderr for op=exit. Capped so a chatty server cannot
|
|
61
|
+
// grow the buffer without bound.
|
|
62
|
+
const TAIL_CAP = 2048;
|
|
63
|
+
let stderrTail = "";
|
|
64
|
+
let bootEmitted = false;
|
|
65
|
+
let exitEmitted = false;
|
|
66
|
+
let exitSignal;
|
|
67
|
+
// The real stderr writer, captured before the tee replaces it. Lifecycle lines
|
|
68
|
+
// and stderr passthrough both go through this so they are never re-teed into
|
|
69
|
+
// the per-date sink nor recursed back into the patched writer.
|
|
70
|
+
const rawStderrWrite = process.stderr.write.bind(process.stderr);
|
|
71
|
+
// LOG_DIR is created once, lazily, on the first successful append — not per
|
|
72
|
+
// chunk. teeWrite runs on the server's own stderr hot path now, so a per-call
|
|
73
|
+
// mkdirSync would be two syscalls per log line for nothing.
|
|
74
|
+
let logDirReady = false;
|
|
75
|
+
function appendSafe(path, data) {
|
|
76
|
+
if (!path || !LOG_DIR)
|
|
77
|
+
return;
|
|
78
|
+
try {
|
|
79
|
+
if (!logDirReady) {
|
|
80
|
+
(0, node_fs_1.mkdirSync)(LOG_DIR, { recursive: true });
|
|
81
|
+
logDirReady = true;
|
|
82
|
+
}
|
|
83
|
+
(0, node_fs_1.appendFileSync)(path, data);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
/* unwritable destination — never mask primary output */
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Best-effort mirror of a lifecycle line to server.log via the loopback
|
|
90
|
+
// log-ingest route. Fire-and-forget: the per-session file is authoritative, so
|
|
91
|
+
// a dropped POST loses nothing. On the "exit" event the loop is stopping, so
|
|
92
|
+
// the op=exit mirror may not flush — the per-session line, written sync, holds.
|
|
93
|
+
function postToServerLog(suffix, level) {
|
|
94
|
+
if (!PLATFORM_PORT)
|
|
95
|
+
return;
|
|
96
|
+
try {
|
|
97
|
+
const ctrl = new AbortController();
|
|
98
|
+
const t = setTimeout(() => ctrl.abort(), 500);
|
|
99
|
+
t.unref?.(); // never let the abort timer keep the shim's event loop alive
|
|
100
|
+
void fetch(`http://127.0.0.1:${PLATFORM_PORT}/api/admin/log-ingest`, {
|
|
101
|
+
method: "POST",
|
|
102
|
+
headers: { "content-type": "application/json" },
|
|
103
|
+
body: JSON.stringify({ tag: "mcp-helper", level, line: suffix }),
|
|
104
|
+
signal: ctrl.signal,
|
|
105
|
+
}).then(() => clearTimeout(t)).catch(() => clearTimeout(t));
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
/* fetch threw synchronously — best-effort only */
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Emit one [mcp-helper] lifecycle line: authoritative per-session file (sync,
|
|
112
|
+
// survives process.exit), the shim's own stderr via the RAW writer (journald /
|
|
113
|
+
// Claude Code visibility, never re-teed), and a best-effort server.log mirror.
|
|
114
|
+
// `suffix` is the line body after the tag and carries no newline (the
|
|
115
|
+
// log-ingest route rejects newlines).
|
|
116
|
+
function emitLifecycle(suffix, level) {
|
|
117
|
+
const line = `[mcp-helper] ${suffix}\n`;
|
|
118
|
+
appendSafe(perSessionPath, line);
|
|
119
|
+
try {
|
|
120
|
+
rawStderrWrite(line);
|
|
121
|
+
}
|
|
122
|
+
catch { /* stderr closed */ }
|
|
123
|
+
postToServerLog(suffix, level);
|
|
124
|
+
}
|
|
125
|
+
if (!ENTRY) {
|
|
126
|
+
emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason="no entry given (argv[2] missing)"`, "error");
|
|
127
|
+
process.exit(2);
|
|
128
|
+
}
|
|
129
|
+
// Replace process.stderr.write with a tee: mirror every server stderr byte to
|
|
130
|
+
// the per-date and per-session sinks, keep a rolling tail for op=exit, emit
|
|
131
|
+
// op=boot on the first bytes, then pass the write through to the real stderr.
|
|
132
|
+
const teeWrite = ((...args) => {
|
|
133
|
+
const chunk = args[0];
|
|
134
|
+
appendSafe(perDatePath, chunk); // per-date raw (back-compat)
|
|
135
|
+
appendSafe(perSessionPath, chunk); // per-session raw (Task 706)
|
|
136
|
+
const text = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
137
|
+
stderrTail = (stderrTail + text).slice(-TAIL_CAP);
|
|
138
|
+
if (!bootEmitted) {
|
|
139
|
+
bootEmitted = true;
|
|
140
|
+
const head = text.split("\n")[0].slice(0, 200);
|
|
141
|
+
emitLifecycle(`op=boot session=${SESSION_ID8} server=${SERVER_NAME} head=${JSON.stringify(head)}`, "info");
|
|
142
|
+
}
|
|
143
|
+
return rawStderrWrite(...args); // passthrough
|
|
144
|
+
});
|
|
145
|
+
process.stderr.write = teeWrite;
|
|
146
|
+
// Catchable-signal handling. The shim drives the exit ONLY when it is the sole
|
|
147
|
+
// listener for the signal — i.e. the imported entry installed no handler of its
|
|
148
|
+
// own. In that case it records the signal (so op=exit carries signal=<sig>) and
|
|
149
|
+
// exits with 128+signum, mirroring the prior wrapper's exit-status convention.
|
|
150
|
+
//
|
|
151
|
+
// When the entry DID install a handler, the shim defers entirely and records
|
|
152
|
+
// nothing: the entry's handler decides the exit code, and op=exit reflects that
|
|
153
|
+
// exit verbatim. This matches the prior two-process model, where a child that
|
|
154
|
+
// caught the signal and exited cleanly was observed as code=0 signal=— (a clean
|
|
155
|
+
// self-exit), not as a signal death. Setting exitSignal here unconditionally
|
|
156
|
+
// would mislabel every graceful signal-driven shutdown as a signal kill.
|
|
157
|
+
function onSignal(sig, code) {
|
|
158
|
+
return () => {
|
|
159
|
+
if (process.listenerCount(sig) === 1) {
|
|
160
|
+
exitSignal = sig;
|
|
161
|
+
process.exit(code);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
process.on("SIGTERM", onSignal("SIGTERM", 143));
|
|
166
|
+
process.on("SIGINT", onSignal("SIGINT", 130));
|
|
167
|
+
process.on("SIGHUP", onSignal("SIGHUP", 129));
|
|
168
|
+
// op=exit, emitted once from the process "exit" event. Sync-only — the loop is
|
|
169
|
+
// stopping. When a catchable signal caused the exit, report code=— signal=<sig>
|
|
170
|
+
// to match the prior wrapper's format; otherwise code=<exit code> signal=—.
|
|
171
|
+
process.on("exit", (code) => {
|
|
172
|
+
if (exitEmitted)
|
|
173
|
+
return;
|
|
174
|
+
exitEmitted = true;
|
|
175
|
+
const lifetimeMs = Date.now() - spawnStamp;
|
|
176
|
+
const tail = stderrTail.slice(-200);
|
|
177
|
+
const codeField = exitSignal ? "—" : String(code);
|
|
178
|
+
const level = exitSignal || code !== 0 ? "error" : "info";
|
|
179
|
+
emitLifecycle(`op=exit session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} ` +
|
|
180
|
+
`code=${codeField} signal=${exitSignal ?? "—"} lifetimeMs=${lifetimeMs} stderr-tail=${JSON.stringify(tail)}`, level);
|
|
181
|
+
});
|
|
182
|
+
emitLifecycle(`op=spawn session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} entry=${ENTRY}`, "info");
|
|
183
|
+
// Run the real MCP server in THIS process. Dynamic import() (not top-level
|
|
184
|
+
// await — this file compiles to CommonJS) loads the ESM entry; a load-time
|
|
185
|
+
// failure mirrors the old child spawn-error path (op=error, exit 127). The
|
|
186
|
+
// op=exit handler is suppressed on this path so op=error stays the sole record.
|
|
187
|
+
import((0, node_url_1.pathToFileURL)(ENTRY).href).catch((err) => {
|
|
188
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
189
|
+
exitEmitted = true;
|
|
190
|
+
emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${msg}`)}`, "error");
|
|
191
|
+
process.exit(127);
|
|
192
|
+
});
|
|
193
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAuC,gBAAgB,EAAuB,MAAM,8BAA8B,CAAC;AAic1H,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|