@agent-native/core 0.109.2 → 0.109.4
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +16 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +46 -13
- package/corpus/core/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
- package/corpus/core/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
- package/corpus/core/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
- package/corpus/core/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
- package/corpus/core/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
- package/corpus/core/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
- package/corpus/core/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
- package/corpus/core/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
- package/corpus/core/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
- package/corpus/core/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
- package/corpus/core/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
- package/corpus/core/docs/content/toolkit-capability-packages.mdx +52 -0
- package/corpus/core/docs/content/toolkit-context-knowledge.mdx +46 -0
- package/corpus/core/docs/content/toolkit-editors-canvases.mdx +55 -0
- package/corpus/core/package.json +35 -34
- package/corpus/core/src/cli/create.ts +57 -15
- package/corpus/core/src/cli/package-lifecycle.ts +2 -0
- package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +2 -0
- package/corpus/core/src/client/context-xray/ContextMeter.tsx +31 -111
- package/corpus/core/src/client/context-xray/ContextSegmentRow.tsx +8 -111
- package/corpus/core/src/client/context-xray/ContextTreemap.tsx +6 -111
- package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +31 -391
- package/corpus/core/src/client/context-xray/SegmentProvenancePopover.tsx +4 -52
- package/corpus/core/src/client/context-xray/format.ts +0 -33
- package/corpus/core/src/client/require-session.tsx +19 -3
- package/corpus/core/src/client/rich-markdown-editor/index.ts +42 -57
- package/corpus/core/src/client/rich-markdown-editor/uploadEditorImage.ts +2 -1
- package/corpus/core/src/client/use-action.ts +145 -2
- package/corpus/core/src/client/use-session.ts +79 -48
- package/corpus/core/src/client/visual-style-controls.tsx +1 -1088
- package/corpus/core/src/collab/agent-identity.ts +5 -22
- package/corpus/core/src/collab/client.ts +1 -53
- package/corpus/core/src/db/client.ts +13 -7
- package/corpus/core/src/db/create-get-db.ts +20 -13
- package/corpus/core/src/db/request-telemetry.ts +154 -0
- package/corpus/core/src/integrations/index.ts +1 -0
- package/corpus/core/src/integrations/plugin.ts +9 -3
- package/corpus/core/src/integrations/remote-push-delivery-job.ts +48 -0
- package/corpus/core/src/integrations/remote-push-delivery.ts +370 -0
- package/corpus/core/src/integrations/remote-push-store.ts +275 -26
- package/corpus/core/src/server/better-auth-instance.ts +11 -3
- package/corpus/core/src/server/core-routes-plugin.ts +36 -14
- package/corpus/core/src/server/framework-request-handler.ts +11 -1
- package/corpus/core/src/server/http-response-telemetry.ts +233 -31
- package/corpus/core/src/styles/rich-markdown-editor.css +1 -510
- package/corpus/core/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
- package/corpus/core/src/testing.ts +1 -1
- package/corpus/core/src/vite/client.ts +3 -0
- package/corpus/templates/clips/actions/finalize-recording.ts +3 -1
- package/corpus/templates/clips/actions/set-mobile-capture-state.ts +4 -1
- package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -6
- package/corpus/templates/clips/changelog/2026-07-18-new-recording-is-now-emphasized-as-the-primary-action-in-the.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-18-recordings-now-remain-safely-recoverable-until-the-stored-me.md +6 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +5 -3
- package/corpus/templates/content/app/components/editor/extensions/DragHandle.tsx +4 -4
- package/corpus/templates/content/package.json +25 -25
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +2 -1
- package/corpus/templates/design/package.json +1 -1
- package/corpus/templates/mail/package.json +9 -9
- package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +2 -0
- package/corpus/templates/plan/app/components/editor/PlanDocumentEditor.tsx +8 -8
- package/corpus/templates/plan/app/components/editor/planSlashCommands.ts +6 -6
- package/corpus/templates/plan/app/components/plan/PlanImageNode.tsx +4 -7
- package/corpus/templates/plan/app/components/plan/PlanMarkdownEditor.tsx +6 -4
- package/corpus/templates/plan/app/components/plan/PlanVisualSurface.tsx +1 -1
- package/corpus/templates/plan/changelog/2026-07-18-visual-plans-now-open-on-wireframes-by-default-when-a-protot.md +6 -0
- package/corpus/templates/plan/package.json +3 -3
- package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +2 -2
- package/corpus/templates/slides/app/components/editor/TweaksPanel.tsx +2 -2
- package/corpus/templates/slides/package.json +13 -13
- package/corpus/templates/tasks/AGENTS.md +3 -0
- package/corpus/templates/tasks/actions/render-task-list-inline.ts +202 -0
- package/corpus/templates/tasks/changelog/2026-07-18-task-lists-can-now-appear-as-interactive-widgets-inline-in-c.md +6 -0
- package/corpus/templates/tasks/docs/features/f8-chat.mdx +2 -0
- package/corpus/templates/tasks/server/plugins/agent-chat.ts +2 -0
- package/dist/catalog.json +39 -1
- package/dist/cli/create.d.ts +10 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +49 -16
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/package-lifecycle.d.ts.map +1 -1
- package/dist/cli/package-lifecycle.js +2 -0
- package/dist/cli/package-lifecycle.js.map +1 -1
- package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
- package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/visual-plan-skill.js +2 -0
- package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
- package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
- package/dist/client/context-xray/ContextMeter.js +8 -23
- package/dist/client/context-xray/ContextMeter.js.map +1 -1
- package/dist/client/context-xray/ContextSegmentRow.d.ts.map +1 -1
- package/dist/client/context-xray/ContextSegmentRow.js +3 -19
- package/dist/client/context-xray/ContextSegmentRow.js.map +1 -1
- package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -1
- package/dist/client/context-xray/ContextTreemap.js +3 -54
- package/dist/client/context-xray/ContextTreemap.js.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.js +21 -163
- package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
- package/dist/client/context-xray/SegmentProvenancePopover.d.ts.map +1 -1
- package/dist/client/context-xray/SegmentProvenancePopover.js +3 -4
- package/dist/client/context-xray/SegmentProvenancePopover.js.map +1 -1
- package/dist/client/context-xray/format.d.ts +0 -4
- package/dist/client/context-xray/format.d.ts.map +1 -1
- package/dist/client/context-xray/format.js +0 -49
- package/dist/client/context-xray/format.js.map +1 -1
- package/dist/client/require-session.d.ts.map +1 -1
- package/dist/client/require-session.js +6 -3
- package/dist/client/require-session.js.map +1 -1
- package/dist/client/rich-markdown-editor/index.d.ts +1 -12
- package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/index.js +1 -12
- package/dist/client/rich-markdown-editor/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts +1 -1
- package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/uploadEditorImage.js.map +1 -1
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +117 -1
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-session.d.ts.map +1 -1
- package/dist/client/use-session.js +72 -50
- package/dist/client/use-session.js.map +1 -1
- package/dist/client/visual-style-controls.d.ts +1 -89
- package/dist/client/visual-style-controls.d.ts.map +1 -1
- package/dist/client/visual-style-controls.js +1 -498
- package/dist/client/visual-style-controls.js.map +1 -1
- package/dist/collab/agent-identity.d.ts +1 -14
- package/dist/collab/agent-identity.d.ts.map +1 -1
- package/dist/collab/agent-identity.js +1 -13
- package/dist/collab/agent-identity.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/client.d.ts +1 -19
- package/dist/collab/client.d.ts.map +1 -1
- package/dist/collab/client.js +1 -53
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +7 -1
- package/dist/db/client.js.map +1 -1
- package/dist/db/create-get-db.d.ts +3 -6
- package/dist/db/create-get-db.d.ts.map +1 -1
- package/dist/db/create-get-db.js +9 -2
- package/dist/db/create-get-db.js.map +1 -1
- package/dist/db/request-telemetry.d.ts +23 -0
- package/dist/db/request-telemetry.d.ts.map +1 -0
- package/dist/db/request-telemetry.js +95 -0
- package/dist/db/request-telemetry.js.map +1 -0
- package/dist/integrations/index.d.ts +1 -0
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +1 -0
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +8 -3
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/remote-push-delivery-job.d.ts +4 -0
- package/dist/integrations/remote-push-delivery-job.d.ts.map +1 -0
- package/dist/integrations/remote-push-delivery-job.js +44 -0
- package/dist/integrations/remote-push-delivery-job.js.map +1 -0
- package/dist/integrations/remote-push-delivery.d.ts +11 -0
- package/dist/integrations/remote-push-delivery.d.ts.map +1 -0
- package/dist/integrations/remote-push-delivery.js +265 -0
- package/dist/integrations/remote-push-delivery.js.map +1 -0
- package/dist/integrations/remote-push-store.d.ts +33 -0
- package/dist/integrations/remote-push-store.d.ts.map +1 -1
- package/dist/integrations/remote-push-store.js +195 -26
- package/dist/integrations/remote-push-store.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +3 -3
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/better-auth-instance.js +7 -3
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +8 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +23 -8
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +9 -1
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/http-response-telemetry.d.ts +3 -2
- package/dist/server/http-response-telemetry.d.ts.map +1 -1
- package/dist/server/http-response-telemetry.js +160 -27
- package/dist/server/http-response-telemetry.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/styles/rich-markdown-editor.css +1 -510
- package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +3 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/agent-native-toolkit.mdx +46 -13
- package/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
- package/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
- package/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
- package/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
- package/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
- package/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
- package/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
- package/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
- package/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
- package/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
- package/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
- package/docs/content/toolkit-capability-packages.mdx +52 -0
- package/docs/content/toolkit-context-knowledge.mdx +46 -0
- package/docs/content/toolkit-editors-canvases.mdx +55 -0
- package/package.json +27 -26
- package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
- package/corpus/core/src/client/rich-markdown-editor/BubbleToolbar.tsx +0 -253
- package/corpus/core/src/client/rich-markdown-editor/CodeBlockNode.tsx +0 -258
- package/corpus/core/src/client/rich-markdown-editor/DragHandle.ts +0 -1437
- package/corpus/core/src/client/rich-markdown-editor/ImageExtension.ts +0 -306
- package/corpus/core/src/client/rich-markdown-editor/RichMarkdownEditor.tsx +0 -80
- package/corpus/core/src/client/rich-markdown-editor/RunId.ts +0 -61
- package/corpus/core/src/client/rich-markdown-editor/SharedRichEditor.tsx +0 -321
- package/corpus/core/src/client/rich-markdown-editor/SlashCommandMenu.tsx +0 -310
- package/corpus/core/src/client/rich-markdown-editor/extensions.ts +0 -402
- package/corpus/core/src/client/rich-markdown-editor/gfmDoc.ts +0 -92
- package/corpus/core/src/client/rich-markdown-editor/surgical-apply.ts +0 -192
- package/corpus/core/src/client/rich-markdown-editor/useCollabReconcile.ts +0 -590
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +0 -37
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.js +0 -171
- package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +0 -1
- package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts +0 -49
- package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/CodeBlockNode.js +0 -127
- package/dist/client/rich-markdown-editor/CodeBlockNode.js.map +0 -1
- package/dist/client/rich-markdown-editor/DragHandle.d.ts +0 -97
- package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/DragHandle.js +0 -1066
- package/dist/client/rich-markdown-editor/DragHandle.js.map +0 -1
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts +0 -63
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/ImageExtension.js +0 -243
- package/dist/client/rich-markdown-editor/ImageExtension.js.map +0 -1
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +0 -51
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.js +0 -37
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.js.map +0 -1
- package/dist/client/rich-markdown-editor/RunId.d.ts +0 -28
- package/dist/client/rich-markdown-editor/RunId.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/RunId.js +0 -60
- package/dist/client/rich-markdown-editor/RunId.js.map +0 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +0 -110
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +0 -144
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +0 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +0 -41
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js +0 -221
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +0 -1
- package/dist/client/rich-markdown-editor/extensions.d.ts +0 -178
- package/dist/client/rich-markdown-editor/extensions.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/extensions.js +0 -224
- package/dist/client/rich-markdown-editor/extensions.js.map +0 -1
- package/dist/client/rich-markdown-editor/gfmDoc.d.ts +0 -24
- package/dist/client/rich-markdown-editor/gfmDoc.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/gfmDoc.js +0 -83
- package/dist/client/rich-markdown-editor/gfmDoc.js.map +0 -1
- package/dist/client/rich-markdown-editor/surgical-apply.d.ts +0 -66
- package/dist/client/rich-markdown-editor/surgical-apply.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/surgical-apply.js +0 -147
- package/dist/client/rich-markdown-editor/surgical-apply.js.map +0 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +0 -110
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +0 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.js +0 -441
- package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +0 -1
|
@@ -4,7 +4,12 @@ import {
|
|
|
4
4
|
intType,
|
|
5
5
|
retryOnDdlRace,
|
|
6
6
|
} from "../db/client.js";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ensureColumnExists,
|
|
9
|
+
ensureIndexExists,
|
|
10
|
+
ensureTableExists,
|
|
11
|
+
} from "../db/ddl-guard.js";
|
|
12
|
+
import { isDuplicateColumnError } from "../db/migrations.js";
|
|
8
13
|
import type {
|
|
9
14
|
PublicRemotePushRegistration,
|
|
10
15
|
RemotePushNotification,
|
|
@@ -46,6 +51,10 @@ function buildCreateNotificationsSql(): string {
|
|
|
46
51
|
payload_json TEXT NOT NULL,
|
|
47
52
|
status TEXT NOT NULL,
|
|
48
53
|
attempts ${intType()} NOT NULL DEFAULT 0,
|
|
54
|
+
provider_ticket_id TEXT,
|
|
55
|
+
next_attempt_at ${intType()} NOT NULL DEFAULT 0,
|
|
56
|
+
last_error TEXT,
|
|
57
|
+
delivered_at ${intType()},
|
|
49
58
|
created_at ${intType()} NOT NULL,
|
|
50
59
|
updated_at ${intType()} NOT NULL
|
|
51
60
|
)
|
|
@@ -80,6 +89,30 @@ async function ensureTables(): Promise<void> {
|
|
|
80
89
|
"idx_remote_push_notifications_owner",
|
|
81
90
|
`CREATE INDEX IF NOT EXISTS idx_remote_push_notifications_owner ON integration_remote_push_notifications(owner_email, org_id, status, created_at)`,
|
|
82
91
|
);
|
|
92
|
+
await ensureColumnExists(
|
|
93
|
+
"integration_remote_push_notifications",
|
|
94
|
+
"provider_ticket_id",
|
|
95
|
+
`ALTER TABLE integration_remote_push_notifications ADD COLUMN IF NOT EXISTS provider_ticket_id TEXT`,
|
|
96
|
+
);
|
|
97
|
+
await ensureColumnExists(
|
|
98
|
+
"integration_remote_push_notifications",
|
|
99
|
+
"next_attempt_at",
|
|
100
|
+
`ALTER TABLE integration_remote_push_notifications ADD COLUMN IF NOT EXISTS next_attempt_at ${intType()} NOT NULL DEFAULT 0`,
|
|
101
|
+
);
|
|
102
|
+
await ensureColumnExists(
|
|
103
|
+
"integration_remote_push_notifications",
|
|
104
|
+
"last_error",
|
|
105
|
+
`ALTER TABLE integration_remote_push_notifications ADD COLUMN IF NOT EXISTS last_error TEXT`,
|
|
106
|
+
);
|
|
107
|
+
await ensureColumnExists(
|
|
108
|
+
"integration_remote_push_notifications",
|
|
109
|
+
"delivered_at",
|
|
110
|
+
`ALTER TABLE integration_remote_push_notifications ADD COLUMN IF NOT EXISTS delivered_at ${intType()}`,
|
|
111
|
+
);
|
|
112
|
+
await ensureIndexExists(
|
|
113
|
+
"idx_remote_push_notifications_delivery",
|
|
114
|
+
`CREATE INDEX IF NOT EXISTS idx_remote_push_notifications_delivery ON integration_remote_push_notifications(status, next_attempt_at, updated_at)`,
|
|
115
|
+
);
|
|
83
116
|
return;
|
|
84
117
|
}
|
|
85
118
|
// SQLite (local dev): keep existing behavior
|
|
@@ -101,6 +134,18 @@ async function ensureTables(): Promise<void> {
|
|
|
101
134
|
`CREATE INDEX IF NOT EXISTS idx_remote_push_notifications_owner ON integration_remote_push_notifications(owner_email, org_id, status, created_at)`,
|
|
102
135
|
),
|
|
103
136
|
);
|
|
137
|
+
await addNotificationColumnIfMissing("provider_ticket_id", "TEXT");
|
|
138
|
+
await addNotificationColumnIfMissing(
|
|
139
|
+
"next_attempt_at",
|
|
140
|
+
`${intType()} NOT NULL DEFAULT 0`,
|
|
141
|
+
);
|
|
142
|
+
await addNotificationColumnIfMissing("last_error", "TEXT");
|
|
143
|
+
await addNotificationColumnIfMissing("delivered_at", intType());
|
|
144
|
+
await retryOnDdlRace(() =>
|
|
145
|
+
client.execute(
|
|
146
|
+
`CREATE INDEX IF NOT EXISTS idx_remote_push_notifications_delivery ON integration_remote_push_notifications(status, next_attempt_at, updated_at)`,
|
|
147
|
+
),
|
|
148
|
+
);
|
|
104
149
|
})().catch((err) => {
|
|
105
150
|
// Retry init on the next call after a failed startup.
|
|
106
151
|
_initPromise = undefined;
|
|
@@ -110,6 +155,21 @@ async function ensureTables(): Promise<void> {
|
|
|
110
155
|
return _initPromise;
|
|
111
156
|
}
|
|
112
157
|
|
|
158
|
+
async function addNotificationColumnIfMissing(
|
|
159
|
+
name: string,
|
|
160
|
+
definition: string,
|
|
161
|
+
): Promise<void> {
|
|
162
|
+
try {
|
|
163
|
+
await retryOnDdlRace(() =>
|
|
164
|
+
getDbExec().execute(
|
|
165
|
+
`ALTER TABLE integration_remote_push_notifications ADD COLUMN ${name} ${definition}`,
|
|
166
|
+
),
|
|
167
|
+
);
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (!isDuplicateColumnError(error)) throw error;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
113
173
|
function rowToRegistration(
|
|
114
174
|
row: Record<string, unknown>,
|
|
115
175
|
): RemotePushRegistration {
|
|
@@ -134,13 +194,18 @@ function rowToRegistration(
|
|
|
134
194
|
function rowToNotification(
|
|
135
195
|
row: Record<string, unknown>,
|
|
136
196
|
): RemotePushNotification {
|
|
197
|
+
const storedStatus = String(row.status ?? "pending");
|
|
198
|
+
const status =
|
|
199
|
+
storedStatus === "delivered" || storedStatus === "failed"
|
|
200
|
+
? storedStatus
|
|
201
|
+
: "pending";
|
|
137
202
|
return {
|
|
138
203
|
id: row.id as string,
|
|
139
204
|
ownerEmail: row.owner_email as string,
|
|
140
205
|
orgId: (row.org_id as string | null) ?? null,
|
|
141
206
|
registrationId: row.registration_id as string,
|
|
142
207
|
payload: parseJson(row.payload_json, null),
|
|
143
|
-
status
|
|
208
|
+
status,
|
|
144
209
|
attempts: Number(row.attempts ?? 0),
|
|
145
210
|
createdAt: Number(row.created_at ?? 0),
|
|
146
211
|
updatedAt: Number(row.updated_at ?? 0),
|
|
@@ -314,31 +379,34 @@ export async function queueRemotePushNotifications(input: {
|
|
|
314
379
|
orgId: input.orgId ?? null,
|
|
315
380
|
limit: 100,
|
|
316
381
|
});
|
|
382
|
+
if (registrations.length === 0) return { queued: 0 };
|
|
383
|
+
|
|
317
384
|
const client = getDbExec();
|
|
318
385
|
const now = Date.now();
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
386
|
+
const payload = JSON.stringify(input.payload ?? null);
|
|
387
|
+
const values = registrations.map(
|
|
388
|
+
() => "(?, ?, ?, ?, ?, 'pending', 0, ?, ?, ?)",
|
|
389
|
+
);
|
|
390
|
+
const args = registrations.flatMap((registration) => [
|
|
391
|
+
`remote-push-notification-${now}-${randomHex(8)}`,
|
|
392
|
+
input.ownerEmail,
|
|
393
|
+
input.orgId ?? null,
|
|
394
|
+
registration.id,
|
|
395
|
+
payload,
|
|
396
|
+
now,
|
|
397
|
+
now,
|
|
398
|
+
now,
|
|
399
|
+
]);
|
|
400
|
+
const result = await client.execute({
|
|
401
|
+
sql: `INSERT INTO integration_remote_push_notifications
|
|
324
402
|
(id, owner_email, org_id, registration_id, payload_json, status,
|
|
325
|
-
attempts, created_at, updated_at)
|
|
326
|
-
VALUES (
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
JSON.stringify(input.payload ?? null),
|
|
333
|
-
"pending",
|
|
334
|
-
0,
|
|
335
|
-
now,
|
|
336
|
-
now,
|
|
337
|
-
],
|
|
338
|
-
});
|
|
339
|
-
queued += result.rowsAffected ?? (result as any).rowCount ?? 0;
|
|
340
|
-
}
|
|
341
|
-
return { queued };
|
|
403
|
+
attempts, next_attempt_at, created_at, updated_at)
|
|
404
|
+
VALUES ${values.join(", ")}`,
|
|
405
|
+
args,
|
|
406
|
+
});
|
|
407
|
+
return {
|
|
408
|
+
queued: result.rowsAffected ?? (result as any).rowCount ?? 0,
|
|
409
|
+
};
|
|
342
410
|
}
|
|
343
411
|
|
|
344
412
|
export async function listRemotePushNotificationsForOwner(input: {
|
|
@@ -349,13 +417,17 @@ export async function listRemotePushNotificationsForOwner(input: {
|
|
|
349
417
|
}): Promise<RemotePushNotification[]> {
|
|
350
418
|
await ensureTables();
|
|
351
419
|
const limit = Math.max(1, Math.min(input.limit ?? 50, 100));
|
|
352
|
-
const statusClause = input.status
|
|
420
|
+
const statusClause = input.status
|
|
421
|
+
? input.status === "pending"
|
|
422
|
+
? " AND status IN ('pending', 'sending', 'sent', 'checking')"
|
|
423
|
+
: " AND status = ?"
|
|
424
|
+
: "";
|
|
353
425
|
const args: Array<string | number | null> = [
|
|
354
426
|
input.ownerEmail,
|
|
355
427
|
input.orgId ?? null,
|
|
356
428
|
input.orgId ?? null,
|
|
357
429
|
];
|
|
358
|
-
if (input.status) args.push(input.status);
|
|
430
|
+
if (input.status && input.status !== "pending") args.push(input.status);
|
|
359
431
|
args.push(limit);
|
|
360
432
|
const { rows } = await getDbExec().execute({
|
|
361
433
|
sql: `SELECT * FROM integration_remote_push_notifications
|
|
@@ -368,6 +440,183 @@ export async function listRemotePushNotificationsForOwner(input: {
|
|
|
368
440
|
return rows.map((row) => rowToNotification(row as Record<string, unknown>));
|
|
369
441
|
}
|
|
370
442
|
|
|
443
|
+
export interface ClaimedRemotePushDelivery {
|
|
444
|
+
id: string;
|
|
445
|
+
registrationId: string;
|
|
446
|
+
provider: string;
|
|
447
|
+
token: string;
|
|
448
|
+
payload: unknown;
|
|
449
|
+
phase: "send" | "receipt";
|
|
450
|
+
providerTicketId: string | null;
|
|
451
|
+
attempts: number;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export async function claimNextRemotePushDelivery(input?: {
|
|
455
|
+
now?: number;
|
|
456
|
+
staleAfterMs?: number;
|
|
457
|
+
}): Promise<ClaimedRemotePushDelivery | null> {
|
|
458
|
+
await ensureTables();
|
|
459
|
+
const client = getDbExec();
|
|
460
|
+
const now = input?.now ?? Date.now();
|
|
461
|
+
const staleBefore = now - Math.max(30_000, input?.staleAfterMs ?? 120_000);
|
|
462
|
+
const { rows } = await client.execute({
|
|
463
|
+
sql: `SELECT n.id, n.registration_id, n.payload_json, n.status, n.attempts,
|
|
464
|
+
n.provider_ticket_id, n.updated_at, r.provider, r.token
|
|
465
|
+
FROM integration_remote_push_notifications n
|
|
466
|
+
INNER JOIN integration_remote_push_registrations r
|
|
467
|
+
ON r.id = n.registration_id
|
|
468
|
+
WHERE r.status = 'active'
|
|
469
|
+
AND (
|
|
470
|
+
(n.status IN ('pending', 'sent') AND n.next_attempt_at <= ?)
|
|
471
|
+
OR (n.status IN ('sending', 'checking') AND n.updated_at <= ?)
|
|
472
|
+
)
|
|
473
|
+
ORDER BY n.created_at ASC
|
|
474
|
+
LIMIT 1`,
|
|
475
|
+
args: [now, staleBefore],
|
|
476
|
+
});
|
|
477
|
+
const row = rows[0] as Record<string, unknown> | undefined;
|
|
478
|
+
if (!row) return null;
|
|
479
|
+
|
|
480
|
+
const previousStatus = String(row.status ?? "pending");
|
|
481
|
+
const providerTicketId = sanitizeString(
|
|
482
|
+
row.provider_ticket_id as string | null,
|
|
483
|
+
200,
|
|
484
|
+
);
|
|
485
|
+
const phase =
|
|
486
|
+
(previousStatus === "sent" || previousStatus === "checking") &&
|
|
487
|
+
providerTicketId
|
|
488
|
+
? "receipt"
|
|
489
|
+
: "send";
|
|
490
|
+
const claimedStatus = phase === "receipt" ? "checking" : "sending";
|
|
491
|
+
const result = await client.execute({
|
|
492
|
+
sql: `UPDATE integration_remote_push_notifications
|
|
493
|
+
SET status = ?, attempts = attempts + 1, updated_at = ?
|
|
494
|
+
WHERE id = ? AND status = ? AND updated_at = ?`,
|
|
495
|
+
args: [
|
|
496
|
+
claimedStatus,
|
|
497
|
+
now,
|
|
498
|
+
row.id as string,
|
|
499
|
+
previousStatus,
|
|
500
|
+
Number(row.updated_at),
|
|
501
|
+
],
|
|
502
|
+
});
|
|
503
|
+
if ((result.rowsAffected ?? (result as any).rowCount ?? 0) !== 1) return null;
|
|
504
|
+
|
|
505
|
+
return {
|
|
506
|
+
id: row.id as string,
|
|
507
|
+
registrationId: row.registration_id as string,
|
|
508
|
+
provider: String(row.provider ?? "unknown"),
|
|
509
|
+
token: row.token as string,
|
|
510
|
+
payload: parseJson(row.payload_json, null),
|
|
511
|
+
phase,
|
|
512
|
+
providerTicketId,
|
|
513
|
+
attempts: Number(row.attempts ?? 0) + 1,
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export async function markRemotePushTicketAccepted(input: {
|
|
518
|
+
id: string;
|
|
519
|
+
providerTicketId: string;
|
|
520
|
+
checkAfter: number;
|
|
521
|
+
}): Promise<boolean> {
|
|
522
|
+
await ensureTables();
|
|
523
|
+
const now = Date.now();
|
|
524
|
+
const result = await getDbExec().execute({
|
|
525
|
+
sql: `UPDATE integration_remote_push_notifications
|
|
526
|
+
SET status = 'sent', provider_ticket_id = ?, next_attempt_at = ?,
|
|
527
|
+
last_error = NULL, updated_at = ?
|
|
528
|
+
WHERE id = ? AND status = 'sending'`,
|
|
529
|
+
args: [input.providerTicketId, input.checkAfter, now, input.id],
|
|
530
|
+
});
|
|
531
|
+
return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export async function markRemotePushDelivered(id: string): Promise<boolean> {
|
|
535
|
+
await ensureTables();
|
|
536
|
+
const now = Date.now();
|
|
537
|
+
const result = await getDbExec().execute({
|
|
538
|
+
sql: `UPDATE integration_remote_push_notifications
|
|
539
|
+
SET status = 'delivered', last_error = NULL, delivered_at = ?,
|
|
540
|
+
updated_at = ?
|
|
541
|
+
WHERE id = ? AND status = 'checking'`,
|
|
542
|
+
args: [now, now, id],
|
|
543
|
+
});
|
|
544
|
+
return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export async function retryRemotePushDelivery(input: {
|
|
548
|
+
id: string;
|
|
549
|
+
phase: "send" | "receipt";
|
|
550
|
+
retryAt: number;
|
|
551
|
+
errorCode: string;
|
|
552
|
+
resend?: boolean;
|
|
553
|
+
}): Promise<boolean> {
|
|
554
|
+
await ensureTables();
|
|
555
|
+
const currentStatus = input.phase === "receipt" ? "checking" : "sending";
|
|
556
|
+
const retryStatus =
|
|
557
|
+
input.phase === "receipt" && !input.resend ? "sent" : "pending";
|
|
558
|
+
const clearTicketClause = input.resend ? ", provider_ticket_id = NULL" : "";
|
|
559
|
+
const result = await getDbExec().execute({
|
|
560
|
+
sql: `UPDATE integration_remote_push_notifications
|
|
561
|
+
SET status = ?, next_attempt_at = ?, last_error = ?${clearTicketClause},
|
|
562
|
+
updated_at = ?
|
|
563
|
+
WHERE id = ? AND status = ?`,
|
|
564
|
+
args: [
|
|
565
|
+
retryStatus,
|
|
566
|
+
input.retryAt,
|
|
567
|
+
sanitizeString(input.errorCode, 160) ?? "temporary_error",
|
|
568
|
+
Date.now(),
|
|
569
|
+
input.id,
|
|
570
|
+
currentStatus,
|
|
571
|
+
],
|
|
572
|
+
});
|
|
573
|
+
return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export async function failRemotePushDelivery(input: {
|
|
577
|
+
id: string;
|
|
578
|
+
phase: "send" | "receipt";
|
|
579
|
+
errorCode: string;
|
|
580
|
+
}): Promise<boolean> {
|
|
581
|
+
await ensureTables();
|
|
582
|
+
const currentStatus = input.phase === "receipt" ? "checking" : "sending";
|
|
583
|
+
const result = await getDbExec().execute({
|
|
584
|
+
sql: `UPDATE integration_remote_push_notifications
|
|
585
|
+
SET status = 'failed', last_error = ?, updated_at = ?
|
|
586
|
+
WHERE id = ? AND status = ?`,
|
|
587
|
+
args: [
|
|
588
|
+
sanitizeString(input.errorCode, 160) ?? "delivery_failed",
|
|
589
|
+
Date.now(),
|
|
590
|
+
input.id,
|
|
591
|
+
currentStatus,
|
|
592
|
+
],
|
|
593
|
+
});
|
|
594
|
+
return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export async function deactivateRemotePushRegistration(
|
|
598
|
+
registrationId: string,
|
|
599
|
+
): Promise<boolean> {
|
|
600
|
+
await ensureTables();
|
|
601
|
+
const client = getDbExec();
|
|
602
|
+
const now = Date.now();
|
|
603
|
+
const result = await client.execute({
|
|
604
|
+
sql: `UPDATE integration_remote_push_registrations
|
|
605
|
+
SET status = 'inactive', updated_at = ?
|
|
606
|
+
WHERE id = ? AND status = 'active'`,
|
|
607
|
+
args: [now, registrationId],
|
|
608
|
+
});
|
|
609
|
+
await client.execute({
|
|
610
|
+
sql: `UPDATE integration_remote_push_notifications
|
|
611
|
+
SET status = 'failed', last_error = 'registration_inactive',
|
|
612
|
+
updated_at = ?
|
|
613
|
+
WHERE registration_id = ?
|
|
614
|
+
AND status IN ('pending', 'sending', 'sent', 'checking')`,
|
|
615
|
+
args: [now, registrationId],
|
|
616
|
+
});
|
|
617
|
+
return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
|
|
618
|
+
}
|
|
619
|
+
|
|
371
620
|
async function getRemotePushRegistrationByTokenHash(
|
|
372
621
|
tokenHash: string,
|
|
373
622
|
): Promise<RemotePushRegistration | null> {
|
|
@@ -1105,7 +1105,11 @@ async function buildDatabaseConfig(
|
|
|
1105
1105
|
): Promise<BetterAuthOptions["database"]> {
|
|
1106
1106
|
if (dialect === "postgres") {
|
|
1107
1107
|
const url = getDatabaseUrl();
|
|
1108
|
-
const {
|
|
1108
|
+
const {
|
|
1109
|
+
buildResilientNeonPool,
|
|
1110
|
+
buildResilientPostgresJsClient,
|
|
1111
|
+
isNeonUrl,
|
|
1112
|
+
} = await import("../db/create-get-db.js");
|
|
1109
1113
|
|
|
1110
1114
|
if (isPgliteUrl(url)) {
|
|
1111
1115
|
const { drizzle } = await loadPgliteDrizzle();
|
|
@@ -1133,7 +1137,9 @@ async function buildDatabaseConfig(
|
|
|
1133
1137
|
});
|
|
1134
1138
|
attachNeonPoolErrorLogger(_neonAuthPool, "db/neon-auth");
|
|
1135
1139
|
const { drizzle } = await import("drizzle-orm/neon-serverless");
|
|
1136
|
-
const db = drizzle(_neonAuthPool, {
|
|
1140
|
+
const db = drizzle(buildResilientNeonPool(_neonAuthPool), {
|
|
1141
|
+
schema: pgAuthSchema,
|
|
1142
|
+
});
|
|
1137
1143
|
const { drizzleAdapter } = await import("better-auth/adapters/drizzle");
|
|
1138
1144
|
return drizzleAdapter(db, {
|
|
1139
1145
|
provider: "pg",
|
|
@@ -1149,7 +1155,9 @@ async function buildDatabaseConfig(
|
|
|
1149
1155
|
const { default: postgres } = await import("postgres");
|
|
1150
1156
|
const sql = postgres(url, pgPoolOptions(url));
|
|
1151
1157
|
const { drizzle } = await import("drizzle-orm/postgres-js");
|
|
1152
|
-
const db = drizzle(sql, {
|
|
1158
|
+
const db = drizzle(buildResilientPostgresJsClient(sql), {
|
|
1159
|
+
schema: pgAuthSchema,
|
|
1160
|
+
});
|
|
1153
1161
|
const { drizzleAdapter } = await import("better-auth/adapters/drizzle");
|
|
1154
1162
|
return drizzleAdapter(db, {
|
|
1155
1163
|
provider: "pg",
|
|
@@ -165,7 +165,6 @@ import {
|
|
|
165
165
|
DEFAULT_UPLOAD_MAX_FILE_BYTES,
|
|
166
166
|
isAllowedUploadMimeType,
|
|
167
167
|
} from "./h3-helpers.js";
|
|
168
|
-
import { createHttpResponseTelemetryMiddleware } from "./http-response-telemetry.js";
|
|
169
168
|
import { isIdentitySsoEnabled } from "./identity-sso-store.js";
|
|
170
169
|
import { handleIdentitySso } from "./identity-sso.js";
|
|
171
170
|
import { createOpenRouteHandler } from "./open-route.js";
|
|
@@ -1069,6 +1068,35 @@ export interface CoreRoutesPluginOptions {
|
|
|
1069
1068
|
anonymousOwner?: BuilderAnonymousOwnerResolver;
|
|
1070
1069
|
}
|
|
1071
1070
|
|
|
1071
|
+
interface LegacyCoreRouteInitSettings {
|
|
1072
|
+
persistedEnvVars: Record<string, string> | null;
|
|
1073
|
+
builderDisconnected: { at?: number } | null;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
type CoreRouteSettingReader = (
|
|
1077
|
+
key: string,
|
|
1078
|
+
) => Promise<Record<string, unknown> | null>;
|
|
1079
|
+
|
|
1080
|
+
export async function readLegacyCoreRouteInitSettings(
|
|
1081
|
+
readSetting: CoreRouteSettingReader = getSetting,
|
|
1082
|
+
): Promise<LegacyCoreRouteInitSettings> {
|
|
1083
|
+
const readOrNull = async (key: string) => {
|
|
1084
|
+
try {
|
|
1085
|
+
return await readSetting(key);
|
|
1086
|
+
} catch {
|
|
1087
|
+
return null;
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
const [persistedEnvVars, builderDisconnected] = await Promise.all([
|
|
1091
|
+
readOrNull("persisted-env-vars"),
|
|
1092
|
+
readOrNull("builder-disconnected"),
|
|
1093
|
+
]);
|
|
1094
|
+
return {
|
|
1095
|
+
persistedEnvVars: persistedEnvVars as Record<string, string> | null,
|
|
1096
|
+
builderDisconnected: builderDisconnected as { at?: number } | null,
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1072
1100
|
/**
|
|
1073
1101
|
* Creates a Nitro plugin that mounts all standard agent-native framework routes.
|
|
1074
1102
|
*
|
|
@@ -1110,18 +1138,17 @@ export function createCoreRoutesPlugin(
|
|
|
1110
1138
|
try {
|
|
1111
1139
|
await awaitBootstrap(nitroApp);
|
|
1112
1140
|
|
|
1141
|
+
const { persistedEnvVars, builderDisconnected } =
|
|
1142
|
+
await readLegacyCoreRouteInitSettings();
|
|
1143
|
+
|
|
1113
1144
|
// Legacy cleanup: key saves now go to scoped app_secrets rows. Do not
|
|
1114
1145
|
// rehydrate the old deployment-global `persisted-env-vars` row into
|
|
1115
1146
|
// process.env; keep only the Builder scrub so stale leaked keys self-heal.
|
|
1116
1147
|
try {
|
|
1117
|
-
|
|
1118
|
-
string,
|
|
1119
|
-
string
|
|
1120
|
-
> | null;
|
|
1121
|
-
if (persisted) {
|
|
1148
|
+
if (persistedEnvVars) {
|
|
1122
1149
|
const builderKeys = new Set<string>(BUILDER_ENV_KEYS);
|
|
1123
1150
|
let scrubbed = 0;
|
|
1124
|
-
for (const k of Object.keys(
|
|
1151
|
+
for (const k of Object.keys(persistedEnvVars)) {
|
|
1125
1152
|
if (builderKeys.has(k)) {
|
|
1126
1153
|
scrubbed++;
|
|
1127
1154
|
}
|
|
@@ -1129,7 +1156,7 @@ export function createCoreRoutesPlugin(
|
|
|
1129
1156
|
if (scrubbed > 0) {
|
|
1130
1157
|
try {
|
|
1131
1158
|
const cleaned: Record<string, string> = {};
|
|
1132
|
-
for (const [k, v] of Object.entries(
|
|
1159
|
+
for (const [k, v] of Object.entries(persistedEnvVars)) {
|
|
1133
1160
|
if (!builderKeys.has(k)) cleaned[k] = v;
|
|
1134
1161
|
}
|
|
1135
1162
|
await putSetting("persisted-env-vars", cleaned);
|
|
@@ -1154,10 +1181,7 @@ export function createCoreRoutesPlugin(
|
|
|
1154
1181
|
// plugin init while the flag is set. The flag is cleared by the
|
|
1155
1182
|
// Builder cli-auth callback when the user re-connects.
|
|
1156
1183
|
try {
|
|
1157
|
-
|
|
1158
|
-
at?: number;
|
|
1159
|
-
} | null;
|
|
1160
|
-
if (disconnected) {
|
|
1184
|
+
if (builderDisconnected) {
|
|
1161
1185
|
for (const key of BUILDER_ENV_KEYS) {
|
|
1162
1186
|
delete process.env[key];
|
|
1163
1187
|
}
|
|
@@ -1223,8 +1247,6 @@ export function createCoreRoutesPlugin(
|
|
|
1223
1247
|
);
|
|
1224
1248
|
}
|
|
1225
1249
|
|
|
1226
|
-
getH3App(nitroApp).use(createHttpResponseTelemetryMiddleware());
|
|
1227
|
-
|
|
1228
1250
|
// Security response headers — emitted on every framework response.
|
|
1229
1251
|
// Mounted before route handlers so 4xx/5xx error pages also carry the
|
|
1230
1252
|
// headers. Routes that need to tighten a specific header override via
|
|
@@ -19,6 +19,10 @@ import { MCP_PUBLIC_ROUTE_PREFIX } from "../mcp/route-paths.js";
|
|
|
19
19
|
import { getConfiguredAppBasePath } from "./app-base-path.js";
|
|
20
20
|
import { captureError } from "./capture-error.js";
|
|
21
21
|
import { createCsrfMiddleware } from "./csrf.js";
|
|
22
|
+
import {
|
|
23
|
+
installHttpResponseTelemetryHooks,
|
|
24
|
+
recordFrameworkReadyWait,
|
|
25
|
+
} from "./http-response-telemetry.js";
|
|
22
26
|
|
|
23
27
|
const BOOTSTRAPPED = new WeakSet<object>();
|
|
24
28
|
const IN_BOOTSTRAP = new WeakSet<object>();
|
|
@@ -114,6 +118,7 @@ export function markDefaultPluginProvided(nitroApp: any, stem: string): void {
|
|
|
114
118
|
export function getH3App(nitroApp: any): H3AppShim {
|
|
115
119
|
if (!nitroApp) throw new Error("getH3App: nitroApp is required");
|
|
116
120
|
ensureGlobalMiddlewareDispatch(nitroApp);
|
|
121
|
+
installHttpResponseTelemetryHooks(nitroApp);
|
|
117
122
|
|
|
118
123
|
// Reuse the cached shim if we've wrapped this nitroApp before
|
|
119
124
|
const cached = nitroApp[APP_SHIM_KEY] as H3AppShim | undefined;
|
|
@@ -204,7 +209,12 @@ export function getH3App(nitroApp: any): H3AppShim {
|
|
|
204
209
|
resolveMountMatch(reqPath, WELL_KNOWN_PREFIX) ||
|
|
205
210
|
resolveMountMatch(reqPath, MCP_PUBLIC_ROUTE_PREFIX)
|
|
206
211
|
) {
|
|
207
|
-
|
|
212
|
+
const startedAt = Date.now();
|
|
213
|
+
try {
|
|
214
|
+
await awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath);
|
|
215
|
+
} finally {
|
|
216
|
+
recordFrameworkReadyWait(event, Date.now() - startedAt);
|
|
217
|
+
}
|
|
208
218
|
}
|
|
209
219
|
});
|
|
210
220
|
}
|