@raybase/core 0.0.1 → 0.3.3
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/LICENSE +21 -0
- package/dist/.admin-build/AdminApp.css +2 -0
- package/dist/.admin-build/AdminApp.js +77 -0
- package/dist/.admin-docs-build/AdminDocsApp.css +2 -0
- package/dist/.admin-docs-build/AdminDocsApp.js +45 -0
- package/dist/actions.d.ts +347 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +661 -0
- package/dist/actions.js.map +1 -0
- package/dist/admin-assets/admin.7738f50720a8ed7b.css +2 -0
- package/dist/admin-assets/admin.8678cb61db34dc81.js +77 -0
- package/dist/admin-boot.d.ts +94 -0
- package/dist/admin-boot.d.ts.map +1 -0
- package/dist/admin-boot.js +139 -0
- package/dist/admin-boot.js.map +1 -0
- package/dist/admin-docs-content.d.ts +95 -0
- package/dist/admin-docs-content.d.ts.map +1 -0
- package/dist/admin-docs-content.js +463 -0
- package/dist/admin-docs-content.js.map +1 -0
- package/dist/admin-docs-ui.d.ts +11 -0
- package/dist/admin-docs-ui.d.ts.map +1 -0
- package/dist/admin-docs-ui.js +23 -0
- package/dist/admin-docs-ui.js.map +1 -0
- package/dist/admin-kit.d.ts +29 -0
- package/dist/admin-kit.js +1557 -0
- package/dist/admin-role.d.ts +8 -0
- package/dist/admin-role.d.ts.map +1 -0
- package/dist/admin-role.js +22 -0
- package/dist/admin-role.js.map +1 -0
- package/dist/admin-ui.d.ts +3 -0
- package/dist/admin-ui.d.ts.map +1 -0
- package/dist/admin-ui.js +16 -0
- package/dist/admin-ui.js.map +1 -0
- package/dist/agent-ai-chat.d.ts +127 -0
- package/dist/agent-ai-chat.d.ts.map +1 -0
- package/dist/agent-ai-chat.js +5975 -0
- package/dist/agent-ai-chat.js.map +1 -0
- package/dist/agent-chapter-archive.d.ts +214 -0
- package/dist/agent-chapter-archive.d.ts.map +1 -0
- package/dist/agent-chapter-archive.js +696 -0
- package/dist/agent-chapter-archive.js.map +1 -0
- package/dist/agent-chapter-search.d.ts +116 -0
- package/dist/agent-chapter-search.d.ts.map +1 -0
- package/dist/agent-chapter-search.js +605 -0
- package/dist/agent-chapter-search.js.map +1 -0
- package/dist/agent-chapter-tools.d.ts +45 -0
- package/dist/agent-chapter-tools.d.ts.map +1 -0
- package/dist/agent-chapter-tools.js +344 -0
- package/dist/agent-chapter-tools.js.map +1 -0
- package/dist/agent-chapters.d.ts +228 -0
- package/dist/agent-chapters.d.ts.map +1 -0
- package/dist/agent-chapters.js +737 -0
- package/dist/agent-chapters.js.map +1 -0
- package/dist/agent-data-parts.d.ts +167 -0
- package/dist/agent-data-parts.d.ts.map +1 -0
- package/dist/agent-data-parts.js +68 -0
- package/dist/agent-data-parts.js.map +1 -0
- package/dist/agent-errors.d.ts +41 -0
- package/dist/agent-errors.d.ts.map +1 -0
- package/dist/agent-errors.js +191 -0
- package/dist/agent-errors.js.map +1 -0
- package/dist/agent-follow-up-store.d.ts +273 -0
- package/dist/agent-follow-up-store.d.ts.map +1 -0
- package/dist/agent-follow-up-store.js +703 -0
- package/dist/agent-follow-up-store.js.map +1 -0
- package/dist/agent-follow-ups.d.ts +314 -0
- package/dist/agent-follow-ups.d.ts.map +1 -0
- package/dist/agent-follow-ups.js +840 -0
- package/dist/agent-follow-ups.js.map +1 -0
- package/dist/agent-memory.d.ts +323 -0
- package/dist/agent-memory.d.ts.map +1 -0
- package/dist/agent-memory.js +1270 -0
- package/dist/agent-memory.js.map +1 -0
- package/dist/agent-message-parts.d.ts +58 -0
- package/dist/agent-message-parts.d.ts.map +1 -0
- package/dist/agent-message-parts.js +163 -0
- package/dist/agent-message-parts.js.map +1 -0
- package/dist/agent-remote-mcp-credentials.d.ts +154 -0
- package/dist/agent-remote-mcp-credentials.d.ts.map +1 -0
- package/dist/agent-remote-mcp-credentials.js +287 -0
- package/dist/agent-remote-mcp-credentials.js.map +1 -0
- package/dist/agent-remote-mcp-crypto.d.ts +32 -0
- package/dist/agent-remote-mcp-crypto.d.ts.map +1 -0
- package/dist/agent-remote-mcp-crypto.js +101 -0
- package/dist/agent-remote-mcp-crypto.js.map +1 -0
- package/dist/agent-remote-mcp-install.d.ts +299 -0
- package/dist/agent-remote-mcp-install.d.ts.map +1 -0
- package/dist/agent-remote-mcp-install.js +785 -0
- package/dist/agent-remote-mcp-install.js.map +1 -0
- package/dist/agent-remote-mcp-oauth.d.ts +73 -0
- package/dist/agent-remote-mcp-oauth.d.ts.map +1 -0
- package/dist/agent-remote-mcp-oauth.js +344 -0
- package/dist/agent-remote-mcp-oauth.js.map +1 -0
- package/dist/agent-remote-mcp-transport.d.ts +46 -0
- package/dist/agent-remote-mcp-transport.d.ts.map +1 -0
- package/dist/agent-remote-mcp-transport.js +225 -0
- package/dist/agent-remote-mcp-transport.js.map +1 -0
- package/dist/agent-remote-mcp.d.ts +147 -0
- package/dist/agent-remote-mcp.d.ts.map +1 -0
- package/dist/agent-remote-mcp.js +681 -0
- package/dist/agent-remote-mcp.js.map +1 -0
- package/dist/agent-room-redaction.d.ts +66 -0
- package/dist/agent-room-redaction.d.ts.map +1 -0
- package/dist/agent-room-redaction.js +264 -0
- package/dist/agent-room-redaction.js.map +1 -0
- package/dist/agent-rooms.d.ts +209 -0
- package/dist/agent-rooms.d.ts.map +1 -0
- package/dist/agent-rooms.js +244 -0
- package/dist/agent-rooms.js.map +1 -0
- package/dist/agent-runtime.d.ts +541 -0
- package/dist/agent-runtime.d.ts.map +1 -0
- package/dist/agent-runtime.js +4260 -0
- package/dist/agent-runtime.js.map +1 -0
- package/dist/agent-skill-archive.d.ts +20 -0
- package/dist/agent-skill-archive.d.ts.map +1 -0
- package/dist/agent-skill-archive.js +316 -0
- package/dist/agent-skill-archive.js.map +1 -0
- package/dist/agent-skill-discovery.d.ts +96 -0
- package/dist/agent-skill-discovery.d.ts.map +1 -0
- package/dist/agent-skill-discovery.js +464 -0
- package/dist/agent-skill-discovery.js.map +1 -0
- package/dist/agent-skill-format.d.ts +57 -0
- package/dist/agent-skill-format.d.ts.map +1 -0
- package/dist/agent-skill-format.js +238 -0
- package/dist/agent-skill-format.js.map +1 -0
- package/dist/agent-skill-import.d.ts +64 -0
- package/dist/agent-skill-import.d.ts.map +1 -0
- package/dist/agent-skill-import.js +295 -0
- package/dist/agent-skill-import.js.map +1 -0
- package/dist/agent-skill-publish.d.ts +51 -0
- package/dist/agent-skill-publish.d.ts.map +1 -0
- package/dist/agent-skill-publish.js +136 -0
- package/dist/agent-skill-publish.js.map +1 -0
- package/dist/agent-skill-store.d.ts +252 -0
- package/dist/agent-skill-store.d.ts.map +1 -0
- package/dist/agent-skill-store.js +514 -0
- package/dist/agent-skill-store.js.map +1 -0
- package/dist/agent-skills.d.ts +85 -0
- package/dist/agent-skills.d.ts.map +1 -0
- package/dist/agent-skills.js +291 -0
- package/dist/agent-skills.js.map +1 -0
- package/dist/agent-transcript-pager.d.ts +77 -0
- package/dist/agent-transcript-pager.d.ts.map +1 -0
- package/dist/agent-transcript-pager.js +210 -0
- package/dist/agent-transcript-pager.js.map +1 -0
- package/dist/agent-user-data-parts.d.ts +20 -0
- package/dist/agent-user-data-parts.d.ts.map +1 -0
- package/dist/agent-user-data-parts.js +161 -0
- package/dist/agent-user-data-parts.js.map +1 -0
- package/dist/agent-user-transcript.d.ts +46 -0
- package/dist/agent-user-transcript.d.ts.map +1 -0
- package/dist/agent-user-transcript.js +106 -0
- package/dist/agent-user-transcript.js.map +1 -0
- package/dist/agent-voice-notes.d.ts +15 -0
- package/dist/agent-voice-notes.d.ts.map +1 -0
- package/dist/agent-voice-notes.js +17 -0
- package/dist/agent-voice-notes.js.map +1 -0
- package/dist/agent-wakes.d.ts +213 -0
- package/dist/agent-wakes.d.ts.map +1 -0
- package/dist/agent-wakes.js +534 -0
- package/dist/agent-wakes.js.map +1 -0
- package/dist/agent.d.ts +1780 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +3123 -0
- package/dist/agent.js.map +1 -0
- package/dist/ai.d.ts +583 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +1858 -0
- package/dist/ai.js.map +1 -0
- package/dist/app-manifest.d.ts +255 -0
- package/dist/app-manifest.d.ts.map +1 -0
- package/dist/app-manifest.js +372 -0
- package/dist/app-manifest.js.map +1 -0
- package/dist/app-users.d.ts +30 -0
- package/dist/app-users.d.ts.map +1 -0
- package/dist/app-users.js +91 -0
- package/dist/app-users.js.map +1 -0
- package/dist/audit-archive.d.ts +85 -0
- package/dist/audit-archive.d.ts.map +1 -0
- package/dist/audit-archive.js +178 -0
- package/dist/audit-archive.js.map +1 -0
- package/dist/audit.d.ts +54 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +95 -0
- package/dist/audit.js.map +1 -0
- package/dist/auth-logger.d.ts +28 -0
- package/dist/auth-logger.d.ts.map +1 -0
- package/dist/auth-logger.js +53 -0
- package/dist/auth-logger.js.map +1 -0
- package/dist/auth-password-secret.d.ts +59 -0
- package/dist/auth-password-secret.d.ts.map +1 -0
- package/dist/auth-password-secret.js +409 -0
- package/dist/auth-password-secret.js.map +1 -0
- package/dist/auth-schema.d.ts +120 -0
- package/dist/auth-schema.d.ts.map +1 -0
- package/dist/auth-schema.js +285 -0
- package/dist/auth-schema.js.map +1 -0
- package/dist/auth.d.ts +321 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +1562 -0
- package/dist/auth.js.map +1 -0
- package/dist/backup-archive.d.ts +257 -0
- package/dist/backup-archive.d.ts.map +1 -0
- package/dist/backup-archive.js +2068 -0
- package/dist/backup-archive.js.map +1 -0
- package/dist/backup-crypto.d.ts +313 -0
- package/dist/backup-crypto.d.ts.map +1 -0
- package/dist/backup-crypto.js +693 -0
- package/dist/backup-crypto.js.map +1 -0
- package/dist/backup-format.d.ts +200 -0
- package/dist/backup-format.d.ts.map +1 -0
- package/dist/backup-format.js +1247 -0
- package/dist/backup-format.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -0
- package/dist/clock.d.ts +35 -0
- package/dist/clock.d.ts.map +1 -0
- package/dist/clock.js +83 -0
- package/dist/clock.js.map +1 -0
- package/dist/data-client.d.ts +187 -0
- package/dist/data-client.d.ts.map +1 -0
- package/dist/data-client.js +590 -0
- package/dist/data-client.js.map +1 -0
- package/dist/data-secrets.d.ts +164 -0
- package/dist/data-secrets.d.ts.map +1 -0
- package/dist/data-secrets.js +383 -0
- package/dist/data-secrets.js.map +1 -0
- package/dist/db.d.ts +453 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +324 -0
- package/dist/db.js.map +1 -0
- package/dist/dev-activity.d.ts +48 -0
- package/dist/dev-activity.d.ts.map +1 -0
- package/dist/dev-activity.js +50 -0
- package/dist/dev-activity.js.map +1 -0
- package/dist/do.d.ts +429 -0
- package/dist/do.d.ts.map +1 -0
- package/dist/do.js +4526 -0
- package/dist/do.js.map +1 -0
- package/dist/email.d.ts +137 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +527 -0
- package/dist/email.js.map +1 -0
- package/dist/generated/admin-assets.d.ts +16 -0
- package/dist/generated/admin-assets.d.ts.map +1 -0
- package/dist/generated/admin-assets.js +16 -0
- package/dist/generated/admin-assets.js.map +1 -0
- package/dist/generated/admin-docs-assets.d.ts +3 -0
- package/dist/generated/admin-docs-assets.d.ts.map +1 -0
- package/dist/generated/admin-docs-assets.js +3 -0
- package/dist/generated/admin-docs-assets.js.map +1 -0
- package/dist/handoff-consumer.d.ts +79 -0
- package/dist/handoff-consumer.d.ts.map +1 -0
- package/dist/handoff-consumer.js +300 -0
- package/dist/handoff-consumer.js.map +1 -0
- package/dist/handoff.d.ts +70 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +228 -0
- package/dist/handoff.js.map +1 -0
- package/dist/host-auth.d.ts +47 -0
- package/dist/host-auth.d.ts.map +1 -0
- package/dist/host-auth.js +59 -0
- package/dist/host-auth.js.map +1 -0
- package/dist/host-user.d.ts +15 -0
- package/dist/host-user.d.ts.map +1 -0
- package/dist/host-user.js +23 -0
- package/dist/host-user.js.map +1 -0
- package/dist/html.d.ts +35 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +634 -0
- package/dist/html.js.map +1 -0
- package/dist/http-error.d.ts +13 -0
- package/dist/http-error.d.ts.map +1 -0
- package/dist/http-error.js +15 -0
- package/dist/http-error.js.map +1 -0
- package/dist/imports.d.ts +219 -0
- package/dist/imports.d.ts.map +1 -0
- package/dist/imports.js +571 -0
- package/dist/imports.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/inference-tape.d.ts +64 -0
- package/dist/inference-tape.d.ts.map +1 -0
- package/dist/inference-tape.js +278 -0
- package/dist/inference-tape.js.map +1 -0
- package/dist/internal.d.ts +15 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +48 -0
- package/dist/internal.js.map +1 -0
- package/dist/jobs.d.ts +796 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +538 -0
- package/dist/jobs.js.map +1 -0
- package/dist/json-schema.d.ts +91 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +884 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/knowledge.d.ts +33 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +348 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/local-dev-chrome.d.ts +29 -0
- package/dist/local-dev-chrome.d.ts.map +1 -0
- package/dist/local-dev-chrome.js +514 -0
- package/dist/local-dev-chrome.js.map +1 -0
- package/dist/local-dev-personas.d.ts +15 -0
- package/dist/local-dev-personas.d.ts.map +1 -0
- package/dist/local-dev-personas.js +46 -0
- package/dist/local-dev-personas.js.map +1 -0
- package/dist/mcp.d.ts +567 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +2480 -0
- package/dist/mcp.js.map +1 -0
- package/dist/modules.d.ts +145 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +164 -0
- package/dist/modules.js.map +1 -0
- package/dist/notification-client.d.ts +94 -0
- package/dist/notification-client.d.ts.map +1 -0
- package/dist/notification-client.js +127 -0
- package/dist/notification-client.js.map +1 -0
- package/dist/notifications.d.ts +447 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +1625 -0
- package/dist/notifications.js.map +1 -0
- package/dist/operator-data-query.d.ts +117 -0
- package/dist/operator-data-query.d.ts.map +1 -0
- package/dist/operator-data-query.js +431 -0
- package/dist/operator-data-query.js.map +1 -0
- package/dist/operator-mcp.d.ts +63 -0
- package/dist/operator-mcp.d.ts.map +1 -0
- package/dist/operator-mcp.js +2828 -0
- package/dist/operator-mcp.js.map +1 -0
- package/dist/outbound-https.d.ts +24 -0
- package/dist/outbound-https.d.ts.map +1 -0
- package/dist/outbound-https.js +172 -0
- package/dist/outbound-https.js.map +1 -0
- package/dist/pitr.d.ts +60 -0
- package/dist/pitr.d.ts.map +1 -0
- package/dist/pitr.js +94 -0
- package/dist/pitr.js.map +1 -0
- package/dist/platform.d.ts +199 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +196 -0
- package/dist/platform.js.map +1 -0
- package/dist/policies.d.ts +115 -0
- package/dist/policies.d.ts.map +1 -0
- package/dist/policies.js +158 -0
- package/dist/policies.js.map +1 -0
- package/dist/principal.d.ts +143 -0
- package/dist/principal.d.ts.map +1 -0
- package/dist/principal.js +174 -0
- package/dist/principal.js.map +1 -0
- package/dist/realtime.d.ts +280 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +578 -0
- package/dist/realtime.js.map +1 -0
- package/dist/retrieval.d.ts +263 -0
- package/dist/retrieval.d.ts.map +1 -0
- package/dist/retrieval.js +602 -0
- package/dist/retrieval.js.map +1 -0
- package/dist/runtime-error-client.d.ts +10 -0
- package/dist/runtime-error-client.d.ts.map +1 -0
- package/dist/runtime-error-client.js +70 -0
- package/dist/runtime-error-client.js.map +1 -0
- package/dist/runtime-errors.d.ts +180 -0
- package/dist/runtime-errors.d.ts.map +1 -0
- package/dist/runtime-errors.js +572 -0
- package/dist/runtime-errors.js.map +1 -0
- package/dist/schema.d.ts +434 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +232 -0
- package/dist/schema.js.map +1 -0
- package/dist/search.d.ts +216 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +785 -0
- package/dist/search.js.map +1 -0
- package/dist/settings.d.ts +191 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +478 -0
- package/dist/settings.js.map +1 -0
- package/dist/sql.d.ts +7 -0
- package/dist/sql.d.ts.map +1 -0
- package/dist/sql.js +30 -0
- package/dist/sql.js.map +1 -0
- package/dist/storage-client.d.ts +69 -0
- package/dist/storage-client.d.ts.map +1 -0
- package/dist/storage-client.js +469 -0
- package/dist/storage-client.js.map +1 -0
- package/dist/storage.d.ts +21 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +82 -0
- package/dist/storage.js.map +1 -0
- package/dist/subject-domains.d.ts +15 -0
- package/dist/subject-domains.d.ts.map +1 -0
- package/dist/subject-domains.js +38 -0
- package/dist/subject-domains.js.map +1 -0
- package/dist/support.d.ts +132 -0
- package/dist/support.d.ts.map +1 -0
- package/dist/support.js +483 -0
- package/dist/support.js.map +1 -0
- package/dist/system-tables.d.ts +12 -0
- package/dist/system-tables.d.ts.map +1 -0
- package/dist/system-tables.js +225 -0
- package/dist/system-tables.js.map +1 -0
- package/dist/test.d.ts +57 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +454 -0
- package/dist/test.js.map +1 -0
- package/dist/vite.d.ts +82 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +82 -0
- package/dist/vite.js.map +1 -0
- package/dist/webpush-crypto.d.ts +39 -0
- package/dist/webpush-crypto.d.ts.map +1 -0
- package/dist/webpush-crypto.js +213 -0
- package/dist/webpush-crypto.js.map +1 -0
- package/dist/webpush-private.d.ts +11 -0
- package/dist/webpush-private.d.ts.map +1 -0
- package/dist/webpush-private.js +11 -0
- package/dist/webpush-private.js.map +1 -0
- package/dist/webpush.d.ts +86 -0
- package/dist/webpush.d.ts.map +1 -0
- package/dist/webpush.js +375 -0
- package/dist/webpush.js.map +1 -0
- package/dist/worker.d.ts +185 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +13021 -0
- package/dist/worker.js.map +1 -0
- package/package.json +161 -8
- package/README.md +0 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persisted subject-bearing columns owned by the shared runtime. Settings is
|
|
3
|
+
* intentionally qualified because one physical column stores app constants,
|
|
4
|
+
* scoped IDs, and identity subjects according to its explicit `scope` value.
|
|
5
|
+
*/
|
|
6
|
+
export const raybaseSubjectDomainManifest = [
|
|
7
|
+
{ table: "_auth_users", column: "id", domain: "identity" },
|
|
8
|
+
{ table: "_auth_sessions", column: "userId", domain: "identity" },
|
|
9
|
+
{ table: "_auth_accounts", column: "userId", domain: "identity" },
|
|
10
|
+
{ table: "_auth_passkeys", column: "userId", domain: "identity" },
|
|
11
|
+
{ table: "_settings", column: "subjectId", domain: "identity", qualifier: "scope=user" },
|
|
12
|
+
{ table: "_audit", column: "actorId", domain: "policy" },
|
|
13
|
+
{ table: "_audit", column: "runAsId", domain: "policy" },
|
|
14
|
+
{ table: "_changes", column: "actorId", domain: "policy" },
|
|
15
|
+
{ table: "_files", column: "createdBy", domain: "policy" },
|
|
16
|
+
{ table: "_notifications", column: "createdBy", domain: "policy" },
|
|
17
|
+
{ table: "_notification_recipients", column: "recipientSubjectId", domain: "policy" },
|
|
18
|
+
{ table: "_notification_subscriptions", column: "subjectId", domain: "policy" },
|
|
19
|
+
{ table: "_notification_throttle_windows", column: "recipientSubjectId", domain: "policy" },
|
|
20
|
+
{ table: "_agent_instances", column: "userId", domain: "policy" },
|
|
21
|
+
{ table: "_agent_requests", column: "authorUserId", domain: "policy" },
|
|
22
|
+
{ table: "_agent_room_members", column: "userId", domain: "policy" },
|
|
23
|
+
{ table: "_agent_memories", column: "userId", domain: "policy" },
|
|
24
|
+
{ table: "_agent_follow_ups", column: "ownerId", domain: "policy" },
|
|
25
|
+
{ table: "_job_runs", column: "actorId", domain: "policy" },
|
|
26
|
+
{ table: "_job_runs", column: "runAsId", domain: "policy" },
|
|
27
|
+
{ table: "_job_batches", column: "actorId", domain: "policy" }
|
|
28
|
+
];
|
|
29
|
+
export function validateRaybaseSubjectDomainManifest(manifest = raybaseSubjectDomainManifest) {
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
for (const entry of manifest) {
|
|
32
|
+
const key = `${entry.table}.${entry.column}:${entry.qualifier ?? "*"}`;
|
|
33
|
+
if (seen.has(key))
|
|
34
|
+
throw new Error(`Persisted subject ${key} is assigned more than once`);
|
|
35
|
+
seen.add(key);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=subject-domains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subject-domains.js","sourceRoot":"","sources":["../src/subject-domains.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAuC;IAC9E,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE;IAC1D,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE;IACjE,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE;IACjE,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE;IACjE,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,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,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC3D,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC3D,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;CACtD,CAAC;AAEX,MAAM,UAAU,oCAAoC,CAClD,WAA+C,4BAA4B;IAE3E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC;QACvE,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,6BAA6B,CAAC,CAAC;QAC1F,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type RaybaseAction, type RaybaseActionContext } from "./actions.js";
|
|
3
|
+
import type { RaybaseAuditContextEvent } from "./audit.js";
|
|
4
|
+
import type { SqlExecutor } from "./db.js";
|
|
5
|
+
import { type RaybaseModule } from "./modules.js";
|
|
6
|
+
import { type RaybaseNotificationsRuntime } from "./notifications.js";
|
|
7
|
+
import { type RaybasePrincipal } from "./principal.js";
|
|
8
|
+
import { type RaybaseSystemTable } from "./schema.js";
|
|
9
|
+
export declare const raybaseSupportRequestsTableName = "_support_requests";
|
|
10
|
+
export declare const supportRequestCreatedNotificationKind = "support.request.created";
|
|
11
|
+
export declare const raybaseSupportSystemTables: RaybaseSystemTable[];
|
|
12
|
+
declare const createSupportRequestInput: z.ZodObject<{
|
|
13
|
+
sourceKind: z.ZodOptional<z.ZodString>;
|
|
14
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
agentName: z.ZodOptional<z.ZodString>;
|
|
17
|
+
agentInstanceId: z.ZodOptional<z.ZodString>;
|
|
18
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
20
|
+
toolCallId: z.ZodOptional<z.ZodString>;
|
|
21
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
22
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
23
|
+
route: z.ZodOptional<z.ZodString>;
|
|
24
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
25
|
+
body: z.ZodString;
|
|
26
|
+
transcriptSummary: z.ZodOptional<z.ZodString>;
|
|
27
|
+
transcriptEvidence: z.ZodOptional<z.ZodString>;
|
|
28
|
+
category: z.ZodOptional<z.ZodString>;
|
|
29
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
docsConsulted: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
31
|
+
sources: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
32
|
+
escalationReason: z.ZodOptional<z.ZodString>;
|
|
33
|
+
suggestedHumanReply: z.ZodOptional<z.ZodString>;
|
|
34
|
+
createdMessageId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
contactEmail: z.ZodOptional<z.ZodString>;
|
|
36
|
+
metadata: z.ZodOptional<z.ZodUnknown>;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
declare const supportRequestActionOutput: z.ZodObject<{
|
|
39
|
+
supportRequestId: z.ZodString;
|
|
40
|
+
status: z.ZodString;
|
|
41
|
+
subject: z.ZodString;
|
|
42
|
+
createdAt: z.ZodString;
|
|
43
|
+
conversationId: z.ZodNullable<z.ZodString>;
|
|
44
|
+
route: z.ZodNullable<z.ZodString>;
|
|
45
|
+
surface: z.ZodNullable<z.ZodString>;
|
|
46
|
+
contactEmail: z.ZodNullable<z.ZodString>;
|
|
47
|
+
created: z.ZodBoolean;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
export type CreateSupportRequestInput = z.infer<typeof createSupportRequestInput>;
|
|
50
|
+
export type CreateSupportRequestResult = z.infer<typeof supportRequestActionOutput>;
|
|
51
|
+
export type RaybaseSupportModuleOptions = {
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
};
|
|
54
|
+
export type SupportRequestRow = {
|
|
55
|
+
id: string;
|
|
56
|
+
sourceKind: string;
|
|
57
|
+
sourceId: string | null;
|
|
58
|
+
conversationId: string | null;
|
|
59
|
+
agentName: string | null;
|
|
60
|
+
agentInstanceId: string | null;
|
|
61
|
+
runId: string | null;
|
|
62
|
+
requestId: string | null;
|
|
63
|
+
toolCallId: string | null;
|
|
64
|
+
idempotencyKey: string | null;
|
|
65
|
+
userId: string | null;
|
|
66
|
+
organizationId: string | null;
|
|
67
|
+
principalKind: string | null;
|
|
68
|
+
publicIdentity: string | null;
|
|
69
|
+
surface: string | null;
|
|
70
|
+
route: string | null;
|
|
71
|
+
subject: string;
|
|
72
|
+
body: string;
|
|
73
|
+
transcriptSummary: string | null;
|
|
74
|
+
transcriptEvidence: string | null;
|
|
75
|
+
category: string | null;
|
|
76
|
+
confidence: number | null;
|
|
77
|
+
docsConsultedJson: string | null;
|
|
78
|
+
sourcesJson: string | null;
|
|
79
|
+
escalationReason: string | null;
|
|
80
|
+
suggestedHumanReply: string | null;
|
|
81
|
+
createdMessageId: string | null;
|
|
82
|
+
contactEmail: string | null;
|
|
83
|
+
metadataJson: string | null;
|
|
84
|
+
status: string;
|
|
85
|
+
createdAt: string;
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
};
|
|
88
|
+
export type ListSupportRequestsOptions = {
|
|
89
|
+
organizationId?: string | null;
|
|
90
|
+
status?: string | null;
|
|
91
|
+
sourceKind?: string | null;
|
|
92
|
+
search?: string | null;
|
|
93
|
+
limit?: number;
|
|
94
|
+
offset?: number;
|
|
95
|
+
};
|
|
96
|
+
export type ListSupportRequestsResult = {
|
|
97
|
+
supportRequests: SupportRequestRow[];
|
|
98
|
+
total: number;
|
|
99
|
+
appliedFilters: {
|
|
100
|
+
organizationId: string | null;
|
|
101
|
+
status: string | null;
|
|
102
|
+
sourceKind: string | null;
|
|
103
|
+
search: string | null;
|
|
104
|
+
limit: number;
|
|
105
|
+
offset: number;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
type SupportRequestContext<Env = unknown> = {
|
|
109
|
+
control: SqlExecutor;
|
|
110
|
+
notifications?: RaybaseNotificationsRuntime<Env>;
|
|
111
|
+
principal?: RaybasePrincipal;
|
|
112
|
+
user?: {
|
|
113
|
+
id: string;
|
|
114
|
+
email?: string | null;
|
|
115
|
+
} | null;
|
|
116
|
+
organizationId?: string | null;
|
|
117
|
+
agentName?: string;
|
|
118
|
+
agentInstanceId?: string;
|
|
119
|
+
conversationId?: string;
|
|
120
|
+
runId?: string;
|
|
121
|
+
requestId?: string;
|
|
122
|
+
toolCallId?: string;
|
|
123
|
+
route?: string;
|
|
124
|
+
surface?: string;
|
|
125
|
+
audit?: (event: RaybaseAuditContextEvent) => Promise<void>;
|
|
126
|
+
};
|
|
127
|
+
export declare function createSupportRequestAction<Env = unknown>(): RaybaseAction<CreateSupportRequestInput, CreateSupportRequestResult, Env>;
|
|
128
|
+
export declare function supportModule<Env = unknown>(options?: RaybaseSupportModuleOptions): RaybaseModule<Env>;
|
|
129
|
+
export declare function listSupportRequests(control: SqlExecutor, options?: ListSupportRequestsOptions): Promise<ListSupportRequestsResult>;
|
|
130
|
+
export declare function createSupportRequest<Env>(ctx: SupportRequestContext<Env> | RaybaseActionContext<Env>, input: CreateSupportRequestInput): Promise<CreateSupportRequestResult>;
|
|
131
|
+
export {};
|
|
132
|
+
//# sourceMappingURL=support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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C;IACjB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,GAAG,GAAG,OAAO,KAAK,aAAa,CAAC,yBAAyB,EAAE,0BAA0B,EAAE,GAAG,CAAC,CAgBrI;AAED,wBAAgB,aAAa,CAAC,GAAG,GAAG,OAAO,EAAE,OAAO,GAAE,2BAAgC,GAAG,aAAa,CAAC,GAAG,CAAC,CAuG1G;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,yBAAyB,CAAC,CAuDpC;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAC5C,GAAG,EAAE,qBAAqB,CAAC,GAAG,CAAC,GAAG,oBAAoB,CAAC,GAAG,CAAC,EAC3D,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAqErC"}
|
package/dist/support.js
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction, mcpToolFromAction } from "./actions.js";
|
|
3
|
+
import { sha256Hex, stableJson } from "./internal.js";
|
|
4
|
+
import { defineRaybaseModule } from "./modules.js";
|
|
5
|
+
import { getNotificationSubscription, listNotificationSubscribers, raybaseNotificationSubscriptionsTableName, setNotificationSubscription } from "./notifications.js";
|
|
6
|
+
import { allowAll } from "./policies.js";
|
|
7
|
+
import { principalOnBehalfOf } from "./principal.js";
|
|
8
|
+
import { id, integer, longText, raybaseSystemTable, text } from "./schema.js";
|
|
9
|
+
import { nowIso, q, randomId } from "./sql.js";
|
|
10
|
+
export const raybaseSupportRequestsTableName = "_support_requests";
|
|
11
|
+
export const supportRequestCreatedNotificationKind = "support.request.created";
|
|
12
|
+
export const raybaseSupportSystemTables = [
|
|
13
|
+
raybaseSystemTable(raybaseSupportRequestsTableName, {
|
|
14
|
+
id: id(),
|
|
15
|
+
sourceKind: text({ required: true }),
|
|
16
|
+
sourceId: text(),
|
|
17
|
+
conversationId: text(),
|
|
18
|
+
agentName: text(),
|
|
19
|
+
agentInstanceId: text(),
|
|
20
|
+
runId: text(),
|
|
21
|
+
requestId: text(),
|
|
22
|
+
toolCallId: text(),
|
|
23
|
+
idempotencyKey: text({ unique: true }),
|
|
24
|
+
userId: text(),
|
|
25
|
+
organizationId: text(),
|
|
26
|
+
principalKind: text(),
|
|
27
|
+
publicIdentity: text(),
|
|
28
|
+
surface: text(),
|
|
29
|
+
route: text(),
|
|
30
|
+
subject: text({ required: true }),
|
|
31
|
+
body: longText({ required: true }),
|
|
32
|
+
transcriptSummary: longText(),
|
|
33
|
+
transcriptEvidence: longText(),
|
|
34
|
+
category: text(),
|
|
35
|
+
confidence: integer(),
|
|
36
|
+
docsConsultedJson: longText(),
|
|
37
|
+
sourcesJson: longText(),
|
|
38
|
+
escalationReason: longText(),
|
|
39
|
+
suggestedHumanReply: longText(),
|
|
40
|
+
createdMessageId: text(),
|
|
41
|
+
contactEmail: text(),
|
|
42
|
+
metadataJson: longText(),
|
|
43
|
+
status: text({ required: true }),
|
|
44
|
+
createdAt: text({ required: true }),
|
|
45
|
+
updatedAt: text({ required: true })
|
|
46
|
+
}, {
|
|
47
|
+
label: "Support requests",
|
|
48
|
+
indexes: [
|
|
49
|
+
["status", "updatedAt"],
|
|
50
|
+
["sourceKind", "updatedAt"],
|
|
51
|
+
["userId", "updatedAt"],
|
|
52
|
+
["surface", "updatedAt"],
|
|
53
|
+
["conversationId", "updatedAt"],
|
|
54
|
+
["runId", "updatedAt"],
|
|
55
|
+
["idempotencyKey"]
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
];
|
|
59
|
+
const createSupportRequestInput = z.object({
|
|
60
|
+
sourceKind: z.string().min(1).max(80).optional(),
|
|
61
|
+
sourceId: z.string().max(200).optional(),
|
|
62
|
+
conversationId: z.string().max(200).optional(),
|
|
63
|
+
agentName: z.string().max(120).optional(),
|
|
64
|
+
agentInstanceId: z.string().max(200).optional(),
|
|
65
|
+
runId: z.string().max(200).optional(),
|
|
66
|
+
requestId: z.string().max(200).optional(),
|
|
67
|
+
toolCallId: z.string().max(200).optional(),
|
|
68
|
+
idempotencyKey: z.string().max(240).optional(),
|
|
69
|
+
surface: z.string().max(120).optional(),
|
|
70
|
+
route: z.string().max(500).optional(),
|
|
71
|
+
subject: z.string().min(1).max(200).optional(),
|
|
72
|
+
body: z.string().min(1).max(12000),
|
|
73
|
+
transcriptSummary: z.string().max(4000).optional(),
|
|
74
|
+
transcriptEvidence: z.string().max(12000).optional(),
|
|
75
|
+
category: z.string().max(120).optional(),
|
|
76
|
+
confidence: z.number().int().min(0).max(100).optional(),
|
|
77
|
+
docsConsulted: z.array(z.unknown()).max(50).optional(),
|
|
78
|
+
sources: z.array(z.unknown()).max(50).optional(),
|
|
79
|
+
escalationReason: z.string().max(2000).optional(),
|
|
80
|
+
suggestedHumanReply: z.string().max(4000).optional(),
|
|
81
|
+
createdMessageId: z.string().max(200).optional(),
|
|
82
|
+
contactEmail: z.string().email().max(320).optional(),
|
|
83
|
+
metadata: z.unknown().optional()
|
|
84
|
+
}).strict();
|
|
85
|
+
const supportRequestActionOutput = z.object({
|
|
86
|
+
supportRequestId: z.string(),
|
|
87
|
+
status: z.string(),
|
|
88
|
+
subject: z.string(),
|
|
89
|
+
createdAt: z.string(),
|
|
90
|
+
conversationId: z.string().nullable(),
|
|
91
|
+
route: z.string().nullable(),
|
|
92
|
+
surface: z.string().nullable(),
|
|
93
|
+
contactEmail: z.string().nullable(),
|
|
94
|
+
created: z.boolean()
|
|
95
|
+
}).strict();
|
|
96
|
+
export function createSupportRequestAction() {
|
|
97
|
+
return defineAction({
|
|
98
|
+
name: "create_support_request",
|
|
99
|
+
description: "Create a support request for a user who needs human help. Use this for app support escalation, not for general data entry.",
|
|
100
|
+
input: createSupportRequestInput,
|
|
101
|
+
output: supportRequestActionOutput,
|
|
102
|
+
audience: ["signed-in", "public"],
|
|
103
|
+
policy: allowAll,
|
|
104
|
+
annotations: {
|
|
105
|
+
title: "Create support request",
|
|
106
|
+
idempotentHint: true
|
|
107
|
+
},
|
|
108
|
+
requiresInternalControl: true,
|
|
109
|
+
idempotencyKey: (input) => input.idempotencyKey,
|
|
110
|
+
handler: async (ctx, input) => createSupportRequest(ctx, input)
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export function supportModule(options = {}) {
|
|
114
|
+
return defineRaybaseModule({
|
|
115
|
+
id: "support",
|
|
116
|
+
packageName: "@raybase/core",
|
|
117
|
+
runtime: () => {
|
|
118
|
+
const enabled = options.enabled !== false;
|
|
119
|
+
if (!enabled) {
|
|
120
|
+
return {
|
|
121
|
+
manifest: {
|
|
122
|
+
id: "support",
|
|
123
|
+
packageName: "@raybase/core"
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const createAction = createSupportRequestAction();
|
|
128
|
+
return {
|
|
129
|
+
systemTables: raybaseSupportSystemTables,
|
|
130
|
+
actions: { [createAction.name]: createAction },
|
|
131
|
+
mcpTools: [
|
|
132
|
+
mcpToolFromAction(createAction, {
|
|
133
|
+
allowInternalControl: true,
|
|
134
|
+
context: (ctx) => ({
|
|
135
|
+
control: ctx.control,
|
|
136
|
+
notifications: ctx.notifications
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
],
|
|
140
|
+
adminRoutes: [
|
|
141
|
+
{
|
|
142
|
+
method: "GET",
|
|
143
|
+
path: "/api/admin/support/requests",
|
|
144
|
+
handle: async (routeCtx) => {
|
|
145
|
+
routeCtx.requireAdmin();
|
|
146
|
+
const url = new URL(routeCtx.request.url);
|
|
147
|
+
const result = await listSupportRequests(routeCtx.control, {
|
|
148
|
+
organizationId: routeCtx.organizationId ?? null,
|
|
149
|
+
status: url.searchParams.get("status"),
|
|
150
|
+
sourceKind: url.searchParams.get("sourceKind"),
|
|
151
|
+
search: url.searchParams.get("search"),
|
|
152
|
+
limit: numberParam(url.searchParams.get("limit"), 50, 1, 100),
|
|
153
|
+
offset: numberParam(url.searchParams.get("offset"), 0, 0, 100000)
|
|
154
|
+
});
|
|
155
|
+
return routeCtx.json(result);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
method: "GET",
|
|
160
|
+
path: "/api/admin/support/notification-subscription",
|
|
161
|
+
handle: async (routeCtx) => {
|
|
162
|
+
const user = routeCtx.requireAdmin();
|
|
163
|
+
if (!routeCtx.notifications.enabled)
|
|
164
|
+
return routeCtx.json({ error: "Notifications are not enabled" }, 404);
|
|
165
|
+
const subscription = await getNotificationSubscription(routeCtx.control, {
|
|
166
|
+
organizationId: routeCtx.organizationId ?? undefined,
|
|
167
|
+
userId: user.id,
|
|
168
|
+
kind: supportRequestCreatedNotificationKind
|
|
169
|
+
});
|
|
170
|
+
return routeCtx.json({
|
|
171
|
+
kind: supportRequestCreatedNotificationKind,
|
|
172
|
+
organizationId: routeCtx.organizationId ?? null,
|
|
173
|
+
enabled: subscription?.enabled ?? false,
|
|
174
|
+
channels: subscription?.channels ?? ["feed"],
|
|
175
|
+
subscription
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
method: "PUT",
|
|
181
|
+
path: "/api/admin/support/notification-subscription",
|
|
182
|
+
handle: async (routeCtx) => {
|
|
183
|
+
const user = routeCtx.requireAdmin();
|
|
184
|
+
if (!routeCtx.notifications.enabled)
|
|
185
|
+
return routeCtx.json({ error: "Notifications are not enabled" }, 404);
|
|
186
|
+
const body = await routeCtx.request.json().catch(() => ({}));
|
|
187
|
+
const channels = Array.isArray(body.channels)
|
|
188
|
+
? body.channels.filter((channel) => typeof channel === "string")
|
|
189
|
+
: ["feed"];
|
|
190
|
+
const subscription = await setNotificationSubscription(routeCtx.control, {
|
|
191
|
+
organizationId: routeCtx.organizationId ?? undefined,
|
|
192
|
+
userId: user.id,
|
|
193
|
+
kind: supportRequestCreatedNotificationKind,
|
|
194
|
+
enabled: body.enabled === true,
|
|
195
|
+
channels
|
|
196
|
+
});
|
|
197
|
+
await routeCtx.audit({
|
|
198
|
+
action: "support.notification_subscription.update",
|
|
199
|
+
target: { type: raybaseNotificationSubscriptionsTableName, id: subscription.id },
|
|
200
|
+
metadata: {
|
|
201
|
+
kind: supportRequestCreatedNotificationKind,
|
|
202
|
+
organizationId: subscription.organizationId,
|
|
203
|
+
enabled: subscription.enabled,
|
|
204
|
+
channels: subscription.channels
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return routeCtx.json({ subscription });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
],
|
|
211
|
+
manifest: {
|
|
212
|
+
id: "support",
|
|
213
|
+
packageName: "@raybase/core"
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
export async function listSupportRequests(control, options = {}) {
|
|
220
|
+
const limit = clampInteger(options.limit ?? 50, 1, 500);
|
|
221
|
+
const offset = clampInteger(options.offset ?? 0, 0, 100000);
|
|
222
|
+
const organizationId = clean(options.organizationId) ?? null;
|
|
223
|
+
const status = clean(options.status) ?? null;
|
|
224
|
+
const sourceKind = clean(options.sourceKind) ?? null;
|
|
225
|
+
const search = clean(options.search) ?? null;
|
|
226
|
+
const where = [];
|
|
227
|
+
const params = [];
|
|
228
|
+
if (organizationId) {
|
|
229
|
+
where.push(`"organizationId" = ?`);
|
|
230
|
+
params.push(organizationId);
|
|
231
|
+
}
|
|
232
|
+
if (status) {
|
|
233
|
+
where.push(`"status" = ?`);
|
|
234
|
+
params.push(status);
|
|
235
|
+
}
|
|
236
|
+
if (sourceKind) {
|
|
237
|
+
where.push(`"sourceKind" = ?`);
|
|
238
|
+
params.push(sourceKind);
|
|
239
|
+
}
|
|
240
|
+
if (search) {
|
|
241
|
+
const pattern = `%${escapeLike(search)}%`;
|
|
242
|
+
where.push(`("subject" LIKE ? ESCAPE '\\' OR "body" LIKE ? ESCAPE '\\' OR "contactEmail" LIKE ? ESCAPE '\\' OR "route" LIKE ? ESCAPE '\\')`);
|
|
243
|
+
params.push(pattern, pattern, pattern, pattern);
|
|
244
|
+
}
|
|
245
|
+
const whereSql = where.length ? `WHERE ${where.join(" AND ")}` : "";
|
|
246
|
+
const [supportRequests, countRow] = await Promise.all([
|
|
247
|
+
control.all(`SELECT *
|
|
248
|
+
FROM ${q(raybaseSupportRequestsTableName)}
|
|
249
|
+
${whereSql}
|
|
250
|
+
ORDER BY "updatedAt" DESC, "createdAt" DESC
|
|
251
|
+
LIMIT ? OFFSET ?`, [...params, limit, offset]),
|
|
252
|
+
control.first(`SELECT COUNT(*) as "count"
|
|
253
|
+
FROM ${q(raybaseSupportRequestsTableName)}
|
|
254
|
+
${whereSql}`, params)
|
|
255
|
+
]);
|
|
256
|
+
return {
|
|
257
|
+
supportRequests,
|
|
258
|
+
total: Number(countRow?.count ?? supportRequests.length),
|
|
259
|
+
appliedFilters: {
|
|
260
|
+
organizationId,
|
|
261
|
+
status,
|
|
262
|
+
sourceKind,
|
|
263
|
+
search,
|
|
264
|
+
limit,
|
|
265
|
+
offset
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
export async function createSupportRequest(ctx, input) {
|
|
270
|
+
const control = ctx.control;
|
|
271
|
+
if (!control)
|
|
272
|
+
throw new Error("Support request storage is unavailable");
|
|
273
|
+
const body = input.body.trim();
|
|
274
|
+
if (!body)
|
|
275
|
+
throw new Error("Support request body is required");
|
|
276
|
+
const sourceKind = clean(input.sourceKind) ?? defaultSourceKind(ctx);
|
|
277
|
+
const organizationId = clean(ctx.organizationId) ?? null;
|
|
278
|
+
const idempotencyKey = clean(input.idempotencyKey) ?? await defaultSupportIdempotencyKey(ctx, input, sourceKind, organizationId);
|
|
279
|
+
const existing = await loadSupportRequestByIdempotencyKey(control, idempotencyKey);
|
|
280
|
+
if (existing)
|
|
281
|
+
return supportRequestResult(existing, false);
|
|
282
|
+
const principal = ctx.principal;
|
|
283
|
+
// A support request raised through an agent belongs to the person the agent
|
|
284
|
+
// ran for; the agent itself is recorded in agentName.
|
|
285
|
+
const authority = principal ? principalOnBehalfOf(principal) : undefined;
|
|
286
|
+
const now = nowIso();
|
|
287
|
+
const row = {
|
|
288
|
+
id: randomId("support"),
|
|
289
|
+
sourceKind,
|
|
290
|
+
sourceId: clean(input.sourceId) ?? null,
|
|
291
|
+
conversationId: clean(input.conversationId) ?? clean(ctx.conversationId) ?? null,
|
|
292
|
+
agentName: clean(input.agentName) ?? clean(ctx.agentName) ?? null,
|
|
293
|
+
agentInstanceId: clean(input.agentInstanceId) ?? clean(ctx.agentInstanceId) ?? null,
|
|
294
|
+
runId: clean(input.runId) ?? clean(ctx.runId) ?? null,
|
|
295
|
+
requestId: clean(input.requestId) ?? clean(ctx.requestId) ?? null,
|
|
296
|
+
toolCallId: clean(input.toolCallId) ?? clean(ctx.toolCallId) ?? null,
|
|
297
|
+
idempotencyKey,
|
|
298
|
+
userId: userIdFromPrincipal(principal, ctx.user),
|
|
299
|
+
organizationId,
|
|
300
|
+
principalKind: authority?.kind ?? (ctx.user ? "user" : null),
|
|
301
|
+
publicIdentity: authority?.kind === "public" ? authority.id : null,
|
|
302
|
+
surface: clean(input.surface) ?? clean(ctx.surface) ?? null,
|
|
303
|
+
route: clean(input.route) ?? clean(ctx.route) ?? null,
|
|
304
|
+
subject: clean(input.subject)?.slice(0, 200) ?? (body.slice(0, 120) || "Support request"),
|
|
305
|
+
body,
|
|
306
|
+
transcriptSummary: clean(input.transcriptSummary) ?? null,
|
|
307
|
+
transcriptEvidence: clean(input.transcriptEvidence) ?? null,
|
|
308
|
+
category: clean(input.category) ?? "support",
|
|
309
|
+
confidence: input.confidence ?? null,
|
|
310
|
+
docsConsultedJson: input.docsConsulted ? stableJson(input.docsConsulted) : null,
|
|
311
|
+
sourcesJson: input.sources ? stableJson(input.sources) : null,
|
|
312
|
+
escalationReason: clean(input.escalationReason) ?? null,
|
|
313
|
+
suggestedHumanReply: clean(input.suggestedHumanReply) ?? null,
|
|
314
|
+
createdMessageId: clean(input.createdMessageId) ?? null,
|
|
315
|
+
contactEmail: clean(input.contactEmail) ?? clean(ctx.user?.email) ?? null,
|
|
316
|
+
metadataJson: input.metadata === undefined ? null : stableJson(input.metadata),
|
|
317
|
+
status: "open",
|
|
318
|
+
createdAt: now,
|
|
319
|
+
updatedAt: now
|
|
320
|
+
};
|
|
321
|
+
await insertSupportRequest(control, row);
|
|
322
|
+
await ctx.audit?.({
|
|
323
|
+
action: "support.request.create",
|
|
324
|
+
target: { type: raybaseSupportRequestsTableName, id: row.id },
|
|
325
|
+
metadata: {
|
|
326
|
+
sourceKind: row.sourceKind,
|
|
327
|
+
sourceId: row.sourceId,
|
|
328
|
+
organizationId: row.organizationId,
|
|
329
|
+
conversationId: row.conversationId,
|
|
330
|
+
runId: row.runId,
|
|
331
|
+
toolCallId: row.toolCallId,
|
|
332
|
+
route: row.route,
|
|
333
|
+
surface: row.surface
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
await notifySupportRequestCreated(ctx, row).catch(() => undefined);
|
|
337
|
+
return supportRequestResult(row, true);
|
|
338
|
+
}
|
|
339
|
+
async function insertSupportRequest(control, row) {
|
|
340
|
+
await control.run(`INSERT INTO ${q(raybaseSupportRequestsTableName)}
|
|
341
|
+
("id", "sourceKind", "sourceId", "conversationId", "agentName", "agentInstanceId", "runId", "requestId", "toolCallId", "idempotencyKey",
|
|
342
|
+
"userId", "organizationId", "principalKind", "publicIdentity", "surface", "route", "subject", "body", "transcriptSummary",
|
|
343
|
+
"transcriptEvidence", "category", "confidence", "docsConsultedJson", "sourcesJson", "escalationReason",
|
|
344
|
+
"suggestedHumanReply", "createdMessageId", "contactEmail", "metadataJson", "status", "createdAt", "updatedAt")
|
|
345
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
346
|
+
row.id,
|
|
347
|
+
row.sourceKind,
|
|
348
|
+
row.sourceId,
|
|
349
|
+
row.conversationId,
|
|
350
|
+
row.agentName,
|
|
351
|
+
row.agentInstanceId,
|
|
352
|
+
row.runId,
|
|
353
|
+
row.requestId,
|
|
354
|
+
row.toolCallId,
|
|
355
|
+
row.idempotencyKey,
|
|
356
|
+
row.userId,
|
|
357
|
+
row.organizationId,
|
|
358
|
+
row.principalKind,
|
|
359
|
+
row.publicIdentity,
|
|
360
|
+
row.surface,
|
|
361
|
+
row.route,
|
|
362
|
+
row.subject,
|
|
363
|
+
row.body,
|
|
364
|
+
row.transcriptSummary,
|
|
365
|
+
row.transcriptEvidence,
|
|
366
|
+
row.category,
|
|
367
|
+
row.confidence,
|
|
368
|
+
row.docsConsultedJson,
|
|
369
|
+
row.sourcesJson,
|
|
370
|
+
row.escalationReason,
|
|
371
|
+
row.suggestedHumanReply,
|
|
372
|
+
row.createdMessageId,
|
|
373
|
+
row.contactEmail,
|
|
374
|
+
row.metadataJson,
|
|
375
|
+
row.status,
|
|
376
|
+
row.createdAt,
|
|
377
|
+
row.updatedAt
|
|
378
|
+
]);
|
|
379
|
+
}
|
|
380
|
+
async function loadSupportRequestByIdempotencyKey(control, idempotencyKey) {
|
|
381
|
+
return control.first(`SELECT *
|
|
382
|
+
FROM ${q(raybaseSupportRequestsTableName)}
|
|
383
|
+
WHERE "idempotencyKey" = ? LIMIT 1`, [idempotencyKey]);
|
|
384
|
+
}
|
|
385
|
+
async function defaultSupportIdempotencyKey(ctx, input, sourceKind, organizationId) {
|
|
386
|
+
const digest = await sha256Hex(stableJson({
|
|
387
|
+
organizationId,
|
|
388
|
+
sourceKind,
|
|
389
|
+
sourceId: clean(input.sourceId),
|
|
390
|
+
conversationId: clean(input.conversationId) ?? clean(ctx.conversationId),
|
|
391
|
+
runId: clean(input.runId) ?? clean(ctx.runId),
|
|
392
|
+
toolCallId: clean(input.toolCallId) ?? clean(ctx.toolCallId),
|
|
393
|
+
subject: clean(input.subject),
|
|
394
|
+
body: input.body.trim()
|
|
395
|
+
}));
|
|
396
|
+
return `support:${digest.slice(0, 48)}`;
|
|
397
|
+
}
|
|
398
|
+
async function notifySupportRequestCreated(ctx, row) {
|
|
399
|
+
if (!ctx.notifications?.enabled)
|
|
400
|
+
return;
|
|
401
|
+
const subscribers = await listNotificationSubscribers(ctx.control, supportRequestCreatedNotificationKind, {
|
|
402
|
+
organizationId: row.organizationId ?? undefined
|
|
403
|
+
});
|
|
404
|
+
if (!subscribers.length)
|
|
405
|
+
return;
|
|
406
|
+
const groups = new Map();
|
|
407
|
+
for (const subscriber of subscribers) {
|
|
408
|
+
const channels = subscriber.channels.length ? subscriber.channels : ["feed"];
|
|
409
|
+
const key = stableJson(channels);
|
|
410
|
+
const group = groups.get(key) ?? { channels, recipients: [] };
|
|
411
|
+
group.recipients.push({ kind: "user", userId: subscriber.userId });
|
|
412
|
+
groups.set(key, group);
|
|
413
|
+
}
|
|
414
|
+
for (const [key, group] of groups) {
|
|
415
|
+
await ctx.notifications.send({
|
|
416
|
+
to: group.recipients,
|
|
417
|
+
kind: supportRequestCreatedNotificationKind,
|
|
418
|
+
severity: "info",
|
|
419
|
+
title: "New support request",
|
|
420
|
+
body: row.subject,
|
|
421
|
+
target: {
|
|
422
|
+
href: `/admin/data/system/${encodeURIComponent(raybaseSupportRequestsTableName)}`,
|
|
423
|
+
entity: { type: "support_request", id: row.id }
|
|
424
|
+
},
|
|
425
|
+
channels: group.channels,
|
|
426
|
+
dedupeKey: `${supportRequestCreatedNotificationKind}:${row.id}:${key}`,
|
|
427
|
+
metadata: {
|
|
428
|
+
supportRequestId: row.id,
|
|
429
|
+
organizationId: row.organizationId,
|
|
430
|
+
sourceKind: row.sourceKind,
|
|
431
|
+
sourceId: row.sourceId,
|
|
432
|
+
route: row.route,
|
|
433
|
+
surface: row.surface,
|
|
434
|
+
contactEmail: row.contactEmail
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function supportRequestResult(row, created) {
|
|
440
|
+
return {
|
|
441
|
+
supportRequestId: row.id,
|
|
442
|
+
status: row.status,
|
|
443
|
+
subject: row.subject,
|
|
444
|
+
createdAt: row.createdAt,
|
|
445
|
+
conversationId: row.conversationId,
|
|
446
|
+
route: row.route,
|
|
447
|
+
surface: row.surface,
|
|
448
|
+
contactEmail: row.contactEmail,
|
|
449
|
+
created
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
function clean(value) {
|
|
453
|
+
const trimmed = value?.trim();
|
|
454
|
+
return trimmed ? trimmed : undefined;
|
|
455
|
+
}
|
|
456
|
+
function numberParam(value, fallback, min, max) {
|
|
457
|
+
if (!value)
|
|
458
|
+
return fallback;
|
|
459
|
+
const parsed = Number(value);
|
|
460
|
+
if (!Number.isFinite(parsed))
|
|
461
|
+
return fallback;
|
|
462
|
+
return clampInteger(parsed, min, max);
|
|
463
|
+
}
|
|
464
|
+
function clampInteger(value, min, max) {
|
|
465
|
+
return Math.min(max, Math.max(min, Math.trunc(value)));
|
|
466
|
+
}
|
|
467
|
+
function escapeLike(value) {
|
|
468
|
+
return value.replace(/[\\%_]/g, (match) => `\\${match}`);
|
|
469
|
+
}
|
|
470
|
+
function defaultSourceKind(ctx) {
|
|
471
|
+
if (ctx.surface === "mcp")
|
|
472
|
+
return "mcp";
|
|
473
|
+
if (ctx.surface === "guide")
|
|
474
|
+
return "guide";
|
|
475
|
+
return "api";
|
|
476
|
+
}
|
|
477
|
+
function userIdFromPrincipal(principal, user) {
|
|
478
|
+
const authority = principal ? principalOnBehalfOf(principal) : undefined;
|
|
479
|
+
if (authority?.kind === "user" || authority?.kind === "operator")
|
|
480
|
+
return authority.user.id;
|
|
481
|
+
return user?.id ?? null;
|
|
482
|
+
}
|
|
483
|
+
//# sourceMappingURL=support.js.map
|