@rubytech/create-maxy-code 0.1.470 → 0.1.472
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__/google-client-id-env.test.js +68 -0
- package/dist/index.js +26 -18
- package/dist/port-resolution.js +7 -1
- package/package.json +1 -1
- package/payload/platform/config/brand.json +1 -1
- package/payload/platform/docs/superpowers/plans/2026-07-18-graph-native-ledger.md +807 -0
- package/payload/platform/docs/superpowers/specs/2026-07-18-graph-native-ledger-design.md +241 -0
- package/payload/platform/lib/ledger-core/dist/ageing.d.ts +14 -0
- package/payload/platform/lib/ledger-core/dist/ageing.d.ts.map +1 -0
- package/payload/platform/lib/ledger-core/dist/ageing.js +38 -0
- package/payload/platform/lib/ledger-core/dist/ageing.js.map +1 -0
- package/payload/platform/lib/ledger-core/dist/balance.d.ts +25 -0
- package/payload/platform/lib/ledger-core/dist/balance.d.ts.map +1 -0
- package/payload/platform/lib/ledger-core/dist/balance.js +38 -0
- package/payload/platform/lib/ledger-core/dist/balance.js.map +1 -0
- package/payload/platform/lib/ledger-core/dist/index.d.ts +5 -0
- package/payload/platform/lib/ledger-core/dist/index.d.ts.map +1 -0
- package/payload/platform/lib/ledger-core/dist/index.js +5 -0
- package/payload/platform/lib/ledger-core/dist/index.js.map +1 -0
- package/payload/platform/lib/ledger-core/dist/money.d.ts +12 -0
- package/payload/platform/lib/ledger-core/dist/money.d.ts.map +1 -0
- package/payload/platform/lib/ledger-core/dist/money.js +16 -0
- package/payload/platform/lib/ledger-core/dist/money.js.map +1 -0
- package/payload/platform/lib/ledger-core/dist/reconcile.d.ts +51 -0
- package/payload/platform/lib/ledger-core/dist/reconcile.d.ts.map +1 -0
- package/payload/platform/lib/ledger-core/dist/reconcile.js +77 -0
- package/payload/platform/lib/ledger-core/dist/reconcile.js.map +1 -0
- package/payload/platform/lib/ledger-core/package.json +16 -0
- package/payload/platform/lib/ledger-core/src/__tests__/ageing.test.ts +42 -0
- package/payload/platform/lib/ledger-core/src/__tests__/balance.test.ts +48 -0
- package/payload/platform/lib/ledger-core/src/__tests__/reconcile.test.ts +87 -0
- package/payload/platform/lib/ledger-core/src/ageing.ts +51 -0
- package/payload/platform/lib/ledger-core/src/balance.ts +52 -0
- package/payload/platform/lib/ledger-core/src/index.ts +4 -0
- package/payload/platform/lib/ledger-core/src/money.ts +17 -0
- package/payload/platform/lib/ledger-core/src/reconcile.ts +109 -0
- package/payload/platform/lib/ledger-core/tsconfig.json +6 -0
- package/payload/platform/neo4j/schema.cypher +16 -0
- package/payload/platform/package.json +2 -2
- 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 +98 -2
- package/payload/platform/plugins/cloudflare/bin/__tests__/portal-brand-css.test.sh +139 -0
- package/payload/platform/plugins/cloudflare/bin/portal-brand-css.mjs +128 -0
- package/payload/platform/plugins/cloudflare/mcp/__tests__/portal-enrol.test.ts +1 -1
- package/payload/platform/plugins/cloudflare/mcp/__tests__/skill-contract.test.ts +25 -0
- package/payload/platform/plugins/cloudflare/mcp/__tests__/template-config.test.ts +55 -3
- package/payload/platform/plugins/cloudflare/skills/data-portal/SKILL.md +38 -3
- package/payload/platform/plugins/cloudflare/skills/data-portal/template/{public/portal.css → portal.css} +13 -2
- package/payload/platform/plugins/cloudflare/skills/data-portal/template/wrangler.toml +1 -1
- package/payload/platform/plugins/docs/references/admin-ui.md +48 -0
- package/payload/platform/plugins/docs/references/internals.md +1 -1
- package/payload/platform/plugins/docs/references/ledger.md +43 -0
- package/payload/platform/plugins/email/PLUGIN.md +4 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/display-truncation.test.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/display-truncation.test.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/display-truncation.test.js +196 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/display-truncation.test.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/source-fetch-efficiency.test.js +10 -8
- package/payload/platform/plugins/email/mcp/dist/__tests__/source-fetch-efficiency.test.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/__tests__/truncation-tool-output.test.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/truncation-tool-output.test.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/truncation-tool-output.test.js +110 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/truncation-tool-output.test.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/lib/imap.d.ts +22 -0
- package/payload/platform/plugins/email/mcp/dist/lib/imap.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/imap.js +90 -36
- package/payload/platform/plugins/email/mcp/dist/lib/imap.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-read.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-read.js +6 -2
- package/payload/platform/plugins/email/mcp/dist/tools/email-read.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-search.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-search.js +6 -2
- package/payload/platform/plugins/email/mcp/dist/tools/email-search.js.map +1 -1
- package/payload/platform/plugins/email/skills/email-ingest/SKILL.md +4 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/account-register.test.d.ts +2 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/account-register.test.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/account-register.test.js +99 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/account-register.test.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/calendar-tools.test.d.ts +2 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/calendar-tools.test.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/calendar-tools.test.js +48 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/calendar-tools.test.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/google-client.test.d.ts +2 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/google-client.test.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/google-client.test.js +25 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/google-client.test.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/index-registration.test.d.ts +2 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/index-registration.test.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/index-registration.test.js +40 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/index-registration.test.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/pending-store.test.d.ts +2 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/pending-store.test.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/pending-store.test.js +35 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/pending-store.test.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/token-store.test.d.ts +2 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/token-store.test.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/token-store.test.js +85 -0
- package/payload/platform/plugins/google/mcp/dist/__tests__/token-store.test.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/auth/pending-store.d.ts +25 -0
- package/payload/platform/plugins/google/mcp/dist/auth/pending-store.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/auth/pending-store.js +87 -0
- package/payload/platform/plugins/google/mcp/dist/auth/pending-store.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/auth/token-store.d.ts +46 -0
- package/payload/platform/plugins/google/mcp/dist/auth/token-store.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/auth/token-store.js +138 -0
- package/payload/platform/plugins/google/mcp/dist/auth/token-store.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/index.d.ts +25 -0
- package/payload/platform/plugins/google/mcp/dist/index.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/index.js +300 -0
- package/payload/platform/plugins/google/mcp/dist/index.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/lib/google-client.d.ts +28 -0
- package/payload/platform/plugins/google/mcp/dist/lib/google-client.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/lib/google-client.js +102 -0
- package/payload/platform/plugins/google/mcp/dist/lib/google-client.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/lib/log.d.ts +3 -0
- package/payload/platform/plugins/google/mcp/dist/lib/log.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/lib/log.js +16 -0
- package/payload/platform/plugins/google/mcp/dist/lib/log.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-info.d.ts +12 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-info.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-info.js +23 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-info.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-list.d.ts +12 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-list.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-list.js +9 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-list.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-register.d.ts +59 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-register.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-register.js +126 -0
- package/payload/platform/plugins/google/mcp/dist/tools/account-register.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-cancel.d.ts +10 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-cancel.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-cancel.js +9 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-cancel.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-create.d.ts +20 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-create.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-create.js +25 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-create.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-event.d.ts +6 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-event.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-event.js +7 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-event.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-freebusy.d.ts +14 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-freebusy.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-freebusy.js +16 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-freebusy.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-list.d.ts +44 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-list.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-list.js +36 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-list.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-respond.d.ts +16 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-respond.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-respond.js +29 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-respond.js.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-update.d.ts +16 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-update.d.ts.map +1 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-update.js +32 -0
- package/payload/platform/plugins/google/mcp/dist/tools/calendar-update.js.map +1 -0
- package/payload/platform/plugins/google/references/auth.md +35 -0
- package/payload/platform/plugins/ledger/.claude-plugin/plugin.json +21 -0
- package/payload/platform/plugins/ledger/PLUGIN.md +82 -0
- package/payload/platform/plugins/ledger/lib/mcp-spawn-tee/index.js +193 -0
- package/payload/platform/plugins/ledger/lib/mcp-spawn-tee/package.json +3 -0
- package/payload/platform/plugins/ledger/mcp/dist/index.d.ts +2 -0
- package/payload/platform/plugins/ledger/mcp/dist/index.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/index.js +168 -0
- package/payload/platform/plugins/ledger/mcp/dist/index.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/ids.d.ts +4 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/ids.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/ids.js +0 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/ids.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/neo4j.d.ts +5 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/neo4j.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/neo4j.js +40 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/neo4j.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/read.d.ts +29 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/read.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/read.js +138 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/read.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/types.d.ts +47 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/types.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/types.js +14 -0
- package/payload/platform/plugins/ledger/mcp/dist/lib/types.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/balance.d.ts +18 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/balance.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/balance.js +23 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/balance.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/cash-record.d.ts +26 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/cash-record.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/cash-record.js +33 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/cash-record.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/invoice-record.d.ts +27 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/invoice-record.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/invoice-record.js +40 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/invoice-record.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/payment-record.d.ts +46 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/payment-record.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/payment-record.js +68 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/payment-record.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/reconcile.d.ts +20 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/reconcile.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/reconcile.js +30 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/reconcile.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/statement.d.ts +26 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/statement.d.ts.map +1 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/statement.js +35 -0
- package/payload/platform/plugins/ledger/mcp/dist/tools/statement.js.map +1 -0
- package/payload/platform/plugins/ledger/mcp/package.json +21 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/ledger-vertical-coverage.test.d.ts +2 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/ledger-vertical-coverage.test.d.ts.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/ledger-vertical-coverage.test.js +81 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/ledger-vertical-coverage.test.js.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.d.ts +9 -7
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.js +10 -8
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.js.map +1 -1
- package/payload/platform/plugins/memory/references/schema-base.md +22 -0
- package/payload/platform/plugins/memory/references/schema-construction.md +0 -18
- package/payload/platform/plugins/scheduling/PLUGIN.md +20 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/meeting-write.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/meeting-write.js +11 -2
- package/payload/platform/plugins/scheduling/mcp/dist/lib/meeting-write.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.js +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.js.map +1 -1
- package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-create.js +3 -3
- package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-create.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/activity-rows.d.ts +138 -0
- package/payload/platform/services/claude-session-manager/dist/activity-rows.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/activity-rows.js +268 -0
- package/payload/platform/services/claude-session-manager/dist/activity-rows.js.map +1 -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 +8 -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.d.ts +6 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +42 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/index.js +10 -1
- package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-census.d.ts +80 -6
- package/payload/platform/services/claude-session-manager/dist/pty-census.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-census.js +96 -20
- package/payload/platform/services/claude-session-manager/dist/pty-census.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/slice-memory-policy.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/slice-memory-policy.js +5 -1
- package/payload/platform/services/claude-session-manager/dist/slice-memory-policy.js.map +1 -1
- package/payload/platform/templates/specialists/agents/database-operator.md +1 -1
- package/payload/platform/templates/specialists/agents/project-manager.md +1 -1
- package/payload/server/{chunk-JRIBGO45.js → chunk-BSTIQX52.js} +44 -0
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/activity.html +19 -0
- package/payload/server/public/assets/{AdminLoginScreens-Bed8SDxY.js → AdminLoginScreens-BfamGqS7.js} +1 -1
- package/payload/server/public/assets/AdminShell-5nHOAzXO.js +2 -0
- package/payload/server/public/assets/{Checkbox-BC_KSbpS.js → Checkbox-CD6aHwac.js} +1 -1
- package/payload/server/public/assets/activity-Dj2nJzPw.js +1 -0
- package/payload/server/public/assets/{admin-DfWgJVI3.js → admin-Cpcw_YE-.js} +1 -1
- package/payload/server/public/assets/{arc-qKfXIt8v.js → arc-BrHWN2Kr.js} +1 -1
- package/payload/server/public/assets/architecture-YZFGNWBL-CZQzGRSM.js +1 -0
- package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-DkVrGn7G.js → architectureDiagram-Q4EWVU46-Clt9NOr0.js} +1 -1
- package/payload/server/public/assets/{blockDiagram-DXYQGD6D-DqavswGH.js → blockDiagram-DXYQGD6D-BOe_jmXi.js} +1 -1
- package/payload/server/public/assets/{browser-C0vkv-hH.js → browser-0znOwk1W.js} +1 -1
- package/payload/server/public/assets/{c4Diagram-AHTNJAMY-B7fyKiXe.js → c4Diagram-AHTNJAMY-B64FaKMV.js} +1 -1
- package/payload/server/public/assets/calendar-CykigHdg.js +1 -0
- package/payload/server/public/assets/channel-zDUAN9Ks.js +1 -0
- package/payload/server/public/assets/chat-DIOJZ411.js +1 -0
- package/payload/server/public/assets/chevron-left-Cq7UvOI0.js +1 -0
- package/payload/server/public/assets/{chunk-2KRD3SAO-DsgMtGkv.js → chunk-2KRD3SAO-BGAUfWvM.js} +1 -1
- package/payload/server/public/assets/{chunk-336JU56O-CkdISfNt.js → chunk-336JU56O-PFi6uQZ0.js} +2 -2
- package/payload/server/public/assets/chunk-426QAEUC-iJnqNRug.js +1 -0
- package/payload/server/public/assets/{chunk-4BX2VUAB-CYpiF2bl.js → chunk-4BX2VUAB-CkxXXCiF.js} +1 -1
- package/payload/server/public/assets/{chunk-4TB4RGXK-CWyc_F7v.js → chunk-4TB4RGXK-B-7tN4IA.js} +1 -1
- package/payload/server/public/assets/{chunk-55IACEB6-BbzKMw2Z.js → chunk-55IACEB6-CBkNmqrt.js} +1 -1
- package/payload/server/public/assets/{chunk-5FUZZQ4R-u19Nai9e.js → chunk-5FUZZQ4R-wa9ujn7i.js} +1 -1
- package/payload/server/public/assets/{chunk-5PVQY5BW-Ba8by6Uy.js → chunk-5PVQY5BW-DIk-xBaE.js} +1 -1
- package/payload/server/public/assets/{chunk-67CJDMHE-BwUuxtyb.js → chunk-67CJDMHE-BbMV1lgW.js} +1 -1
- package/payload/server/public/assets/{chunk-7N4EOEYR-BRH9iM9L.js → chunk-7N4EOEYR-C49Mv-nQ.js} +1 -1
- package/payload/server/public/assets/{chunk-AA7GKIK3-BGoztgLL.js → chunk-AA7GKIK3-Dy_pJOp_.js} +1 -1
- package/payload/server/public/assets/{chunk-BSJP7CBP-C5GDAZTl.js → chunk-BSJP7CBP-Ce-OmPqn.js} +1 -1
- package/payload/server/public/assets/{chunk-CIAEETIT-ChY32VPS.js → chunk-CIAEETIT-tnjq-APC.js} +1 -1
- package/payload/server/public/assets/{chunk-EDXVE4YY-CPSD3p6p.js → chunk-EDXVE4YY-Bvv_deZ2.js} +1 -1
- package/payload/server/public/assets/{chunk-ENJZ2VHE-D1oL-iUr.js → chunk-ENJZ2VHE-CmxCPKyU.js} +1 -1
- package/payload/server/public/assets/{chunk-FMBD7UC4-CPvYEr54.js → chunk-FMBD7UC4-Top6y08S.js} +1 -1
- package/payload/server/public/assets/{chunk-FOC6F5B3-9Yyj7Vbz.js → chunk-FOC6F5B3-B9LPNCUS.js} +1 -1
- package/payload/server/public/assets/{chunk-ICPOFSXX-BaYgh8FR.js → chunk-ICPOFSXX-Bi-_c351.js} +2 -2
- package/payload/server/public/assets/{chunk-K5T4RW27-5ucpeRvm.js → chunk-K5T4RW27-DAnRM04h.js} +1 -1
- package/payload/server/public/assets/{chunk-KGLVRYIC-DW-FHk7T.js → chunk-KGLVRYIC-C0QYcbLe.js} +1 -1
- package/payload/server/public/assets/{chunk-LIHQZDEY-CGGVfAyG.js → chunk-LIHQZDEY-BjvA5ykt.js} +1 -1
- package/payload/server/public/assets/{chunk-ORNJ4GCN-Bv8EUa5d.js → chunk-ORNJ4GCN-Cs46Gj7z.js} +1 -1
- package/payload/server/public/assets/{chunk-OYMX7WX6-C1mXJnyw.js → chunk-OYMX7WX6-BBpimab5.js} +1 -1
- package/payload/server/public/assets/chunk-QZHKN3VN-Qlc2PFAj.js +1 -0
- package/payload/server/public/assets/{chunk-U2HBQHQK-PwSQz6EP.js → chunk-U2HBQHQK-CQUSBHoK.js} +1 -1
- package/payload/server/public/assets/{chunk-X2U36JSP--NPHTBlU.js → chunk-X2U36JSP-Dm8TevG0.js} +1 -1
- package/payload/server/public/assets/{chunk-XPW4576I-Bbc7Da32.js → chunk-XPW4576I-B10QuxYb.js} +1 -1
- package/payload/server/public/assets/{chunk-YZCP3GAM-D-9v8e--.js → chunk-YZCP3GAM-vaGsu4Wk.js} +1 -1
- package/payload/server/public/assets/{chunk-ZZ45TVLE-CMPg670Q.js → chunk-ZZ45TVLE-D1Qi22bL.js} +1 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-CFsKL52p.js +1 -0
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-BWBUUCiO.js +1 -0
- package/payload/server/public/assets/clone-h5XhkDUL.js +1 -0
- package/payload/server/public/assets/{cose-bilkent-S5V4N54A-NVSb1Bhy.js → cose-bilkent-S5V4N54A-CRDvLRXs.js} +1 -1
- package/payload/server/public/assets/{dagre-QfLcO-1j.js → dagre-CEmqJTt3.js} +1 -1
- package/payload/server/public/assets/{dagre-KV5264BT-V2Ai1DFl.js → dagre-KV5264BT-LXMTo7Fp.js} +1 -1
- package/payload/server/public/assets/data-lHgqlhmu.js +1 -0
- package/payload/server/public/assets/{diagram-5BDNPKRD-Caw21693.js → diagram-5BDNPKRD-zyis6nPt.js} +1 -1
- package/payload/server/public/assets/{diagram-G4DWMVQ6-CgwVkT2q.js → diagram-G4DWMVQ6-BiU0XAAD.js} +1 -1
- package/payload/server/public/assets/{diagram-MMDJMWI5-DFUrLZhs.js → diagram-MMDJMWI5-rGFiz1SX.js} +1 -1
- package/payload/server/public/assets/{diagram-TYMM5635-CEEiEuZJ.js → diagram-TYMM5635-B0wak1ZJ.js} +1 -1
- package/payload/server/public/assets/{dist-Cvgxm7qv.js → dist-B2N0v8hZ.js} +1 -1
- package/payload/server/public/assets/{erDiagram-SMLLAGMA-CG10NrT3.js → erDiagram-SMLLAGMA-D8AUxLyX.js} +1 -1
- package/payload/server/public/assets/{flatten-DAO0sfCM.js → flatten-naJ5PJ4f.js} +1 -1
- package/payload/server/public/assets/{flowDiagram-DWJPFMVM-BqkV9Okv.js → flowDiagram-DWJPFMVM-BtdUf68b.js} +1 -1
- package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-DRiCDQF6.js → ganttDiagram-T4ZO3ILL-C-lkzDmf.js} +1 -1
- package/payload/server/public/assets/gitGraph-7Q5UKJZL-CBZPQJLj.js +1 -0
- package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-BZV2voyy.js → gitGraphDiagram-UUTBAWPF-DRUKumq2.js} +1 -1
- package/payload/server/public/assets/{graph-BZiudUGr.js → graph-JV5_xF3V.js} +3 -3
- package/payload/server/public/assets/{graph-labels-BzmmJwCR.js → graph-labels-DPYORjBH.js} +1 -1
- package/payload/server/public/assets/{graphlib-DGPThX8M.js → graphlib-zRsaoFEC.js} +1 -1
- package/payload/server/public/assets/info-OMHHGYJF-1vIoX-kP.js +1 -0
- package/payload/server/public/assets/infoDiagram-42DDH7IO-KHcXRaan.js +2 -0
- package/payload/server/public/assets/{isEmpty-Cb_U81C6.js → isEmpty-Bnpg7b8f.js} +1 -1
- package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-BKsAxSvp.js → ishikawaDiagram-UXIWVN3A-BguMgoR8.js} +1 -1
- package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-CmliuOd-.js → journeyDiagram-VCZTEJTY-CXhyK1n-.js} +1 -1
- package/payload/server/public/assets/{kanban-definition-6JOO6SKY-DAlElMb-.js → kanban-definition-6JOO6SKY-C0UCWVx-.js} +1 -1
- package/payload/server/public/assets/{line-DKZqLKAC.js → line--uhS9YDE.js} +1 -1
- package/payload/server/public/assets/{linear-CbSGdh1x.js → linear-CAOWPodQ.js} +1 -1
- package/payload/server/public/assets/{maximize-2-Bhdsv0U-.js → maximize-2-8vKr3h21.js} +1 -1
- package/payload/server/public/assets/{mermaid-parser.core-DFvbao9C.js → mermaid-parser.core-D6kPx7vc.js} +2 -2
- package/payload/server/public/assets/{mermaid.core-C0vEBxDm.js → mermaid.core-CTd4DS6O.js} +3 -3
- package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-CShASUKd.js → mindmap-definition-QFDTVHPH-_AyvyG8C.js} +1 -1
- package/payload/server/public/assets/operator-Liul1QEq.js +1 -0
- package/payload/server/public/assets/{ordinal-H0tVmBDP.js → ordinal-Wx4m9zHk.js} +1 -1
- package/payload/server/public/assets/packet-4T2RLAQJ-CTU0gCGb.js +1 -0
- package/payload/server/public/assets/page-CYRA87CB.js +1 -0
- package/payload/server/public/assets/{page-BoPorLg-.js → page-Cg7B1RQx.js} +4 -4
- package/payload/server/public/assets/{pdf-render-jAQU0nXt.js → pdf-render-CeX6d2v7.js} +1 -1
- package/payload/server/public/assets/pie-ZZUOXDRM-D-EEHxhC.js +1 -0
- package/payload/server/public/assets/{pieDiagram-DEJITSTG-CBZHpDAJ.js → pieDiagram-DEJITSTG-6TsUDkkQ.js} +1 -1
- package/payload/server/public/assets/{public-DqJk6qgW.js → public-B4HMtpjt.js} +1 -1
- package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-n3bB3K91.js → quadrantDiagram-34T5L4WZ-CWw9gOI4.js} +1 -1
- package/payload/server/public/assets/radar-PYXPWWZC-DHXATZGB.js +1 -0
- package/payload/server/public/assets/{reduce-DAvwat-a.js → reduce-BUmc8RDR.js} +1 -1
- package/payload/server/public/assets/{requirementDiagram-MS252O5E-DiDvQK3c.js → requirementDiagram-MS252O5E-DCOlxNvx.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-D_5cETGt.js → rotate-ccw-sz5IQSnr.js} +1 -1
- package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-DWDQQZmd.js → sankeyDiagram-XADWPNL6-CW4Xbir3.js} +1 -1
- package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-DmAqRlBT.js → sequenceDiagram-FGHM5R23-vhb_pBLG.js} +1 -1
- package/payload/server/public/assets/{src-DV4LKv2E.js → src-DHSQDYx-.js} +1 -1
- package/payload/server/public/assets/{stateDiagram-FHFEXIEX-D4R-n6bZ.js → stateDiagram-FHFEXIEX-Cb1WExEX.js} +1 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-CxOIKvXh.js +1 -0
- package/payload/server/public/assets/tasks-D9oYgEzs.js +1 -0
- package/payload/server/public/assets/{time-entry-format-DAwmmR3i.js → time-entry-format-CSuCexpM.js} +1 -1
- package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-CjiHGP4l.js → timeline-definition-GMOUNBTQ-BAHTf_AF.js} +1 -1
- package/payload/server/public/assets/treeView-SZITEDCU-CC7ouMFd.js +1 -0
- package/payload/server/public/assets/treemap-W4RFUUIX-CaCg27im.js +1 -0
- package/payload/server/public/assets/triangle-alert-ClS81-CU.js +1 -0
- package/payload/server/public/assets/{useCopyFeedback-rOWd_lzl.js → useCopyFeedback-Cn6YgeNx.js} +1 -1
- package/payload/server/public/assets/{useSelectionMode-DDmLmPph.js → useSelectionMode-BaD-ZZRk.js} +1 -1
- package/payload/server/public/assets/{useSubAccountSwitcher-pu0jjLCz.css → useSubAccountSwitcher-CNZL3PKn.css} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-CvjWJSGv.js +9 -0
- package/payload/server/public/assets/{useVoiceRecorder-azG8zSUI.js → useVoiceRecorder-BOzHrDAU.js} +2 -2
- package/payload/server/public/assets/{vennDiagram-DHZGUBPP-CBdDQ7c-.js → vennDiagram-DHZGUBPP-DtEttvW4.js} +1 -1
- package/payload/server/public/assets/wardley-RL74JXVD-bMPsqQZ7.js +1 -0
- package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-BlIQPKLb.js → wardleyDiagram-NUSXRM2D-K06y6CVJ.js} +1 -1
- package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-CslKgh9B.js → xychartDiagram-5P7HB3ND-D66c40lp.js} +1 -1
- package/payload/server/public/browser.html +6 -6
- package/payload/server/public/calendar.html +7 -7
- package/payload/server/public/chat.html +14 -14
- package/payload/server/public/data.html +13 -12
- package/payload/server/public/graph.html +12 -12
- package/payload/server/public/index.html +16 -15
- package/payload/server/public/operator.html +16 -16
- package/payload/server/public/public.html +14 -14
- package/payload/server/public/tasks.html +6 -6
- package/payload/server/server.js +558 -260
- package/payload/server/public/assets/AdminShell-BLh9O6dn.js +0 -2
- package/payload/server/public/assets/architecture-YZFGNWBL-FPHT7s-C.js +0 -1
- package/payload/server/public/assets/calendar-_pfHw0Hp.js +0 -1
- package/payload/server/public/assets/channel-j70eMvcL.js +0 -1
- package/payload/server/public/assets/chat-DYT5H81o.js +0 -1
- package/payload/server/public/assets/chevron-left-BnpVBu51.js +0 -1
- package/payload/server/public/assets/chunk-426QAEUC-D-NcAlTW.js +0 -1
- package/payload/server/public/assets/chunk-QZHKN3VN-CAwbQBtf.js +0 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-Ct6Rn0vt.js +0 -1
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-B_2XCIFv.js +0 -1
- package/payload/server/public/assets/clone-DjPWA_NH.js +0 -1
- package/payload/server/public/assets/data-CR-fbPWr.js +0 -1
- package/payload/server/public/assets/gitGraph-7Q5UKJZL-B8Hx7f-D.js +0 -1
- package/payload/server/public/assets/info-OMHHGYJF-BicCJTqU.js +0 -1
- package/payload/server/public/assets/infoDiagram-42DDH7IO-tf-8rOez.js +0 -2
- package/payload/server/public/assets/operator-gm2eP4r6.js +0 -1
- package/payload/server/public/assets/packet-4T2RLAQJ-Ckn_5hq0.js +0 -1
- package/payload/server/public/assets/page-8AB3jUa_.js +0 -1
- package/payload/server/public/assets/pie-ZZUOXDRM-DzlGQW3J.js +0 -1
- package/payload/server/public/assets/radar-PYXPWWZC-BHo2YD8b.js +0 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-BcFRbGRu.js +0 -1
- package/payload/server/public/assets/tasks-EyKLXINi.js +0 -1
- package/payload/server/public/assets/treeView-SZITEDCU-BtRr5vXp.js +0 -1
- package/payload/server/public/assets/treemap-W4RFUUIX-D8p0sbyo.js +0 -1
- package/payload/server/public/assets/useSubAccountSwitcher-CU-lOxTd.js +0 -9
- package/payload/server/public/assets/wardley-RL74JXVD-DgMn-9ZJ.js +0 -1
- /package/payload/platform/plugins/cloudflare/skills/data-portal/{template/schema.sql → schema.sql} +0 -0
- /package/payload/platform/plugins/cloudflare/skills/data-portal/template/{public/index.html → index.html} +0 -0
- /package/payload/platform/plugins/cloudflare/skills/data-portal/template/{public/portal.js → portal.js} +0 -0
- /package/payload/server/public/assets/{_baseFor-D3BqAOBr.js → _baseFor-k8hYPe-U.js} +0 -0
- /package/payload/server/public/assets/{array-iYP9fzJp.js → array-BFDiaBgf.js} +0 -0
- /package/payload/server/public/assets/{chunk-Ck5AOu5v.js → chunk-TPjIAO9U.js} +0 -0
- /package/payload/server/public/assets/{cytoscape.esm-BQSBzPsB.js → cytoscape.esm-Ch0xptA4.js} +0 -0
- /package/payload/server/public/assets/{defaultLocale-BrdA1gDi.js → defaultLocale-ZeknFqNe.js} +0 -0
- /package/payload/server/public/assets/{init-Bx0S6pkp.js → init-0VJVrkRJ.js} +0 -0
- /package/payload/server/public/assets/{katex-BsiH_a6d.js → katex-Br7bH10N.js} +0 -0
- /package/payload/server/public/assets/{path-BLSgTy3w.js → path-INs8XTPH.js} +0 -0
- /package/payload/server/public/assets/{preload-helper-ClBMtM1g.js → preload-helper-D_sPnjeL.js} +0 -0
- /package/payload/server/public/assets/{rough.esm-BMOtDaaS.js → rough.esm-DU9bZLvZ.js} +0 -0
package/payload/server/server.js
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
embed,
|
|
43
43
|
emitMissingOnResolve,
|
|
44
44
|
ensureConversation,
|
|
45
|
+
ensureSessionConversation,
|
|
45
46
|
fetchAccountName,
|
|
46
47
|
fetchBranding,
|
|
47
48
|
findMissingPlugins,
|
|
@@ -111,7 +112,7 @@ import {
|
|
|
111
112
|
vncLog,
|
|
112
113
|
walkPremiumBundles,
|
|
113
114
|
writeAdminUserAndPerson
|
|
114
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-BSTIQX52.js";
|
|
115
116
|
import {
|
|
116
117
|
D1_MAX_SQL_STATEMENT_BYTES,
|
|
117
118
|
D1_QUERY_MAX_BODY_BYTES,
|
|
@@ -1533,7 +1534,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
1533
1534
|
};
|
|
1534
1535
|
|
|
1535
1536
|
// server/index.ts
|
|
1536
|
-
import { readFileSync as readFileSync39, existsSync as existsSync37, watchFile, readdirSync as
|
|
1537
|
+
import { readFileSync as readFileSync39, existsSync as existsSync37, watchFile, readdirSync as readdirSync23, statSync as statSync14 } from "fs";
|
|
1537
1538
|
import { spawn as spawn3 } from "child_process";
|
|
1538
1539
|
import { createHash as createHash7 } from "crypto";
|
|
1539
1540
|
import { resolve as resolve36, join as join39, basename as basename12 } from "path";
|
|
@@ -6675,8 +6676,8 @@ function webchatTurnTimeoutMs() {
|
|
|
6675
6676
|
return Number(process.env.WEBCHAT_TURN_TIMEOUT_MS ?? String(2 * 6e4));
|
|
6676
6677
|
}
|
|
6677
6678
|
function createChatRoutes(deps) {
|
|
6678
|
-
const
|
|
6679
|
-
|
|
6679
|
+
const app64 = new Hono();
|
|
6680
|
+
app64.post("/", async (c) => {
|
|
6680
6681
|
console.log(`[chat-route] entered route=public method=POST`);
|
|
6681
6682
|
const contentType = c.req.header("content-type") ?? "";
|
|
6682
6683
|
const account = resolveAccount();
|
|
@@ -6940,7 +6941,7 @@ ${result.result.text}` : result.result.text;
|
|
|
6940
6941
|
}
|
|
6941
6942
|
});
|
|
6942
6943
|
});
|
|
6943
|
-
return
|
|
6944
|
+
return app64;
|
|
6944
6945
|
}
|
|
6945
6946
|
|
|
6946
6947
|
// app/lib/channel-pty-bridge/admin-session-id.ts
|
|
@@ -6974,8 +6975,8 @@ function isLoopbackAddr(addr) {
|
|
|
6974
6975
|
return addr === "127.0.0.1" || addr === "::1" || addr === "::ffff:127.0.0.1";
|
|
6975
6976
|
}
|
|
6976
6977
|
function createScheduleInjectRoutes(deps) {
|
|
6977
|
-
const
|
|
6978
|
-
|
|
6978
|
+
const app64 = new Hono();
|
|
6979
|
+
app64.post("/", async (c) => {
|
|
6979
6980
|
const env = c.env;
|
|
6980
6981
|
const remoteAddr = env?.incoming?.socket?.remoteAddress ?? "";
|
|
6981
6982
|
if (!isLoopbackAddr(remoteAddr)) {
|
|
@@ -7076,11 +7077,11 @@ function createScheduleInjectRoutes(deps) {
|
|
|
7076
7077
|
console.error(`${TAG17} op=inject-spawn eventId=${eventId} sessionId=${sessionId} result=ok status=-`);
|
|
7077
7078
|
return c.json({ ok: true }, 200);
|
|
7078
7079
|
});
|
|
7079
|
-
return
|
|
7080
|
+
return app64;
|
|
7080
7081
|
}
|
|
7081
7082
|
|
|
7082
7083
|
// server/index.ts
|
|
7083
|
-
var
|
|
7084
|
+
var import_dist10 = __toESM(require_dist(), 1);
|
|
7084
7085
|
|
|
7085
7086
|
// app/lib/whatsapp/socket-resolution-error.ts
|
|
7086
7087
|
function formatPresentKeys(presentKeys) {
|
|
@@ -12012,8 +12013,8 @@ async function reapplyLeversViaManager() {
|
|
|
12012
12013
|
var WEBCHAT_SEND_TURN_WINDOW_MS = Number(process.env.WEBCHAT_SEND_TURN_WINDOW_MS ?? String(15e3));
|
|
12013
12014
|
var sendSeq = 0;
|
|
12014
12015
|
function createWebchatRoutes(deps) {
|
|
12015
|
-
const
|
|
12016
|
-
|
|
12016
|
+
const app64 = new Hono();
|
|
12017
|
+
app64.post("/send", requireAdminSession, async (c) => {
|
|
12017
12018
|
let accountId;
|
|
12018
12019
|
try {
|
|
12019
12020
|
accountId = resolvePlatformAccountId();
|
|
@@ -12225,7 +12226,7 @@ ${note}` : note;
|
|
|
12225
12226
|
if (turnTimer.unref) turnTimer.unref();
|
|
12226
12227
|
return c.json({ ok: true });
|
|
12227
12228
|
});
|
|
12228
|
-
|
|
12229
|
+
app64.post("/interrupt", requireAdminSession, async (c) => {
|
|
12229
12230
|
const cacheKey = c.get("cacheKey");
|
|
12230
12231
|
const requesterUserId = (cacheKey ? getUserIdForSession(cacheKey) : void 0) ?? null;
|
|
12231
12232
|
const primaryUserId = resolvePrimaryAdminUserId();
|
|
@@ -12253,7 +12254,7 @@ ${note}` : note;
|
|
|
12253
12254
|
}
|
|
12254
12255
|
return c.json({ ok: true, stopped: outcome.stopped, intId: outcome.intId, deadChild: outcome.deadChild }, 200);
|
|
12255
12256
|
});
|
|
12256
|
-
|
|
12257
|
+
app64.post("/settings", requireAdminSession, async (c) => {
|
|
12257
12258
|
const body = await c.req.json().catch(() => null);
|
|
12258
12259
|
const op = body?.op;
|
|
12259
12260
|
const value = body?.value;
|
|
@@ -12293,7 +12294,7 @@ ${note}` : note;
|
|
|
12293
12294
|
console.log(`[webchat:settings] op=${op} outcome=accepted value=${value} settingsApplied=${settingsApplied}`);
|
|
12294
12295
|
return c.json({ ok: true, settingsApplied });
|
|
12295
12296
|
});
|
|
12296
|
-
|
|
12297
|
+
app64.get("/session", requireAdminSession, async (c) => {
|
|
12297
12298
|
let accountId;
|
|
12298
12299
|
try {
|
|
12299
12300
|
accountId = resolvePlatformAccountId();
|
|
@@ -12371,7 +12372,7 @@ ${note}` : note;
|
|
|
12371
12372
|
const indicators = await fetchComposerIndicators(sessionId);
|
|
12372
12373
|
return c.json({ sessionId, projectDir, source, sizeBytes: jsonlSizeBytes(projectDir, sessionId), pendingPermissionPrompt: deps.pendingPromptFor?.(`session:${sessionId}`) ?? null, deliveryFailure: deps.deliveryFailureFor?.(`session:${sessionId}`) ?? null, ...indicators, ...readLevers(account) });
|
|
12373
12374
|
});
|
|
12374
|
-
|
|
12375
|
+
app64.post("/permission-verdict", requireAdminSession, async (c) => {
|
|
12375
12376
|
const body = await c.req.json().catch(() => null);
|
|
12376
12377
|
const sessionId = body?.sessionId;
|
|
12377
12378
|
const requestId = body?.request_id;
|
|
@@ -12388,7 +12389,7 @@ ${note}` : note;
|
|
|
12388
12389
|
const ok = deps.resolvePermissionVerdict?.(`session:${sessionId}`, requestId, behavior) ?? false;
|
|
12389
12390
|
return c.json({ ok });
|
|
12390
12391
|
});
|
|
12391
|
-
return
|
|
12392
|
+
return app64;
|
|
12392
12393
|
}
|
|
12393
12394
|
|
|
12394
12395
|
// server/routes/webchat-greeting.ts
|
|
@@ -12803,6 +12804,9 @@ function sanitizeAccountKey(key) {
|
|
|
12803
12804
|
function secretsDir(accountsDir, accountId) {
|
|
12804
12805
|
return join24(accountsDir, sanitizeAccountKey(accountId), "secrets", "google");
|
|
12805
12806
|
}
|
|
12807
|
+
function buildRedirectUri(publicBase) {
|
|
12808
|
+
return `${publicBase.replace(/\/+$/, "")}/api/google/oauth/callback`;
|
|
12809
|
+
}
|
|
12806
12810
|
function esc(s) {
|
|
12807
12811
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
12808
12812
|
}
|
|
@@ -12909,20 +12913,26 @@ function createGoogleOAuthRoutes(platformRoot5, accountsDir) {
|
|
|
12909
12913
|
routes.get("/oauth/callback", async (c) => {
|
|
12910
12914
|
const code = c.req.query("code");
|
|
12911
12915
|
const state = c.req.query("state");
|
|
12912
|
-
|
|
12913
|
-
if (!code || !state || !accountId) {
|
|
12916
|
+
if (!code || !state) {
|
|
12914
12917
|
console.error(`${TAG26} op=callback outcome=error error=missing-params`);
|
|
12915
12918
|
return c.html(page2("Missing parameters", "Return to your chat and start again."), 400);
|
|
12916
12919
|
}
|
|
12920
|
+
const dot = state.lastIndexOf(".");
|
|
12921
|
+
if (dot <= 0 || dot === state.length - 1) {
|
|
12922
|
+
console.error(`${TAG26} op=callback outcome=error error=malformed-state`);
|
|
12923
|
+
return c.html(page2("This link has expired", "Return to your chat and start again."), 400);
|
|
12924
|
+
}
|
|
12925
|
+
const accountId = state.slice(0, dot);
|
|
12926
|
+
const nonce = state.slice(dot + 1);
|
|
12917
12927
|
const held = readPending(accountsDir, accountId);
|
|
12918
|
-
const stateMatch = held !== null && held.state ===
|
|
12919
|
-
console.error(`${TAG26} op=callback reg=${
|
|
12928
|
+
const stateMatch = held !== null && held.state === nonce;
|
|
12929
|
+
console.error(`${TAG26} op=callback reg=${nonce} account=${accountId} state-match=${stateMatch}`);
|
|
12920
12930
|
if (!held || !stateMatch) {
|
|
12921
12931
|
return c.html(page2("This link has expired", "Return to your chat and start again."), 400);
|
|
12922
12932
|
}
|
|
12923
12933
|
const ageMs = Date.now() - held.createdAt;
|
|
12924
12934
|
if (ageMs > PENDING_LIFETIME_MS) {
|
|
12925
|
-
console.error(`${TAG26} op=callback reg=${
|
|
12935
|
+
console.error(`${TAG26} op=callback reg=${nonce} outcome=error error=pending-expired ageMs=${ageMs}`);
|
|
12926
12936
|
clearPending(accountsDir, accountId);
|
|
12927
12937
|
return c.html(page2("This link has expired", "Return to your chat and start again."), 400);
|
|
12928
12938
|
}
|
|
@@ -12932,15 +12942,15 @@ function createGoogleOAuthRoutes(platformRoot5, accountsDir) {
|
|
|
12932
12942
|
};
|
|
12933
12943
|
const creds = readHouseGoogleCreds(platformRoot5);
|
|
12934
12944
|
if (!creds) {
|
|
12935
|
-
console.error(`${TAG26} op=token-exchange reg=${
|
|
12945
|
+
console.error(`${TAG26} op=token-exchange reg=${nonce} outcome=error error=house-env-missing`);
|
|
12936
12946
|
return failed("Not configured", "This install has no Google credentials yet.", 500);
|
|
12937
12947
|
}
|
|
12938
12948
|
const publicBase = (process.env.GOOGLE_PUBLIC_BASE ?? "").replace(/\/+$/, "");
|
|
12939
12949
|
if (!publicBase) {
|
|
12940
|
-
console.error(`${TAG26} op=callback reg=${
|
|
12950
|
+
console.error(`${TAG26} op=callback reg=${nonce} outcome=error error=public-base-unset`);
|
|
12941
12951
|
return failed("Not configured", "This install has no public base configured.", 500);
|
|
12942
12952
|
}
|
|
12943
|
-
const redirectUri =
|
|
12953
|
+
const redirectUri = buildRedirectUri(publicBase);
|
|
12944
12954
|
try {
|
|
12945
12955
|
const res = await fetch(TOKEN_URL, {
|
|
12946
12956
|
method: "POST",
|
|
@@ -12956,21 +12966,21 @@ function createGoogleOAuthRoutes(platformRoot5, accountsDir) {
|
|
|
12956
12966
|
});
|
|
12957
12967
|
const text = await res.text();
|
|
12958
12968
|
if (!res.ok) {
|
|
12959
|
-
console.error(`${TAG26} op=token-exchange reg=${
|
|
12969
|
+
console.error(`${TAG26} op=token-exchange reg=${nonce} outcome=error status=${res.status} body=${text.slice(0, 300)}`);
|
|
12960
12970
|
return failed("Could not connect", `Google refused the exchange (${res.status}).`, 502);
|
|
12961
12971
|
}
|
|
12962
|
-
console.error(`${TAG26} op=token-exchange reg=${
|
|
12972
|
+
console.error(`${TAG26} op=token-exchange reg=${nonce} outcome=ok`);
|
|
12963
12973
|
const tok = JSON.parse(text);
|
|
12964
12974
|
const calRes = await fetch(PRIMARY_CALENDAR_URL, {
|
|
12965
12975
|
headers: { authorization: `Bearer ${tok.access_token}` }
|
|
12966
12976
|
});
|
|
12967
12977
|
const calText = await calRes.text();
|
|
12968
12978
|
if (!calRes.ok) {
|
|
12969
|
-
console.error(`${TAG26} op=identity reg=${
|
|
12979
|
+
console.error(`${TAG26} op=identity reg=${nonce} outcome=error status=${calRes.status} body=${calText.slice(0, 300)}`);
|
|
12970
12980
|
return failed("Could not connect", "Connected, but the calendar identity could not be read.", 502);
|
|
12971
12981
|
}
|
|
12972
12982
|
const email = JSON.parse(calText).id;
|
|
12973
|
-
console.error(`${TAG26} op=identity reg=${
|
|
12983
|
+
console.error(`${TAG26} op=identity reg=${nonce} email=${email}`);
|
|
12974
12984
|
writeTokens(accountsDir, accountId, email, {
|
|
12975
12985
|
accessToken: tok.access_token,
|
|
12976
12986
|
refreshToken: tok.refresh_token ?? null,
|
|
@@ -12978,11 +12988,11 @@ function createGoogleOAuthRoutes(platformRoot5, accountsDir) {
|
|
|
12978
12988
|
scopes: tok.scope ? tok.scope.split(" ") : []
|
|
12979
12989
|
});
|
|
12980
12990
|
console.error(
|
|
12981
|
-
`${TAG26} op=tokens-write reg=${
|
|
12991
|
+
`${TAG26} op=tokens-write reg=${nonce} account=${accountId} refreshIssued=${tok.refresh_token ? "true" : "false"}`
|
|
12982
12992
|
);
|
|
12983
12993
|
clearPending(accountsDir, accountId);
|
|
12984
|
-
console.error(`${TAG26} op=pending-clear reg=${
|
|
12985
|
-
console.error(`${TAG26} op=registered reg=${
|
|
12994
|
+
console.error(`${TAG26} op=pending-clear reg=${nonce} verified=${readPending(accountsDir, accountId) === null}`);
|
|
12995
|
+
console.error(`${TAG26} op=registered reg=${nonce} account=${accountId} email=${email}`);
|
|
12986
12996
|
return c.html(
|
|
12987
12997
|
page2(
|
|
12988
12998
|
"Calendar connected",
|
|
@@ -12991,7 +13001,7 @@ function createGoogleOAuthRoutes(platformRoot5, accountsDir) {
|
|
|
12991
13001
|
);
|
|
12992
13002
|
} catch (err) {
|
|
12993
13003
|
const msg = err.message;
|
|
12994
|
-
console.error(`${TAG26} op=token-exchange reg=${
|
|
13004
|
+
console.error(`${TAG26} op=token-exchange reg=${nonce} outcome=error error=${msg}`);
|
|
12995
13005
|
return failed("Could not connect", "Something went wrong. Return to your chat and try again.", 502);
|
|
12996
13006
|
}
|
|
12997
13007
|
});
|
|
@@ -15679,18 +15689,18 @@ var ALLOWED_EVENTS = /* @__PURE__ */ new Set([
|
|
|
15679
15689
|
]);
|
|
15680
15690
|
var app21 = new Hono();
|
|
15681
15691
|
app21.post("/", async (c) => {
|
|
15682
|
-
const
|
|
15692
|
+
const TAG51 = "[admin:events]";
|
|
15683
15693
|
let body;
|
|
15684
15694
|
try {
|
|
15685
15695
|
body = await c.req.json();
|
|
15686
15696
|
} catch (err) {
|
|
15687
15697
|
const detail = err instanceof Error ? err.message : String(err);
|
|
15688
|
-
console.error(`${
|
|
15698
|
+
console.error(`${TAG51} reject reason=body-not-json detail=${detail}`);
|
|
15689
15699
|
return c.json({ ok: false, detail: "Request body was not valid JSON" }, 400);
|
|
15690
15700
|
}
|
|
15691
15701
|
const event = typeof body.event === "string" ? body.event : "";
|
|
15692
15702
|
if (!ALLOWED_EVENTS.has(event)) {
|
|
15693
|
-
console.error(`${
|
|
15703
|
+
console.error(`${TAG51} reject reason=event-not-allowed event=${JSON.stringify(event)}`);
|
|
15694
15704
|
return c.json({ ok: false, detail: `Event "${event}" is not allowed` }, 400);
|
|
15695
15705
|
}
|
|
15696
15706
|
const rawFields = body.fields && typeof body.fields === "object" ? body.fields : {};
|
|
@@ -22149,57 +22159,158 @@ app51.post("/", requireAdminSession, async (c) => {
|
|
|
22149
22159
|
});
|
|
22150
22160
|
var task_time_adjust_default = app51;
|
|
22151
22161
|
|
|
22152
|
-
// server/routes/admin/
|
|
22162
|
+
// server/routes/admin/activity.ts
|
|
22163
|
+
import { readdirSync as readdirSync22 } from "fs";
|
|
22153
22164
|
var app52 = new Hono();
|
|
22154
|
-
|
|
22155
|
-
|
|
22156
|
-
|
|
22157
|
-
|
|
22158
|
-
|
|
22159
|
-
|
|
22160
|
-
|
|
22161
|
-
|
|
22162
|
-
|
|
22163
|
-
|
|
22164
|
-
|
|
22165
|
-
|
|
22166
|
-
|
|
22167
|
-
|
|
22168
|
-
|
|
22169
|
-
|
|
22170
|
-
|
|
22171
|
-
|
|
22172
|
-
|
|
22173
|
-
|
|
22174
|
-
|
|
22175
|
-
app52.
|
|
22176
|
-
|
|
22177
|
-
|
|
22178
|
-
|
|
22179
|
-
|
|
22180
|
-
|
|
22181
|
-
|
|
22182
|
-
|
|
22183
|
-
|
|
22184
|
-
|
|
22185
|
-
|
|
22186
|
-
|
|
22187
|
-
|
|
22188
|
-
|
|
22189
|
-
|
|
22190
|
-
|
|
22191
|
-
|
|
22192
|
-
|
|
22193
|
-
|
|
22194
|
-
|
|
22195
|
-
|
|
22165
|
+
var TAG40 = "[activity]";
|
|
22166
|
+
function resolveHouseAccountId(accounts) {
|
|
22167
|
+
const houses = accounts.filter((a) => a.config.role === "house");
|
|
22168
|
+
if (houses.length === 1) return { accountId: houses[0].accountId, reason: "house" };
|
|
22169
|
+
if (houses.length > 1) return { accountId: null, reason: "multiple-houses" };
|
|
22170
|
+
if (accounts.length === 1) return { accountId: accounts[0].accountId, reason: "sole-account" };
|
|
22171
|
+
return { accountId: null, reason: "no-house" };
|
|
22172
|
+
}
|
|
22173
|
+
function requestToken() {
|
|
22174
|
+
return Math.random().toString(16).slice(2, 10);
|
|
22175
|
+
}
|
|
22176
|
+
var short = (id) => id ? id.slice(0, 8) : "unset";
|
|
22177
|
+
function countAccountDirsOnDisk() {
|
|
22178
|
+
try {
|
|
22179
|
+
return readdirSync22(ACCOUNTS_DIR, { withFileTypes: true }).filter(
|
|
22180
|
+
(e) => e.isDirectory() && !e.name.startsWith(".")
|
|
22181
|
+
).length;
|
|
22182
|
+
} catch {
|
|
22183
|
+
return null;
|
|
22184
|
+
}
|
|
22185
|
+
}
|
|
22186
|
+
app52.get("/", requireAdminSession, async (c) => {
|
|
22187
|
+
const req = requestToken();
|
|
22188
|
+
const cacheKey = c.var.cacheKey;
|
|
22189
|
+
const caller2 = getAccountIdForSession(cacheKey) ?? null;
|
|
22190
|
+
const valid = listValidAccounts();
|
|
22191
|
+
const house = resolveHouseAccountId(valid);
|
|
22192
|
+
const isHouse = caller2 !== null && house.accountId !== null && caller2 === house.accountId;
|
|
22193
|
+
console.log(
|
|
22194
|
+
`${TAG40} op=request req=${req} caller=${short(caller2)} house=${isHouse} houseVia=${house.reason}`
|
|
22195
|
+
);
|
|
22196
|
+
if (!isHouse) {
|
|
22197
|
+
const reason = house.accountId === null ? house.reason : "not-house";
|
|
22198
|
+
console.error(
|
|
22199
|
+
`${TAG40} op=gate req=${req} decision=deny reason=${reason} caller=${short(caller2)} houseAcct=${short(house.accountId)} accounts=${valid.length}`
|
|
22200
|
+
);
|
|
22201
|
+
return c.json({ error: "house-only" }, 403);
|
|
22202
|
+
}
|
|
22203
|
+
console.log(`${TAG40} op=gate req=${req} decision=allow caller=${short(caller2)} via=${house.reason}`);
|
|
22204
|
+
const onDisk = countAccountDirsOnDisk();
|
|
22205
|
+
console.log(
|
|
22206
|
+
`${TAG40} op=accounts req=${req} onDisk=${onDisk ?? "unknown"} valid=${valid.length} ids=${valid.map((a) => short(a.accountId)).join(",")}`
|
|
22207
|
+
);
|
|
22208
|
+
const start = Date.now();
|
|
22209
|
+
let res;
|
|
22210
|
+
try {
|
|
22211
|
+
res = await fetch(`${managerBase("activity:wrapper")}/activity`, {
|
|
22212
|
+
signal: AbortSignal.timeout(3e4)
|
|
22213
|
+
});
|
|
22214
|
+
} catch (err) {
|
|
22215
|
+
console.error(
|
|
22216
|
+
`${TAG40} op=manager-fail req=${req} reason=unreachable err=${err instanceof Error ? err.message : String(err)}`
|
|
22217
|
+
);
|
|
22218
|
+
return c.json({ error: "manager-unreachable" }, 502);
|
|
22219
|
+
}
|
|
22220
|
+
if (res.status !== 200) {
|
|
22221
|
+
console.error(`${TAG40} op=manager-fail req=${req} reason=status status=${res.status}`);
|
|
22222
|
+
return c.json({ error: `manager-status-${res.status}` }, 502);
|
|
22223
|
+
}
|
|
22224
|
+
const body = await res.json().catch(() => null);
|
|
22225
|
+
if (!body || !Array.isArray(body.rows)) {
|
|
22226
|
+
console.error(`${TAG40} op=manager-fail req=${req} reason=bad-json`);
|
|
22227
|
+
return c.json({ error: "manager-bad-json" }, 502);
|
|
22228
|
+
}
|
|
22229
|
+
const rows = body.rows;
|
|
22230
|
+
const census = body.census ?? null;
|
|
22231
|
+
const untaggedCount = rows.filter((r) => r.accountId === null).length;
|
|
22232
|
+
const meteringFailed = rows.filter((r) => r.meteringError !== null).length;
|
|
22233
|
+
const censusAgeMs = census ? Date.now() - census.sampleAtMs : null;
|
|
22234
|
+
console.log(
|
|
22235
|
+
`${TAG40} op=census req=${req} ageMs=${censusAgeMs ?? "none"} live=${census?.live ?? "none"} cpuNull=${census?.cpuNull ?? "none"}`
|
|
22236
|
+
);
|
|
22237
|
+
console.log(
|
|
22238
|
+
`${TAG40} op=response req=${req} rows=${rows.length} accounts=${valid.length} untagged=${untaggedCount} meteringFailed=${meteringFailed} ms=${Date.now() - start}`
|
|
22239
|
+
);
|
|
22240
|
+
const names = {};
|
|
22241
|
+
await Promise.all(
|
|
22242
|
+
valid.map(async (a) => {
|
|
22243
|
+
const name = await fetchAccountName(a.accountId).catch(() => null);
|
|
22244
|
+
if (name) names[a.accountId] = name;
|
|
22245
|
+
})
|
|
22246
|
+
);
|
|
22247
|
+
return c.json({
|
|
22248
|
+
rows,
|
|
22249
|
+
census,
|
|
22250
|
+
censusAgeMs,
|
|
22251
|
+
accounts: {
|
|
22252
|
+
onDisk,
|
|
22253
|
+
valid: valid.length,
|
|
22254
|
+
ids: valid.map((a) => a.accountId),
|
|
22255
|
+
names,
|
|
22256
|
+
untaggedCount
|
|
22257
|
+
}
|
|
22258
|
+
});
|
|
22259
|
+
});
|
|
22260
|
+
var activity_default = app52;
|
|
22261
|
+
|
|
22262
|
+
// server/routes/admin/index.ts
|
|
22263
|
+
var app53 = new Hono();
|
|
22264
|
+
app53.route("/session", session_default);
|
|
22265
|
+
app53.route("/accounts", accounts_default);
|
|
22266
|
+
app53.route("/logs", logs_default);
|
|
22267
|
+
app53.route("/claude-info", claude_info_default);
|
|
22268
|
+
app53.route("/attachment", attachment_default);
|
|
22269
|
+
app53.route("/agents", agents_default);
|
|
22270
|
+
app53.route("/sessions", sessions_default);
|
|
22271
|
+
app53.route("/claude-sessions", claude_sessions_default);
|
|
22272
|
+
app53.route("/log-ingest", log_ingest_default);
|
|
22273
|
+
app53.route("/events", events_default);
|
|
22274
|
+
app53.route("/files", files_default);
|
|
22275
|
+
app53.route("/graph-search", graph_search_default);
|
|
22276
|
+
app53.route("/graph-subgraph", graph_subgraph_default);
|
|
22277
|
+
app53.route("/graph-delete", graph_delete_default);
|
|
22278
|
+
app53.route("/graph-restore", graph_restore_default);
|
|
22279
|
+
app53.route("/graph-labels-in-graph", graph_labels_in_graph_default);
|
|
22280
|
+
app53.route("/graph-default-view", graph_default_view_default);
|
|
22281
|
+
app53.route("/sidebar-artefacts", sidebar_artefacts_default);
|
|
22282
|
+
app53.route("/sidebar-sessions", sidebar_sessions_default);
|
|
22283
|
+
app53.route("/session-delete", session_delete_default);
|
|
22284
|
+
app53.route("/session-stop", session_stop_default);
|
|
22285
|
+
app53.route("/session-archive", session_archive_default);
|
|
22286
|
+
app53.route("/session-rename", session_rename_default);
|
|
22287
|
+
app53.route("/session-usage", session_usage_default);
|
|
22288
|
+
app53.route("/browser", browser_default);
|
|
22289
|
+
app53.route("/session-rc-spawn", session_rc_spawn_default);
|
|
22290
|
+
app53.route("/session-reseat", session_reseat_default);
|
|
22291
|
+
app53.route("/system-stats", system_stats_default);
|
|
22292
|
+
app53.route("/health-brand", health_default2);
|
|
22293
|
+
app53.route("/linkedin-ingest", linkedin_ingest_default);
|
|
22294
|
+
app53.route("/post-turn-context", post_turn_context_default);
|
|
22295
|
+
app53.route("/public-session-context", public_session_context_default);
|
|
22296
|
+
app53.route("/public-session-exit", public_session_exit_default);
|
|
22297
|
+
app53.route("/access-session-evict", access_session_evict_default);
|
|
22298
|
+
app53.route("/enrol-person", enrol_person_default);
|
|
22299
|
+
app53.route("/calendar", calendar_default);
|
|
22300
|
+
app53.route("/tasks-list", tasks_list_default);
|
|
22301
|
+
app53.route("/task-timer-start", task_timer_start_default);
|
|
22302
|
+
app53.route("/task-timer-stop", task_timer_stop_default);
|
|
22303
|
+
app53.route("/task-complete", task_complete_default);
|
|
22304
|
+
app53.route("/task-time-adjust", task_time_adjust_default);
|
|
22305
|
+
app53.route("/activity", activity_default);
|
|
22306
|
+
var admin_default = app53;
|
|
22196
22307
|
|
|
22197
22308
|
// server/routes/access/verify-token.ts
|
|
22198
|
-
var
|
|
22309
|
+
var TAG41 = "[access-verify]";
|
|
22199
22310
|
var MINT_TAG = "[access-session-mint]";
|
|
22200
22311
|
var COOKIE_NAME = "__access_session";
|
|
22201
|
-
var
|
|
22202
|
-
|
|
22312
|
+
var app54 = new Hono();
|
|
22313
|
+
app54.post("/", async (c) => {
|
|
22203
22314
|
const ip = c.var.clientIp || "unknown";
|
|
22204
22315
|
let body;
|
|
22205
22316
|
try {
|
|
@@ -22214,39 +22325,39 @@ app53.post("/", async (c) => {
|
|
|
22214
22325
|
}
|
|
22215
22326
|
const rateMsg = checkAccessRateLimit(ip, agentSlug);
|
|
22216
22327
|
if (rateMsg) {
|
|
22217
|
-
console.error(`${
|
|
22328
|
+
console.error(`${TAG41} grantId=- agentSlug=${agentSlug} result=rate-limited ip=${ip}`);
|
|
22218
22329
|
return c.json({ error: rateMsg }, 429);
|
|
22219
22330
|
}
|
|
22220
22331
|
const grant = await findGrantByMagicToken(token);
|
|
22221
22332
|
if (!grant) {
|
|
22222
22333
|
recordAccessFailedAttempt(ip, agentSlug);
|
|
22223
|
-
console.error(`${
|
|
22334
|
+
console.error(`${TAG41} grantId=- agentSlug=${agentSlug} result=notfound ip=${ip}`);
|
|
22224
22335
|
return c.json({ error: "invalid-or-expired-link" }, 401);
|
|
22225
22336
|
}
|
|
22226
22337
|
if (grant.agentSlug !== agentSlug) {
|
|
22227
22338
|
recordAccessFailedAttempt(ip, agentSlug);
|
|
22228
22339
|
console.error(
|
|
22229
|
-
`${
|
|
22340
|
+
`${TAG41} grantId=${grant.grantId} agentSlug=${agentSlug} result=agent-mismatch grantAgent=${grant.agentSlug} ip=${ip}`
|
|
22230
22341
|
);
|
|
22231
22342
|
return c.json({ error: "invalid-or-expired-link" }, 401);
|
|
22232
22343
|
}
|
|
22233
22344
|
if (grant.status === "expired" || grant.status === "revoked") {
|
|
22234
22345
|
recordAccessFailedAttempt(ip, agentSlug);
|
|
22235
22346
|
console.error(
|
|
22236
|
-
`${
|
|
22347
|
+
`${TAG41} grantId=${grant.grantId} agentSlug=${agentSlug} result=expired status=${grant.status} ip=${ip}`
|
|
22237
22348
|
);
|
|
22238
22349
|
return c.json({ error: "access-no-longer-valid" }, 401);
|
|
22239
22350
|
}
|
|
22240
22351
|
if (grant.expiresAt !== null && grant.expiresAt < Date.now()) {
|
|
22241
22352
|
recordAccessFailedAttempt(ip, agentSlug);
|
|
22242
22353
|
console.error(
|
|
22243
|
-
`${
|
|
22354
|
+
`${TAG41} grantId=${grant.grantId} agentSlug=${agentSlug} result=expired reason=expiresAt-past ip=${ip}`
|
|
22244
22355
|
);
|
|
22245
22356
|
return c.json({ error: "access-no-longer-valid" }, 401);
|
|
22246
22357
|
}
|
|
22247
22358
|
if (!grant.sliceToken) {
|
|
22248
22359
|
console.error(
|
|
22249
|
-
`${
|
|
22360
|
+
`${TAG41} grantId=${grant.grantId} agentSlug=${agentSlug} result=no-slice-token reason=schema-violation`
|
|
22250
22361
|
);
|
|
22251
22362
|
return c.json({ error: "grant-misconfigured" }, 500);
|
|
22252
22363
|
}
|
|
@@ -22262,12 +22373,12 @@ app53.post("/", async (c) => {
|
|
|
22262
22373
|
await consumeMagicTokenAndActivate(grant.grantId);
|
|
22263
22374
|
} catch (err) {
|
|
22264
22375
|
console.error(
|
|
22265
|
-
`${
|
|
22376
|
+
`${TAG41} grantId=${grant.grantId} agentSlug=${agentSlug} result=consume-failed err="${err instanceof Error ? err.message : String(err)}"`
|
|
22266
22377
|
);
|
|
22267
22378
|
return c.json({ error: "verification-failed" }, 500);
|
|
22268
22379
|
}
|
|
22269
22380
|
clearAccessRateLimit(ip, agentSlug);
|
|
22270
|
-
console.log(`${
|
|
22381
|
+
console.log(`${TAG41} grantId=${grant.grantId} agentSlug=${agentSlug} result=ok ip=${ip}`);
|
|
22271
22382
|
console.log(
|
|
22272
22383
|
`${MINT_TAG} grantId=${grant.grantId} sliceToken=${grant.sliceToken.slice(0, 8)} agentSlug=${agentSlug} personId=${grant.personId ?? "none"}`
|
|
22273
22384
|
);
|
|
@@ -22281,7 +22392,7 @@ app53.post("/", async (c) => {
|
|
|
22281
22392
|
displayName: grant.displayName
|
|
22282
22393
|
});
|
|
22283
22394
|
});
|
|
22284
|
-
var verify_token_default =
|
|
22395
|
+
var verify_token_default = app54;
|
|
22285
22396
|
|
|
22286
22397
|
// app/lib/access-email.ts
|
|
22287
22398
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -22343,10 +22454,10 @@ async function sendMagicLinkEmail(payload) {
|
|
|
22343
22454
|
}
|
|
22344
22455
|
|
|
22345
22456
|
// server/routes/access/request-magic-link.ts
|
|
22346
|
-
var
|
|
22347
|
-
var
|
|
22457
|
+
var TAG42 = "[access-request-link]";
|
|
22458
|
+
var app55 = new Hono();
|
|
22348
22459
|
var VISITOR_MESSAGE = "If that email is on the invite list, a fresh link is on the way.";
|
|
22349
|
-
|
|
22460
|
+
app55.post("/", async (c) => {
|
|
22350
22461
|
let body;
|
|
22351
22462
|
try {
|
|
22352
22463
|
body = await c.req.json();
|
|
@@ -22360,18 +22471,18 @@ app54.post("/", async (c) => {
|
|
|
22360
22471
|
}
|
|
22361
22472
|
const rateMsg = checkRequestLinkRateLimit(contactValue);
|
|
22362
22473
|
if (rateMsg) {
|
|
22363
|
-
console.error(`${
|
|
22474
|
+
console.error(`${TAG42} contactValue=${maskContact(contactValue)} result=rate-limited`);
|
|
22364
22475
|
return c.json({ error: rateMsg }, 429);
|
|
22365
22476
|
}
|
|
22366
22477
|
recordRequestLinkAttempt(contactValue);
|
|
22367
22478
|
const accountId = process.env.ACCOUNT_ID ?? "";
|
|
22368
22479
|
if (!accountId) {
|
|
22369
|
-
console.error(`${
|
|
22480
|
+
console.error(`${TAG42} contactValue=${maskContact(contactValue)} result=no-account-id`);
|
|
22370
22481
|
return c.json({ message: VISITOR_MESSAGE }, 200);
|
|
22371
22482
|
}
|
|
22372
22483
|
const grant = await findActiveGrantByContact(contactValue, agentSlug, accountId);
|
|
22373
22484
|
if (!grant) {
|
|
22374
|
-
console.log(`${
|
|
22485
|
+
console.log(`${TAG42} contactValue=${maskContact(contactValue)} result=notfound`);
|
|
22375
22486
|
return c.json({ message: VISITOR_MESSAGE }, 200);
|
|
22376
22487
|
}
|
|
22377
22488
|
let token;
|
|
@@ -22379,7 +22490,7 @@ app54.post("/", async (c) => {
|
|
|
22379
22490
|
token = await generateNewMagicToken(grant.grantId);
|
|
22380
22491
|
} catch (err) {
|
|
22381
22492
|
console.error(
|
|
22382
|
-
`${
|
|
22493
|
+
`${TAG42} contactValue=${maskContact(contactValue)} result=mint-failed err="${err instanceof Error ? err.message : String(err)}"`
|
|
22383
22494
|
);
|
|
22384
22495
|
return c.json({ message: VISITOR_MESSAGE }, 200);
|
|
22385
22496
|
}
|
|
@@ -22411,22 +22522,22 @@ app54.post("/", async (c) => {
|
|
|
22411
22522
|
});
|
|
22412
22523
|
if (!sendResult.ok) {
|
|
22413
22524
|
console.error(
|
|
22414
|
-
`${
|
|
22525
|
+
`${TAG42} contactValue=${maskContact(contactValue)} result=send-failed err="${sendResult.error}"`
|
|
22415
22526
|
);
|
|
22416
22527
|
return c.json({ message: VISITOR_MESSAGE }, 200);
|
|
22417
22528
|
}
|
|
22418
22529
|
console.log(
|
|
22419
|
-
`${
|
|
22530
|
+
`${TAG42} contactValue=${maskContact(contactValue)} result=ok messageId=${sendResult.messageId}`
|
|
22420
22531
|
);
|
|
22421
22532
|
return c.json({ message: VISITOR_MESSAGE }, 200);
|
|
22422
22533
|
});
|
|
22423
|
-
var request_magic_link_default =
|
|
22534
|
+
var request_magic_link_default = app55;
|
|
22424
22535
|
|
|
22425
22536
|
// server/routes/access/index.ts
|
|
22426
|
-
var
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
var access_default =
|
|
22537
|
+
var app56 = new Hono();
|
|
22538
|
+
app56.route("/verify-token", verify_token_default);
|
|
22539
|
+
app56.route("/request-magic-link", request_magic_link_default);
|
|
22540
|
+
var access_default = app56;
|
|
22430
22541
|
|
|
22431
22542
|
// server/routes/sites.ts
|
|
22432
22543
|
import { existsSync as existsSync32, readFileSync as readFileSync35, realpathSync as realpathSync7, statSync as statSync12 } from "fs";
|
|
@@ -22461,8 +22572,8 @@ function getExt(p) {
|
|
|
22461
22572
|
if (idx < p.lastIndexOf("/")) return "";
|
|
22462
22573
|
return p.slice(idx).toLowerCase();
|
|
22463
22574
|
}
|
|
22464
|
-
var
|
|
22465
|
-
|
|
22575
|
+
var app57 = new Hono();
|
|
22576
|
+
app57.get("/:rel{.*}", (c) => {
|
|
22466
22577
|
const reqPath = c.req.path;
|
|
22467
22578
|
const rawRel = c.req.param("rel") ?? "";
|
|
22468
22579
|
const trimmed = rawRel.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
@@ -22565,7 +22676,7 @@ app56.get("/:rel{.*}", (c) => {
|
|
|
22565
22676
|
"X-Content-Type-Options": "nosniff"
|
|
22566
22677
|
});
|
|
22567
22678
|
});
|
|
22568
|
-
var sites_default =
|
|
22679
|
+
var sites_default = app57;
|
|
22569
22680
|
|
|
22570
22681
|
// app/lib/visitor-token.ts
|
|
22571
22682
|
import { createHmac, randomBytes as randomBytes2, timingSafeEqual } from "crypto";
|
|
@@ -22665,7 +22776,7 @@ function readBrandConfig() {
|
|
|
22665
22776
|
}
|
|
22666
22777
|
|
|
22667
22778
|
// server/routes/visitor-consent.ts
|
|
22668
|
-
var
|
|
22779
|
+
var app58 = new Hono();
|
|
22669
22780
|
var CONSENT_COOKIE_NAME = "mxy_consent";
|
|
22670
22781
|
var CONSENT_COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 365;
|
|
22671
22782
|
var DEFAULT_CONSENT_COPY = {
|
|
@@ -22710,17 +22821,17 @@ function siteSlugFromReferer(referer) {
|
|
|
22710
22821
|
return "";
|
|
22711
22822
|
}
|
|
22712
22823
|
}
|
|
22713
|
-
|
|
22824
|
+
app58.options("/consent", (c) => {
|
|
22714
22825
|
const origin = getOrigin(c);
|
|
22715
22826
|
setCorsHeaders(c, origin);
|
|
22716
22827
|
return c.body(null, 204);
|
|
22717
22828
|
});
|
|
22718
|
-
|
|
22829
|
+
app58.options("/brand-config", (c) => {
|
|
22719
22830
|
const origin = getOrigin(c);
|
|
22720
22831
|
setCorsHeaders(c, origin);
|
|
22721
22832
|
return c.body(null, 204);
|
|
22722
22833
|
});
|
|
22723
|
-
|
|
22834
|
+
app58.post("/consent", async (c) => {
|
|
22724
22835
|
const origin = getOrigin(c);
|
|
22725
22836
|
setCorsHeaders(c, origin);
|
|
22726
22837
|
let raw;
|
|
@@ -22760,7 +22871,7 @@ app57.post("/consent", async (c) => {
|
|
|
22760
22871
|
console.log(`[consent] ${parsed.decision} site=${site} brand=${brandName} tokenBound=${tokenBound}`);
|
|
22761
22872
|
return c.body(null, 204);
|
|
22762
22873
|
});
|
|
22763
|
-
|
|
22874
|
+
app58.get("/brand-config", (c) => {
|
|
22764
22875
|
const origin = getOrigin(c);
|
|
22765
22876
|
setCorsHeaders(c, origin);
|
|
22766
22877
|
const brand = readBrandConfig();
|
|
@@ -22770,7 +22881,7 @@ app57.get("/brand-config", (c) => {
|
|
|
22770
22881
|
c.header("Cache-Control", "public, max-age=300");
|
|
22771
22882
|
return c.json({ consent: { copy, palette } });
|
|
22772
22883
|
});
|
|
22773
|
-
var visitor_consent_default =
|
|
22884
|
+
var visitor_consent_default = app58;
|
|
22774
22885
|
|
|
22775
22886
|
// server/routes/listings.ts
|
|
22776
22887
|
function getCookie(headerValue, name) {
|
|
@@ -22797,8 +22908,8 @@ function appendConsentParams(pageUrl, token) {
|
|
|
22797
22908
|
}
|
|
22798
22909
|
var SAFE_SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,118}[a-z0-9])?$/;
|
|
22799
22910
|
var CHAT_SESSION_KEY_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{7,127}$/;
|
|
22800
|
-
var
|
|
22801
|
-
|
|
22911
|
+
var app59 = new Hono();
|
|
22912
|
+
app59.get("/:slug/click", async (c) => {
|
|
22802
22913
|
const slug = c.req.param("slug") ?? "";
|
|
22803
22914
|
const rawSession = c.req.query("session") ?? "";
|
|
22804
22915
|
const sessionKey = CHAT_SESSION_KEY_RE.test(rawSession) ? rawSession : "invalid";
|
|
@@ -22862,10 +22973,10 @@ app58.get("/:slug/click", async (c) => {
|
|
|
22862
22973
|
console.log(`[property-card-click] sessionKey=${sessionKey} listingSlug=${slug} consent=${consentCookie ?? "absent"} ts=${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
22863
22974
|
return c.redirect(redirectUrl, 302);
|
|
22864
22975
|
});
|
|
22865
|
-
var listings_default =
|
|
22976
|
+
var listings_default = app59;
|
|
22866
22977
|
|
|
22867
22978
|
// server/routes/visitor-event.ts
|
|
22868
|
-
var
|
|
22979
|
+
var app60 = new Hono();
|
|
22869
22980
|
var BOT_UA_RE = /\b(bot|crawl|spider|slurp|headlesschrome|phantomjs|googlebot|bingbot|yandex|baiduspider|ahrefsbot|semrushbot|mj12bot|dotbot|petalbot)\b/i;
|
|
22870
22981
|
var buckets = /* @__PURE__ */ new Map();
|
|
22871
22982
|
var RATE_LIMIT = 60;
|
|
@@ -22932,12 +23043,12 @@ function originAllowed(origin, allowlist) {
|
|
|
22932
23043
|
return false;
|
|
22933
23044
|
}
|
|
22934
23045
|
}
|
|
22935
|
-
|
|
23046
|
+
app60.options("/event", (c) => {
|
|
22936
23047
|
const origin = getOrigin2(c);
|
|
22937
23048
|
setCorsHeaders2(c, origin);
|
|
22938
23049
|
return c.body(null, 204);
|
|
22939
23050
|
});
|
|
22940
|
-
|
|
23051
|
+
app60.post("/event", async (c) => {
|
|
22941
23052
|
const origin = getOrigin2(c);
|
|
22942
23053
|
setCorsHeaders2(c, origin);
|
|
22943
23054
|
const ua = c.req.header("user-agent") ?? "";
|
|
@@ -23142,7 +23253,7 @@ async function writeEvent(opts) {
|
|
|
23142
23253
|
);
|
|
23143
23254
|
}
|
|
23144
23255
|
}
|
|
23145
|
-
var visitor_event_default =
|
|
23256
|
+
var visitor_event_default = app60;
|
|
23146
23257
|
|
|
23147
23258
|
// server/routes/session.ts
|
|
23148
23259
|
import { resolve as resolve29 } from "path";
|
|
@@ -23188,8 +23299,8 @@ function withVisitorCookie(response, visitorId) {
|
|
|
23188
23299
|
headers
|
|
23189
23300
|
});
|
|
23190
23301
|
}
|
|
23191
|
-
var
|
|
23192
|
-
|
|
23302
|
+
var app61 = new Hono();
|
|
23303
|
+
app61.post("/", async (c) => {
|
|
23193
23304
|
let body;
|
|
23194
23305
|
try {
|
|
23195
23306
|
body = await c.req.json();
|
|
@@ -23336,7 +23447,7 @@ app60.post("/", async (c) => {
|
|
|
23336
23447
|
newVisitorId
|
|
23337
23448
|
);
|
|
23338
23449
|
});
|
|
23339
|
-
var session_default2 =
|
|
23450
|
+
var session_default2 = app61;
|
|
23340
23451
|
|
|
23341
23452
|
// server/lib/calendar-slots.ts
|
|
23342
23453
|
var WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
@@ -23419,17 +23530,17 @@ function computeOpenSlots(config, busy, fromISO, toISO) {
|
|
|
23419
23530
|
}
|
|
23420
23531
|
|
|
23421
23532
|
// server/routes/calendar-public.ts
|
|
23422
|
-
var
|
|
23533
|
+
var app62 = new Hono();
|
|
23423
23534
|
function setCors(c) {
|
|
23424
23535
|
c.header("Access-Control-Allow-Origin", "*");
|
|
23425
23536
|
c.header("Access-Control-Allow-Methods", "GET, OPTIONS");
|
|
23426
23537
|
c.header("Access-Control-Allow-Headers", "content-type");
|
|
23427
23538
|
}
|
|
23428
|
-
|
|
23539
|
+
app62.options("/free-busy", (c) => {
|
|
23429
23540
|
setCors(c);
|
|
23430
23541
|
return c.body(null, 204);
|
|
23431
23542
|
});
|
|
23432
|
-
|
|
23543
|
+
app62.get("/free-busy", async (c) => {
|
|
23433
23544
|
setCors(c);
|
|
23434
23545
|
const from = c.req.query("from");
|
|
23435
23546
|
const to = c.req.query("to");
|
|
@@ -23475,10 +23586,10 @@ app61.get("/free-busy", async (c) => {
|
|
|
23475
23586
|
await session.close();
|
|
23476
23587
|
}
|
|
23477
23588
|
});
|
|
23478
|
-
var calendar_public_default =
|
|
23589
|
+
var calendar_public_default = app62;
|
|
23479
23590
|
|
|
23480
23591
|
// app/lib/timeentry-census.ts
|
|
23481
|
-
var
|
|
23592
|
+
var TAG43 = "[timeentry-census]";
|
|
23482
23593
|
function reconcileTimeEntries(rows, now, horizonMs) {
|
|
23483
23594
|
const openEntries = rows.openEntries.length;
|
|
23484
23595
|
let oldestOpenAgeMs = 0;
|
|
@@ -23518,12 +23629,12 @@ async function runTimeEntryCensusOnce(session, now, horizonMs) {
|
|
|
23518
23629
|
sumAdjustments: toNum(r.get("sumAdjustments"))
|
|
23519
23630
|
}));
|
|
23520
23631
|
const finding = reconcileTimeEntries({ openEntries, taskSums }, now, horizonMs);
|
|
23521
|
-
const line = `${
|
|
23632
|
+
const line = `${TAG43} openEntries=${finding.openEntries} oldestOpenAgeMin=${finding.oldestOpenAgeMin} maxOpenPerAccount=${finding.maxOpenPerAccount} driftTasks=${finding.driftTasks}`;
|
|
23522
23633
|
if (finding.alarm) console.error(`${line} alarm=true`);
|
|
23523
23634
|
else console.log(line);
|
|
23524
23635
|
return finding;
|
|
23525
23636
|
} catch (err) {
|
|
23526
|
-
console.error(`${
|
|
23637
|
+
console.error(`${TAG43} error="${err instanceof Error ? err.message : String(err)}"`);
|
|
23527
23638
|
return null;
|
|
23528
23639
|
}
|
|
23529
23640
|
}
|
|
@@ -23537,13 +23648,13 @@ function startTimeEntryCensus(openSession, opts = {}) {
|
|
|
23537
23648
|
try {
|
|
23538
23649
|
session = openSession();
|
|
23539
23650
|
} catch (err) {
|
|
23540
|
-
console.error(`${
|
|
23651
|
+
console.error(`${TAG43} open-session-failed error="${err instanceof Error ? err.message : String(err)}"`);
|
|
23541
23652
|
return;
|
|
23542
23653
|
}
|
|
23543
23654
|
try {
|
|
23544
23655
|
await runTimeEntryCensusOnce(session, Date.now(), horizonMs);
|
|
23545
23656
|
} catch (err) {
|
|
23546
|
-
console.error(`${
|
|
23657
|
+
console.error(`${TAG43} tick-failed error="${err instanceof Error ? err.message : String(err)}"`);
|
|
23547
23658
|
} finally {
|
|
23548
23659
|
try {
|
|
23549
23660
|
await session.close();
|
|
@@ -23561,8 +23672,181 @@ function startTimeEntryCensus(openSession, opts = {}) {
|
|
|
23561
23672
|
return () => clearInterval(id);
|
|
23562
23673
|
}
|
|
23563
23674
|
|
|
23675
|
+
// ../lib/ledger-core/dist/reconcile.js
|
|
23676
|
+
var LEDGER_INDEX_NAMES = [
|
|
23677
|
+
"invoice_account_confirmation_unique",
|
|
23678
|
+
"cash_entry_account_entryid_unique",
|
|
23679
|
+
"cash_entry_account",
|
|
23680
|
+
"invoice_line_account",
|
|
23681
|
+
"invoice_payment_account",
|
|
23682
|
+
"credit_account"
|
|
23683
|
+
];
|
|
23684
|
+
function countSuspectDuplicates(keys) {
|
|
23685
|
+
const groups = /* @__PURE__ */ new Map();
|
|
23686
|
+
for (const k of keys) {
|
|
23687
|
+
const composite = `${k.invoiceId}|${k.amount}|${k.date}`;
|
|
23688
|
+
const ids = groups.get(composite) ?? /* @__PURE__ */ new Set();
|
|
23689
|
+
ids.add(k.paymentId);
|
|
23690
|
+
groups.set(composite, ids);
|
|
23691
|
+
}
|
|
23692
|
+
let total = 0;
|
|
23693
|
+
for (const ids of groups.values())
|
|
23694
|
+
total += Math.max(0, ids.size - 1);
|
|
23695
|
+
return total;
|
|
23696
|
+
}
|
|
23697
|
+
function reconcileLedger(rows, _now) {
|
|
23698
|
+
const suspectDuplicates = countSuspectDuplicates(rows.paymentKeys);
|
|
23699
|
+
const alarm = rows.orphanPayments > 0 || rows.storedBalanceProps > 0 || suspectDuplicates > 0 || rows.declaredNotLive.length > 0;
|
|
23700
|
+
return {
|
|
23701
|
+
invoices: rows.invoices,
|
|
23702
|
+
payments: rows.payments,
|
|
23703
|
+
orphanPayments: rows.orphanPayments,
|
|
23704
|
+
storedBalanceProps: rows.storedBalanceProps,
|
|
23705
|
+
suspectDuplicates,
|
|
23706
|
+
declaredNotLive: rows.declaredNotLive,
|
|
23707
|
+
alarm
|
|
23708
|
+
};
|
|
23709
|
+
}
|
|
23710
|
+
function formatCensusLine(f) {
|
|
23711
|
+
return `[ledger-census] invoices=${f.invoices} payments=${f.payments} orphanPayments=${f.orphanPayments} storedBalanceProps=${f.storedBalanceProps} suspectDuplicates=${f.suspectDuplicates} declaredNotLive=${f.declaredNotLive.length === 0 ? "none" : f.declaredNotLive.join(",")}`;
|
|
23712
|
+
}
|
|
23713
|
+
|
|
23714
|
+
// app/lib/ledger-census.ts
|
|
23715
|
+
var TAG44 = "[ledger-census]";
|
|
23716
|
+
function toNum2(v) {
|
|
23717
|
+
if (typeof v === "number") return v;
|
|
23718
|
+
if (v && typeof v === "object" && "toNumber" in v) {
|
|
23719
|
+
return v.toNumber();
|
|
23720
|
+
}
|
|
23721
|
+
return 0;
|
|
23722
|
+
}
|
|
23723
|
+
async function runLedgerCensusOnce(session, now) {
|
|
23724
|
+
try {
|
|
23725
|
+
const counts = await session.run(
|
|
23726
|
+
`MATCH (i:Invoice|InboundInvoice) WITH count(i) AS invoices
|
|
23727
|
+
OPTIONAL MATCH (p:InvoicePayment)
|
|
23728
|
+
RETURN invoices, count(p) AS payments`
|
|
23729
|
+
);
|
|
23730
|
+
const orphans = await session.run(
|
|
23731
|
+
`MATCH (p:InvoicePayment)
|
|
23732
|
+
WHERE NOT ( (:Invoice|InboundInvoice)-[:HAS_PAYMENT]->(p) )
|
|
23733
|
+
RETURN count(p) AS orphanPayments`
|
|
23734
|
+
);
|
|
23735
|
+
const stored = await session.run(
|
|
23736
|
+
`MATCH (i:Invoice|InboundInvoice)
|
|
23737
|
+
WHERE i.outstanding IS NOT NULL OR i.balance IS NOT NULL OR i.amountPaid IS NOT NULL
|
|
23738
|
+
RETURN count(i) AS storedBalanceProps`
|
|
23739
|
+
);
|
|
23740
|
+
const keys = await session.run(
|
|
23741
|
+
`MATCH (i:Invoice|InboundInvoice)-[:HAS_PAYMENT]->(p:InvoicePayment)
|
|
23742
|
+
RETURN i.confirmationNumber AS invoiceId, p.paymentId AS paymentId,
|
|
23743
|
+
p.amount AS amount, p.date AS date`
|
|
23744
|
+
);
|
|
23745
|
+
const indexes = await session.run(`SHOW INDEXES YIELD name RETURN collect(name) AS names`);
|
|
23746
|
+
const live = new Set(indexes.records[0]?.get("names") ?? []);
|
|
23747
|
+
const finding = reconcileLedger(
|
|
23748
|
+
{
|
|
23749
|
+
invoices: toNum2(counts.records[0]?.get("invoices")),
|
|
23750
|
+
payments: toNum2(counts.records[0]?.get("payments")),
|
|
23751
|
+
orphanPayments: toNum2(orphans.records[0]?.get("orphanPayments")),
|
|
23752
|
+
storedBalanceProps: toNum2(stored.records[0]?.get("storedBalanceProps")),
|
|
23753
|
+
paymentKeys: keys.records.map((r) => ({
|
|
23754
|
+
invoiceId: r.get("invoiceId") ?? "",
|
|
23755
|
+
paymentId: r.get("paymentId") ?? "",
|
|
23756
|
+
amount: toNum2(r.get("amount")),
|
|
23757
|
+
date: r.get("date") ?? ""
|
|
23758
|
+
})),
|
|
23759
|
+
declaredNotLive: LEDGER_INDEX_NAMES.filter((n) => !live.has(n))
|
|
23760
|
+
},
|
|
23761
|
+
now
|
|
23762
|
+
);
|
|
23763
|
+
const line = formatCensusLine(finding);
|
|
23764
|
+
if (finding.alarm) console.error(`${line} alarm=true`);
|
|
23765
|
+
else console.log(line);
|
|
23766
|
+
return finding;
|
|
23767
|
+
} catch (err) {
|
|
23768
|
+
console.error(`${TAG44} error="${err instanceof Error ? err.message : String(err)}"`);
|
|
23769
|
+
return null;
|
|
23770
|
+
}
|
|
23771
|
+
}
|
|
23772
|
+
var DEFAULT_INTERVAL_MS2 = 15 * 60 * 1e3;
|
|
23773
|
+
function startLedgerCensus(openSession, opts = {}) {
|
|
23774
|
+
const intervalMs = opts.intervalMs ?? DEFAULT_INTERVAL_MS2;
|
|
23775
|
+
const tick = async () => {
|
|
23776
|
+
let session;
|
|
23777
|
+
try {
|
|
23778
|
+
session = openSession();
|
|
23779
|
+
} catch (err) {
|
|
23780
|
+
console.error(
|
|
23781
|
+
`${TAG44} open-session-failed error="${err instanceof Error ? err.message : String(err)}"`
|
|
23782
|
+
);
|
|
23783
|
+
return;
|
|
23784
|
+
}
|
|
23785
|
+
try {
|
|
23786
|
+
await runLedgerCensusOnce(session, Date.now());
|
|
23787
|
+
} catch (err) {
|
|
23788
|
+
console.error(
|
|
23789
|
+
`${TAG44} tick-failed error="${err instanceof Error ? err.message : String(err)}"`
|
|
23790
|
+
);
|
|
23791
|
+
} finally {
|
|
23792
|
+
try {
|
|
23793
|
+
await session.close();
|
|
23794
|
+
} catch {
|
|
23795
|
+
}
|
|
23796
|
+
}
|
|
23797
|
+
};
|
|
23798
|
+
void tick();
|
|
23799
|
+
const id = setInterval(() => {
|
|
23800
|
+
void tick();
|
|
23801
|
+
}, intervalMs);
|
|
23802
|
+
if (typeof id.unref === "function") {
|
|
23803
|
+
;
|
|
23804
|
+
id.unref();
|
|
23805
|
+
}
|
|
23806
|
+
return () => clearInterval(id);
|
|
23807
|
+
}
|
|
23808
|
+
|
|
23809
|
+
// app/lib/conversation-audit.ts
|
|
23810
|
+
var TAG45 = "[conversation-audit]";
|
|
23811
|
+
async function runConversationAudit() {
|
|
23812
|
+
const session = getSession();
|
|
23813
|
+
try {
|
|
23814
|
+
const res = await session.run(
|
|
23815
|
+
`MATCH (a:Conversation {channel: 'whatsapp'})
|
|
23816
|
+
WHERE a.channelAddress =~ '[0-9]+'
|
|
23817
|
+
WITH collect(a.channelAddress) AS anchored
|
|
23818
|
+
MATCH (c:Conversation {channel: 'whatsapp'})
|
|
23819
|
+
WITH anchored,
|
|
23820
|
+
count(*) AS total,
|
|
23821
|
+
sum(CASE WHEN c.channelAddress = 'default' THEN 1 ELSE 0 END) AS unpairable,
|
|
23822
|
+
collect(CASE WHEN c.channelAddress =~ 'default:[0-9]+'
|
|
23823
|
+
THEN substring(c.channelAddress, 8) END) AS forensic
|
|
23824
|
+
RETURN total,
|
|
23825
|
+
unpairable,
|
|
23826
|
+
size([p IN forensic WHERE p IS NOT NULL AND NOT p IN anchored]) AS unreconciled`,
|
|
23827
|
+
{}
|
|
23828
|
+
);
|
|
23829
|
+
const rec = res.records[0];
|
|
23830
|
+
const result = {
|
|
23831
|
+
total: Number(rec?.get("total") ?? 0),
|
|
23832
|
+
unreconciled: Number(rec?.get("unreconciled") ?? 0),
|
|
23833
|
+
unpairable: Number(rec?.get("unpairable") ?? 0)
|
|
23834
|
+
};
|
|
23835
|
+
console.error(
|
|
23836
|
+
`${TAG45} channel=whatsapp total=${result.total} unreconciled=${result.unreconciled} unpairable=${result.unpairable}`
|
|
23837
|
+
);
|
|
23838
|
+
return result;
|
|
23839
|
+
} catch (err) {
|
|
23840
|
+
const reason = err instanceof Error ? `${err.name}:${err.message.slice(0, 200)}` : String(err).slice(0, 200);
|
|
23841
|
+
console.error(`${TAG45} op=failed reason=${reason}`);
|
|
23842
|
+
return null;
|
|
23843
|
+
} finally {
|
|
23844
|
+
await session.close();
|
|
23845
|
+
}
|
|
23846
|
+
}
|
|
23847
|
+
|
|
23564
23848
|
// app/lib/graph-health.ts
|
|
23565
|
-
var
|
|
23849
|
+
var import_dist5 = __toESM(require_dist4(), 1);
|
|
23566
23850
|
var HOUR_MS = 60 * 60 * 1e3;
|
|
23567
23851
|
function renderLabelTop(rows) {
|
|
23568
23852
|
return rows.map((b) => {
|
|
@@ -23607,7 +23891,7 @@ async function runGraphHealthTick() {
|
|
|
23607
23891
|
console.error(
|
|
23608
23892
|
`[graph-health] userprofile-multi accounts=${upAccounts} top=${upTop.length > 0 ? upTop.join(",") : "none"}`
|
|
23609
23893
|
);
|
|
23610
|
-
const indexed = [...
|
|
23894
|
+
const indexed = [...import_dist5.VECTOR_INDEXED_LABELS];
|
|
23611
23895
|
const embCount = await session.run(
|
|
23612
23896
|
`MATCH (n) WHERE n.embedding IS NULL AND any(l IN labels(n) WHERE l IN $indexed)
|
|
23613
23897
|
RETURN count(n) AS total`,
|
|
@@ -24175,7 +24459,7 @@ var InboundHub = class {
|
|
|
24175
24459
|
};
|
|
24176
24460
|
|
|
24177
24461
|
// app/lib/whatsapp/gateway/wa-gateway.ts
|
|
24178
|
-
var
|
|
24462
|
+
var import_dist6 = __toESM(require_dist(), 1);
|
|
24179
24463
|
|
|
24180
24464
|
// node_modules/hono/dist/utils/stream.js
|
|
24181
24465
|
var StreamingApi = class {
|
|
@@ -24328,8 +24612,8 @@ var streamSSE = (c, cb, onError) => {
|
|
|
24328
24612
|
|
|
24329
24613
|
// app/lib/whatsapp/gateway/routes.ts
|
|
24330
24614
|
function createWaChannelRoutes(deps) {
|
|
24331
|
-
const
|
|
24332
|
-
|
|
24615
|
+
const app64 = new Hono();
|
|
24616
|
+
app64.get("/wa-channel/inbound", (c) => {
|
|
24333
24617
|
const senderId = c.req.query("senderId");
|
|
24334
24618
|
if (!senderId) return c.json({ error: "senderId required" }, 400);
|
|
24335
24619
|
return streamSSE(c, async (stream2) => {
|
|
@@ -24347,7 +24631,7 @@ function createWaChannelRoutes(deps) {
|
|
|
24347
24631
|
}
|
|
24348
24632
|
});
|
|
24349
24633
|
});
|
|
24350
|
-
|
|
24634
|
+
app64.post("/wa-channel/reply", async (c) => {
|
|
24351
24635
|
const body = await c.req.json().catch(() => null);
|
|
24352
24636
|
const senderId = body?.senderId;
|
|
24353
24637
|
const text = body?.text;
|
|
@@ -24368,7 +24652,7 @@ function createWaChannelRoutes(deps) {
|
|
|
24368
24652
|
console.error(`[whatsapp-native] op=reply-dispatch senderId=${senderId} bytes=${bytes}`);
|
|
24369
24653
|
return c.json({ ok: true });
|
|
24370
24654
|
});
|
|
24371
|
-
|
|
24655
|
+
app64.post("/wa-channel/reply-document", async (c) => {
|
|
24372
24656
|
const body = await c.req.json().catch(() => null);
|
|
24373
24657
|
const senderId = body?.senderId;
|
|
24374
24658
|
const files = body?.files;
|
|
@@ -24407,7 +24691,7 @@ function createWaChannelRoutes(deps) {
|
|
|
24407
24691
|
}
|
|
24408
24692
|
return c.json({ ok: true, results });
|
|
24409
24693
|
});
|
|
24410
|
-
|
|
24694
|
+
app64.post("/wa-channel/ready", async (c) => {
|
|
24411
24695
|
const body = await c.req.json().catch(() => null);
|
|
24412
24696
|
const senderId = body?.senderId;
|
|
24413
24697
|
if (typeof senderId !== "string") {
|
|
@@ -24416,7 +24700,7 @@ function createWaChannelRoutes(deps) {
|
|
|
24416
24700
|
deps.onReady?.(senderId);
|
|
24417
24701
|
return c.json({ ok: true });
|
|
24418
24702
|
});
|
|
24419
|
-
|
|
24703
|
+
app64.post("/wa-channel/received", async (c) => {
|
|
24420
24704
|
const body = await c.req.json().catch(() => null);
|
|
24421
24705
|
const senderId = body?.senderId;
|
|
24422
24706
|
const waMessageId = body?.waMessageId;
|
|
@@ -24426,7 +24710,7 @@ function createWaChannelRoutes(deps) {
|
|
|
24426
24710
|
deps.onReceived?.(senderId, waMessageId);
|
|
24427
24711
|
return c.json({ ok: true });
|
|
24428
24712
|
});
|
|
24429
|
-
|
|
24713
|
+
app64.post("/wa-channel/turn-end", async (c) => {
|
|
24430
24714
|
const body = await c.req.json().catch(() => null);
|
|
24431
24715
|
const senderId = body?.senderId;
|
|
24432
24716
|
const sessionId = body?.sessionId;
|
|
@@ -24459,7 +24743,7 @@ function createWaChannelRoutes(deps) {
|
|
|
24459
24743
|
console.error(`[whatsapp-native] op=turn-end sessionId=${sid} replied=no delivered=none`);
|
|
24460
24744
|
return c.json({ ok: true, delivered: "none" });
|
|
24461
24745
|
});
|
|
24462
|
-
return
|
|
24746
|
+
return app64;
|
|
24463
24747
|
}
|
|
24464
24748
|
|
|
24465
24749
|
// app/lib/whatsapp/gateway/wa-gateway.ts
|
|
@@ -24561,7 +24845,7 @@ var WaGateway = class {
|
|
|
24561
24845
|
const injected = res.block ? (res.block.match(/^- /gm) ?? []).length : 0;
|
|
24562
24846
|
const owner8 = res.ownerUserId ? res.ownerUserId.slice(0, 8) : "-";
|
|
24563
24847
|
console.error(
|
|
24564
|
-
`[preference-inject] op=inject channel=wa accountId=${input.effectiveAccountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >=
|
|
24848
|
+
`[preference-inject] op=inject channel=wa accountId=${input.effectiveAccountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >= import_dist6.INJECTION_RULE_CAP}`
|
|
24565
24849
|
);
|
|
24566
24850
|
}
|
|
24567
24851
|
this.hub.deliver(
|
|
@@ -24834,12 +25118,12 @@ var InboundHub2 = class {
|
|
|
24834
25118
|
};
|
|
24835
25119
|
|
|
24836
25120
|
// app/lib/webchat/gateway/webchat-gateway.ts
|
|
24837
|
-
var
|
|
25121
|
+
var import_dist7 = __toESM(require_dist(), 1);
|
|
24838
25122
|
|
|
24839
25123
|
// app/lib/webchat/gateway/routes.ts
|
|
24840
25124
|
function createWebchatChannelRoutes(deps) {
|
|
24841
|
-
const
|
|
24842
|
-
|
|
25125
|
+
const app64 = new Hono();
|
|
25126
|
+
app64.get("/webchat-channel/inbound", (c) => {
|
|
24843
25127
|
const key = c.req.query("key");
|
|
24844
25128
|
if (!key) return c.json({ error: "key required" }, 400);
|
|
24845
25129
|
return streamSSE(c, async (stream2) => {
|
|
@@ -24857,7 +25141,7 @@ function createWebchatChannelRoutes(deps) {
|
|
|
24857
25141
|
}
|
|
24858
25142
|
});
|
|
24859
25143
|
});
|
|
24860
|
-
|
|
25144
|
+
app64.post("/webchat-channel/reply", async (c) => {
|
|
24861
25145
|
const body = await c.req.json().catch(() => null);
|
|
24862
25146
|
const key = body?.key;
|
|
24863
25147
|
const text = body?.text;
|
|
@@ -24867,7 +25151,7 @@ function createWebchatChannelRoutes(deps) {
|
|
|
24867
25151
|
deps.onReply?.(key, text);
|
|
24868
25152
|
return c.json({ ok: true });
|
|
24869
25153
|
});
|
|
24870
|
-
|
|
25154
|
+
app64.post("/webchat-channel/connector-auth", async (c) => {
|
|
24871
25155
|
const body = await c.req.json().catch(() => null);
|
|
24872
25156
|
const key = body?.key;
|
|
24873
25157
|
const sessionId = body?.sessionId;
|
|
@@ -24880,7 +25164,7 @@ function createWebchatChannelRoutes(deps) {
|
|
|
24880
25164
|
const result = await deps.onConnectorAuth({ key, sessionId, name, completed });
|
|
24881
25165
|
return c.json(result);
|
|
24882
25166
|
});
|
|
24883
|
-
|
|
25167
|
+
app64.post("/webchat-channel/ready", async (c) => {
|
|
24884
25168
|
const body = await c.req.json().catch(() => null);
|
|
24885
25169
|
const key = body?.key;
|
|
24886
25170
|
if (typeof key !== "string") {
|
|
@@ -24889,7 +25173,7 @@ function createWebchatChannelRoutes(deps) {
|
|
|
24889
25173
|
deps.onReady?.(key);
|
|
24890
25174
|
return c.json({ ok: true });
|
|
24891
25175
|
});
|
|
24892
|
-
|
|
25176
|
+
app64.post("/webchat-channel/permission-request", async (c) => {
|
|
24893
25177
|
const body = await c.req.json().catch(() => null);
|
|
24894
25178
|
const key = body?.key;
|
|
24895
25179
|
const requestId = body?.request_id;
|
|
@@ -24903,7 +25187,7 @@ function createWebchatChannelRoutes(deps) {
|
|
|
24903
25187
|
const verdict = await deps.awaitPermissionVerdict({ key, requestId, toolName, description, inputPreview });
|
|
24904
25188
|
return c.json(verdict);
|
|
24905
25189
|
});
|
|
24906
|
-
|
|
25190
|
+
app64.post("/webchat-channel/received", async (c) => {
|
|
24907
25191
|
const body = await c.req.json().catch(() => null);
|
|
24908
25192
|
const key = body?.key;
|
|
24909
25193
|
const messageId = body?.messageId;
|
|
@@ -24913,7 +25197,7 @@ function createWebchatChannelRoutes(deps) {
|
|
|
24913
25197
|
deps.onReceived?.(key, messageId);
|
|
24914
25198
|
return c.json({ ok: true });
|
|
24915
25199
|
});
|
|
24916
|
-
|
|
25200
|
+
app64.post("/webchat-channel/turn-end", async (c) => {
|
|
24917
25201
|
const body = await c.req.json().catch(() => null);
|
|
24918
25202
|
const key = body?.key;
|
|
24919
25203
|
const sessionId = body?.sessionId;
|
|
@@ -24936,7 +25220,7 @@ function createWebchatChannelRoutes(deps) {
|
|
|
24936
25220
|
console.error(`[webchat-native] op=turn-end channel=webchat key=${k} sessionId=${sid} replied=no delivered=none`);
|
|
24937
25221
|
return c.json({ ok: true, delivered: "none" });
|
|
24938
25222
|
});
|
|
24939
|
-
return
|
|
25223
|
+
return app64;
|
|
24940
25224
|
}
|
|
24941
25225
|
|
|
24942
25226
|
// app/lib/webchat/gateway/webchat-gateway.ts
|
|
@@ -25282,7 +25566,7 @@ var WebchatGateway = class _WebchatGateway {
|
|
|
25282
25566
|
const injected = res.block ? (res.block.match(/^- /gm) ?? []).length : 0;
|
|
25283
25567
|
const owner8 = res.ownerUserId ? res.ownerUserId.slice(0, 8) : "-";
|
|
25284
25568
|
console.error(
|
|
25285
|
-
`[preference-inject] op=inject channel=web accountId=${input.accountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >=
|
|
25569
|
+
`[preference-inject] op=inject channel=web accountId=${input.accountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >= import_dist7.INJECTION_RULE_CAP}`
|
|
25286
25570
|
);
|
|
25287
25571
|
}
|
|
25288
25572
|
this.hub.deliver(
|
|
@@ -25651,14 +25935,14 @@ function makeFileDelivery(opts) {
|
|
|
25651
25935
|
}
|
|
25652
25936
|
|
|
25653
25937
|
// app/lib/webchat/file-delivery.ts
|
|
25654
|
-
var
|
|
25938
|
+
var TAG46 = "[webchat-adaptor]";
|
|
25655
25939
|
function platformRoot2() {
|
|
25656
25940
|
return process.env.MAXY_PLATFORM_ROOT || "";
|
|
25657
25941
|
}
|
|
25658
25942
|
function makeWebchatSendFile(entry) {
|
|
25659
25943
|
return async (filePath) => {
|
|
25660
25944
|
if (!entry.accountId) {
|
|
25661
|
-
console.error(`${
|
|
25945
|
+
console.error(`${TAG46} file-delivery reject reason=no-account sender=${entry.senderId}`);
|
|
25662
25946
|
return { ok: false, error: "no-account" };
|
|
25663
25947
|
}
|
|
25664
25948
|
const accountDir = resolve32(platformRoot2(), "..", "data/accounts", entry.accountId);
|
|
@@ -25666,14 +25950,14 @@ function makeWebchatSendFile(entry) {
|
|
|
25666
25950
|
const resolved = realpathSync8(filePath);
|
|
25667
25951
|
const accountResolved = realpathSync8(accountDir);
|
|
25668
25952
|
if (!resolved.startsWith(accountResolved + "/")) {
|
|
25669
|
-
console.error(`${
|
|
25953
|
+
console.error(`${TAG46} file-delivery reject reason=outside_account_directory sender=${entry.senderId}`);
|
|
25670
25954
|
return { ok: false, error: "outside-account" };
|
|
25671
25955
|
}
|
|
25672
25956
|
return { ok: true };
|
|
25673
25957
|
} catch (err) {
|
|
25674
25958
|
const code = err.code;
|
|
25675
25959
|
console.error(
|
|
25676
|
-
`${
|
|
25960
|
+
`${TAG46} file-delivery reject reason=${code === "ENOENT" ? "not-found" : "path-error"} sender=${entry.senderId}`
|
|
25677
25961
|
);
|
|
25678
25962
|
return { ok: false, error: code === "ENOENT" ? "not-found" : "path-error" };
|
|
25679
25963
|
}
|
|
@@ -25682,7 +25966,7 @@ function makeWebchatSendFile(entry) {
|
|
|
25682
25966
|
function makeWebchatFileDelivery(entry) {
|
|
25683
25967
|
return makeFileDelivery({
|
|
25684
25968
|
entry,
|
|
25685
|
-
tag:
|
|
25969
|
+
tag: TAG46,
|
|
25686
25970
|
channel: "webchat",
|
|
25687
25971
|
sendFile: makeWebchatSendFile(entry),
|
|
25688
25972
|
deferUntilVerdict: true
|
|
@@ -25744,7 +26028,7 @@ function buildPublicWebchatSpawnRequest(input) {
|
|
|
25744
26028
|
}
|
|
25745
26029
|
|
|
25746
26030
|
// app/lib/whatsapp/inbound/file-delivery-bridge.ts
|
|
25747
|
-
var
|
|
26031
|
+
var TAG47 = "[whatsapp-adaptor]";
|
|
25748
26032
|
var SEND_USER_FILE2 = "SendUserFile";
|
|
25749
26033
|
var WHATSAPP_SEND_DOCUMENT = "whatsapp-send-document";
|
|
25750
26034
|
function platformRoot3() {
|
|
@@ -25762,7 +26046,7 @@ function makeWhatsAppSendFile(entry, maxyAccountId) {
|
|
|
25762
26046
|
});
|
|
25763
26047
|
if (result.ok) return { ok: true };
|
|
25764
26048
|
console.error(
|
|
25765
|
-
`${
|
|
26049
|
+
`${TAG47} file-delivery reject reason=send-failed sender=${entry.senderId} status=${result.status} message=${result.error}`
|
|
25766
26050
|
);
|
|
25767
26051
|
return { ok: false, error: result.error };
|
|
25768
26052
|
};
|
|
@@ -25770,7 +26054,7 @@ function makeWhatsAppSendFile(entry, maxyAccountId) {
|
|
|
25770
26054
|
function makeWhatsAppFileDelivery(entry, maxyAccountId) {
|
|
25771
26055
|
const shared = makeFileDelivery({
|
|
25772
26056
|
entry,
|
|
25773
|
-
tag:
|
|
26057
|
+
tag: TAG47,
|
|
25774
26058
|
channel: "whatsapp",
|
|
25775
26059
|
sendFile: makeWhatsAppSendFile(entry, maxyAccountId)
|
|
25776
26060
|
});
|
|
@@ -25805,7 +26089,7 @@ function makeWhatsAppFileDelivery(entry, maxyAccountId) {
|
|
|
25805
26089
|
if (!delivered) {
|
|
25806
26090
|
const fileField = call.filePath !== void 0 ? ` file=${call.filePath}` : "";
|
|
25807
26091
|
console.error(
|
|
25808
|
-
`${
|
|
26092
|
+
`${TAG47} file-delivery-unreconciled sender=${entry.senderId} sessionId=${sid} tool=${WHATSAPP_SEND_DOCUMENT}${fileField}`
|
|
25809
26093
|
);
|
|
25810
26094
|
}
|
|
25811
26095
|
}
|
|
@@ -25987,12 +26271,12 @@ var InboundHub3 = class {
|
|
|
25987
26271
|
};
|
|
25988
26272
|
|
|
25989
26273
|
// app/lib/telegram/gateway/telegram-gateway.ts
|
|
25990
|
-
var
|
|
26274
|
+
var import_dist8 = __toESM(require_dist(), 1);
|
|
25991
26275
|
|
|
25992
26276
|
// app/lib/telegram/gateway/routes.ts
|
|
25993
26277
|
function createTelegramChannelRoutes(deps) {
|
|
25994
|
-
const
|
|
25995
|
-
|
|
26278
|
+
const app64 = new Hono();
|
|
26279
|
+
app64.get("/tg-channel/inbound", (c) => {
|
|
25996
26280
|
const key = c.req.query("key");
|
|
25997
26281
|
if (!key) return c.json({ error: "key required" }, 400);
|
|
25998
26282
|
return streamSSE(c, async (stream2) => {
|
|
@@ -26010,7 +26294,7 @@ function createTelegramChannelRoutes(deps) {
|
|
|
26010
26294
|
}
|
|
26011
26295
|
});
|
|
26012
26296
|
});
|
|
26013
|
-
|
|
26297
|
+
app64.post("/tg-channel/reply", async (c) => {
|
|
26014
26298
|
const body = await c.req.json().catch(() => null);
|
|
26015
26299
|
const key = body?.key;
|
|
26016
26300
|
const text = body?.text;
|
|
@@ -26026,7 +26310,7 @@ function createTelegramChannelRoutes(deps) {
|
|
|
26026
26310
|
console.error(`[telegram-native] op=reply key=${key} bytes=${Buffer.byteLength(text, "utf8")}`);
|
|
26027
26311
|
return c.json({ ok: true });
|
|
26028
26312
|
});
|
|
26029
|
-
|
|
26313
|
+
app64.post("/tg-channel/ready", async (c) => {
|
|
26030
26314
|
const body = await c.req.json().catch(() => null);
|
|
26031
26315
|
const key = body?.key;
|
|
26032
26316
|
if (typeof key !== "string") {
|
|
@@ -26035,7 +26319,7 @@ function createTelegramChannelRoutes(deps) {
|
|
|
26035
26319
|
deps.onReady?.(key);
|
|
26036
26320
|
return c.json({ ok: true });
|
|
26037
26321
|
});
|
|
26038
|
-
|
|
26322
|
+
app64.post("/tg-channel/received", async (c) => {
|
|
26039
26323
|
const body = await c.req.json().catch(() => null);
|
|
26040
26324
|
const key = body?.key;
|
|
26041
26325
|
const messageId = body?.messageId;
|
|
@@ -26045,7 +26329,7 @@ function createTelegramChannelRoutes(deps) {
|
|
|
26045
26329
|
deps.onReceived?.(key, messageId);
|
|
26046
26330
|
return c.json({ ok: true });
|
|
26047
26331
|
});
|
|
26048
|
-
|
|
26332
|
+
app64.post("/tg-channel/turn-end", async (c) => {
|
|
26049
26333
|
const body = await c.req.json().catch(() => null);
|
|
26050
26334
|
const key = body?.key;
|
|
26051
26335
|
const sessionId = body?.sessionId;
|
|
@@ -26078,7 +26362,7 @@ function createTelegramChannelRoutes(deps) {
|
|
|
26078
26362
|
console.error(`[telegram-native] op=turn-end key=${key} sessionId=${sid} replied=no delivered=none`);
|
|
26079
26363
|
return c.json({ ok: true, delivered: "none" });
|
|
26080
26364
|
});
|
|
26081
|
-
return
|
|
26365
|
+
return app64;
|
|
26082
26366
|
}
|
|
26083
26367
|
|
|
26084
26368
|
// app/lib/telegram/gateway/telegram-gateway.ts
|
|
@@ -26143,7 +26427,7 @@ var TelegramGateway = class {
|
|
|
26143
26427
|
const injected = res.block ? (res.block.match(/^- /gm) ?? []).length : 0;
|
|
26144
26428
|
const owner8 = res.ownerUserId ? res.ownerUserId.slice(0, 8) : "-";
|
|
26145
26429
|
console.error(
|
|
26146
|
-
`[preference-inject] op=inject channel=tg accountId=${input.accountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >=
|
|
26430
|
+
`[preference-inject] op=inject channel=tg accountId=${input.accountId} injected=${injected} owner=${owner8} source=${res.source} capped=${injected >= import_dist8.INJECTION_RULE_CAP}`
|
|
26147
26431
|
);
|
|
26148
26432
|
}
|
|
26149
26433
|
this.hub.deliver(
|
|
@@ -26209,7 +26493,7 @@ function buildTelegramSpawnRequest(input) {
|
|
|
26209
26493
|
import { realpathSync as realpathSync9 } from "fs";
|
|
26210
26494
|
import { readFile as readFile7, stat as stat7 } from "fs/promises";
|
|
26211
26495
|
import { resolve as resolve33, basename as basename11 } from "path";
|
|
26212
|
-
var
|
|
26496
|
+
var TAG48 = "[telegram:outbound]";
|
|
26213
26497
|
var TELEGRAM_DOCUMENT_MAX_BYTES = 50 * 1024 * 1024;
|
|
26214
26498
|
async function sendTelegramDocument(input) {
|
|
26215
26499
|
const { botToken, chatId, filePath, caption, maxyAccountId, platformRoot: platformRoot5 } = input;
|
|
@@ -26225,16 +26509,16 @@ async function sendTelegramDocument(input) {
|
|
|
26225
26509
|
resolvedPath = realpathSync9(filePath);
|
|
26226
26510
|
const accountResolved = realpathSync9(accountDir);
|
|
26227
26511
|
if (!resolvedPath.startsWith(accountResolved + "/")) {
|
|
26228
|
-
console.error(`${
|
|
26512
|
+
console.error(`${TAG48} document REJECTED reason=outside_account_directory maxyAccountId=${maxyAccountId}`);
|
|
26229
26513
|
return { ok: false, status: 403, error: "Access denied: file is outside the account directory" };
|
|
26230
26514
|
}
|
|
26231
26515
|
} catch (err) {
|
|
26232
26516
|
const code = err.code;
|
|
26233
26517
|
if (code === "ENOENT") {
|
|
26234
|
-
console.error(`${
|
|
26518
|
+
console.error(`${TAG48} document ENOENT path=${filePath}`);
|
|
26235
26519
|
return { ok: false, status: 404, error: `File not found: ${filePath}` };
|
|
26236
26520
|
}
|
|
26237
|
-
console.error(`${
|
|
26521
|
+
console.error(`${TAG48} document path error: ${String(err)}`);
|
|
26238
26522
|
return { ok: false, status: 500, error: String(err) };
|
|
26239
26523
|
}
|
|
26240
26524
|
const fileStat = await stat7(resolvedPath);
|
|
@@ -26267,13 +26551,13 @@ async function sendTelegramDocument(input) {
|
|
|
26267
26551
|
error = e instanceof Error ? e.message : String(e);
|
|
26268
26552
|
}
|
|
26269
26553
|
console.error(
|
|
26270
|
-
`${
|
|
26554
|
+
`${TAG48} sent document to=${chatId} file=${filename} bytes=${fileStat.size} ok=${ok}` + (messageId !== void 0 ? ` id=${messageId}` : "")
|
|
26271
26555
|
);
|
|
26272
26556
|
return ok ? { ok: true, messageId } : { ok: false, status: 500, error };
|
|
26273
26557
|
}
|
|
26274
26558
|
|
|
26275
26559
|
// app/lib/telegram/outbound/file-delivery.ts
|
|
26276
|
-
var
|
|
26560
|
+
var TAG49 = "[telegram:outbound]";
|
|
26277
26561
|
function platformRoot4() {
|
|
26278
26562
|
return process.env.MAXY_PLATFORM_ROOT || "";
|
|
26279
26563
|
}
|
|
@@ -26285,11 +26569,11 @@ function makeTelegramSendFile(entry) {
|
|
|
26285
26569
|
botToken = (entry.role === "admin" ? tg?.adminBotToken : tg?.publicBotToken) ?? null;
|
|
26286
26570
|
}
|
|
26287
26571
|
if (!botToken) {
|
|
26288
|
-
console.error(`${
|
|
26572
|
+
console.error(`${TAG49} file-delivery reject reason=no-bot-token sender=${entry.senderId} role=${entry.role}`);
|
|
26289
26573
|
return { ok: false, error: "no-bot-token" };
|
|
26290
26574
|
}
|
|
26291
26575
|
if (entry.replyTarget == null) {
|
|
26292
|
-
console.error(`${
|
|
26576
|
+
console.error(`${TAG49} file-delivery reject reason=no-reply-target sender=${entry.senderId} role=${entry.role}`);
|
|
26293
26577
|
return { ok: false, error: "no-reply-target" };
|
|
26294
26578
|
}
|
|
26295
26579
|
const result = await sendTelegramDocument({
|
|
@@ -26306,7 +26590,7 @@ function makeTelegramSendFile(entry) {
|
|
|
26306
26590
|
function makeTelegramFileDelivery(entry) {
|
|
26307
26591
|
return makeFileDelivery({
|
|
26308
26592
|
entry,
|
|
26309
|
-
tag:
|
|
26593
|
+
tag: TAG49,
|
|
26310
26594
|
channel: "telegram",
|
|
26311
26595
|
sendFile: makeTelegramSendFile(entry)
|
|
26312
26596
|
});
|
|
@@ -26356,7 +26640,7 @@ function telegramServerPath() {
|
|
|
26356
26640
|
|
|
26357
26641
|
// app/lib/channel-pty-bridge/public-session-end-review.ts
|
|
26358
26642
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
26359
|
-
var
|
|
26643
|
+
var TAG50 = "[public-session-review]";
|
|
26360
26644
|
var CONSUMED_CAP = 500;
|
|
26361
26645
|
var consumed = /* @__PURE__ */ new Set();
|
|
26362
26646
|
function consumeOnce(sessionId) {
|
|
@@ -26383,7 +26667,7 @@ async function fetchJsonl(sessionId) {
|
|
|
26383
26667
|
return await res.text();
|
|
26384
26668
|
} catch (err) {
|
|
26385
26669
|
console.error(
|
|
26386
|
-
`${
|
|
26670
|
+
`${TAG50} jsonl-fetch-failed sessionId=${sessionId} err="${err instanceof Error ? err.message : String(err)}"`
|
|
26387
26671
|
);
|
|
26388
26672
|
return null;
|
|
26389
26673
|
}
|
|
@@ -26407,7 +26691,7 @@ async function fetchPriorWrites(sliceToken, accountId) {
|
|
|
26407
26691
|
const res = await fetch(url);
|
|
26408
26692
|
if (!res.ok) {
|
|
26409
26693
|
console.error(
|
|
26410
|
-
`${
|
|
26694
|
+
`${TAG50} prior-writes-fetch-failed sliceToken=${sliceToken.slice(0, 8)} status=${res.status}`
|
|
26411
26695
|
);
|
|
26412
26696
|
return [];
|
|
26413
26697
|
}
|
|
@@ -26415,7 +26699,7 @@ async function fetchPriorWrites(sliceToken, accountId) {
|
|
|
26415
26699
|
return Array.isArray(body.writes) ? body.writes : [];
|
|
26416
26700
|
} catch (err) {
|
|
26417
26701
|
console.error(
|
|
26418
|
-
`${
|
|
26702
|
+
`${TAG50} prior-writes-fetch-threw sliceToken=${sliceToken.slice(0, 8)} err="${err instanceof Error ? err.message : String(err)}"`
|
|
26419
26703
|
);
|
|
26420
26704
|
return [];
|
|
26421
26705
|
}
|
|
@@ -26444,7 +26728,7 @@ function composeInitialMessage(input) {
|
|
|
26444
26728
|
}
|
|
26445
26729
|
async function dispatchReviewer(input, initialMessage) {
|
|
26446
26730
|
const sessionId = randomUUID16();
|
|
26447
|
-
console.log(`${
|
|
26731
|
+
console.log(`${TAG50} route target=rc-spawn sessionId=${sessionId.slice(0, 8)} sourceSession=${input.sessionId.slice(0, 8)}`);
|
|
26448
26732
|
const spawned = await managerRcSpawn({
|
|
26449
26733
|
sessionId,
|
|
26450
26734
|
initialMessage,
|
|
@@ -26464,21 +26748,21 @@ async function firePublicSessionEndReview(input) {
|
|
|
26464
26748
|
const dispatchedAt = Date.now();
|
|
26465
26749
|
if (consumed.has(input.sessionId)) {
|
|
26466
26750
|
console.log(
|
|
26467
|
-
`${
|
|
26751
|
+
`${TAG50} dispatchFor=${input.dispatchFor} sessionId=${input.sessionId} sliceToken=${sliceShort} personId=${personField} result=skipped-already-reviewed`
|
|
26468
26752
|
);
|
|
26469
26753
|
return;
|
|
26470
26754
|
}
|
|
26471
26755
|
const jsonl = await fetchJsonl(input.sessionId);
|
|
26472
26756
|
if (!jsonl) {
|
|
26473
26757
|
console.log(
|
|
26474
|
-
`${
|
|
26758
|
+
`${TAG50} dispatchFor=${input.dispatchFor} sessionId=${input.sessionId} sliceToken=${sliceShort} personId=${personField} result=skipped-jsonl-missing`
|
|
26475
26759
|
);
|
|
26476
26760
|
return;
|
|
26477
26761
|
}
|
|
26478
26762
|
const operatorTurns = countOperatorTurns(jsonl);
|
|
26479
26763
|
if (operatorTurns === 0) {
|
|
26480
26764
|
console.log(
|
|
26481
|
-
`${
|
|
26765
|
+
`${TAG50} dispatchFor=${input.dispatchFor} sessionId=${input.sessionId} sliceToken=${sliceShort} personId=${personField} result=skipped-no-turns`
|
|
26482
26766
|
);
|
|
26483
26767
|
return;
|
|
26484
26768
|
}
|
|
@@ -26492,28 +26776,28 @@ async function firePublicSessionEndReview(input) {
|
|
|
26492
26776
|
});
|
|
26493
26777
|
if (!consumeOnce(input.sessionId)) {
|
|
26494
26778
|
console.log(
|
|
26495
|
-
`${
|
|
26779
|
+
`${TAG50} dispatchFor=${input.dispatchFor} sessionId=${input.sessionId} sliceToken=${sliceShort} personId=${personField} result=skipped-already-reviewed`
|
|
26496
26780
|
);
|
|
26497
26781
|
return;
|
|
26498
26782
|
}
|
|
26499
26783
|
const dispatched = await dispatchReviewer(input, initialMessage);
|
|
26500
26784
|
if (!dispatched.ok) {
|
|
26501
26785
|
console.error(
|
|
26502
|
-
`${
|
|
26786
|
+
`${TAG50} dispatchFor=${input.dispatchFor} sessionId=${input.sessionId} sliceToken=${sliceShort} personId=${personField} result=skipped-spawn-failed reason=${dispatched.reason}`
|
|
26503
26787
|
);
|
|
26504
26788
|
return;
|
|
26505
26789
|
}
|
|
26506
26790
|
console.log(
|
|
26507
|
-
`${
|
|
26791
|
+
`${TAG50} dispatchFor=${input.dispatchFor} sessionId=${input.sessionId} sliceToken=${sliceShort} personId=${personField} result=dispatched managerSessionId=${dispatched.managerSessionId} operatorTurns=${operatorTurns} priorWrites=${priorWrites.length} ms=${Date.now() - dispatchedAt}`
|
|
26508
26792
|
);
|
|
26509
26793
|
}
|
|
26510
26794
|
|
|
26511
26795
|
// app/lib/whatsapp/inbound/resolve-client-graph-owner.ts
|
|
26512
|
-
var
|
|
26796
|
+
var import_dist9 = __toESM(require_dist(), 1);
|
|
26513
26797
|
async function resolveClientOwnerUserId(accountId, deps = {}) {
|
|
26514
26798
|
const listAccounts = deps.listAccounts ?? listValidAccounts;
|
|
26515
26799
|
const getSession4 = deps.getSession ?? getSession;
|
|
26516
|
-
const resolveOwner2 = deps.resolveOwner ??
|
|
26800
|
+
const resolveOwner2 = deps.resolveOwner ?? import_dist9.resolveOwnerUserId;
|
|
26517
26801
|
const role = listAccounts().find((a) => a.accountId === accountId)?.config.role;
|
|
26518
26802
|
if (role !== "client") return null;
|
|
26519
26803
|
const session = getSession4();
|
|
@@ -26944,14 +27228,14 @@ watchFile(ALIAS_DOMAINS_PATH, { interval: 2e3 }, () => {
|
|
|
26944
27228
|
function isPublicHost(host) {
|
|
26945
27229
|
return host.startsWith("public.") || aliasDomains.has(host);
|
|
26946
27230
|
}
|
|
26947
|
-
var
|
|
27231
|
+
var app63 = new Hono();
|
|
26948
27232
|
var nativeFileFollowers = /* @__PURE__ */ new Map();
|
|
26949
27233
|
var webchatFileFollowers = /* @__PURE__ */ new Map();
|
|
26950
27234
|
async function fetchAccountStandingRules(accountId) {
|
|
26951
27235
|
const session = getSession();
|
|
26952
27236
|
try {
|
|
26953
|
-
const res = await (0,
|
|
26954
|
-
return { block: (0,
|
|
27237
|
+
const res = await (0, import_dist10.resolveActiveRules)(session, accountId);
|
|
27238
|
+
return { block: (0, import_dist10.formatStandingRulesBlock)(res.rules), ownerUserId: res.ownerUserId, source: res.source };
|
|
26955
27239
|
} catch (err) {
|
|
26956
27240
|
console.error(
|
|
26957
27241
|
`[preference-inject] op=fetch-failed accountId=${accountId} error=${err instanceof Error ? err.message : String(err)}`
|
|
@@ -27052,6 +27336,13 @@ var waGateway = new WaGateway({
|
|
|
27052
27336
|
console.error(`[whatsapp-native] op=account-manager-route senderId=${senderId} managesAccount=${managesAccount} effectiveAccount=${effectiveAccountId} source=gate`);
|
|
27053
27337
|
}
|
|
27054
27338
|
const req = buildWaSpawnRequest({ accountId: effectiveAccountId, senderId, role, personId, gatewayUrl, serverPath });
|
|
27339
|
+
await ensureSessionConversation({
|
|
27340
|
+
accountId: effectiveAccountId,
|
|
27341
|
+
sessionId: req.sessionId,
|
|
27342
|
+
channel: "whatsapp",
|
|
27343
|
+
channelAddress: senderId,
|
|
27344
|
+
agentType: role === "admin" ? "admin" : "public"
|
|
27345
|
+
});
|
|
27055
27346
|
let userId = role === "admin" ? resolveAdminUserId({ accountId: effectiveAccountId, senderPhone: senderId }) ?? (ownerSelfPhone ? resolveOwnerUserId(effectiveAccountId) ?? void 0 : void 0) : void 0;
|
|
27056
27347
|
let graphOwnerResolved = false;
|
|
27057
27348
|
if (role === "admin" && userId === void 0) {
|
|
@@ -27090,7 +27381,7 @@ var waGateway = new WaGateway({
|
|
|
27090
27381
|
nativeFileFollowers.set(senderId, ac);
|
|
27091
27382
|
}
|
|
27092
27383
|
});
|
|
27093
|
-
|
|
27384
|
+
app63.route("/", waGateway.routes());
|
|
27094
27385
|
waGateway.startSweeper();
|
|
27095
27386
|
function runDuplicateSenderAudit() {
|
|
27096
27387
|
try {
|
|
@@ -27208,7 +27499,7 @@ var webchatGateway = new WebchatGateway({
|
|
|
27208
27499
|
firePublicSessionEndReview: (input) => firePublicSessionEndReview(input)
|
|
27209
27500
|
});
|
|
27210
27501
|
setWebchatGateway(webchatGateway);
|
|
27211
|
-
|
|
27502
|
+
app63.route("/", webchatGateway.routes());
|
|
27212
27503
|
webchatGateway.startSweeper();
|
|
27213
27504
|
webchatGateway.startPublicReaper();
|
|
27214
27505
|
var telegramFileFollowers = /* @__PURE__ */ new Map();
|
|
@@ -27242,7 +27533,7 @@ var telegramGateway = new TelegramGateway({
|
|
|
27242
27533
|
}
|
|
27243
27534
|
});
|
|
27244
27535
|
setTelegramGateway(telegramGateway);
|
|
27245
|
-
|
|
27536
|
+
app63.route("/", telegramGateway.routes());
|
|
27246
27537
|
telegramGateway.startSweeper();
|
|
27247
27538
|
var chatRoutes = createChatRoutes({
|
|
27248
27539
|
handleInbound: (input) => webchatGateway.handleInbound(input),
|
|
@@ -27276,19 +27567,19 @@ var scheduleInjectRoutes = createScheduleInjectRoutes({
|
|
|
27276
27567
|
return managed.account;
|
|
27277
27568
|
}
|
|
27278
27569
|
});
|
|
27279
|
-
|
|
27280
|
-
|
|
27570
|
+
app63.route("/api/channel/schedule-inject", scheduleInjectRoutes);
|
|
27571
|
+
app63.use("*", clientIpMiddleware);
|
|
27281
27572
|
function allowsSameOriginFraming(path3) {
|
|
27282
27573
|
return path3 === "/vnc-viewer.html" || path3.startsWith("/api/admin/attachment/") || path3.startsWith("/api/public-reader/attachment/") || path3 === "/api/admin/files/download";
|
|
27283
27574
|
}
|
|
27284
|
-
|
|
27575
|
+
app63.use("*", async (c, next) => {
|
|
27285
27576
|
await next();
|
|
27286
27577
|
c.header("X-Content-Type-Options", "nosniff");
|
|
27287
27578
|
c.header("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
27288
27579
|
c.header("X-Frame-Options", allowsSameOriginFraming(c.req.path) ? "SAMEORIGIN" : "DENY");
|
|
27289
27580
|
});
|
|
27290
27581
|
var HTTP_LOG_PATHS = /* @__PURE__ */ new Set(["/vnc-viewer.html", "/vnc-popout.html"]);
|
|
27291
|
-
|
|
27582
|
+
app63.use("*", async (c, next) => {
|
|
27292
27583
|
if (!HTTP_LOG_PATHS.has(c.req.path)) {
|
|
27293
27584
|
await next();
|
|
27294
27585
|
return;
|
|
@@ -27306,7 +27597,7 @@ app62.use("*", async (c, next) => {
|
|
|
27306
27597
|
});
|
|
27307
27598
|
}
|
|
27308
27599
|
});
|
|
27309
|
-
|
|
27600
|
+
app63.use("*", async (c, next) => {
|
|
27310
27601
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27311
27602
|
if (isOperatorHost(host, getOperatorDomains()) || !isPublicHost(host)) {
|
|
27312
27603
|
await next();
|
|
@@ -27344,7 +27635,7 @@ function resolveRemoteAuthOpts(c) {
|
|
|
27344
27635
|
return { ...brandLoginOpts, origin };
|
|
27345
27636
|
}
|
|
27346
27637
|
var MAX_LOGIN_BODY = 8 * 1024;
|
|
27347
|
-
|
|
27638
|
+
app63.post("/__remote-auth/login", async (c) => {
|
|
27348
27639
|
const client = clientFrom(c);
|
|
27349
27640
|
const clientIp = client.ip || "unknown";
|
|
27350
27641
|
if (!requestIsTlsTerminated(c)) {
|
|
@@ -27389,7 +27680,7 @@ app62.post("/__remote-auth/login", async (c) => {
|
|
|
27389
27680
|
}
|
|
27390
27681
|
});
|
|
27391
27682
|
});
|
|
27392
|
-
|
|
27683
|
+
app63.get("/__remote-auth/logout", (c) => {
|
|
27393
27684
|
const client = clientFrom(c);
|
|
27394
27685
|
const clientIp = client.ip || "unknown";
|
|
27395
27686
|
console.error(`[remote-auth] logout ip=${clientIp}`);
|
|
@@ -27402,7 +27693,7 @@ app62.get("/__remote-auth/logout", (c) => {
|
|
|
27402
27693
|
}
|
|
27403
27694
|
});
|
|
27404
27695
|
});
|
|
27405
|
-
|
|
27696
|
+
app63.post("/__remote-auth/change-password", async (c) => {
|
|
27406
27697
|
const client = clientFrom(c);
|
|
27407
27698
|
const clientIp = client.ip || "unknown";
|
|
27408
27699
|
const rateLimited = checkRateLimit(client);
|
|
@@ -27461,13 +27752,13 @@ app62.post("/__remote-auth/change-password", async (c) => {
|
|
|
27461
27752
|
return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(c), mode: "change", changeError: "Failed to save password", redirect }), 200);
|
|
27462
27753
|
}
|
|
27463
27754
|
});
|
|
27464
|
-
|
|
27755
|
+
app63.get("/__remote-auth/setup", (c) => {
|
|
27465
27756
|
if (isRemoteAuthConfigured()) {
|
|
27466
27757
|
return c.redirect("/");
|
|
27467
27758
|
}
|
|
27468
27759
|
return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(c), mode: "setup" }), 200);
|
|
27469
27760
|
});
|
|
27470
|
-
|
|
27761
|
+
app63.post("/__remote-auth/set-initial-password", async (c) => {
|
|
27471
27762
|
if (isRemoteAuthConfigured()) {
|
|
27472
27763
|
return c.redirect("/");
|
|
27473
27764
|
}
|
|
@@ -27505,10 +27796,10 @@ app62.post("/__remote-auth/set-initial-password", async (c) => {
|
|
|
27505
27796
|
return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(c), mode: "setup", setupError: "Failed to save password. Please try again." }), 200);
|
|
27506
27797
|
}
|
|
27507
27798
|
});
|
|
27508
|
-
|
|
27799
|
+
app63.get("/api/remote-auth/status", (c) => {
|
|
27509
27800
|
return c.json({ configured: isRemoteAuthConfigured() });
|
|
27510
27801
|
});
|
|
27511
|
-
|
|
27802
|
+
app63.post("/api/remote-auth/set-password", async (c) => {
|
|
27512
27803
|
let body;
|
|
27513
27804
|
try {
|
|
27514
27805
|
body = await c.req.json();
|
|
@@ -27547,10 +27838,10 @@ app62.post("/api/remote-auth/set-password", async (c) => {
|
|
|
27547
27838
|
return c.json({ error: "Failed to save password" }, 500);
|
|
27548
27839
|
}
|
|
27549
27840
|
});
|
|
27550
|
-
|
|
27841
|
+
app63.route("/api/_client-error", client_error_default);
|
|
27551
27842
|
console.log("[client-error-route] mounted");
|
|
27552
27843
|
var PWA_PUBLIC_PATHS = /* @__PURE__ */ new Set(["/sw.js", ...PWA_SURFACES.map((s) => s.manifestPath)]);
|
|
27553
|
-
|
|
27844
|
+
app63.use("*", async (c, next) => {
|
|
27554
27845
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27555
27846
|
const path3 = c.req.path;
|
|
27556
27847
|
if (path3 === "/favicon.ico" || path3.startsWith("/assets/") || path3.startsWith("/brand/") || // Public free/busy is read by the booking page (a separate Cloudflare Pages
|
|
@@ -27594,34 +27885,34 @@ app62.use("*", async (c, next) => {
|
|
|
27594
27885
|
}
|
|
27595
27886
|
return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(c), redirect: path3 }), 200);
|
|
27596
27887
|
});
|
|
27597
|
-
|
|
27598
|
-
|
|
27599
|
-
|
|
27600
|
-
|
|
27601
|
-
|
|
27602
|
-
|
|
27603
|
-
|
|
27888
|
+
app63.route("/api/health", health_default);
|
|
27889
|
+
app63.route("/api/chat", chatRoutes);
|
|
27890
|
+
app63.route("/api/whatsapp", whatsapp_default);
|
|
27891
|
+
app63.route("/api/storage", storage_broker_default);
|
|
27892
|
+
app63.route("/api/whatsapp-reader", whatsapp_reader_default);
|
|
27893
|
+
app63.route("/api/public-reader", public_reader_default);
|
|
27894
|
+
app63.route("/api/webchat", createWebchatRoutes({
|
|
27604
27895
|
handleInbound: (input) => webchatGateway.handleInbound(input),
|
|
27605
27896
|
// Task 940 — the permission relay's pointer read + verdict write.
|
|
27606
27897
|
pendingPromptFor: (key) => webchatGateway.pendingPromptFor(key),
|
|
27607
27898
|
deliveryFailureFor: (key) => webchatGateway.deliveryFailureFor(key),
|
|
27608
27899
|
resolvePermissionVerdict: (key, requestId, behavior) => webchatGateway.resolvePermissionVerdict(key, requestId, behavior)
|
|
27609
27900
|
}));
|
|
27610
|
-
|
|
27611
|
-
|
|
27612
|
-
|
|
27613
|
-
|
|
27901
|
+
app63.route("/api/webchat/greeting", webchat_greeting_default);
|
|
27902
|
+
app63.route("/api/telegram", telegram_default);
|
|
27903
|
+
app63.route("/api/quickbooks", quickbooks_default);
|
|
27904
|
+
app63.route(
|
|
27614
27905
|
"/api/google",
|
|
27615
27906
|
createGoogleOAuthRoutes(
|
|
27616
27907
|
resolve36(process.env.MAXY_PLATFORM_ROOT ?? join39(__dirname, "..")),
|
|
27617
27908
|
resolve36(process.env.MAXY_PLATFORM_ROOT ?? join39(__dirname, ".."), "..", "data/accounts")
|
|
27618
27909
|
)
|
|
27619
27910
|
);
|
|
27620
|
-
|
|
27621
|
-
|
|
27622
|
-
|
|
27623
|
-
|
|
27624
|
-
|
|
27911
|
+
app63.route("/api/onboarding", onboarding_default);
|
|
27912
|
+
app63.route("/api/admin", admin_default);
|
|
27913
|
+
app63.route("/api/access", access_default);
|
|
27914
|
+
app63.route("/api/session", session_default2);
|
|
27915
|
+
app63.route("/api/calendar", calendar_public_default);
|
|
27625
27916
|
var SAFE_SLUG_RE2 = /^[a-z][a-z0-9-]{2,49}$/;
|
|
27626
27917
|
var SAFE_FILENAME_RE = /^[a-z0-9_][a-z0-9_.-]{0,99}$/i;
|
|
27627
27918
|
var IMAGE_MIME = {
|
|
@@ -27633,7 +27924,7 @@ var IMAGE_MIME = {
|
|
|
27633
27924
|
".svg": "image/svg+xml",
|
|
27634
27925
|
".ico": "image/x-icon"
|
|
27635
27926
|
};
|
|
27636
|
-
|
|
27927
|
+
app63.get("/agent-assets/:slug/:filename", (c) => {
|
|
27637
27928
|
const slug = c.req.param("slug");
|
|
27638
27929
|
const filename = c.req.param("filename");
|
|
27639
27930
|
if (!SAFE_SLUG_RE2.test(slug)) {
|
|
@@ -27668,7 +27959,7 @@ app62.get("/agent-assets/:slug/:filename", (c) => {
|
|
|
27668
27959
|
"Cache-Control": "public, max-age=3600"
|
|
27669
27960
|
});
|
|
27670
27961
|
});
|
|
27671
|
-
|
|
27962
|
+
app63.get("/generated/:filename", (c) => {
|
|
27672
27963
|
const filename = c.req.param("filename");
|
|
27673
27964
|
if (!SAFE_FILENAME_RE.test(filename) || filename.includes("..")) {
|
|
27674
27965
|
console.error(`[generated] serve file=${filename} status=403`);
|
|
@@ -27698,10 +27989,10 @@ app62.get("/generated/:filename", (c) => {
|
|
|
27698
27989
|
"Cache-Control": "public, max-age=86400"
|
|
27699
27990
|
});
|
|
27700
27991
|
});
|
|
27701
|
-
|
|
27702
|
-
|
|
27703
|
-
|
|
27704
|
-
|
|
27992
|
+
app63.route("/sites", sites_default);
|
|
27993
|
+
app63.route("/listings", listings_default);
|
|
27994
|
+
app63.route("/v", visitor_event_default);
|
|
27995
|
+
app63.route("/v", visitor_consent_default);
|
|
27705
27996
|
var htmlCache = /* @__PURE__ */ new Map();
|
|
27706
27997
|
var brandLogoPath = "/brand/maxy-monochrome.png";
|
|
27707
27998
|
var brandIconPath = "/brand/maxy-monochrome.png";
|
|
@@ -27856,7 +28147,7 @@ function brandedPublicHtml(agentSlug) {
|
|
|
27856
28147
|
function agentUnavailableHtml() {
|
|
27857
28148
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escapeHtml(BRAND.productName)}</title></head><body style="font-family:system-ui,sans-serif;max-width:32rem;margin:4rem auto;padding:0 1.5rem;color:#222"><h1 style="font-size:1.25rem">Agent unavailable</h1><p>This agent isn't available right now. If you reached this page from a saved link, the agent may have been turned off.</p></body></html>`;
|
|
27858
28149
|
}
|
|
27859
|
-
|
|
28150
|
+
app63.get("/", (c) => {
|
|
27860
28151
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27861
28152
|
const klass = classifyHost(host, getOperatorDomains(), isPublicHost);
|
|
27862
28153
|
if (klass === "operator") {
|
|
@@ -27878,12 +28169,12 @@ app62.get("/", (c) => {
|
|
|
27878
28169
|
console.log(`[host-class] host=${host} class=admin served=index.html`);
|
|
27879
28170
|
return c.html(cachedHtml("index.html"));
|
|
27880
28171
|
});
|
|
27881
|
-
|
|
28172
|
+
app63.get("/public", (c) => {
|
|
27882
28173
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27883
28174
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
27884
28175
|
return c.html(cachedHtml("public.html"));
|
|
27885
28176
|
});
|
|
27886
|
-
|
|
28177
|
+
app63.get("/public-chat", (c) => {
|
|
27887
28178
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27888
28179
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
27889
28180
|
return c.html(cachedHtml("public.html"));
|
|
@@ -27902,9 +28193,9 @@ async function logViewerFetch(c, next) {
|
|
|
27902
28193
|
duration_ms: Date.now() - start
|
|
27903
28194
|
});
|
|
27904
28195
|
}
|
|
27905
|
-
|
|
27906
|
-
|
|
27907
|
-
|
|
28196
|
+
app63.use("/vnc-viewer.html", logViewerFetch);
|
|
28197
|
+
app63.use("/vnc-popout.html", logViewerFetch);
|
|
28198
|
+
app63.get("/vnc-popout.html", (c) => {
|
|
27908
28199
|
let html = htmlCache.get("vnc-popout.html");
|
|
27909
28200
|
if (!html) {
|
|
27910
28201
|
html = readFileSync39(resolve36(process.cwd(), "public", "vnc-popout.html"), "utf-8");
|
|
@@ -27917,7 +28208,7 @@ app62.get("/vnc-popout.html", (c) => {
|
|
|
27917
28208
|
}
|
|
27918
28209
|
return c.html(html);
|
|
27919
28210
|
});
|
|
27920
|
-
|
|
28211
|
+
app63.post("/api/vnc/client-event", async (c) => {
|
|
27921
28212
|
let body;
|
|
27922
28213
|
try {
|
|
27923
28214
|
body = await c.req.json();
|
|
@@ -27938,11 +28229,11 @@ app62.post("/api/vnc/client-event", async (c) => {
|
|
|
27938
28229
|
});
|
|
27939
28230
|
return c.json({ ok: true });
|
|
27940
28231
|
});
|
|
27941
|
-
|
|
28232
|
+
app63.get("/g/:slug", (c) => {
|
|
27942
28233
|
return c.html(brandedPublicHtml(resolveDefaultSlug() ?? void 0));
|
|
27943
28234
|
});
|
|
27944
28235
|
for (const pwa of PWA_SURFACES) {
|
|
27945
|
-
|
|
28236
|
+
app63.get(pwa.manifestPath, (c) => {
|
|
27946
28237
|
const manifest = buildManifest(pwa, {
|
|
27947
28238
|
productName: BRAND.productName,
|
|
27948
28239
|
appIcon192: brandAppIcon192Path,
|
|
@@ -27958,7 +28249,7 @@ for (const pwa of PWA_SURFACES) {
|
|
|
27958
28249
|
return c.body(JSON.stringify(manifest));
|
|
27959
28250
|
});
|
|
27960
28251
|
}
|
|
27961
|
-
|
|
28252
|
+
app63.get("/sw.js", (c) => {
|
|
27962
28253
|
if (SW_SOURCE == null) {
|
|
27963
28254
|
console.error("[pwa] op=sw status=500 reason=sw-source-missing");
|
|
27964
28255
|
return c.text("Service worker unavailable", 500);
|
|
@@ -27967,12 +28258,12 @@ app62.get("/sw.js", (c) => {
|
|
|
27967
28258
|
console.log(`[pwa] op=sw status=200 ct=${SW_CONTENT_TYPE}`);
|
|
27968
28259
|
return c.body(SW_SOURCE);
|
|
27969
28260
|
});
|
|
27970
|
-
|
|
28261
|
+
app63.get("/graph", (c) => {
|
|
27971
28262
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27972
28263
|
if (isPublicHost(host) || isOperatorHost(host, getOperatorDomains())) return c.text("Not found", 404);
|
|
27973
28264
|
return c.html(cachedHtml("graph.html"));
|
|
27974
28265
|
});
|
|
27975
|
-
|
|
28266
|
+
app63.get("/chat", (c) => {
|
|
27976
28267
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27977
28268
|
if (isOperatorHost(host, getOperatorDomains())) {
|
|
27978
28269
|
console.log(`[host-class] host=${host} class=operator served=operator.html`);
|
|
@@ -27981,27 +28272,32 @@ app62.get("/chat", (c) => {
|
|
|
27981
28272
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
27982
28273
|
return c.html(cachedHtml("chat.html"));
|
|
27983
28274
|
});
|
|
27984
|
-
|
|
28275
|
+
app63.get("/data", (c) => {
|
|
27985
28276
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27986
28277
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
27987
28278
|
return c.html(cachedHtml("data.html"));
|
|
27988
28279
|
});
|
|
27989
|
-
|
|
28280
|
+
app63.get("/tasks", (c) => {
|
|
27990
28281
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27991
28282
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
27992
28283
|
return c.html(cachedHtml("tasks.html"));
|
|
27993
28284
|
});
|
|
27994
|
-
|
|
28285
|
+
app63.get("/activity", (c) => {
|
|
28286
|
+
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
28287
|
+
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
28288
|
+
return c.html(cachedHtml("activity.html"));
|
|
28289
|
+
});
|
|
28290
|
+
app63.get("/calendar", (c) => {
|
|
27995
28291
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
27996
28292
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
27997
28293
|
return c.html(cachedHtml("calendar.html"));
|
|
27998
28294
|
});
|
|
27999
|
-
|
|
28295
|
+
app63.get("/browser", (c) => {
|
|
28000
28296
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
28001
28297
|
if (isPublicHost(host) || isOperatorHost(host, getOperatorDomains())) return c.text("Not found", 404);
|
|
28002
28298
|
return c.html(cachedHtml("browser.html"));
|
|
28003
28299
|
});
|
|
28004
|
-
|
|
28300
|
+
app63.get("/:slug", async (c, next) => {
|
|
28005
28301
|
const slug = c.req.param("slug");
|
|
28006
28302
|
if (AGENT_SLUG_PATTERN.test(`/${slug}`)) {
|
|
28007
28303
|
const account = resolveAccount();
|
|
@@ -28016,13 +28312,13 @@ app62.get("/:slug", async (c, next) => {
|
|
|
28016
28312
|
await next();
|
|
28017
28313
|
});
|
|
28018
28314
|
if (brandFaviconPath !== "/favicon.ico") {
|
|
28019
|
-
|
|
28315
|
+
app63.get("/favicon.ico", (c) => {
|
|
28020
28316
|
c.header("Cache-Control", "public, max-age=300");
|
|
28021
28317
|
return c.redirect(brandFaviconPath, 302);
|
|
28022
28318
|
});
|
|
28023
28319
|
}
|
|
28024
|
-
|
|
28025
|
-
|
|
28320
|
+
app63.use("/*", serveStatic({ root: "./public" }));
|
|
28321
|
+
app63.all("*", (c) => {
|
|
28026
28322
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
28027
28323
|
const path3 = c.req.path;
|
|
28028
28324
|
if (isPublicHost(host)) {
|
|
@@ -28036,7 +28332,7 @@ app62.all("*", (c) => {
|
|
|
28036
28332
|
});
|
|
28037
28333
|
var port = requirePortEnv("MAXY_UI_INTERNAL_PORT", { tag: "ui-server" });
|
|
28038
28334
|
var hostname = process.env.HOSTNAME ?? "127.0.0.1";
|
|
28039
|
-
var httpServer = serve({ fetch:
|
|
28335
|
+
var httpServer = serve({ fetch: app63.fetch, port, hostname });
|
|
28040
28336
|
console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
|
|
28041
28337
|
{
|
|
28042
28338
|
const reconcilePlatformRoot = process.env.MAXY_PLATFORM_ROOT ?? join39(__dirname, "..");
|
|
@@ -28092,7 +28388,7 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
|
|
|
28092
28388
|
try {
|
|
28093
28389
|
if (!existsSync37(strandedAccountsDir)) return;
|
|
28094
28390
|
const now = Date.now();
|
|
28095
|
-
for (const name of
|
|
28391
|
+
for (const name of readdirSync23(strandedAccountsDir)) {
|
|
28096
28392
|
if (!STRANDED_UUID_RE.test(name)) continue;
|
|
28097
28393
|
const pendingPath2 = resolve36(strandedAccountsDir, name, "secrets/outlook/pending-devicecode.enc");
|
|
28098
28394
|
if (!existsSync37(pendingPath2)) continue;
|
|
@@ -28200,6 +28496,7 @@ console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
|
|
|
28200
28496
|
publishLoop.unref();
|
|
28201
28497
|
}
|
|
28202
28498
|
startTimeEntryCensus(() => getSession());
|
|
28499
|
+
startLedgerCensus(() => getSession());
|
|
28203
28500
|
{
|
|
28204
28501
|
const auditPlatformRoot = process.env.MAXY_PLATFORM_ROOT ?? join39(__dirname, "..");
|
|
28205
28502
|
const auditScript = resolve36(auditPlatformRoot, "plugins/connector/mcp/dist/scripts/audit-connectors.js");
|
|
@@ -28277,7 +28574,7 @@ for (const m of SUBAPP_MANIFEST) {
|
|
|
28277
28574
|
}
|
|
28278
28575
|
try {
|
|
28279
28576
|
const registered = [];
|
|
28280
|
-
for (const r of
|
|
28577
|
+
for (const r of app63.routes ?? []) {
|
|
28281
28578
|
if (typeof r.path !== "string" || r.path.includes(":") || r.path.includes("*")) continue;
|
|
28282
28579
|
if (AGENT_SLUG_PATTERN.test(r.path)) {
|
|
28283
28580
|
registered.push({ method: (r.method ?? "ALL").toUpperCase(), path: r.path });
|
|
@@ -28339,6 +28636,7 @@ async function runAdminUserReconcileTick() {
|
|
|
28339
28636
|
}
|
|
28340
28637
|
await runAdminUserSelfHeal({ userId, accountId: account.accountId });
|
|
28341
28638
|
await runUserProfileReconcile();
|
|
28639
|
+
await runConversationAudit();
|
|
28342
28640
|
} catch (err) {
|
|
28343
28641
|
console.error(`[adminuser-self-heal] rejected: ${err instanceof Error ? err.message : String(err)}`);
|
|
28344
28642
|
}
|