@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
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export const AGENT_CLIENT_ID = 2147483647; // Max 32-bit signed int, reserved for agent
|
|
9
|
-
|
|
10
|
-
export interface AgentIdentity {
|
|
11
|
-
clientId: number;
|
|
12
|
-
name: string;
|
|
13
|
-
email: string;
|
|
14
|
-
color: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const DEFAULT_AGENT_IDENTITY: AgentIdentity = {
|
|
18
|
-
clientId: AGENT_CLIENT_ID,
|
|
19
|
-
name: "AI Assistant",
|
|
20
|
-
email: "agent@system",
|
|
21
|
-
color: "#00B5FF", // agent-native blue
|
|
22
|
-
};
|
|
1
|
+
export {
|
|
2
|
+
AGENT_CLIENT_ID,
|
|
3
|
+
DEFAULT_AGENT_IDENTITY,
|
|
4
|
+
type AgentIdentity,
|
|
5
|
+
} from "@agent-native/toolkit/collab-ui";
|
|
@@ -45,12 +45,11 @@ import * as Y from "yjs";
|
|
|
45
45
|
|
|
46
46
|
import { agentNativePath } from "../client/api-path.js";
|
|
47
47
|
import { subscribeSyncEvents, type SyncEvent } from "../client/use-db-sync.js";
|
|
48
|
-
import { AGENT_CLIENT_ID } from "./agent-identity.js";
|
|
49
|
-
|
|
50
48
|
export {
|
|
51
49
|
dedupeCollabUsersByEmail,
|
|
52
50
|
emailToColor,
|
|
53
51
|
emailToName,
|
|
52
|
+
isReconcileLeadClient,
|
|
54
53
|
type CollabUser,
|
|
55
54
|
} from "@agent-native/toolkit/collab-ui";
|
|
56
55
|
|
|
@@ -119,57 +118,6 @@ function collabUsersEqual(a: CollabUser[], b: CollabUser[]): boolean {
|
|
|
119
118
|
return true;
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
/**
|
|
123
|
-
* Leader election for applying authoritative external snapshots into a shared
|
|
124
|
-
* collaborative document.
|
|
125
|
-
*
|
|
126
|
-
* When the agent (or a Notion pull, or any full-document rewrite) writes new
|
|
127
|
-
* content to SQL, the open editor reconciles it into the live Y.Doc with
|
|
128
|
-
* `setContent`. If EVERY connected client did that independently, each would
|
|
129
|
-
* diff the same snapshot into the CRDT and the changed region would be inserted
|
|
130
|
-
* N times (concurrent inserts at the same position → duplicated text). So only
|
|
131
|
-
* ONE client — the "lead" — applies the snapshot; every other client receives
|
|
132
|
-
* the result through normal Yjs sync.
|
|
133
|
-
*
|
|
134
|
-
* The lead is the present client with the lowest Yjs `clientID`. The agent's
|
|
135
|
-
* awareness entry uses `AGENT_CLIENT_ID` (max int) so it can never be the lead,
|
|
136
|
-
* and a client editing alone is always the lead. This is deterministic across
|
|
137
|
-
* clients with no coordination round-trip.
|
|
138
|
-
*/
|
|
139
|
-
export function isReconcileLeadClient(
|
|
140
|
-
awareness: Awareness | null | undefined,
|
|
141
|
-
localClientId: number | null | undefined,
|
|
142
|
-
): boolean {
|
|
143
|
-
if (localClientId == null) return false;
|
|
144
|
-
if (!awareness) return true; // standalone / tests — act alone
|
|
145
|
-
|
|
146
|
-
let hasPeer = false;
|
|
147
|
-
let minVisible = localClientId;
|
|
148
|
-
awareness.getStates().forEach((state, clientId) => {
|
|
149
|
-
if (clientId === AGENT_CLIENT_ID) return; // agent never leads
|
|
150
|
-
if (clientId === localClientId) return;
|
|
151
|
-
const s = state as { user?: unknown; visible?: boolean };
|
|
152
|
-
if (!s || !s.user) return; // skip empty/stale entries
|
|
153
|
-
hasPeer = true;
|
|
154
|
-
// Only VISIBLE peers can act; a peer published `visible: false` (backgrounded)
|
|
155
|
-
// is skipped. A peer that hasn't published the field is treated as visible.
|
|
156
|
-
if (s.visible !== false && clientId < minVisible) minVisible = clientId;
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// Sole client: always the applier — no other client can duplicate the edit,
|
|
160
|
-
// so single-user agent edits apply even if this tab reports hidden.
|
|
161
|
-
if (!hasPeer) return true;
|
|
162
|
-
|
|
163
|
-
// With peers present, exactly one VISIBLE client applies (the lowest clientId
|
|
164
|
-
// among visible ones). A backgrounded tab pauses its poll and can't reliably
|
|
165
|
-
// act, so it yields — otherwise an agent edit would never reach the tab the
|
|
166
|
-
// user is actually looking at. The caller re-elects on visibility change.
|
|
167
|
-
const localHidden =
|
|
168
|
-
typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
169
|
-
if (localHidden) return false;
|
|
170
|
-
return localClientId <= minVisible;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
121
|
export interface RemoteAwarenessSnapshot {
|
|
174
122
|
clientId: number;
|
|
175
123
|
state: unknown;
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import path from "path";
|
|
12
12
|
|
|
13
|
+
import {
|
|
14
|
+
beginDatabaseOperation,
|
|
15
|
+
recordDatabaseRetry,
|
|
16
|
+
} from "./request-telemetry.js";
|
|
17
|
+
|
|
13
18
|
const recyclingPostgresPools = new WeakSet<object>();
|
|
14
19
|
const loggedNeonPools = new WeakSet<object>();
|
|
15
20
|
|
|
@@ -735,6 +740,7 @@ export async function retryOnConnectionError<T>(
|
|
|
735
740
|
} catch (e) {
|
|
736
741
|
last = e;
|
|
737
742
|
if (!isConnectionError(e) || attempt === maxAttempts - 1) throw e;
|
|
743
|
+
recordDatabaseRetry();
|
|
738
744
|
await new Promise((r) => setTimeout(r, 100 * (attempt + 1)));
|
|
739
745
|
}
|
|
740
746
|
}
|
|
@@ -790,6 +796,9 @@ export async function withDbTimeout<T>(
|
|
|
790
796
|
): Promise<T> {
|
|
791
797
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
792
798
|
let settled = false;
|
|
799
|
+
const finishTelemetry = beginDatabaseOperation(
|
|
800
|
+
op === "connect" ? "connect" : "query",
|
|
801
|
+
);
|
|
793
802
|
|
|
794
803
|
const runCleanup = async () => {
|
|
795
804
|
if (!onTimeout) return;
|
|
@@ -811,12 +820,14 @@ export async function withDbTimeout<T>(
|
|
|
811
820
|
if (settled) return;
|
|
812
821
|
settled = true;
|
|
813
822
|
if (timer) clearTimeout(timer);
|
|
823
|
+
finishTelemetry("success");
|
|
814
824
|
complete(value);
|
|
815
825
|
};
|
|
816
826
|
const fail = (err: unknown) => {
|
|
817
827
|
if (settled) return;
|
|
818
828
|
settled = true;
|
|
819
829
|
if (timer) clearTimeout(timer);
|
|
830
|
+
finishTelemetry("error");
|
|
820
831
|
reject(err);
|
|
821
832
|
};
|
|
822
833
|
|
|
@@ -825,6 +836,7 @@ export async function withDbTimeout<T>(
|
|
|
825
836
|
settled = true;
|
|
826
837
|
void (async () => {
|
|
827
838
|
await runCleanup();
|
|
839
|
+
finishTelemetry("timeout");
|
|
828
840
|
reject(new DbTimeoutError(op, ms));
|
|
829
841
|
})();
|
|
830
842
|
}, ms);
|
|
@@ -1171,13 +1183,7 @@ async function createDbExecInternal(
|
|
|
1171
1183
|
return retryOnConnectionError<{
|
|
1172
1184
|
rows: unknown[];
|
|
1173
1185
|
rowsAffected: number;
|
|
1174
|
-
}>(() =>
|
|
1175
|
-
withDbTimeout(
|
|
1176
|
-
"http-query",
|
|
1177
|
-
() => queryNeonClient(pool, sql),
|
|
1178
|
-
dbOpTimeoutMs(),
|
|
1179
|
-
),
|
|
1180
|
-
);
|
|
1186
|
+
}>(() => queryNeonClient(pool, sql));
|
|
1181
1187
|
}
|
|
1182
1188
|
const result = await retryOnConnectionError<{
|
|
1183
1189
|
rows: unknown[];
|
|
@@ -84,23 +84,28 @@ export function isSqlRead(sql: string): boolean {
|
|
|
84
84
|
* connection the transaction needs. The pool-level error logger still fires
|
|
85
85
|
* on idle-client drops inside transactions.
|
|
86
86
|
*/
|
|
87
|
-
export function buildResilientNeonPool
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}): typeof pool {
|
|
87
|
+
export function buildResilientNeonPool<
|
|
88
|
+
T extends {
|
|
89
|
+
connect(): Promise<any>;
|
|
90
|
+
query(...args: any[]): Promise<any>;
|
|
91
|
+
end(): Promise<void>;
|
|
92
|
+
on(event: string, listener: (...args: any[]) => void): unknown;
|
|
93
|
+
},
|
|
94
|
+
>(pool: T): T {
|
|
96
95
|
// Preserve all original pool methods and properties; only override `connect`
|
|
97
96
|
// and `query` at the Pool level (used by drizzle's neon-serverless adapter
|
|
98
97
|
// when it calls pool.query() directly, e.g. outside a transaction).
|
|
99
98
|
const resilientQuery = async (
|
|
100
|
-
sql: string,
|
|
99
|
+
sql: string | { text?: unknown },
|
|
101
100
|
args?: any[],
|
|
102
101
|
): Promise<{ rows: unknown[]; rowCount?: number }> => {
|
|
103
|
-
const
|
|
102
|
+
const sqlText =
|
|
103
|
+
typeof sql === "string"
|
|
104
|
+
? sql
|
|
105
|
+
: typeof sql?.text === "string"
|
|
106
|
+
? sql.text
|
|
107
|
+
: "";
|
|
108
|
+
const isRead = isSqlRead(sqlText);
|
|
104
109
|
|
|
105
110
|
const runAttempt = async (): Promise<{
|
|
106
111
|
rows: unknown[];
|
|
@@ -135,7 +140,9 @@ export function buildResilientNeonPool(pool: {
|
|
|
135
140
|
const result = await withDbTimeout(
|
|
136
141
|
"query",
|
|
137
142
|
() =>
|
|
138
|
-
|
|
143
|
+
(args === undefined
|
|
144
|
+
? client.query(sql)
|
|
145
|
+
: client.query(sql, args)) as Promise<{
|
|
139
146
|
rows: unknown[];
|
|
140
147
|
rowCount?: number;
|
|
141
148
|
}>,
|
|
@@ -180,7 +187,7 @@ export function buildResilientNeonPool(pool: {
|
|
|
180
187
|
const val = (target as any)[prop];
|
|
181
188
|
return typeof val === "function" ? val.bind(target) : val;
|
|
182
189
|
},
|
|
183
|
-
});
|
|
190
|
+
}) as T;
|
|
184
191
|
}
|
|
185
192
|
|
|
186
193
|
/**
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
|
|
3
|
+
export type DatabaseOperationKind = "connect" | "query";
|
|
4
|
+
|
|
5
|
+
export interface DatabaseRequestTelemetry {
|
|
6
|
+
operationCount: number;
|
|
7
|
+
queryCount: number;
|
|
8
|
+
connectCount: number;
|
|
9
|
+
retryCount: number;
|
|
10
|
+
errorCount: number;
|
|
11
|
+
timeoutCount: number;
|
|
12
|
+
operationTotalMs: number;
|
|
13
|
+
operationWallMs: number;
|
|
14
|
+
queryTotalMs: number;
|
|
15
|
+
connectTotalMs: number;
|
|
16
|
+
slowestOperationMs: number;
|
|
17
|
+
activeOperationCount: number;
|
|
18
|
+
activeWindowStartedAt?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const STORAGE_KEY = Symbol.for(
|
|
22
|
+
"@agent-native/core/db.request-telemetry-storage",
|
|
23
|
+
);
|
|
24
|
+
const STARTUP_STATE_KEY = Symbol.for(
|
|
25
|
+
"@agent-native/core/db.startup-telemetry-state",
|
|
26
|
+
);
|
|
27
|
+
const STARTUP_CAPTURE_WINDOW_MS = 120_000;
|
|
28
|
+
interface StartupDatabaseTelemetryState {
|
|
29
|
+
captureUntil: number;
|
|
30
|
+
claimed: boolean;
|
|
31
|
+
telemetry: DatabaseRequestTelemetry;
|
|
32
|
+
}
|
|
33
|
+
type GlobalWithDatabaseTelemetry = typeof globalThis & {
|
|
34
|
+
[STORAGE_KEY]?: AsyncLocalStorage<DatabaseRequestTelemetry>;
|
|
35
|
+
[STARTUP_STATE_KEY]?: StartupDatabaseTelemetryState;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const globalRef = globalThis as GlobalWithDatabaseTelemetry;
|
|
39
|
+
const storage =
|
|
40
|
+
globalRef[STORAGE_KEY] ??
|
|
41
|
+
(globalRef[STORAGE_KEY] = new AsyncLocalStorage<DatabaseRequestTelemetry>());
|
|
42
|
+
|
|
43
|
+
export function createDatabaseRequestTelemetry(): DatabaseRequestTelemetry {
|
|
44
|
+
return {
|
|
45
|
+
operationCount: 0,
|
|
46
|
+
queryCount: 0,
|
|
47
|
+
connectCount: 0,
|
|
48
|
+
retryCount: 0,
|
|
49
|
+
errorCount: 0,
|
|
50
|
+
timeoutCount: 0,
|
|
51
|
+
operationTotalMs: 0,
|
|
52
|
+
operationWallMs: 0,
|
|
53
|
+
queryTotalMs: 0,
|
|
54
|
+
connectTotalMs: 0,
|
|
55
|
+
slowestOperationMs: 0,
|
|
56
|
+
activeOperationCount: 0,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const startupState =
|
|
61
|
+
globalRef[STARTUP_STATE_KEY] ??
|
|
62
|
+
(globalRef[STARTUP_STATE_KEY] = {
|
|
63
|
+
captureUntil: Date.now() + STARTUP_CAPTURE_WINDOW_MS,
|
|
64
|
+
claimed: false,
|
|
65
|
+
telemetry: createDatabaseRequestTelemetry(),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
function currentDatabaseTelemetry(): DatabaseRequestTelemetry | undefined {
|
|
69
|
+
const requestTelemetry = storage.getStore();
|
|
70
|
+
if (requestTelemetry) return requestTelemetry;
|
|
71
|
+
if (!startupState.claimed && Date.now() <= startupState.captureUntil) {
|
|
72
|
+
return startupState.telemetry;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function claimStartupDatabaseTelemetry():
|
|
78
|
+
| DatabaseRequestTelemetry
|
|
79
|
+
| undefined {
|
|
80
|
+
if (startupState.claimed) return undefined;
|
|
81
|
+
startupState.claimed = true;
|
|
82
|
+
return startupState.telemetry;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function runWithDatabaseRequestTelemetry<T>(
|
|
86
|
+
telemetry: DatabaseRequestTelemetry,
|
|
87
|
+
fn: () => T,
|
|
88
|
+
): T {
|
|
89
|
+
return storage.run(telemetry, fn);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function enterDatabaseRequestTelemetry(
|
|
93
|
+
telemetry: DatabaseRequestTelemetry,
|
|
94
|
+
): void {
|
|
95
|
+
storage.enterWith(telemetry);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function beginDatabaseOperation(
|
|
99
|
+
operation: DatabaseOperationKind,
|
|
100
|
+
): (outcome: "success" | "error" | "timeout") => void {
|
|
101
|
+
const telemetry = currentDatabaseTelemetry();
|
|
102
|
+
if (!telemetry) return () => {};
|
|
103
|
+
|
|
104
|
+
const startedAt = Date.now();
|
|
105
|
+
if (telemetry.activeOperationCount === 0) {
|
|
106
|
+
telemetry.activeWindowStartedAt = startedAt;
|
|
107
|
+
}
|
|
108
|
+
telemetry.activeOperationCount += 1;
|
|
109
|
+
let completed = false;
|
|
110
|
+
|
|
111
|
+
return (outcome) => {
|
|
112
|
+
if (completed) return;
|
|
113
|
+
completed = true;
|
|
114
|
+
const completedAt = Date.now();
|
|
115
|
+
const duration = Math.max(0, completedAt - startedAt);
|
|
116
|
+
telemetry.operationCount += 1;
|
|
117
|
+
telemetry.operationTotalMs += duration;
|
|
118
|
+
telemetry.slowestOperationMs = Math.max(
|
|
119
|
+
telemetry.slowestOperationMs,
|
|
120
|
+
duration,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (operation === "connect") {
|
|
124
|
+
telemetry.connectCount += 1;
|
|
125
|
+
telemetry.connectTotalMs += duration;
|
|
126
|
+
} else {
|
|
127
|
+
telemetry.queryCount += 1;
|
|
128
|
+
telemetry.queryTotalMs += duration;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (outcome !== "success") telemetry.errorCount += 1;
|
|
132
|
+
if (outcome === "timeout") telemetry.timeoutCount += 1;
|
|
133
|
+
|
|
134
|
+
telemetry.activeOperationCount = Math.max(
|
|
135
|
+
0,
|
|
136
|
+
telemetry.activeOperationCount - 1,
|
|
137
|
+
);
|
|
138
|
+
if (
|
|
139
|
+
telemetry.activeOperationCount === 0 &&
|
|
140
|
+
telemetry.activeWindowStartedAt !== undefined
|
|
141
|
+
) {
|
|
142
|
+
telemetry.operationWallMs += Math.max(
|
|
143
|
+
0,
|
|
144
|
+
completedAt - telemetry.activeWindowStartedAt,
|
|
145
|
+
);
|
|
146
|
+
telemetry.activeWindowStartedAt = undefined;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function recordDatabaseRetry(): void {
|
|
152
|
+
const telemetry = currentDatabaseTelemetry();
|
|
153
|
+
if (telemetry) telemetry.retryCount += 1;
|
|
154
|
+
}
|
|
@@ -84,6 +84,7 @@ export {
|
|
|
84
84
|
unregisterRemotePushRegistrationForOwner,
|
|
85
85
|
upsertRemotePushRegistration,
|
|
86
86
|
} from "./remote-push-store.js";
|
|
87
|
+
export { deliverPendingRemotePushNotifications } from "./remote-push-delivery.js";
|
|
87
88
|
export type {
|
|
88
89
|
ComputerApprovalScope,
|
|
89
90
|
ComputerCommandAction,
|
|
@@ -109,6 +109,7 @@ import {
|
|
|
109
109
|
unregisterRemoteDevice,
|
|
110
110
|
updateRemoteDeviceDetails,
|
|
111
111
|
} from "./remote-devices-store.js";
|
|
112
|
+
import { startRemotePushDeliveryJob } from "./remote-push-delivery-job.js";
|
|
112
113
|
import {
|
|
113
114
|
listRemotePushNotificationsForOwner,
|
|
114
115
|
listRemotePushRegistrationsForOwner,
|
|
@@ -579,7 +580,6 @@ function mountedPathParts(event: any, mountSuffix: string): string[] {
|
|
|
579
580
|
function remoteCommandPushPayload(
|
|
580
581
|
command: RemoteCommand,
|
|
581
582
|
): Record<string, unknown> {
|
|
582
|
-
const result = readObject(command.result);
|
|
583
583
|
const status = command.status;
|
|
584
584
|
const title =
|
|
585
585
|
status === "completed"
|
|
@@ -587,14 +587,19 @@ function remoteCommandPushPayload(
|
|
|
587
587
|
: status === "failed"
|
|
588
588
|
? "Remote run failed"
|
|
589
589
|
: "Remote run updated";
|
|
590
|
+
const body =
|
|
591
|
+
status === "completed"
|
|
592
|
+
? "Open Agent Native to review the result."
|
|
593
|
+
: status === "failed"
|
|
594
|
+
? "Open Agent Native to review the failure."
|
|
595
|
+
: "Open Agent Native to review the latest status.";
|
|
590
596
|
return {
|
|
591
597
|
title,
|
|
592
|
-
body
|
|
598
|
+
body,
|
|
593
599
|
commandId: command.id,
|
|
594
600
|
hostId: command.deviceId,
|
|
595
601
|
kind: command.kind,
|
|
596
602
|
status,
|
|
597
|
-
result: command.result,
|
|
598
603
|
updatedAt: command.updatedAt,
|
|
599
604
|
};
|
|
600
605
|
}
|
|
@@ -2897,6 +2902,7 @@ export function createIntegrationsPlugin(
|
|
|
2897
2902
|
});
|
|
2898
2903
|
startA2AContinuationRetryJob(adapterMap);
|
|
2899
2904
|
startRemoteCommandsRetryJob();
|
|
2905
|
+
startRemotePushDeliveryJob();
|
|
2900
2906
|
|
|
2901
2907
|
// ─── Start Google Docs poller/push ────────────────────────────
|
|
2902
2908
|
if (adapterMap.has("google-docs")) {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { deliverPendingRemotePushNotifications } from "./remote-push-delivery.js";
|
|
2
|
+
|
|
3
|
+
const DELIVERY_INTERVAL_MS = 60_000;
|
|
4
|
+
|
|
5
|
+
let retryInterval: ReturnType<typeof setInterval> | null = null;
|
|
6
|
+
let initialTimer: ReturnType<typeof setTimeout> | null = null;
|
|
7
|
+
let running = false;
|
|
8
|
+
|
|
9
|
+
export async function runRemotePushDelivery(): Promise<void> {
|
|
10
|
+
if (running) return;
|
|
11
|
+
running = true;
|
|
12
|
+
try {
|
|
13
|
+
await deliverPendingRemotePushNotifications();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error("[integrations] Remote push delivery failed", {
|
|
16
|
+
error: error instanceof Error ? error.name : "UnknownError",
|
|
17
|
+
});
|
|
18
|
+
} finally {
|
|
19
|
+
running = false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function startRemotePushDeliveryJob(): void {
|
|
24
|
+
if (retryInterval) return;
|
|
25
|
+
initialTimer = setTimeout(() => void runRemotePushDelivery(), 10_000);
|
|
26
|
+
unrefTimer(initialTimer);
|
|
27
|
+
retryInterval = setInterval(
|
|
28
|
+
() => void runRemotePushDelivery(),
|
|
29
|
+
DELIVERY_INTERVAL_MS,
|
|
30
|
+
);
|
|
31
|
+
unrefTimer(retryInterval);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function stopRemotePushDeliveryJob(): void {
|
|
35
|
+
if (initialTimer) {
|
|
36
|
+
clearTimeout(initialTimer);
|
|
37
|
+
initialTimer = null;
|
|
38
|
+
}
|
|
39
|
+
if (retryInterval) {
|
|
40
|
+
clearInterval(retryInterval);
|
|
41
|
+
retryInterval = null;
|
|
42
|
+
}
|
|
43
|
+
running = false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function unrefTimer(timer: ReturnType<typeof setInterval>): void {
|
|
47
|
+
(timer as unknown as { unref?: () => void }).unref?.();
|
|
48
|
+
}
|