@agent-native/core 0.92.12 → 0.94.0
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 +64 -0
- package/corpus/core/docs/content/a2a-protocol.mdx +21 -5
- package/corpus/core/docs/content/actions.mdx +9 -23
- package/corpus/core/docs/content/agent-mentions.mdx +31 -29
- package/corpus/core/docs/content/agent-native-toolkit.mdx +15 -6
- package/corpus/core/docs/content/agent-surfaces.mdx +9 -13
- package/corpus/core/docs/content/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/authentication.mdx +10 -3
- package/corpus/core/docs/content/automation-connectors.mdx +123 -0
- package/corpus/core/docs/content/automations.mdx +17 -3
- package/corpus/core/docs/content/blueprint-installer.mdx +11 -4
- package/corpus/core/docs/content/cli-adapters.mdx +9 -6
- package/corpus/core/docs/content/client.mdx +16 -0
- package/corpus/core/docs/content/cloneable-saas.mdx +14 -11
- package/corpus/core/docs/content/code-agents-ui.mdx +65 -0
- package/corpus/core/docs/content/components.mdx +30 -14
- package/corpus/core/docs/content/context-awareness.mdx +27 -15
- package/corpus/core/docs/content/creating-templates.mdx +15 -9
- package/corpus/core/docs/content/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/data-programs.mdx +1 -1
- package/corpus/core/docs/content/database.mdx +17 -5
- package/corpus/core/docs/content/deployment.mdx +19 -18
- package/corpus/core/docs/content/dispatch.mdx +6 -2
- package/corpus/core/docs/content/drop-in-agent.mdx +10 -4
- package/corpus/core/docs/content/durable-background-runs.mdx +9 -5
- package/corpus/core/docs/content/durable-resume.mdx +9 -4
- package/corpus/core/docs/content/embedding-sdk.mdx +26 -8
- package/corpus/core/docs/content/evals.mdx +3 -5
- package/corpus/core/docs/content/extensions.mdx +23 -2
- package/corpus/core/docs/content/external-agents.mdx +25 -34
- package/corpus/core/docs/content/faq.mdx +8 -0
- package/corpus/core/docs/content/file-uploads.mdx +12 -3
- package/corpus/core/docs/content/frames.mdx +16 -0
- package/corpus/core/docs/content/generative-ui.mdx +1 -1
- package/corpus/core/docs/content/getting-started.mdx +34 -21
- package/corpus/core/docs/content/harness-agents.mdx +8 -4
- package/corpus/core/docs/content/human-approval.mdx +8 -3
- package/corpus/core/docs/content/internationalization.mdx +9 -4
- package/corpus/core/docs/content/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/local-file-mode.mdx +14 -8
- package/corpus/core/docs/content/locales/ar-SA/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/ar-SA/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/ar-SA/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/ar-SA/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/ar-SA/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/ar-SA/components.mdx +11 -1
- package/corpus/core/docs/content/locales/ar-SA/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/ar-SA/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/ar-SA/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/ar-SA/extensions.mdx +8 -0
- package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +2 -7
- package/corpus/core/docs/content/locales/ar-SA/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/ar-SA/messaging.mdx +84 -15
- package/corpus/core/docs/content/locales/ar-SA/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/ar-SA/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/ar-SA/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/ar-SA/server.mdx +17 -10
- package/corpus/core/docs/content/locales/ar-SA/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/ar-SA/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/ar-SA/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/ar-SA/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/ar-SA/template-clips.mdx +4 -3
- package/corpus/core/docs/content/locales/ar-SA/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/ar-SA/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/ar-SA/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/ar-SA/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/ar-SA/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/ar-SA/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/ar-SA/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/ar-SA/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/de-DE/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/de-DE/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/de-DE/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/de-DE/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/de-DE/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/components.mdx +11 -1
- package/corpus/core/docs/content/locales/de-DE/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/de-DE/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/de-DE/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/de-DE/extensions.mdx +10 -0
- package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +3 -7
- package/corpus/core/docs/content/locales/de-DE/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/de-DE/messaging.mdx +92 -15
- package/corpus/core/docs/content/locales/de-DE/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/de-DE/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/de-DE/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/de-DE/server.mdx +18 -10
- package/corpus/core/docs/content/locales/de-DE/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/de-DE/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/de-DE/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/de-DE/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/de-DE/template-clips.mdx +4 -3
- package/corpus/core/docs/content/locales/de-DE/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/de-DE/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/de-DE/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/de-DE/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/de-DE/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/de-DE/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/de-DE/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/de-DE/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/es-ES/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/es-ES/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/es-ES/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/es-ES/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/es-ES/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/components.mdx +11 -1
- package/corpus/core/docs/content/locales/es-ES/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/es-ES/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/es-ES/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/es-ES/extensions.mdx +10 -0
- package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +3 -7
- package/corpus/core/docs/content/locales/es-ES/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/es-ES/messaging.mdx +91 -15
- package/corpus/core/docs/content/locales/es-ES/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/es-ES/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/es-ES/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/es-ES/server.mdx +17 -10
- package/corpus/core/docs/content/locales/es-ES/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/es-ES/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/es-ES/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/es-ES/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/es-ES/template-clips.mdx +4 -3
- package/corpus/core/docs/content/locales/es-ES/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/es-ES/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/es-ES/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/es-ES/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/es-ES/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/es-ES/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/es-ES/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/es-ES/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/fr-FR/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/fr-FR/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/fr-FR/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/fr-FR/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/fr-FR/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/components.mdx +11 -1
- package/corpus/core/docs/content/locales/fr-FR/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/fr-FR/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/fr-FR/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/fr-FR/extensions.mdx +10 -0
- package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +3 -7
- package/corpus/core/docs/content/locales/fr-FR/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/fr-FR/messaging.mdx +91 -15
- package/corpus/core/docs/content/locales/fr-FR/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/fr-FR/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/fr-FR/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/fr-FR/server.mdx +17 -10
- package/corpus/core/docs/content/locales/fr-FR/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/fr-FR/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/fr-FR/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/fr-FR/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/fr-FR/template-clips.mdx +4 -3
- package/corpus/core/docs/content/locales/fr-FR/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/fr-FR/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/fr-FR/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/fr-FR/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/fr-FR/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/fr-FR/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/fr-FR/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/fr-FR/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/hi-IN/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/hi-IN/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/hi-IN/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/hi-IN/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/hi-IN/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/components.mdx +11 -1
- package/corpus/core/docs/content/locales/hi-IN/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/hi-IN/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/hi-IN/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/hi-IN/extensions.mdx +8 -0
- package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +2 -7
- package/corpus/core/docs/content/locales/hi-IN/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/hi-IN/messaging.mdx +81 -15
- package/corpus/core/docs/content/locales/hi-IN/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/hi-IN/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/hi-IN/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/hi-IN/server.mdx +17 -10
- package/corpus/core/docs/content/locales/hi-IN/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/hi-IN/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/hi-IN/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/hi-IN/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/hi-IN/template-clips.mdx +4 -3
- package/corpus/core/docs/content/locales/hi-IN/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/hi-IN/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/hi-IN/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/hi-IN/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/hi-IN/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/hi-IN/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/hi-IN/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/hi-IN/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/ja-JP/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/ja-JP/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/ja-JP/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/ja-JP/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/ja-JP/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/components.mdx +11 -1
- package/corpus/core/docs/content/locales/ja-JP/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/ja-JP/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/ja-JP/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/ja-JP/extensions.mdx +9 -0
- package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +2 -7
- package/corpus/core/docs/content/locales/ja-JP/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/ja-JP/messaging.mdx +81 -15
- package/corpus/core/docs/content/locales/ja-JP/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/ja-JP/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/ja-JP/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/ja-JP/server.mdx +17 -10
- package/corpus/core/docs/content/locales/ja-JP/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/ja-JP/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/ja-JP/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/ja-JP/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/ja-JP/template-clips.mdx +4 -4
- package/corpus/core/docs/content/locales/ja-JP/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/ja-JP/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/ja-JP/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/ja-JP/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/ja-JP/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/ja-JP/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/ja-JP/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/ja-JP/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/ko-KR/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/ko-KR/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/ko-KR/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/ko-KR/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/ko-KR/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/components.mdx +11 -1
- package/corpus/core/docs/content/locales/ko-KR/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/ko-KR/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/ko-KR/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/ko-KR/extensions.mdx +8 -0
- package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +2 -7
- package/corpus/core/docs/content/locales/ko-KR/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/ko-KR/messaging.mdx +80 -15
- package/corpus/core/docs/content/locales/ko-KR/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/ko-KR/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/ko-KR/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/ko-KR/server.mdx +17 -10
- package/corpus/core/docs/content/locales/ko-KR/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/ko-KR/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/ko-KR/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/ko-KR/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/ko-KR/template-clips.mdx +4 -4
- package/corpus/core/docs/content/locales/ko-KR/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/ko-KR/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/ko-KR/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/ko-KR/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/ko-KR/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/ko-KR/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/ko-KR/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/ko-KR/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/pt-BR/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/pt-BR/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/pt-BR/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/pt-BR/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/pt-BR/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/components.mdx +11 -1
- package/corpus/core/docs/content/locales/pt-BR/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/pt-BR/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/pt-BR/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/pt-BR/extensions.mdx +9 -0
- package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +3 -7
- package/corpus/core/docs/content/locales/pt-BR/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/pt-BR/messaging.mdx +88 -15
- package/corpus/core/docs/content/locales/pt-BR/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/pt-BR/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/pt-BR/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/pt-BR/server.mdx +17 -10
- package/corpus/core/docs/content/locales/pt-BR/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/pt-BR/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/pt-BR/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/pt-BR/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/pt-BR/template-clips.mdx +4 -3
- package/corpus/core/docs/content/locales/pt-BR/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/pt-BR/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/pt-BR/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/pt-BR/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/pt-BR/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/pt-BR/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/pt-BR/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/pt-BR/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/zh-CN/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-CN/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-CN/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/zh-CN/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/zh-CN/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/components.mdx +11 -1
- package/corpus/core/docs/content/locales/zh-CN/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/zh-CN/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/zh-CN/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-CN/extensions.mdx +6 -0
- package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +2 -7
- package/corpus/core/docs/content/locales/zh-CN/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/zh-CN/messaging.mdx +78 -15
- package/corpus/core/docs/content/locales/zh-CN/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/zh-CN/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/zh-CN/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/zh-CN/server.mdx +16 -10
- package/corpus/core/docs/content/locales/zh-CN/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/zh-CN/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/zh-CN/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/zh-CN/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/zh-CN/template-clips.mdx +4 -4
- package/corpus/core/docs/content/locales/zh-CN/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/zh-CN/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/zh-CN/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-CN/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/zh-CN/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/zh-CN/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/zh-CN/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/zh-CN/workspace.mdx +19 -18
- package/corpus/core/docs/content/locales/zh-TW/actions.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-TW/agent-native-toolkit.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-TW/agent-surfaces.mdx +8 -10
- package/corpus/core/docs/content/locales/zh-TW/agent-teams.mdx +1 -0
- package/corpus/core/docs/content/locales/zh-TW/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/components.mdx +11 -1
- package/corpus/core/docs/content/locales/zh-TW/creating-templates.mdx +3 -7
- package/corpus/core/docs/content/locales/zh-TW/cross-app-sso.mdx +16 -6
- package/corpus/core/docs/content/locales/zh-TW/deployment.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-TW/extensions.mdx +6 -0
- package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +2 -7
- package/corpus/core/docs/content/locales/zh-TW/key-concepts.mdx +13 -20
- package/corpus/core/docs/content/locales/zh-TW/messaging.mdx +78 -15
- package/corpus/core/docs/content/locales/zh-TW/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/locales/zh-TW/notifications.mdx +18 -10
- package/corpus/core/docs/content/locales/zh-TW/processors.mdx +11 -5
- package/corpus/core/docs/content/locales/zh-TW/server.mdx +16 -10
- package/corpus/core/docs/content/locales/zh-TW/sharing.mdx +10 -10
- package/corpus/core/docs/content/locales/zh-TW/skills-guide.mdx +34 -17
- package/corpus/core/docs/content/locales/zh-TW/template-assets.mdx +16 -13
- package/corpus/core/docs/content/locales/zh-TW/template-brain.mdx +3 -1
- package/corpus/core/docs/content/locales/zh-TW/template-clips.mdx +4 -4
- package/corpus/core/docs/content/locales/zh-TW/template-design.mdx +4 -1
- package/corpus/core/docs/content/locales/zh-TW/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/locales/zh-TW/template-mail.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-TW/tracking.mdx +9 -6
- package/corpus/core/docs/content/locales/zh-TW/using-your-agent.mdx +0 -7
- package/corpus/core/docs/content/locales/zh-TW/voice-input.mdx +6 -0
- package/corpus/core/docs/content/locales/zh-TW/workspace-connections.mdx +9 -2
- package/corpus/core/docs/content/locales/zh-TW/workspace.mdx +19 -18
- package/corpus/core/docs/content/mcp-apps.mdx +14 -32
- package/corpus/core/docs/content/mcp-clients.mdx +48 -54
- package/corpus/core/docs/content/mcp-protocol.mdx +25 -10
- package/corpus/core/docs/content/messaging.mdx +238 -48
- package/corpus/core/docs/content/multi-app-workspace.mdx +11 -96
- package/corpus/core/docs/content/multi-tenancy.mdx +5 -5
- package/corpus/core/docs/content/native-chat-ui.mdx +4 -4
- package/corpus/core/docs/content/notifications.mdx +19 -12
- package/corpus/core/docs/content/observability.mdx +2 -4
- package/corpus/core/docs/content/observational-memory.mdx +7 -3
- package/corpus/core/docs/content/onboarding.mdx +9 -2
- package/corpus/core/docs/content/plan-plugin.mdx +10 -2
- package/corpus/core/docs/content/pr-visual-recap.mdx +1 -1
- package/corpus/core/docs/content/processors.mdx +11 -5
- package/corpus/core/docs/content/pure-agent-apps.mdx +5 -1
- package/corpus/core/docs/content/real-time-collaboration.mdx +30 -67
- package/corpus/core/docs/content/recurring-jobs.mdx +8 -6
- package/corpus/core/docs/content/routing.mdx +3 -4
- package/corpus/core/docs/content/sandbox-adapters.mdx +30 -53
- package/corpus/core/docs/content/security.mdx +8 -0
- package/corpus/core/docs/content/server.mdx +17 -10
- package/corpus/core/docs/content/sharing.mdx +10 -10
- package/corpus/core/docs/content/skills-guide.mdx +35 -16
- package/corpus/core/docs/content/template-analytics.mdx +11 -8
- package/corpus/core/docs/content/template-assets.mdx +16 -13
- package/corpus/core/docs/content/template-brain.mdx +3 -1
- package/corpus/core/docs/content/template-calendar.mdx +12 -4
- package/corpus/core/docs/content/template-chat.mdx +4 -4
- package/corpus/core/docs/content/template-clips.mdx +6 -3
- package/corpus/core/docs/content/template-content.mdx +23 -18
- package/corpus/core/docs/content/template-design.mdx +7 -1
- package/corpus/core/docs/content/template-dispatch.mdx +5 -1
- package/corpus/core/docs/content/template-mail.mdx +14 -2
- package/corpus/core/docs/content/template-plan.mdx +22 -15
- package/corpus/core/docs/content/template-slides.mdx +11 -3
- package/corpus/core/docs/content/toolkit-agent-ux.mdx +46 -3
- package/corpus/core/docs/content/toolkit-collaboration.mdx +58 -4
- package/corpus/core/docs/content/toolkit-command-navigation.mdx +8 -2
- package/corpus/core/docs/content/toolkit-comments-review.mdx +10 -2
- package/corpus/core/docs/content/toolkit-history.mdx +8 -3
- package/corpus/core/docs/content/toolkit-observability.mdx +48 -2
- package/corpus/core/docs/content/toolkit-org-team.mdx +8 -2
- package/corpus/core/docs/content/toolkit-resources.mdx +45 -2
- package/corpus/core/docs/content/toolkit-settings.mdx +8 -2
- package/corpus/core/docs/content/toolkit-setup-connections.mdx +7 -2
- package/corpus/core/docs/content/toolkit-sharing.mdx +46 -3
- package/corpus/core/docs/content/toolkit-ui.mdx +82 -11
- package/corpus/core/docs/content/tracking.mdx +10 -8
- package/corpus/core/docs/content/using-your-agent.mdx +0 -12
- package/corpus/core/docs/content/voice-input.mdx +7 -1
- package/corpus/core/docs/content/what-is-agent-native.mdx +7 -8
- package/corpus/core/docs/content/workspace-connections.mdx +16 -23
- package/corpus/core/docs/content/workspace-management.mdx +16 -4
- package/corpus/core/docs/content/workspace.mdx +19 -18
- package/corpus/core/package.json +5 -1
- package/corpus/core/src/a2a/artifact-response.ts +131 -2
- package/corpus/core/src/a2a/client.ts +10 -0
- package/corpus/core/src/a2a/handlers.ts +40 -76
- package/corpus/core/src/a2a/types.ts +2 -0
- package/corpus/core/src/agent/context-xray/tokenize.ts +6 -1
- package/corpus/core/src/agent/durable-background.ts +24 -0
- package/corpus/core/src/agent/engine/ai-sdk-engine.ts +9 -5
- package/corpus/core/src/agent/engine/anthropic-engine.ts +2 -4
- package/corpus/core/src/agent/engine/builder-engine.ts +5 -7
- package/corpus/core/src/agent/engine/index.ts +1 -0
- package/corpus/core/src/agent/engine/registry.ts +40 -0
- package/corpus/core/src/agent/harness/ai-sdk-adapter.ts +6 -1
- package/corpus/core/src/agent/harness/background.ts +96 -19
- package/corpus/core/src/agent/harness/index.ts +11 -0
- package/corpus/core/src/agent/harness/lifecycle.ts +498 -0
- package/corpus/core/src/agent/harness/runner.ts +38 -0
- package/corpus/core/src/agent/harness/store.ts +22 -3
- package/corpus/core/src/agent/model-config.ts +4 -1
- package/corpus/core/src/agent/production-agent.ts +205 -9
- package/corpus/core/src/agent/run-manager.ts +135 -11
- package/corpus/core/src/agent/run-store.ts +225 -15
- package/corpus/core/src/agent/types.ts +23 -0
- package/corpus/core/src/application-state/index.ts +1 -0
- package/corpus/core/src/application-state/store.ts +32 -0
- package/corpus/core/src/audit/record.ts +31 -0
- package/corpus/core/src/audit/store.ts +69 -3
- package/corpus/core/src/audit/types.ts +13 -0
- package/corpus/core/src/automation/index.ts +802 -0
- package/corpus/core/src/cli/code-agent-connector.ts +263 -8
- package/corpus/core/src/cli/code-agent-executor.ts +15 -1
- package/corpus/core/src/cli/create.ts +12 -5
- package/corpus/core/src/cli/design-connect.ts +596 -36
- package/corpus/core/src/client/AgentPanel.tsx +92 -44
- package/corpus/core/src/client/AssistantChat.tsx +324 -149
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +36 -40
- package/corpus/core/src/client/RunStuckBanner.tsx +69 -20
- package/corpus/core/src/client/agent-chat-adapter.ts +54 -5
- package/corpus/core/src/client/appearance.ts +8 -5
- package/corpus/core/src/client/automation.ts +22 -0
- package/corpus/core/src/client/chat/connectors.ts +293 -29
- package/corpus/core/src/client/chat/message-components.tsx +23 -1
- package/corpus/core/src/client/chat/run-recovery.tsx +67 -50
- package/corpus/core/src/client/chat/runtime.ts +126 -25
- package/corpus/core/src/client/chat/tool-call-display.tsx +45 -4
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +294 -0
- package/corpus/core/src/client/composer/TiptapComposer.tsx +29 -20
- package/corpus/core/src/client/composer/VoiceButton.tsx +20 -0
- package/corpus/core/src/client/composer/index.ts +22 -0
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +640 -0
- package/corpus/core/src/client/guided-questions.tsx +12 -3
- package/corpus/core/src/client/index.ts +48 -0
- package/corpus/core/src/client/integrations/api.ts +295 -0
- package/corpus/core/src/client/integrations/index.ts +26 -0
- package/corpus/core/src/client/settings/DemoModeSection.tsx +4 -3
- package/corpus/core/src/client/settings/SettingsPanel.tsx +4 -0
- package/corpus/core/src/client/settings/SettingsTabsPage.tsx +95 -37
- package/corpus/core/src/client/transcription/use-live-transcription.ts +68 -5
- package/corpus/core/src/client/use-chat-models.ts +17 -17
- package/corpus/core/src/client/use-db-sync.ts +108 -7
- package/corpus/core/src/client/use-run-stuck-detection.ts +41 -3
- package/corpus/core/src/code-agents/background-controller.ts +18 -0
- package/corpus/core/src/collab/ydoc-manager.ts +41 -6
- package/corpus/core/src/db/migrations.ts +17 -1
- package/corpus/core/src/demo/fetch-interceptor.ts +16 -11
- package/corpus/core/src/deploy/build.ts +59 -3
- package/corpus/core/src/deploy/workspace-deploy.ts +37 -2
- package/corpus/core/src/file-upload/types.ts +2 -0
- package/corpus/core/src/index.ts +37 -0
- package/corpus/core/src/integrations/a2a-continuations-store.ts +6 -4
- package/corpus/core/src/integrations/adapters/discord.ts +362 -0
- package/corpus/core/src/integrations/adapters/index.ts +29 -0
- package/corpus/core/src/integrations/adapters/microsoft-teams.ts +411 -0
- package/corpus/core/src/integrations/adapters/slack.ts +900 -27
- package/corpus/core/src/integrations/adapters/telegram.ts +54 -15
- package/corpus/core/src/integrations/adapters/whatsapp.ts +41 -17
- package/corpus/core/src/integrations/awaiting-input-store.ts +130 -0
- package/corpus/core/src/integrations/catalog.ts +571 -0
- package/corpus/core/src/integrations/computer-supervision-store.ts +423 -0
- package/corpus/core/src/integrations/computer-supervision.ts +213 -0
- package/corpus/core/src/integrations/controls-store.ts +187 -0
- package/corpus/core/src/integrations/index.ts +129 -1
- package/corpus/core/src/integrations/installations-store.ts +677 -0
- package/corpus/core/src/integrations/integration-memory.ts +187 -0
- package/corpus/core/src/integrations/pending-tasks-retry-job.ts +6 -6
- package/corpus/core/src/integrations/pending-tasks-store.ts +83 -5
- package/corpus/core/src/integrations/plugin.ts +916 -49
- package/corpus/core/src/integrations/remote-commands-store.ts +334 -3
- package/corpus/core/src/integrations/remote-devices-store.ts +68 -9
- package/corpus/core/src/integrations/remote-json-safety.ts +127 -0
- package/corpus/core/src/integrations/remote-run-events-store.ts +104 -19
- package/corpus/core/src/integrations/remote-types.ts +66 -3
- package/corpus/core/src/integrations/scope-store.ts +498 -0
- package/corpus/core/src/integrations/slack-manifest.ts +78 -0
- package/corpus/core/src/integrations/slack-oauth.ts +343 -0
- package/corpus/core/src/integrations/types.ts +179 -0
- package/corpus/core/src/integrations/usage-budget-store.ts +906 -0
- package/corpus/core/src/integrations/webhook-handler.ts +723 -53
- package/corpus/core/src/jobs/scheduler.ts +100 -2
- package/corpus/core/src/jobs/tools.ts +45 -9
- package/corpus/core/src/localization/default-messages.ts +28 -0
- package/corpus/core/src/mcp-client/config.ts +48 -2
- package/corpus/core/src/mcp-client/index.ts +35 -2
- package/corpus/core/src/mcp-client/tool-policy.ts +182 -0
- package/corpus/core/src/provider-api/index.ts +72 -1
- package/corpus/core/src/resources/handlers.ts +88 -14
- package/corpus/core/src/resources/script-helpers.ts +36 -7
- package/corpus/core/src/resources/store.ts +59 -52
- package/corpus/core/src/scripts/call-agent.ts +107 -1
- package/corpus/core/src/secrets/register-framework-secrets.ts +27 -4
- package/corpus/core/src/server/agent-chat-plugin.ts +356 -127
- package/corpus/core/src/server/auth.ts +10 -14
- package/corpus/core/src/server/builder-design-systems.ts +16 -1
- package/corpus/core/src/server/edge.ts +18 -0
- package/corpus/core/src/server/index.ts +42 -0
- package/corpus/core/src/server/realtime-voice.ts +590 -0
- package/corpus/core/src/server/request-context.ts +18 -0
- package/corpus/core/src/server/social-og-image.ts +3 -2
- package/corpus/core/src/shared/reasoning-effort.ts +61 -19
- package/corpus/core/src/styles/agent-conversation.css +17 -0
- package/corpus/core/src/styles/agent-native.css +62 -44
- package/corpus/core/src/templates/default/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/core/src/templates/default/AGENTS.md +7 -3
- package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +1 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/core/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +6 -3
- package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +25 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +15 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +39 -5
- package/corpus/core/src/templates/workspace-core/AGENTS.md +3 -2
- package/corpus/core/src/usage/store.ts +37 -2
- package/corpus/templates/analytics/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/analytics/.agents/skills/provider-api/SKILL.md +23 -0
- package/corpus/templates/analytics/.builder/skills/provider-api/SKILL.md +15 -0
- package/corpus/templates/analytics/actions/save-monitor.ts +25 -2
- package/corpus/templates/analytics/app/lib/data-sources.ts +28 -0
- package/corpus/templates/analytics/changelog/2026-07-10-agent-created-uptime-monitors-now-return-a-direct-link-to-th.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-dashboard-email-reports-still-arrive-when-screenshot-capture-temporarily-fails.md +6 -0
- package/corpus/templates/analytics/server/jobs/dashboard-report.ts +3 -7
- package/corpus/templates/analytics/server/lib/credential-keys.ts +12 -0
- package/corpus/templates/analytics/server/lib/dashboard-report.ts +5 -1
- package/corpus/templates/analytics/server/lib/provider-credentials.ts +2 -0
- package/corpus/templates/analytics/server/routes/api/test-connection.post.ts +16 -0
- package/corpus/templates/assets/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/brain/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/brain/app/lib/settings-navigation.ts +22 -0
- package/corpus/templates/brain/app/routes/settings.tsx +367 -252
- package/corpus/templates/brain/changelog/2026-07-10-brain-settings-now-separate-assistant-behavior-publishing-re.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-10-organization-settings-now-opens-directly-from-the-workspace-.md +6 -0
- package/corpus/templates/calendar/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/calendar/.agents/skills/event-management/SKILL.md +36 -4
- package/corpus/templates/calendar/AGENTS.md +4 -0
- package/corpus/templates/calendar/actions/create-event.ts +7 -19
- package/corpus/templates/calendar/actions/delete-event.ts +10 -3
- package/corpus/templates/calendar/actions/rsvp-event.ts +1 -1
- package/corpus/templates/calendar/actions/update-event.ts +4 -3
- package/corpus/templates/calendar/app/components/calendar/CommandPalette.tsx +98 -108
- package/corpus/templates/calendar/app/components/calendar/CreateEventDialog.tsx +100 -13
- package/corpus/templates/calendar/app/components/calendar/DayView.tsx +12 -4
- package/corpus/templates/calendar/app/components/calendar/EventAttendeesSection.tsx +97 -90
- package/corpus/templates/calendar/app/components/calendar/EventDetailPanel.tsx +3 -3
- package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +86 -8
- package/corpus/templates/calendar/app/components/calendar/EventDialog.tsx +3 -1
- package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +12 -4
- package/corpus/templates/calendar/app/hooks/use-events.ts +1 -0
- package/corpus/templates/calendar/app/lib/event-account-selection.ts +36 -0
- package/corpus/templates/calendar/app/lib/event-form-initialization.ts +21 -0
- package/corpus/templates/calendar/app/lib/event-mutation-inputs.ts +18 -0
- package/corpus/templates/calendar/app/pages/CalendarView.tsx +119 -26
- package/corpus/templates/calendar/changelog/2026-07-10-choose-which-connected-google-account-receives-a-new-event-w.md +6 -0
- package/corpus/templates/calendar/changelog/2026-07-10-event-guest-details-and-option-menus-now-use-valid-accessibl.md +6 -0
- package/corpus/templates/calendar/changelog/2026-07-10-natural-language-event-phrases-stay-available-as-quick-creat.md +6 -0
- package/corpus/templates/calendar/server/db/schema.ts +2 -0
- package/corpus/templates/calendar/server/handlers/bookings.ts +43 -6
- package/corpus/templates/calendar/server/handlers/events.ts +28 -9
- package/corpus/templates/calendar/server/lib/google-calendar.ts +66 -38
- package/corpus/templates/calendar/server/plugins/db.ts +5 -0
- package/corpus/templates/chat/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/chat/changelog/2026-07-10-chat-now-makes-ai-connection-setup-clear-without-shifting-th.md +6 -0
- package/corpus/templates/clips/.agents/skills/ai-video-tools/SKILL.md +12 -3
- package/corpus/templates/clips/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/clips/.agents/skills/meetings/SKILL.md +1 -1
- package/corpus/templates/clips/.agents/skills/recording/SKILL.md +17 -1
- package/corpus/templates/clips/.agents/skills/video-sharing/SKILL.md +8 -0
- package/corpus/templates/clips/AGENTS.md +12 -5
- package/corpus/templates/clips/actions/finalize-recording.ts +63 -23
- package/corpus/templates/clips/actions/get-recording-player-data.ts +6 -2
- package/corpus/templates/clips/actions/lib/ensure-seekable-video.ts +72 -9
- package/corpus/templates/clips/actions/list-recordings.ts +19 -3
- package/corpus/templates/clips/actions/navigate.ts +2 -0
- package/corpus/templates/clips/actions/regenerate-title.ts +53 -7
- package/corpus/templates/clips/actions/reprocess-recording.ts +20 -6
- package/corpus/templates/clips/actions/request-transcript.ts +168 -72
- package/corpus/templates/clips/actions/save-browser-transcript.ts +11 -9
- package/corpus/templates/clips/actions/view-screen.ts +57 -5
- package/corpus/templates/clips/app/components/layout/Header.tsx +1 -0
- package/corpus/templates/clips/app/components/library/empty-state.tsx +2 -0
- package/corpus/templates/clips/app/components/library/library-grid.tsx +69 -42
- package/corpus/templates/clips/app/components/library/library-layout.tsx +15 -1
- package/corpus/templates/clips/app/components/library/recording-card.tsx +81 -68
- package/corpus/templates/clips/app/components/library/search-bar.tsx +4 -3
- package/corpus/templates/clips/app/components/player/comments-panel.tsx +101 -53
- package/corpus/templates/clips/app/components/player/delete-recording-menu.tsx +9 -3
- package/corpus/templates/clips/app/components/player/playback-comment-overlay.tsx +102 -0
- package/corpus/templates/clips/app/components/player/share-dialog.tsx +1 -1
- package/corpus/templates/clips/app/components/player/video-player.tsx +10 -1
- package/corpus/templates/clips/app/hooks/use-auto-title.ts +14 -0
- package/corpus/templates/clips/app/hooks/use-library.ts +1 -1
- package/corpus/templates/clips/app/hooks/use-navigation-state.ts +10 -2
- package/corpus/templates/clips/app/i18n/ar-SA.ts +7 -1
- package/corpus/templates/clips/app/i18n/de-DE.ts +7 -1
- package/corpus/templates/clips/app/i18n/en-US.ts +7 -1
- package/corpus/templates/clips/app/i18n/es-ES.ts +7 -1
- package/corpus/templates/clips/app/i18n/fr-FR.ts +7 -1
- package/corpus/templates/clips/app/i18n/hi-IN.ts +7 -1
- package/corpus/templates/clips/app/i18n/ja-JP.ts +7 -1
- package/corpus/templates/clips/app/i18n/ko-KR.ts +7 -1
- package/corpus/templates/clips/app/i18n/pt-BR.ts +7 -1
- package/corpus/templates/clips/app/i18n/zh-CN.ts +8 -1
- package/corpus/templates/clips/app/i18n/zh-TW.ts +8 -1
- package/corpus/templates/clips/app/lib/recording-visibility.ts +70 -0
- package/corpus/templates/clips/app/routes/_app.shared.tsx +20 -0
- package/corpus/templates/clips/app/routes/download.tsx +24 -8
- package/corpus/templates/clips/app/routes/embed.$shareId.tsx +2 -0
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +115 -2
- package/corpus/templates/clips/app/routes/record.tsx +62 -0
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +25 -16
- package/corpus/templates/clips/changelog/2026-07-10-clips-desktop-is-now-available-for-linux-with-appimage-debia.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-clips-downloads-updates-sooner-in-the-background-and-offers-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-clips-shared-with-you-now-appear-in-a-searchable-shared-with.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-clips-with-missing-mobile-video-frames-can-be-repaired-witho.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-comment-replies-now-open-inline-and-focus-immediately-while-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-dismissed-upload-warnings-now-keep-recordings-in-clip-drafts.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-dragging-the-meeting-recorder-no-longer-opens-the-expanded.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-finishing-meeting-notes-no-longer-opens-your-browser.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-meeting-recordings-now-keep-microphone-audio-and-recover-tra.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-mobile-camera-recordings-pause-while-backgrounded.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-mp4-downloads-now-show-progress-immediately-after-the-option.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-recording-pages-now-open-as-soon-as-you-stop-with-a-share-li.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-recording-pause-and-resume-controls-now-respond-reliably-on-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-recordings-now-seek-smoothly-downloads-use-the-correct-file-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-s3-compatible-storage-now-saves-hosted-recordings-without-re.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-starting-and-joining-a-meeting-now-closes-the-desktop-popover.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-timestamped-comments-now-appear-over-the-video-as-playback-r.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-transcript-backed-titles-and-summaries-now-finish-after-recording.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-zoom-meetings-now-open-directly-in-the-desktop-app.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/overlay.ts +49 -7
- package/corpus/templates/clips/desktop/README.md +22 -6
- package/corpus/templates/clips/desktop/package.json +1 -1
- package/corpus/templates/clips/desktop/src/app.tsx +102 -61
- package/corpus/templates/clips/desktop/src/components/ReadinessPanel.tsx +15 -9
- package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +8 -14
- package/corpus/templates/clips/desktop/src/lib/finalization-guard.ts +22 -0
- package/corpus/templates/clips/desktop/src/lib/meeting-join-url.ts +33 -0
- package/corpus/templates/clips/desktop/src/lib/pause-transition.ts +79 -0
- package/corpus/templates/clips/desktop/src/lib/permissions.ts +3 -1
- package/corpus/templates/clips/desktop/src/lib/pill-interaction.ts +19 -0
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +187 -159
- package/corpus/templates/clips/desktop/src/lib/transcription-engine.ts +3 -2
- package/corpus/templates/clips/desktop/src/lib/updater.ts +26 -4
- package/corpus/templates/clips/desktop/src/overlays/finalizing.tsx +4 -8
- package/corpus/templates/clips/desktop/src/overlays/meeting-notification.tsx +3 -2
- package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +32 -6
- package/corpus/templates/clips/desktop/src/overlays/toolbar.tsx +50 -5
- package/corpus/templates/clips/desktop/src/styles.css +11 -19
- package/corpus/templates/clips/desktop/src-tauri/Cargo.toml +1 -1
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +2 -2
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +2 -1
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +121 -4
- package/corpus/templates/clips/desktop/src-tauri/src/native_speech.rs +97 -17
- package/corpus/templates/clips/desktop/src-tauri/src/permission_status.rs +11 -7
- package/corpus/templates/clips/desktop/src-tauri/src/whisper_speech.rs +80 -5
- package/corpus/templates/clips/desktop/src-tauri/tauri.conf.json +1 -1
- package/corpus/templates/clips/desktop/src-tauri/tauri.linux.conf.json +11 -0
- package/corpus/templates/clips/netlify.toml +3 -0
- package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +106 -0
- package/corpus/templates/clips/server/lib/public-agent-context.ts +9 -1
- package/corpus/templates/clips/server/lib/resumable-upload-provider.ts +52 -0
- package/corpus/templates/clips/server/lib/s3-upload-provider.ts +433 -85
- package/corpus/templates/clips/server/lib/video-remux.ts +114 -0
- package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +109 -0
- package/corpus/templates/clips/server/routes/api/clips-updater.json.get.ts +22 -11
- package/corpus/templates/clips/server/routes/api/public-recording.get.ts +4 -2
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/abort.post.ts +47 -5
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +10 -2
- package/corpus/templates/clips/shared/share-loader-response.ts +12 -0
- package/corpus/templates/clips/shared/transcript-status.ts +40 -0
- package/corpus/templates/clips/vitest.config.ts +23 -0
- package/corpus/templates/content/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/content/.agents/skills/content/SKILL.md +57 -5
- package/corpus/templates/content/AGENTS.md +65 -55
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +10 -16
- package/corpus/templates/content/actions/_database-source-utils.ts +58 -11
- package/corpus/templates/content/actions/_property-utils.ts +30 -2
- package/corpus/templates/content/actions/add-content-database-source-field-property.ts +312 -114
- package/corpus/templates/content/actions/submit-content-database-form.ts +497 -0
- package/corpus/templates/content/actions/update-content-database-view.ts +8 -1
- package/corpus/templates/content/actions/view-screen.ts +4 -1
- package/corpus/templates/content/agent-native.app-skill.json +1 -1
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +28 -9
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +250 -64
- package/corpus/templates/content/app/components/editor/database/FormView.tsx +460 -0
- package/corpus/templates/content/app/components/editor/database/navigation-state.ts +3 -0
- package/corpus/templates/content/app/components/editor/database/settings.tsx +30 -37
- package/corpus/templates/content/app/components/editor/database/shared.tsx +2 -0
- package/corpus/templates/content/app/components/editor/database/view-config.ts +29 -1
- package/corpus/templates/content/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/content/app/hooks/use-content-database.ts +22 -0
- package/corpus/templates/content/app/i18n/zh-TW.ts +21 -0
- package/corpus/templates/content/app/i18n-data.ts +225 -0
- package/corpus/templates/content/changelog/2026-07-10-builder-backed-properties-now-load-current-source-values-as-.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-builder-database-refreshes-now-stay-explicit-and-accurate.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-database-form-views-now-collect-ordered-required-answers-and.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-database-tables-now-use-a-quieter-more-compact-layout-with-c.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-open-documents-no-longer-make-constant-background-requests-w.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-slack-intake-routes-to-content-database-forms.md +6 -0
- package/corpus/templates/content/parity/matrix.md +1 -0
- package/corpus/templates/content/parity/matrix.ts +18 -0
- package/corpus/templates/content/shared/api.ts +27 -1
- package/corpus/templates/content/shared/database-form.ts +53 -0
- package/corpus/templates/design/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +26 -0
- package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +106 -16
- package/corpus/templates/design/AGENTS.md +79 -18
- package/corpus/templates/design/DESIGN.md +1 -1
- package/corpus/templates/design/DEVELOPING.md +1 -1
- package/corpus/templates/design/FIGMA_INTEROPERABILITY.md +116 -0
- package/corpus/templates/design/actions/create-design-from-template.ts +220 -0
- package/corpus/templates/design/actions/create-design-system.ts +92 -16
- package/corpus/templates/design/actions/delete-design-template.ts +28 -0
- package/corpus/templates/design/actions/delete-file.ts +7 -0
- package/corpus/templates/design/actions/edit-design.ts +3 -0
- package/corpus/templates/design/actions/export-design-as-figma-svg.ts +137 -5
- package/corpus/templates/design/actions/export-pdf.ts +1 -1
- package/corpus/templates/design/actions/generate-design.ts +3 -0
- package/corpus/templates/design/actions/get-design-snapshot.ts +9 -0
- package/corpus/templates/design/actions/get-figma-connection-status.ts +26 -0
- package/corpus/templates/design/actions/get-figma-design-context.ts +138 -0
- package/corpus/templates/design/actions/get-figma-styles.ts +2 -2
- package/corpus/templates/design/actions/import-figma-clipboard.ts +112 -16
- package/corpus/templates/design/actions/import-figma-frame.ts +15 -4
- package/corpus/templates/design/actions/index-design-system-with-builder.ts +4 -0
- package/corpus/templates/design/actions/list-design-templates.ts +118 -0
- package/corpus/templates/design/actions/navigate.ts +16 -2
- package/corpus/templates/design/actions/provider-api-request.ts +11 -1
- package/corpus/templates/design/actions/save-design-as-template.ts +156 -0
- package/corpus/templates/design/actions/set-active-breakpoint.ts +13 -4
- package/corpus/templates/design/actions/take-design-screenshot.ts +73 -3
- package/corpus/templates/design/actions/update-file.ts +39 -22
- package/corpus/templates/design/actions/view-screen.ts +36 -1
- package/corpus/templates/design/actions/write-local-file.ts +50 -38
- package/corpus/templates/design/app/components/design/AutoLayoutSuggestionDialog.tsx +151 -0
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +20 -0
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +383 -29
- package/corpus/templates/design/app/components/design/DesignEditorSkeleton.tsx +3 -3
- package/corpus/templates/design/app/components/design/DesignImportPanel.tsx +384 -9
- package/corpus/templates/design/app/components/design/EditPanel.tsx +105 -32
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +131 -46
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +6 -0
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +545 -54
- package/corpus/templates/design/app/components/design/bridge/embedded-wheel.bridge.ts +40 -0
- package/corpus/templates/design/app/components/design/code-workbench/CodeWorkbench.tsx +1 -0
- package/corpus/templates/design/app/components/design/code-workbench/explorer/ExplorerView.tsx +1 -0
- package/corpus/templates/design/app/components/design/code-workbench/explorer/FileTree.tsx +5 -1
- package/corpus/templates/design/app/components/design/code-workbench/workspace/create-providers.ts +2 -0
- package/corpus/templates/design/app/components/design/code-workbench/workspace/localhost-provider.ts +3 -1
- package/corpus/templates/design/app/components/design/code-workbench/workspace/types.ts +2 -0
- package/corpus/templates/design/app/components/design/edit-panel/element-identity.ts +19 -0
- package/corpus/templates/design/app/components/design/edit-panel/frame-presets-panel.tsx +1 -0
- package/corpus/templates/design/app/components/design/edit-panel/interaction-state-helpers.ts +27 -0
- package/corpus/templates/design/app/components/design/inspector/InteractionStatePanel.tsx +137 -81
- package/corpus/templates/design/app/components/design/inspector/frame-size-presets.ts +25 -5
- package/corpus/templates/design/app/components/design/multi-screen/chrome-transitions.ts +1 -1
- package/corpus/templates/design/app/components/design/multi-screen/frame-geometry.ts +350 -3
- package/corpus/templates/design/app/components/design/multi-screen/overview-layout.ts +13 -0
- package/corpus/templates/design/app/components/design/multi-screen/types.ts +22 -1
- package/corpus/templates/design/app/components/design/types.ts +4 -0
- package/corpus/templates/design/app/components/design-system/ProductionDesignSystemShowcase.tsx +208 -0
- package/corpus/templates/design/app/components/editor/FigmaLinkComposerBubble.tsx +321 -0
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +24 -4
- package/corpus/templates/design/app/components/layout/Layout.tsx +16 -2
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +2 -0
- package/corpus/templates/design/app/components/templates/TemplatePreview.tsx +72 -0
- package/corpus/templates/design/app/global.css +2 -35
- package/corpus/templates/design/app/hooks/use-navigation-state.ts +10 -0
- package/corpus/templates/design/app/i18n/zh-TW.ts +127 -5
- package/corpus/templates/design/app/i18n-breakpoints.ts +209 -0
- package/corpus/templates/design/app/i18n-data.ts +1317 -59
- package/corpus/templates/design/app/i18n-template-feature.ts +458 -0
- package/corpus/templates/design/app/lib/clipboard-content-lineage.ts +64 -0
- package/corpus/templates/design/app/lib/design-clipboard-managed-styles.ts +247 -0
- package/corpus/templates/design/app/lib/design-clipboard.ts +259 -0
- package/corpus/templates/design/app/lib/design-file-upload.ts +87 -0
- package/corpus/templates/design/app/lib/design-import.ts +198 -13
- package/corpus/templates/design/app/lib/desktop-design-preview.ts +423 -0
- package/corpus/templates/design/app/lib/figma-clipboard.ts +74 -8
- package/corpus/templates/design/app/lib/figma-connection.ts +161 -0
- package/corpus/templates/design/app/lib/figma-svg-copy.ts +814 -22
- package/corpus/templates/design/app/lib/figma-url.ts +77 -0
- package/corpus/templates/design/app/lib/pending-generation.ts +35 -0
- package/corpus/templates/design/app/pages/DesignSystems.tsx +236 -177
- package/corpus/templates/design/app/pages/Index.tsx +38 -0
- package/corpus/templates/design/app/pages/Templates.tsx +498 -0
- package/corpus/templates/design/app/pages/design-editor/auto-layout-suggestion.ts +328 -0
- package/corpus/templates/design/app/pages/design-editor/clone-idrefs.ts +113 -0
- package/corpus/templates/design/app/pages/design-editor/created-screen-navigation.ts +55 -0
- package/corpus/templates/design/app/pages/design-editor/editor-session.ts +32 -0
- package/corpus/templates/design/app/pages/design-editor/editor-state.ts +49 -2
- package/corpus/templates/design/app/pages/design-editor/export-capture.ts +296 -0
- package/corpus/templates/design/app/pages/design-editor/history.ts +101 -2
- package/corpus/templates/design/app/pages/design-editor/latest-write-queue.ts +56 -0
- package/corpus/templates/design/app/pages/design-editor/layout-operations.ts +28 -1
- package/corpus/templates/design/app/pages/design-editor/overview-camera.ts +34 -0
- package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +202 -6
- package/corpus/templates/design/app/pages/design-editor/pending-structure-verification.ts +92 -0
- package/corpus/templates/design/app/pages/design-editor/performance-buffer-guard.ts +80 -0
- package/corpus/templates/design/app/pages/design-editor/save-failure.ts +58 -0
- package/corpus/templates/design/app/routes/templates.tsx +4 -6
- package/corpus/templates/design/changelog/2026-07-10-app-workspaces-now-use-clean-borderless-main-surfaces-throug.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-ask-chat-what-s-in-a-figma-file-or-frame-structure-screensho.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-canvas-edits-now-reject-malformed-html-before-it-can-corrupt.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-complex-designs-now-export-as-valid-secure-svgs-and-crisp-ra.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-complex-figma-masks-arcs-rich-text-transformed-images-and-ad.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-concurrent-agent-and-artboard-edits-no-longer-show-misleadin.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-copied-layers-paste-across-designs-and-browser-tabs.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-copy-and-download-editable-figma-svg.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-copying-design-text-now-pastes-readable-text-into-other-apps.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-deleted-screens-can-be-restored-with-undo-and-removed-again-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-design-changes-now-save-before-switching-apps-and-retry-when.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-design-stays-usable-on-phones-by-keeping-editor-panels-and-f.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-designs-with-html-examples-inside-alpine-attributes-or-comme.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-download-all-screens-as-one-multi-page-pdf-from-the-overview.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-duplicated-layers-now-keep-labels-aria-relationships-fragmen.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-fig-import-results-stay-compact.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-figma-imports-now-load-real-fonts-fix-rotated-gradient-dashe.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-figma-links-in-chat-and-the-import-tab-now-offer-secure-one-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-fixed-cmd-z-not-restoring-content-after-an-agent-driven-desi.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-fixed-download-pdf-being-unreachable-from-the-export-panel-e.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-fixed-dragging-a-layer-out-of-an-auto-layout-row-column-no-l.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-fixed-figma-svg-export-text-wrapping-sizing-and-inner-layer.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-fixed-hiding-or-locking-one-layer-no-longer-hides-or-blocks-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-fixed-png-screenshots-of-tall-screens-being-cropped-to-one-v.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-fixed-png-svg-exports-capturing-broken-layout-when-webfonts-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-frame-tool-now-offers-standard-ad-unit-size-presets-medium-r.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-full-view-controls-stay-within-their-frame-instead-of-coveri.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-hover-focus-focus-visible-pressed-and-disabled-states-now-pr.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-interactive-designs-no-longer-appear-blank-in-the-canvas-whe.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-layer-drops-now-land-in-the-intended-grid-row-stay-visually-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-local-code-workspaces-now-keep-unsaved-edits-across-panel-sw.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-local-visual-editing-now-keeps-authenticated-sessions-shared.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-long-overview-editing-sessions-lots-of-pan-zoom-screen-switc.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-long-running-agent-work-no-longer-shows-a-premature-stuck-wa.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-managed-figma-connections-are-recognized-automatically.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-new-designs-can-open-directly-in-the-editor-without-a-pr.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-new-screens-are-selected-and-revealed-immediately.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-new-text-layers-undo-as-one-safe-creation.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-preview-and-apply-inferred-auto-layout-without-changing-yo.md +5 -0
- package/corpus/templates/design/changelog/2026-07-10-print-pdf-exports-and-paper-size-presets-letter-a4-now-match.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-rapid-breakpoint-and-edit-scope-changes-no-longer-jump-back-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-responsive-breakpoint-previews-stay-visible-while-panning-ac.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-responsive-frame-editing.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-reusable-design-templates.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-rich-design-clipboard-markers-are-now-accepted-only-from-the.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-screen-overview-frames-now-use-a-clearer-interact-action-wit.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-start-designs-from-source-linked-material-3-carbon-or-primer.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-tweaks-guidance.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-uploaded-fig-files-can-now-become-editable-design-screens-wi.md +6 -0
- package/corpus/templates/design/e2e/helpers.ts +18 -7
- package/corpus/templates/design/package.json +2 -0
- package/corpus/templates/design/scripts/qa-figma-stress-import.ts +96 -0
- package/corpus/templates/design/server/db/index.ts +10 -0
- package/corpus/templates/design/server/db/schema.ts +44 -0
- package/corpus/templates/design/server/handlers/import-design-file.ts +114 -80
- package/corpus/templates/design/server/handlers/index-design-system-with-builder.ts +19 -6
- package/corpus/templates/design/server/lib/design-export.ts +240 -3
- package/corpus/templates/design/server/lib/design-template-data.ts +89 -0
- package/corpus/templates/design/server/lib/design-to-figma-svg.ts +250 -26
- package/corpus/templates/design/server/lib/fig-file-decoder.ts +839 -0
- package/corpus/templates/design/server/lib/fig-file-import.ts +287 -0
- package/corpus/templates/design/server/lib/fig-file-limits.ts +3 -0
- package/corpus/templates/design/server/lib/fig-file-to-html.ts +2568 -0
- package/corpus/templates/design/server/lib/figma-design-context.ts +359 -0
- package/corpus/templates/design/server/lib/figma-node-import.ts +478 -22
- package/corpus/templates/design/server/lib/figma-node-to-html.ts +554 -29
- package/corpus/templates/design/server/lib/local-figma-qa-upload.ts +112 -0
- package/corpus/templates/design/server/lib/verify-write-grant.ts +16 -2
- package/corpus/templates/design/server/lib/visible-clipboard-html.ts +13 -3
- package/corpus/templates/design/server/plugins/agent-chat.ts +7 -0
- package/corpus/templates/design/server/plugins/db.ts +42 -0
- package/corpus/templates/design/server/plugins/local-figma-qa-upload.ts +7 -0
- package/corpus/templates/design/server/register-secrets.ts +8 -8
- package/corpus/templates/design/server/routes/api/qa-figma-import-assets/[assetId].get.ts +46 -0
- package/corpus/templates/design/server/source-workspace.ts +131 -13
- package/corpus/templates/design/shared/code-layer.ts +105 -28
- package/corpus/templates/design/shared/design-system-templates.ts +301 -0
- package/corpus/templates/design/shared/design-template-presets.ts +195 -0
- package/corpus/templates/design/shared/figma-url.ts +8 -0
- package/corpus/templates/design/shared/html-integrity.ts +401 -0
- package/corpus/templates/design/shared/interaction-states.ts +318 -23
- package/corpus/templates/design/shared/locked-layers.ts +151 -0
- package/corpus/templates/dispatch/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/dispatch/AGENTS.md +10 -2
- package/corpus/templates/dispatch/actions/view-screen.ts +11 -0
- package/corpus/templates/dispatch/app/hooks/use-navigation-state.ts +13 -0
- package/corpus/templates/dispatch/app/i18n/zh-TW.ts +51 -0
- package/corpus/templates/dispatch/app/i18n-data.ts +572 -1
- package/corpus/templates/dispatch/app/routes/operations.tsx +1 -0
- package/corpus/templates/dispatch/changelog/2026-07-10-connect-slack-workspaces-with-oauth-and-manage-channel-ident.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-10-dispatch-now-has-a-cleaner-chat-history-and-quieter-sidebar-.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-10-microsoft-teams-bots-and-discord-slash-commands-can-now-conn.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-10-operations-console-brings-agent-monitoring-and-database-inspection-tog.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-10-slack-and-telegram-now-route-uptime-monitor-requests-to-anal.md +6 -0
- package/corpus/templates/forms/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/forms/.agents/skills/form-publishing/SKILL.md +7 -0
- package/corpus/templates/forms/AGENTS.md +4 -0
- package/corpus/templates/forms/actions/create-form.ts +44 -7
- package/corpus/templates/forms/actions/lib/assert-publishable-form.ts +38 -0
- package/corpus/templates/forms/actions/patch-form-fields.ts +4 -0
- package/corpus/templates/forms/actions/update-form.ts +2 -36
- package/corpus/templates/forms/app/i18n/ar-SA.ts +3 -0
- package/corpus/templates/forms/app/i18n/de-DE.ts +3 -0
- package/corpus/templates/forms/app/i18n/en-US.ts +3 -0
- package/corpus/templates/forms/app/i18n/es-ES.ts +3 -0
- package/corpus/templates/forms/app/i18n/fr-FR.ts +3 -0
- package/corpus/templates/forms/app/i18n/hi-IN.ts +3 -0
- package/corpus/templates/forms/app/i18n/ja-JP.ts +3 -0
- package/corpus/templates/forms/app/i18n/ko-KR.ts +3 -0
- package/corpus/templates/forms/app/i18n/pt-BR.ts +3 -0
- package/corpus/templates/forms/app/i18n/zh-CN.ts +2 -0
- package/corpus/templates/forms/app/i18n/zh-TW.ts +3 -0
- package/corpus/templates/forms/app/pages/FormBuilderPage.tsx +17 -0
- package/corpus/templates/forms/changelog/2026-07-10-agent-created-published-forms-now-return-the-anonymous-publi.md +6 -0
- package/corpus/templates/forms/changelog/2026-07-10-published-forms-can-no-longer-be-edited-into-an-unusable-emp.md +6 -0
- package/corpus/templates/forms/server/handlers/submissions.ts +4 -3
- package/corpus/templates/forms/server/plugins/agent-chat.ts +1 -0
- package/corpus/templates/forms/shared/types.ts +5 -0
- package/corpus/templates/mail/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/mail/actions/get-integration-statuses.ts +36 -0
- package/corpus/templates/mail/app/components/email/EmailThread.tsx +3 -2
- package/corpus/templates/mail/app/components/email/IntegrationsSidebar.tsx +3 -3
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +2 -2
- package/corpus/templates/mail/app/hooks/use-apollo.ts +5 -71
- package/corpus/templates/mail/app/hooks/use-draft-queue.ts +1 -1
- package/corpus/templates/mail/app/hooks/use-integrations.ts +51 -48
- package/corpus/templates/mail/app/lib/integration-status.ts +31 -0
- package/corpus/templates/mail/app/lib/sync-invalidation.ts +5 -0
- package/corpus/templates/mail/app/pages/SettingsPage.tsx +3 -0
- package/corpus/templates/mail/app/root.tsx +22 -12
- package/corpus/templates/mail/changelog/2026-07-10-email-content-backgrounds-now-blend-cleanly-with-dark-mode.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-10-mail-navigation-now-uses-a-clean-borderless-drawer.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-10-mail-settings-now-group-drafting-automation-and-connected-se.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-10-organization-settings-now-opens-directly-from-the-workspace-.md +6 -0
- package/corpus/templates/plan/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/corpus/templates/plan/app/lib/plan-local-bridge.ts +4 -1
- package/corpus/templates/plan/changelog/2026-07-10-local-plans-now-keep-valid-content-visible-when-one-generate.md +6 -0
- package/corpus/templates/plan/server/lib/local-plan-files.ts +4 -1
- package/corpus/templates/slides/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/dist/a2a/artifact-response.d.ts.map +1 -1
- package/dist/a2a/artifact-response.js +88 -2
- package/dist/a2a/artifact-response.js.map +1 -1
- package/dist/a2a/client.d.ts +9 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +1 -0
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/handlers.d.ts.map +1 -1
- package/dist/a2a/handlers.js +24 -69
- package/dist/a2a/handlers.js.map +1 -1
- package/dist/a2a/types.d.ts +2 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/a2a/types.js.map +1 -1
- package/dist/agent/context-xray/tokenize.d.ts.map +1 -1
- package/dist/agent/context-xray/tokenize.js +6 -1
- package/dist/agent/context-xray/tokenize.js.map +1 -1
- package/dist/agent/durable-background.d.ts +11 -0
- package/dist/agent/durable-background.d.ts.map +1 -1
- package/dist/agent/durable-background.js +17 -0
- package/dist/agent/durable-background.js.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +8 -3
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
- package/dist/agent/engine/anthropic-engine.js +2 -4
- package/dist/agent/engine/anthropic-engine.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +2 -3
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/index.d.ts +1 -1
- package/dist/agent/engine/index.d.ts.map +1 -1
- package/dist/agent/engine/index.js +1 -1
- package/dist/agent/engine/index.js.map +1 -1
- package/dist/agent/engine/registry.d.ts +13 -0
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +33 -0
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/harness/ai-sdk-adapter.d.ts.map +1 -1
- package/dist/agent/harness/ai-sdk-adapter.js +3 -1
- package/dist/agent/harness/ai-sdk-adapter.js.map +1 -1
- package/dist/agent/harness/background.d.ts +9 -9
- package/dist/agent/harness/background.d.ts.map +1 -1
- package/dist/agent/harness/background.js +77 -19
- package/dist/agent/harness/background.js.map +1 -1
- package/dist/agent/harness/index.d.ts +1 -0
- package/dist/agent/harness/index.d.ts.map +1 -1
- package/dist/agent/harness/index.js +1 -0
- package/dist/agent/harness/index.js.map +1 -1
- package/dist/agent/harness/lifecycle.d.ts +45 -0
- package/dist/agent/harness/lifecycle.d.ts.map +1 -0
- package/dist/agent/harness/lifecycle.js +318 -0
- package/dist/agent/harness/lifecycle.js.map +1 -0
- package/dist/agent/harness/runner.d.ts.map +1 -1
- package/dist/agent/harness/runner.js +29 -1
- package/dist/agent/harness/runner.js.map +1 -1
- package/dist/agent/harness/store.d.ts +2 -0
- package/dist/agent/harness/store.d.ts.map +1 -1
- package/dist/agent/harness/store.js +17 -3
- package/dist/agent/harness/store.js.map +1 -1
- package/dist/agent/model-config.d.ts +2 -2
- package/dist/agent/model-config.d.ts.map +1 -1
- package/dist/agent/model-config.js +4 -1
- package/dist/agent/model-config.js.map +1 -1
- package/dist/agent/production-agent.d.ts +40 -2
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +150 -9
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-manager.d.ts +44 -2
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +90 -9
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +109 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +206 -15
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/types.d.ts +22 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/application-state/index.d.ts +1 -1
- package/dist/application-state/index.d.ts.map +1 -1
- package/dist/application-state/index.js +1 -1
- package/dist/application-state/index.js.map +1 -1
- package/dist/application-state/store.d.ts +6 -0
- package/dist/application-state/store.d.ts.map +1 -1
- package/dist/application-state/store.js +31 -0
- package/dist/application-state/store.js.map +1 -1
- package/dist/audit/record.d.ts.map +1 -1
- package/dist/audit/record.js +29 -0
- package/dist/audit/record.js.map +1 -1
- package/dist/audit/store.d.ts.map +1 -1
- package/dist/audit/store.js +62 -3
- package/dist/audit/store.js.map +1 -1
- package/dist/audit/types.d.ts +13 -0
- package/dist/audit/types.d.ts.map +1 -1
- package/dist/audit/types.js.map +1 -1
- package/dist/automation/index.d.ts +193 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +464 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/cli/code-agent-connector.d.ts +9 -0
- package/dist/cli/code-agent-connector.d.ts.map +1 -1
- package/dist/cli/code-agent-connector.js +212 -10
- package/dist/cli/code-agent-connector.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts +2 -0
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +8 -1
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +10 -3
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/design-connect.d.ts.map +1 -1
- package/dist/cli/design-connect.js +492 -35
- package/dist/cli/design-connect.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +7 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +38 -13
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +21 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +147 -49
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +17 -38
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/RunStuckBanner.d.ts +14 -1
- package/dist/client/RunStuckBanner.d.ts.map +1 -1
- package/dist/client/RunStuckBanner.js +35 -7
- package/dist/client/RunStuckBanner.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts +4 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +49 -4
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/appearance.d.ts +4 -2
- package/dist/client/appearance.d.ts.map +1 -1
- package/dist/client/appearance.js +8 -5
- package/dist/client/appearance.js.map +1 -1
- package/dist/client/automation.d.ts +14 -0
- package/dist/client/automation.d.ts.map +1 -0
- package/dist/client/automation.js +9 -0
- package/dist/client/automation.js.map +1 -0
- package/dist/client/chat/connectors.d.ts.map +1 -1
- package/dist/client/chat/connectors.js +206 -28
- package/dist/client/chat/connectors.js.map +1 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +17 -1
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/run-recovery.d.ts +4 -0
- package/dist/client/chat/run-recovery.d.ts.map +1 -1
- package/dist/client/chat/run-recovery.js +12 -10
- package/dist/client/chat/run-recovery.js.map +1 -1
- package/dist/client/chat/runtime.d.ts.map +1 -1
- package/dist/client/chat/runtime.js +84 -24
- package/dist/client/chat/runtime.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +8 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +21 -3
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +54 -0
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -0
- package/dist/client/composer/RealtimeVoiceMode.js +63 -0
- package/dist/client/composer/RealtimeVoiceMode.js.map +1 -0
- package/dist/client/composer/TiptapComposer.d.ts +1 -0
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +25 -20
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/VoiceButton.js +9 -0
- package/dist/client/composer/VoiceButton.js.map +1 -1
- package/dist/client/composer/index.d.ts +2 -0
- package/dist/client/composer/index.d.ts.map +1 -1
- package/dist/client/composer/index.js +2 -0
- package/dist/client/composer/index.js.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.d.ts +56 -0
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -0
- package/dist/client/composer/useRealtimeVoiceMode.js +492 -0
- package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -0
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +7 -2
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/integrations/api.d.ts +115 -0
- package/dist/client/integrations/api.d.ts.map +1 -0
- package/dist/client/integrations/api.js +123 -0
- package/dist/client/integrations/api.js.map +1 -0
- package/dist/client/integrations/index.d.ts +1 -0
- package/dist/client/integrations/index.d.ts.map +1 -1
- package/dist/client/integrations/index.js +1 -0
- package/dist/client/integrations/index.js.map +1 -1
- package/dist/client/settings/DemoModeSection.d.ts.map +1 -1
- package/dist/client/settings/DemoModeSection.js +4 -3
- package/dist/client/settings/DemoModeSection.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +4 -0
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/SettingsTabsPage.d.ts +10 -3
- package/dist/client/settings/SettingsTabsPage.d.ts.map +1 -1
- package/dist/client/settings/SettingsTabsPage.js +49 -11
- package/dist/client/settings/SettingsTabsPage.js.map +1 -1
- package/dist/client/transcription/use-live-transcription.d.ts.map +1 -1
- package/dist/client/transcription/use-live-transcription.js +59 -5
- package/dist/client/transcription/use-live-transcription.js.map +1 -1
- package/dist/client/use-chat-models.d.ts.map +1 -1
- package/dist/client/use-chat-models.js +6 -14
- package/dist/client/use-chat-models.js.map +1 -1
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +87 -7
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/client/use-run-stuck-detection.d.ts +16 -1
- package/dist/client/use-run-stuck-detection.d.ts.map +1 -1
- package/dist/client/use-run-stuck-detection.js +23 -4
- package/dist/client/use-run-stuck-detection.js.map +1 -1
- package/dist/code-agents/background-controller.d.ts +1 -1
- package/dist/code-agents/background-controller.d.ts.map +1 -1
- package/dist/code-agents/background-controller.js +17 -1
- package/dist/code-agents/background-controller.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/ydoc-manager.d.ts +9 -1
- package/dist/collab/ydoc-manager.d.ts.map +1 -1
- package/dist/collab/ydoc-manager.js +30 -6
- package/dist/collab/ydoc-manager.js.map +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +4 -2
- package/dist/db/migrations.js.map +1 -1
- package/dist/demo/fetch-interceptor.d.ts +5 -1
- package/dist/demo/fetch-interceptor.d.ts.map +1 -1
- package/dist/demo/fetch-interceptor.js +16 -12
- package/dist/demo/fetch-interceptor.js.map +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +49 -4
- package/dist/deploy/build.js.map +1 -1
- package/dist/deploy/workspace-deploy.d.ts.map +1 -1
- package/dist/deploy/workspace-deploy.js +31 -2
- package/dist/deploy/workspace-deploy.js.map +1 -1
- package/dist/file-upload/types.d.ts +2 -0
- package/dist/file-upload/types.d.ts.map +1 -1
- package/dist/file-upload/types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/a2a-continuations-store.d.ts.map +1 -1
- package/dist/integrations/a2a-continuations-store.js +6 -4
- package/dist/integrations/a2a-continuations-store.js.map +1 -1
- package/dist/integrations/adapters/discord.d.ts +3 -0
- package/dist/integrations/adapters/discord.d.ts.map +1 -0
- package/dist/integrations/adapters/discord.js +261 -0
- package/dist/integrations/adapters/discord.js.map +1 -0
- package/dist/integrations/adapters/index.d.ts +4 -0
- package/dist/integrations/adapters/index.d.ts.map +1 -0
- package/dist/integrations/adapters/index.js +26 -0
- package/dist/integrations/adapters/index.js.map +1 -0
- package/dist/integrations/adapters/microsoft-teams.d.ts +5 -0
- package/dist/integrations/adapters/microsoft-teams.d.ts.map +1 -0
- package/dist/integrations/adapters/microsoft-teams.js +295 -0
- package/dist/integrations/adapters/microsoft-teams.js.map +1 -0
- package/dist/integrations/adapters/slack.d.ts +10 -2
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +772 -27
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/adapters/telegram.d.ts +0 -2
- package/dist/integrations/adapters/telegram.d.ts.map +1 -1
- package/dist/integrations/adapters/telegram.js +49 -15
- package/dist/integrations/adapters/telegram.js.map +1 -1
- package/dist/integrations/adapters/whatsapp.d.ts +0 -2
- package/dist/integrations/adapters/whatsapp.d.ts.map +1 -1
- package/dist/integrations/adapters/whatsapp.js +40 -17
- package/dist/integrations/adapters/whatsapp.js.map +1 -1
- package/dist/integrations/awaiting-input-store.d.ts +27 -0
- package/dist/integrations/awaiting-input-store.d.ts.map +1 -0
- package/dist/integrations/awaiting-input-store.js +112 -0
- package/dist/integrations/awaiting-input-store.js.map +1 -0
- package/dist/integrations/catalog.d.ts +75 -0
- package/dist/integrations/catalog.d.ts.map +1 -0
- package/dist/integrations/catalog.js +451 -0
- package/dist/integrations/catalog.js.map +1 -0
- package/dist/integrations/computer-supervision-store.d.ts +65 -0
- package/dist/integrations/computer-supervision-store.d.ts.map +1 -0
- package/dist/integrations/computer-supervision-store.js +296 -0
- package/dist/integrations/computer-supervision-store.js.map +1 -0
- package/dist/integrations/computer-supervision.d.ts +11 -0
- package/dist/integrations/computer-supervision.d.ts.map +1 -0
- package/dist/integrations/computer-supervision.js +160 -0
- package/dist/integrations/computer-supervision.js.map +1 -0
- package/dist/integrations/controls-store.d.ts +44 -0
- package/dist/integrations/controls-store.d.ts.map +1 -0
- package/dist/integrations/controls-store.js +129 -0
- package/dist/integrations/controls-store.js.map +1 -0
- package/dist/integrations/index.d.ts +19 -4
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +14 -2
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/installations-store.d.ts +112 -0
- package/dist/integrations/installations-store.d.ts.map +1 -0
- package/dist/integrations/installations-store.js +493 -0
- package/dist/integrations/installations-store.js.map +1 -0
- package/dist/integrations/integration-memory.d.ts +24 -0
- package/dist/integrations/integration-memory.d.ts.map +1 -0
- package/dist/integrations/integration-memory.js +136 -0
- package/dist/integrations/integration-memory.js.map +1 -0
- package/dist/integrations/pending-tasks-retry-job.d.ts.map +1 -1
- package/dist/integrations/pending-tasks-retry-job.js +6 -5
- package/dist/integrations/pending-tasks-retry-job.js.map +1 -1
- package/dist/integrations/pending-tasks-store.d.ts +17 -0
- package/dist/integrations/pending-tasks-store.d.ts.map +1 -1
- package/dist/integrations/pending-tasks-store.js +71 -5
- package/dist/integrations/pending-tasks-store.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +725 -38
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/remote-commands-store.d.ts +15 -1
- package/dist/integrations/remote-commands-store.d.ts.map +1 -1
- package/dist/integrations/remote-commands-store.js +273 -3
- package/dist/integrations/remote-commands-store.js.map +1 -1
- package/dist/integrations/remote-devices-store.d.ts +4 -3
- package/dist/integrations/remote-devices-store.d.ts.map +1 -1
- package/dist/integrations/remote-devices-store.js +49 -2
- package/dist/integrations/remote-devices-store.js.map +1 -1
- package/dist/integrations/remote-json-safety.d.ts +6 -0
- package/dist/integrations/remote-json-safety.d.ts.map +1 -0
- package/dist/integrations/remote-json-safety.js +114 -0
- package/dist/integrations/remote-json-safety.js.map +1 -0
- package/dist/integrations/remote-run-events-store.d.ts +11 -1
- package/dist/integrations/remote-run-events-store.d.ts.map +1 -1
- package/dist/integrations/remote-run-events-store.js +85 -17
- package/dist/integrations/remote-run-events-store.js.map +1 -1
- package/dist/integrations/remote-types.d.ts +54 -3
- package/dist/integrations/remote-types.d.ts.map +1 -1
- package/dist/integrations/remote-types.js.map +1 -1
- package/dist/integrations/scope-store.d.ts +65 -0
- package/dist/integrations/scope-store.d.ts.map +1 -0
- package/dist/integrations/scope-store.js +361 -0
- package/dist/integrations/scope-store.js.map +1 -0
- package/dist/integrations/slack-manifest.d.ts +66 -0
- package/dist/integrations/slack-manifest.d.ts.map +1 -0
- package/dist/integrations/slack-manifest.js +70 -0
- package/dist/integrations/slack-manifest.js.map +1 -0
- package/dist/integrations/slack-oauth.d.ts +99 -0
- package/dist/integrations/slack-oauth.d.ts.map +1 -0
- package/dist/integrations/slack-oauth.js +226 -0
- package/dist/integrations/slack-oauth.js.map +1 -0
- package/dist/integrations/types.d.ts +144 -0
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js +16 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/integrations/usage-budget-store.d.ts +84 -0
- package/dist/integrations/usage-budget-store.d.ts.map +1 -0
- package/dist/integrations/usage-budget-store.js +650 -0
- package/dist/integrations/usage-budget-store.js.map +1 -0
- package/dist/integrations/webhook-handler.d.ts +4 -0
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +548 -51
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/jobs/scheduler.d.ts +6 -0
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +83 -4
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/jobs/tools.d.ts.map +1 -1
- package/dist/jobs/tools.js +43 -11
- package/dist/jobs/tools.js.map +1 -1
- package/dist/localization/default-messages.d.ts +26 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +26 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp-client/config.d.ts.map +1 -1
- package/dist/mcp-client/config.js +44 -3
- package/dist/mcp-client/config.js.map +1 -1
- package/dist/mcp-client/index.d.ts +6 -1
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +11 -3
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/tool-policy.d.ts +24 -0
- package/dist/mcp-client/tool-policy.d.ts.map +1 -0
- package/dist/mcp-client/tool-policy.js +139 -0
- package/dist/mcp-client/tool-policy.js.map +1 -0
- package/dist/observability/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/index.d.ts +4 -4
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +72 -1
- package/dist/provider-api/index.js.map +1 -1
- package/dist/resources/handlers.d.ts.map +1 -1
- package/dist/resources/handlers.js +57 -15
- package/dist/resources/handlers.js.map +1 -1
- package/dist/resources/script-helpers.d.ts.map +1 -1
- package/dist/resources/script-helpers.js +34 -8
- package/dist/resources/script-helpers.js.map +1 -1
- package/dist/resources/store.d.ts +10 -0
- package/dist/resources/store.d.ts.map +1 -1
- package/dist/resources/store.js +54 -47
- package/dist/resources/store.js.map +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +106 -1
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/secrets/register-framework-secrets.d.ts +3 -4
- package/dist/secrets/register-framework-secrets.d.ts.map +1 -1
- package/dist/secrets/register-framework-secrets.js +25 -4
- package/dist/secrets/register-framework-secrets.js.map +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-chat-plugin.d.ts +15 -4
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +300 -118
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +10 -14
- package/dist/server/auth.js.map +1 -1
- package/dist/server/builder-design-systems.d.ts +3 -1
- package/dist/server/builder-design-systems.d.ts.map +1 -1
- package/dist/server/builder-design-systems.js +9 -2
- package/dist/server/builder-design-systems.js.map +1 -1
- package/dist/server/edge.d.ts +1 -1
- package/dist/server/edge.d.ts.map +1 -1
- package/dist/server/edge.js +1 -1
- package/dist/server/edge.js.map +1 -1
- package/dist/server/index.d.ts +4 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/realtime-voice.d.ts +53 -0
- package/dist/server/realtime-voice.d.ts.map +1 -0
- package/dist/server/realtime-voice.js +404 -0
- package/dist/server/realtime-voice.js.map +1 -0
- package/dist/server/request-context.d.ts +18 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/social-og-image.d.ts.map +1 -1
- package/dist/server/social-og-image.js +3 -2
- package/dist/server/social-og-image.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/shared/reasoning-effort.d.ts +20 -0
- package/dist/shared/reasoning-effort.d.ts.map +1 -1
- package/dist/shared/reasoning-effort.js +52 -18
- package/dist/shared/reasoning-effort.js.map +1 -1
- package/dist/styles/agent-conversation.css +17 -0
- package/dist/styles/agent-native.css +62 -44
- package/dist/templates/default/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/dist/templates/default/AGENTS.md +7 -3
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/dist/templates/workspace-core/.agents/skills/extension-points/SKILL.md +6 -3
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +25 -0
- package/dist/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +15 -0
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +39 -5
- package/dist/templates/workspace-core/AGENTS.md +3 -2
- package/dist/usage/store.d.ts +7 -0
- package/dist/usage/store.d.ts.map +1 -1
- package/dist/usage/store.js +24 -3
- package/dist/usage/store.js.map +1 -1
- package/docs/content/a2a-protocol.mdx +21 -5
- package/docs/content/actions.mdx +9 -23
- package/docs/content/agent-mentions.mdx +31 -29
- package/docs/content/agent-native-toolkit.mdx +15 -6
- package/docs/content/agent-surfaces.mdx +9 -13
- package/docs/content/agent-teams.mdx +1 -0
- package/docs/content/authentication.mdx +10 -3
- package/docs/content/automation-connectors.mdx +123 -0
- package/docs/content/automations.mdx +17 -3
- package/docs/content/blueprint-installer.mdx +11 -4
- package/docs/content/cli-adapters.mdx +9 -6
- package/docs/content/client.mdx +16 -0
- package/docs/content/cloneable-saas.mdx +14 -11
- package/docs/content/code-agents-ui.mdx +65 -0
- package/docs/content/components.mdx +30 -14
- package/docs/content/context-awareness.mdx +27 -15
- package/docs/content/creating-templates.mdx +15 -9
- package/docs/content/cross-app-sso.mdx +16 -6
- package/docs/content/data-programs.mdx +1 -1
- package/docs/content/database.mdx +17 -5
- package/docs/content/deployment.mdx +19 -18
- package/docs/content/dispatch.mdx +6 -2
- package/docs/content/drop-in-agent.mdx +10 -4
- package/docs/content/durable-background-runs.mdx +9 -5
- package/docs/content/durable-resume.mdx +9 -4
- package/docs/content/embedding-sdk.mdx +26 -8
- package/docs/content/evals.mdx +3 -5
- package/docs/content/extensions.mdx +23 -2
- package/docs/content/external-agents.mdx +25 -34
- package/docs/content/faq.mdx +8 -0
- package/docs/content/file-uploads.mdx +12 -3
- package/docs/content/frames.mdx +16 -0
- package/docs/content/generative-ui.mdx +1 -1
- package/docs/content/getting-started.mdx +34 -21
- package/docs/content/harness-agents.mdx +8 -4
- package/docs/content/human-approval.mdx +8 -3
- package/docs/content/internationalization.mdx +9 -4
- package/docs/content/key-concepts.mdx +13 -20
- package/docs/content/local-file-mode.mdx +14 -8
- package/docs/content/locales/ar-SA/actions.mdx +2 -2
- package/docs/content/locales/ar-SA/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/ar-SA/agent-surfaces.mdx +8 -10
- package/docs/content/locales/ar-SA/agent-teams.mdx +1 -0
- package/docs/content/locales/ar-SA/authentication.mdx +1 -1
- package/docs/content/locales/ar-SA/components.mdx +11 -1
- package/docs/content/locales/ar-SA/creating-templates.mdx +3 -7
- package/docs/content/locales/ar-SA/cross-app-sso.mdx +16 -6
- package/docs/content/locales/ar-SA/deployment.mdx +8 -0
- package/docs/content/locales/ar-SA/extensions.mdx +8 -0
- package/docs/content/locales/ar-SA/external-agents.mdx +2 -7
- package/docs/content/locales/ar-SA/key-concepts.mdx +13 -20
- package/docs/content/locales/ar-SA/messaging.mdx +84 -15
- package/docs/content/locales/ar-SA/multi-tenancy.mdx +5 -5
- package/docs/content/locales/ar-SA/notifications.mdx +18 -10
- package/docs/content/locales/ar-SA/processors.mdx +11 -5
- package/docs/content/locales/ar-SA/server.mdx +17 -10
- package/docs/content/locales/ar-SA/sharing.mdx +10 -10
- package/docs/content/locales/ar-SA/skills-guide.mdx +34 -17
- package/docs/content/locales/ar-SA/template-assets.mdx +16 -13
- package/docs/content/locales/ar-SA/template-brain.mdx +3 -1
- package/docs/content/locales/ar-SA/template-clips.mdx +4 -3
- package/docs/content/locales/ar-SA/template-design.mdx +4 -1
- package/docs/content/locales/ar-SA/template-dispatch.mdx +5 -1
- package/docs/content/locales/ar-SA/template-mail.mdx +8 -0
- package/docs/content/locales/ar-SA/tracking.mdx +9 -6
- package/docs/content/locales/ar-SA/using-your-agent.mdx +0 -7
- package/docs/content/locales/ar-SA/voice-input.mdx +6 -0
- package/docs/content/locales/ar-SA/workspace-connections.mdx +9 -2
- package/docs/content/locales/ar-SA/workspace.mdx +19 -18
- package/docs/content/locales/de-DE/actions.mdx +2 -2
- package/docs/content/locales/de-DE/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/de-DE/agent-surfaces.mdx +8 -10
- package/docs/content/locales/de-DE/agent-teams.mdx +1 -0
- package/docs/content/locales/de-DE/authentication.mdx +1 -1
- package/docs/content/locales/de-DE/components.mdx +11 -1
- package/docs/content/locales/de-DE/creating-templates.mdx +3 -7
- package/docs/content/locales/de-DE/cross-app-sso.mdx +16 -6
- package/docs/content/locales/de-DE/deployment.mdx +8 -0
- package/docs/content/locales/de-DE/extensions.mdx +10 -0
- package/docs/content/locales/de-DE/external-agents.mdx +3 -7
- package/docs/content/locales/de-DE/key-concepts.mdx +13 -20
- package/docs/content/locales/de-DE/messaging.mdx +92 -15
- package/docs/content/locales/de-DE/multi-tenancy.mdx +5 -5
- package/docs/content/locales/de-DE/notifications.mdx +18 -10
- package/docs/content/locales/de-DE/processors.mdx +11 -5
- package/docs/content/locales/de-DE/server.mdx +18 -10
- package/docs/content/locales/de-DE/sharing.mdx +10 -10
- package/docs/content/locales/de-DE/skills-guide.mdx +34 -17
- package/docs/content/locales/de-DE/template-assets.mdx +16 -13
- package/docs/content/locales/de-DE/template-brain.mdx +3 -1
- package/docs/content/locales/de-DE/template-clips.mdx +4 -3
- package/docs/content/locales/de-DE/template-design.mdx +4 -1
- package/docs/content/locales/de-DE/template-dispatch.mdx +5 -1
- package/docs/content/locales/de-DE/template-mail.mdx +8 -0
- package/docs/content/locales/de-DE/tracking.mdx +9 -6
- package/docs/content/locales/de-DE/using-your-agent.mdx +0 -7
- package/docs/content/locales/de-DE/voice-input.mdx +6 -0
- package/docs/content/locales/de-DE/workspace-connections.mdx +9 -2
- package/docs/content/locales/de-DE/workspace.mdx +19 -18
- package/docs/content/locales/es-ES/actions.mdx +2 -2
- package/docs/content/locales/es-ES/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/es-ES/agent-surfaces.mdx +8 -10
- package/docs/content/locales/es-ES/agent-teams.mdx +1 -0
- package/docs/content/locales/es-ES/authentication.mdx +1 -1
- package/docs/content/locales/es-ES/components.mdx +11 -1
- package/docs/content/locales/es-ES/creating-templates.mdx +3 -7
- package/docs/content/locales/es-ES/cross-app-sso.mdx +16 -6
- package/docs/content/locales/es-ES/deployment.mdx +8 -0
- package/docs/content/locales/es-ES/extensions.mdx +10 -0
- package/docs/content/locales/es-ES/external-agents.mdx +3 -7
- package/docs/content/locales/es-ES/key-concepts.mdx +13 -20
- package/docs/content/locales/es-ES/messaging.mdx +91 -15
- package/docs/content/locales/es-ES/multi-tenancy.mdx +5 -5
- package/docs/content/locales/es-ES/notifications.mdx +18 -10
- package/docs/content/locales/es-ES/processors.mdx +11 -5
- package/docs/content/locales/es-ES/server.mdx +17 -10
- package/docs/content/locales/es-ES/sharing.mdx +10 -10
- package/docs/content/locales/es-ES/skills-guide.mdx +34 -17
- package/docs/content/locales/es-ES/template-assets.mdx +16 -13
- package/docs/content/locales/es-ES/template-brain.mdx +3 -1
- package/docs/content/locales/es-ES/template-clips.mdx +4 -3
- package/docs/content/locales/es-ES/template-design.mdx +4 -1
- package/docs/content/locales/es-ES/template-dispatch.mdx +5 -1
- package/docs/content/locales/es-ES/template-mail.mdx +8 -0
- package/docs/content/locales/es-ES/tracking.mdx +9 -6
- package/docs/content/locales/es-ES/using-your-agent.mdx +0 -7
- package/docs/content/locales/es-ES/voice-input.mdx +6 -0
- package/docs/content/locales/es-ES/workspace-connections.mdx +9 -2
- package/docs/content/locales/es-ES/workspace.mdx +19 -18
- package/docs/content/locales/fr-FR/actions.mdx +2 -2
- package/docs/content/locales/fr-FR/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/fr-FR/agent-surfaces.mdx +8 -10
- package/docs/content/locales/fr-FR/agent-teams.mdx +1 -0
- package/docs/content/locales/fr-FR/authentication.mdx +1 -1
- package/docs/content/locales/fr-FR/components.mdx +11 -1
- package/docs/content/locales/fr-FR/creating-templates.mdx +3 -7
- package/docs/content/locales/fr-FR/cross-app-sso.mdx +16 -6
- package/docs/content/locales/fr-FR/deployment.mdx +8 -0
- package/docs/content/locales/fr-FR/extensions.mdx +10 -0
- package/docs/content/locales/fr-FR/external-agents.mdx +3 -7
- package/docs/content/locales/fr-FR/key-concepts.mdx +13 -20
- package/docs/content/locales/fr-FR/messaging.mdx +91 -15
- package/docs/content/locales/fr-FR/multi-tenancy.mdx +5 -5
- package/docs/content/locales/fr-FR/notifications.mdx +18 -10
- package/docs/content/locales/fr-FR/processors.mdx +11 -5
- package/docs/content/locales/fr-FR/server.mdx +17 -10
- package/docs/content/locales/fr-FR/sharing.mdx +10 -10
- package/docs/content/locales/fr-FR/skills-guide.mdx +34 -17
- package/docs/content/locales/fr-FR/template-assets.mdx +16 -13
- package/docs/content/locales/fr-FR/template-brain.mdx +3 -1
- package/docs/content/locales/fr-FR/template-clips.mdx +4 -3
- package/docs/content/locales/fr-FR/template-design.mdx +4 -1
- package/docs/content/locales/fr-FR/template-dispatch.mdx +5 -1
- package/docs/content/locales/fr-FR/template-mail.mdx +8 -0
- package/docs/content/locales/fr-FR/tracking.mdx +9 -6
- package/docs/content/locales/fr-FR/using-your-agent.mdx +0 -7
- package/docs/content/locales/fr-FR/voice-input.mdx +6 -0
- package/docs/content/locales/fr-FR/workspace-connections.mdx +9 -2
- package/docs/content/locales/fr-FR/workspace.mdx +19 -18
- package/docs/content/locales/hi-IN/actions.mdx +2 -2
- package/docs/content/locales/hi-IN/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/hi-IN/agent-surfaces.mdx +8 -10
- package/docs/content/locales/hi-IN/agent-teams.mdx +1 -0
- package/docs/content/locales/hi-IN/authentication.mdx +1 -1
- package/docs/content/locales/hi-IN/components.mdx +11 -1
- package/docs/content/locales/hi-IN/creating-templates.mdx +3 -7
- package/docs/content/locales/hi-IN/cross-app-sso.mdx +16 -6
- package/docs/content/locales/hi-IN/deployment.mdx +8 -0
- package/docs/content/locales/hi-IN/extensions.mdx +8 -0
- package/docs/content/locales/hi-IN/external-agents.mdx +2 -7
- package/docs/content/locales/hi-IN/key-concepts.mdx +13 -20
- package/docs/content/locales/hi-IN/messaging.mdx +81 -15
- package/docs/content/locales/hi-IN/multi-tenancy.mdx +5 -5
- package/docs/content/locales/hi-IN/notifications.mdx +18 -10
- package/docs/content/locales/hi-IN/processors.mdx +11 -5
- package/docs/content/locales/hi-IN/server.mdx +17 -10
- package/docs/content/locales/hi-IN/sharing.mdx +10 -10
- package/docs/content/locales/hi-IN/skills-guide.mdx +34 -17
- package/docs/content/locales/hi-IN/template-assets.mdx +16 -13
- package/docs/content/locales/hi-IN/template-brain.mdx +3 -1
- package/docs/content/locales/hi-IN/template-clips.mdx +4 -3
- package/docs/content/locales/hi-IN/template-design.mdx +4 -1
- package/docs/content/locales/hi-IN/template-dispatch.mdx +5 -1
- package/docs/content/locales/hi-IN/template-mail.mdx +8 -0
- package/docs/content/locales/hi-IN/tracking.mdx +9 -6
- package/docs/content/locales/hi-IN/using-your-agent.mdx +0 -7
- package/docs/content/locales/hi-IN/voice-input.mdx +6 -0
- package/docs/content/locales/hi-IN/workspace-connections.mdx +9 -2
- package/docs/content/locales/hi-IN/workspace.mdx +19 -18
- package/docs/content/locales/ja-JP/actions.mdx +2 -2
- package/docs/content/locales/ja-JP/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/ja-JP/agent-surfaces.mdx +8 -10
- package/docs/content/locales/ja-JP/agent-teams.mdx +1 -0
- package/docs/content/locales/ja-JP/authentication.mdx +1 -1
- package/docs/content/locales/ja-JP/components.mdx +11 -1
- package/docs/content/locales/ja-JP/creating-templates.mdx +3 -7
- package/docs/content/locales/ja-JP/cross-app-sso.mdx +16 -6
- package/docs/content/locales/ja-JP/deployment.mdx +8 -0
- package/docs/content/locales/ja-JP/extensions.mdx +9 -0
- package/docs/content/locales/ja-JP/external-agents.mdx +2 -7
- package/docs/content/locales/ja-JP/key-concepts.mdx +13 -20
- package/docs/content/locales/ja-JP/messaging.mdx +81 -15
- package/docs/content/locales/ja-JP/multi-tenancy.mdx +5 -5
- package/docs/content/locales/ja-JP/notifications.mdx +18 -10
- package/docs/content/locales/ja-JP/processors.mdx +11 -5
- package/docs/content/locales/ja-JP/server.mdx +17 -10
- package/docs/content/locales/ja-JP/sharing.mdx +10 -10
- package/docs/content/locales/ja-JP/skills-guide.mdx +34 -17
- package/docs/content/locales/ja-JP/template-assets.mdx +16 -13
- package/docs/content/locales/ja-JP/template-brain.mdx +3 -1
- package/docs/content/locales/ja-JP/template-clips.mdx +4 -4
- package/docs/content/locales/ja-JP/template-design.mdx +4 -1
- package/docs/content/locales/ja-JP/template-dispatch.mdx +5 -1
- package/docs/content/locales/ja-JP/template-mail.mdx +8 -0
- package/docs/content/locales/ja-JP/tracking.mdx +9 -6
- package/docs/content/locales/ja-JP/using-your-agent.mdx +0 -7
- package/docs/content/locales/ja-JP/voice-input.mdx +6 -0
- package/docs/content/locales/ja-JP/workspace-connections.mdx +9 -2
- package/docs/content/locales/ja-JP/workspace.mdx +19 -18
- package/docs/content/locales/ko-KR/actions.mdx +2 -2
- package/docs/content/locales/ko-KR/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/ko-KR/agent-surfaces.mdx +8 -10
- package/docs/content/locales/ko-KR/agent-teams.mdx +1 -0
- package/docs/content/locales/ko-KR/authentication.mdx +1 -1
- package/docs/content/locales/ko-KR/components.mdx +11 -1
- package/docs/content/locales/ko-KR/creating-templates.mdx +3 -7
- package/docs/content/locales/ko-KR/cross-app-sso.mdx +16 -6
- package/docs/content/locales/ko-KR/deployment.mdx +8 -0
- package/docs/content/locales/ko-KR/extensions.mdx +8 -0
- package/docs/content/locales/ko-KR/external-agents.mdx +2 -7
- package/docs/content/locales/ko-KR/key-concepts.mdx +13 -20
- package/docs/content/locales/ko-KR/messaging.mdx +80 -15
- package/docs/content/locales/ko-KR/multi-tenancy.mdx +5 -5
- package/docs/content/locales/ko-KR/notifications.mdx +18 -10
- package/docs/content/locales/ko-KR/processors.mdx +11 -5
- package/docs/content/locales/ko-KR/server.mdx +17 -10
- package/docs/content/locales/ko-KR/sharing.mdx +10 -10
- package/docs/content/locales/ko-KR/skills-guide.mdx +34 -17
- package/docs/content/locales/ko-KR/template-assets.mdx +16 -13
- package/docs/content/locales/ko-KR/template-brain.mdx +3 -1
- package/docs/content/locales/ko-KR/template-clips.mdx +4 -4
- package/docs/content/locales/ko-KR/template-design.mdx +4 -1
- package/docs/content/locales/ko-KR/template-dispatch.mdx +5 -1
- package/docs/content/locales/ko-KR/template-mail.mdx +8 -0
- package/docs/content/locales/ko-KR/tracking.mdx +9 -6
- package/docs/content/locales/ko-KR/using-your-agent.mdx +0 -7
- package/docs/content/locales/ko-KR/voice-input.mdx +6 -0
- package/docs/content/locales/ko-KR/workspace-connections.mdx +9 -2
- package/docs/content/locales/ko-KR/workspace.mdx +19 -18
- package/docs/content/locales/pt-BR/actions.mdx +2 -2
- package/docs/content/locales/pt-BR/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/pt-BR/agent-surfaces.mdx +8 -10
- package/docs/content/locales/pt-BR/agent-teams.mdx +1 -0
- package/docs/content/locales/pt-BR/authentication.mdx +1 -1
- package/docs/content/locales/pt-BR/components.mdx +11 -1
- package/docs/content/locales/pt-BR/creating-templates.mdx +3 -7
- package/docs/content/locales/pt-BR/cross-app-sso.mdx +16 -6
- package/docs/content/locales/pt-BR/deployment.mdx +8 -0
- package/docs/content/locales/pt-BR/extensions.mdx +9 -0
- package/docs/content/locales/pt-BR/external-agents.mdx +3 -7
- package/docs/content/locales/pt-BR/key-concepts.mdx +13 -20
- package/docs/content/locales/pt-BR/messaging.mdx +88 -15
- package/docs/content/locales/pt-BR/multi-tenancy.mdx +5 -5
- package/docs/content/locales/pt-BR/notifications.mdx +18 -10
- package/docs/content/locales/pt-BR/processors.mdx +11 -5
- package/docs/content/locales/pt-BR/server.mdx +17 -10
- package/docs/content/locales/pt-BR/sharing.mdx +10 -10
- package/docs/content/locales/pt-BR/skills-guide.mdx +34 -17
- package/docs/content/locales/pt-BR/template-assets.mdx +16 -13
- package/docs/content/locales/pt-BR/template-brain.mdx +3 -1
- package/docs/content/locales/pt-BR/template-clips.mdx +4 -3
- package/docs/content/locales/pt-BR/template-design.mdx +4 -1
- package/docs/content/locales/pt-BR/template-dispatch.mdx +5 -1
- package/docs/content/locales/pt-BR/template-mail.mdx +8 -0
- package/docs/content/locales/pt-BR/tracking.mdx +9 -6
- package/docs/content/locales/pt-BR/using-your-agent.mdx +0 -7
- package/docs/content/locales/pt-BR/voice-input.mdx +6 -0
- package/docs/content/locales/pt-BR/workspace-connections.mdx +9 -2
- package/docs/content/locales/pt-BR/workspace.mdx +19 -18
- package/docs/content/locales/zh-CN/actions.mdx +2 -2
- package/docs/content/locales/zh-CN/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/zh-CN/agent-surfaces.mdx +8 -10
- package/docs/content/locales/zh-CN/agent-teams.mdx +1 -0
- package/docs/content/locales/zh-CN/authentication.mdx +1 -1
- package/docs/content/locales/zh-CN/components.mdx +11 -1
- package/docs/content/locales/zh-CN/creating-templates.mdx +3 -7
- package/docs/content/locales/zh-CN/cross-app-sso.mdx +16 -6
- package/docs/content/locales/zh-CN/deployment.mdx +8 -0
- package/docs/content/locales/zh-CN/extensions.mdx +6 -0
- package/docs/content/locales/zh-CN/external-agents.mdx +2 -7
- package/docs/content/locales/zh-CN/key-concepts.mdx +13 -20
- package/docs/content/locales/zh-CN/messaging.mdx +78 -15
- package/docs/content/locales/zh-CN/multi-tenancy.mdx +5 -5
- package/docs/content/locales/zh-CN/notifications.mdx +18 -10
- package/docs/content/locales/zh-CN/processors.mdx +11 -5
- package/docs/content/locales/zh-CN/server.mdx +16 -10
- package/docs/content/locales/zh-CN/sharing.mdx +10 -10
- package/docs/content/locales/zh-CN/skills-guide.mdx +34 -17
- package/docs/content/locales/zh-CN/template-assets.mdx +16 -13
- package/docs/content/locales/zh-CN/template-brain.mdx +3 -1
- package/docs/content/locales/zh-CN/template-clips.mdx +4 -4
- package/docs/content/locales/zh-CN/template-design.mdx +4 -1
- package/docs/content/locales/zh-CN/template-dispatch.mdx +5 -1
- package/docs/content/locales/zh-CN/template-mail.mdx +8 -0
- package/docs/content/locales/zh-CN/tracking.mdx +9 -6
- package/docs/content/locales/zh-CN/using-your-agent.mdx +0 -7
- package/docs/content/locales/zh-CN/voice-input.mdx +6 -0
- package/docs/content/locales/zh-CN/workspace-connections.mdx +9 -2
- package/docs/content/locales/zh-CN/workspace.mdx +19 -18
- package/docs/content/locales/zh-TW/actions.mdx +2 -2
- package/docs/content/locales/zh-TW/agent-native-toolkit.mdx +2 -2
- package/docs/content/locales/zh-TW/agent-surfaces.mdx +8 -10
- package/docs/content/locales/zh-TW/agent-teams.mdx +1 -0
- package/docs/content/locales/zh-TW/authentication.mdx +1 -1
- package/docs/content/locales/zh-TW/components.mdx +11 -1
- package/docs/content/locales/zh-TW/creating-templates.mdx +3 -7
- package/docs/content/locales/zh-TW/cross-app-sso.mdx +16 -6
- package/docs/content/locales/zh-TW/deployment.mdx +8 -0
- package/docs/content/locales/zh-TW/extensions.mdx +6 -0
- package/docs/content/locales/zh-TW/external-agents.mdx +2 -7
- package/docs/content/locales/zh-TW/key-concepts.mdx +13 -20
- package/docs/content/locales/zh-TW/messaging.mdx +78 -15
- package/docs/content/locales/zh-TW/multi-tenancy.mdx +5 -5
- package/docs/content/locales/zh-TW/notifications.mdx +18 -10
- package/docs/content/locales/zh-TW/processors.mdx +11 -5
- package/docs/content/locales/zh-TW/server.mdx +16 -10
- package/docs/content/locales/zh-TW/sharing.mdx +10 -10
- package/docs/content/locales/zh-TW/skills-guide.mdx +34 -17
- package/docs/content/locales/zh-TW/template-assets.mdx +16 -13
- package/docs/content/locales/zh-TW/template-brain.mdx +3 -1
- package/docs/content/locales/zh-TW/template-clips.mdx +4 -4
- package/docs/content/locales/zh-TW/template-design.mdx +4 -1
- package/docs/content/locales/zh-TW/template-dispatch.mdx +5 -1
- package/docs/content/locales/zh-TW/template-mail.mdx +8 -0
- package/docs/content/locales/zh-TW/tracking.mdx +9 -6
- package/docs/content/locales/zh-TW/using-your-agent.mdx +0 -7
- package/docs/content/locales/zh-TW/voice-input.mdx +6 -0
- package/docs/content/locales/zh-TW/workspace-connections.mdx +9 -2
- package/docs/content/locales/zh-TW/workspace.mdx +19 -18
- package/docs/content/mcp-apps.mdx +14 -32
- package/docs/content/mcp-clients.mdx +48 -54
- package/docs/content/mcp-protocol.mdx +25 -10
- package/docs/content/messaging.mdx +238 -48
- package/docs/content/multi-app-workspace.mdx +11 -96
- package/docs/content/multi-tenancy.mdx +5 -5
- package/docs/content/native-chat-ui.mdx +4 -4
- package/docs/content/notifications.mdx +19 -12
- package/docs/content/observability.mdx +2 -4
- package/docs/content/observational-memory.mdx +7 -3
- package/docs/content/onboarding.mdx +9 -2
- package/docs/content/plan-plugin.mdx +10 -2
- package/docs/content/pr-visual-recap.mdx +1 -1
- package/docs/content/processors.mdx +11 -5
- package/docs/content/pure-agent-apps.mdx +5 -1
- package/docs/content/real-time-collaboration.mdx +30 -67
- package/docs/content/recurring-jobs.mdx +8 -6
- package/docs/content/routing.mdx +3 -4
- package/docs/content/sandbox-adapters.mdx +30 -53
- package/docs/content/security.mdx +8 -0
- package/docs/content/server.mdx +17 -10
- package/docs/content/sharing.mdx +10 -10
- package/docs/content/skills-guide.mdx +35 -16
- package/docs/content/template-analytics.mdx +11 -8
- package/docs/content/template-assets.mdx +16 -13
- package/docs/content/template-brain.mdx +3 -1
- package/docs/content/template-calendar.mdx +12 -4
- package/docs/content/template-chat.mdx +4 -4
- package/docs/content/template-clips.mdx +6 -3
- package/docs/content/template-content.mdx +23 -18
- package/docs/content/template-design.mdx +7 -1
- package/docs/content/template-dispatch.mdx +5 -1
- package/docs/content/template-mail.mdx +14 -2
- package/docs/content/template-plan.mdx +22 -15
- package/docs/content/template-slides.mdx +11 -3
- package/docs/content/toolkit-agent-ux.mdx +46 -3
- package/docs/content/toolkit-collaboration.mdx +58 -4
- package/docs/content/toolkit-command-navigation.mdx +8 -2
- package/docs/content/toolkit-comments-review.mdx +10 -2
- package/docs/content/toolkit-history.mdx +8 -3
- package/docs/content/toolkit-observability.mdx +48 -2
- package/docs/content/toolkit-org-team.mdx +8 -2
- package/docs/content/toolkit-resources.mdx +45 -2
- package/docs/content/toolkit-settings.mdx +8 -2
- package/docs/content/toolkit-setup-connections.mdx +7 -2
- package/docs/content/toolkit-sharing.mdx +46 -3
- package/docs/content/toolkit-ui.mdx +82 -11
- package/docs/content/tracking.mdx +10 -8
- package/docs/content/using-your-agent.mdx +0 -12
- package/docs/content/voice-input.mdx +7 -1
- package/docs/content/what-is-agent-native.mdx +7 -8
- package/docs/content/workspace-connections.mdx +16 -23
- package/docs/content/workspace-management.mdx +16 -4
- package/docs/content/workspace.mdx +19 -18
- package/package.json +5 -1
- package/src/templates/default/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/src/templates/default/AGENTS.md +7 -3
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +1 -1
- package/src/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +22 -9
- package/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +6 -3
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +25 -0
- package/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +15 -0
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +39 -5
- package/src/templates/workspace-core/AGENTS.md +3 -2
- package/corpus/core/docs/content/locales/ar-SA/migration-workbench.mdx +0 -76
- package/corpus/core/docs/content/locales/de-DE/migration-workbench.mdx +0 -76
- package/corpus/core/docs/content/locales/es-ES/migration-workbench.mdx +0 -76
- package/corpus/core/docs/content/locales/fr-FR/migration-workbench.mdx +0 -76
- package/corpus/core/docs/content/locales/hi-IN/migration-workbench.mdx +0 -74
- package/corpus/core/docs/content/locales/ja-JP/migration-workbench.mdx +0 -76
- package/corpus/core/docs/content/locales/ko-KR/migration-workbench.mdx +0 -74
- package/corpus/core/docs/content/locales/pt-BR/migration-workbench.mdx +0 -76
- package/corpus/core/docs/content/locales/zh-CN/migration-workbench.mdx +0 -74
- package/corpus/core/docs/content/locales/zh-TW/migration-workbench.mdx +0 -74
- package/corpus/core/docs/content/migration-workbench.mdx +0 -74
- package/corpus/core/docs/content/toolkit-app-adapters.mdx +0 -55
- package/corpus/core/docs/content/toolkit-collaboration-ui.mdx +0 -60
- package/corpus/core/docs/content/toolkit-sharing-ui.mdx +0 -45
- package/corpus/core/docs/content/toolkit-shell-hooks.mdx +0 -36
- package/docs/content/locales/ar-SA/migration-workbench.mdx +0 -76
- package/docs/content/locales/de-DE/migration-workbench.mdx +0 -76
- package/docs/content/locales/es-ES/migration-workbench.mdx +0 -76
- package/docs/content/locales/fr-FR/migration-workbench.mdx +0 -76
- package/docs/content/locales/hi-IN/migration-workbench.mdx +0 -74
- package/docs/content/locales/ja-JP/migration-workbench.mdx +0 -76
- package/docs/content/locales/ko-KR/migration-workbench.mdx +0 -74
- package/docs/content/locales/pt-BR/migration-workbench.mdx +0 -76
- package/docs/content/locales/zh-CN/migration-workbench.mdx +0 -74
- package/docs/content/locales/zh-TW/migration-workbench.mdx +0 -74
- package/docs/content/migration-workbench.mdx +0 -74
- package/docs/content/toolkit-app-adapters.mdx +0 -55
- package/docs/content/toolkit-collaboration-ui.mdx +0 -60
- package/docs/content/toolkit-sharing-ui.mdx +0 -45
- package/docs/content/toolkit-shell-hooks.mdx +0 -36
|
@@ -24,6 +24,13 @@ export interface RunStuckState {
|
|
|
24
24
|
heartbeatSinceMs: number | null;
|
|
25
25
|
/** How the run was dispatched/continued, e.g. foreground-self-chain or background-processing. */
|
|
26
26
|
dispatchMode: string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Server-authoritative: true when the run holds an open tool call or A2A
|
|
29
|
+
* `agent_call` delegation (`in_flight_since` marker set). Preferred over the
|
|
30
|
+
* client-side proxy for deciding whether Retry (which aborts the run) is
|
|
31
|
+
* safe to offer. Null when the server bundle predates this field.
|
|
32
|
+
*/
|
|
33
|
+
hasInFlightWork: boolean | null;
|
|
27
34
|
}
|
|
28
35
|
export interface UseRunStuckDetectionOptions {
|
|
29
36
|
/** The thread to monitor. Pass null/undefined to disable polling. */
|
|
@@ -50,13 +57,21 @@ export interface UseRunStuckDetectionOptions {
|
|
|
50
57
|
* from the same poll response that computes the elapsed time.
|
|
51
58
|
*/
|
|
52
59
|
backgroundStuckThresholdMs?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Threshold for a claimed durable background worker that is still sending
|
|
62
|
+
* fresh process heartbeats. These workers can legitimately spend up to the
|
|
63
|
+
* 12-minute tool/no-progress window on large Design, Plan, or Assets work.
|
|
64
|
+
* Default 13 minutes, matching the durable chunk handoff boundary.
|
|
65
|
+
*/
|
|
66
|
+
liveBackgroundStuckThresholdMs?: number;
|
|
53
67
|
/** Poll interval. Default 5_000ms. */
|
|
54
68
|
pollIntervalMs?: number;
|
|
55
69
|
/** API base path. Default `/_agent-native/agent-chat`. */
|
|
56
70
|
apiUrl?: string;
|
|
57
71
|
}
|
|
58
72
|
export declare const DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS = 180000;
|
|
59
|
-
export declare
|
|
73
|
+
export declare const DEFAULT_LIVE_BACKGROUND_STUCK_THRESHOLD_MS: number;
|
|
74
|
+
export declare function useRunStuckDetection({ threadId, enabled, stuckThresholdMs, backgroundStuckThresholdMs, liveBackgroundStuckThresholdMs, pollIntervalMs, apiUrl, }: UseRunStuckDetectionOptions): RunStuckState;
|
|
60
75
|
/**
|
|
61
76
|
* POST `/runs/:id/abort` so the server flips the run to "aborted" and the
|
|
62
77
|
* adapter's reconnect loop exits cleanly. Returns the run id that was
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-run-stuck-detection.d.ts","sourceRoot":"","sources":["../../src/client/use-run-stuck-detection.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,8EAA8E;IAC9E,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,2EAA2E;IAC3E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,4EAA4E;IAC5E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,oDAAoD;IACpD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,iEAAiE;IACjE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,2EAA2E;IAC3E,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iGAAiG;IACjG,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"use-run-stuck-detection.d.ts","sourceRoot":"","sources":["../../src/client/use-run-stuck-detection.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,8EAA8E;IAC9E,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,2EAA2E;IAC3E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC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ePath } from "./api-path.js";
|
|
3
3
|
const DEFAULT_STUCK_THRESHOLD_MS = 90_000;
|
|
4
4
|
export const DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS = 180_000;
|
|
5
|
+
export const DEFAULT_LIVE_BACKGROUND_STUCK_THRESHOLD_MS = 13 * 60_000;
|
|
5
6
|
const DEFAULT_POLL_INTERVAL_MS = 5_000;
|
|
6
7
|
const IDLE_BACKOFF_INTERVAL_MS = 15_000;
|
|
8
|
+
const FRESH_BACKGROUND_HEARTBEAT_MS = 30_000;
|
|
7
9
|
const EMPTY_STATE = {
|
|
8
10
|
isStuck: false,
|
|
9
11
|
runId: null,
|
|
@@ -13,8 +15,9 @@ const EMPTY_STATE = {
|
|
|
13
15
|
heartbeatAt: null,
|
|
14
16
|
heartbeatSinceMs: null,
|
|
15
17
|
dispatchMode: null,
|
|
18
|
+
hasInFlightWork: null,
|
|
16
19
|
};
|
|
17
|
-
export function useRunStuckDetection({ threadId, enabled = true, stuckThresholdMs = DEFAULT_STUCK_THRESHOLD_MS, backgroundStuckThresholdMs = DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS, pollIntervalMs = DEFAULT_POLL_INTERVAL_MS, apiUrl, }) {
|
|
20
|
+
export function useRunStuckDetection({ threadId, enabled = true, stuckThresholdMs = DEFAULT_STUCK_THRESHOLD_MS, backgroundStuckThresholdMs = DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS, liveBackgroundStuckThresholdMs = DEFAULT_LIVE_BACKGROUND_STUCK_THRESHOLD_MS, pollIntervalMs = DEFAULT_POLL_INTERVAL_MS, apiUrl, }) {
|
|
18
21
|
const [state, setState] = useState(EMPTY_STATE);
|
|
19
22
|
useEffect(() => {
|
|
20
23
|
// Reset on every thread change so the previous thread's stuck banner
|
|
@@ -51,9 +54,21 @@ export function useRunStuckDetection({ threadId, enabled = true, stuckThresholdM
|
|
|
51
54
|
// get its chance before the user sees a "stuck" affordance.
|
|
52
55
|
const serverContinued = dispatchMode === "foreground-self-chain" ||
|
|
53
56
|
dispatchMode?.startsWith("background") === true;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
// A claimed durable worker with a fresh heartbeat can legitimately
|
|
58
|
+
// be waiting on a bounded long-running tool/sub-agent call. Showing
|
|
59
|
+
// Retry at the generic 3-minute continuation threshold aborts healthy
|
|
60
|
+
// work and starts the same call again. Let the worker's own 12-minute
|
|
61
|
+
// watchdog act first; a dead/stale heartbeat still gets the earlier
|
|
62
|
+
// background fallback below.
|
|
63
|
+
const liveBackgroundWorker = dispatchMode === "background-processing" &&
|
|
64
|
+
heartbeatSinceMs != null &&
|
|
65
|
+
heartbeatSinceMs >= 0 &&
|
|
66
|
+
heartbeatSinceMs < FRESH_BACKGROUND_HEARTBEAT_MS;
|
|
67
|
+
const effectiveThresholdMs = liveBackgroundWorker
|
|
68
|
+
? liveBackgroundStuckThresholdMs
|
|
69
|
+
: serverContinued
|
|
70
|
+
? backgroundStuckThresholdMs
|
|
71
|
+
: stuckThresholdMs;
|
|
57
72
|
const isStuck = Boolean(data.active &&
|
|
58
73
|
data.status === "running" &&
|
|
59
74
|
stuckSinceMs != null &&
|
|
@@ -67,6 +82,9 @@ export function useRunStuckDetection({ threadId, enabled = true, stuckThresholdM
|
|
|
67
82
|
heartbeatAt,
|
|
68
83
|
heartbeatSinceMs,
|
|
69
84
|
dispatchMode,
|
|
85
|
+
hasInFlightWork: typeof data.hasInFlightWork === "boolean"
|
|
86
|
+
? data.hasInFlightWork
|
|
87
|
+
: null,
|
|
70
88
|
});
|
|
71
89
|
// Back off polling when nothing is in flight — there's no point
|
|
72
90
|
// hammering the endpoint while the chat is idle. We still poll
|
|
@@ -97,6 +115,7 @@ export function useRunStuckDetection({ threadId, enabled = true, stuckThresholdM
|
|
|
97
115
|
enabled,
|
|
98
116
|
stuckThresholdMs,
|
|
99
117
|
backgroundStuckThresholdMs,
|
|
118
|
+
liveBackgroundStuckThresholdMs,
|
|
100
119
|
pollIntervalMs,
|
|
101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e;IACzC,OAAO,WAAW,CAChB,KAAK,EAAE,KAAa,EAAE,MAAM,GAAW,MAAM,EAA0B,EAAE;QACvE,MAAM,IAAI,GAAG,MAAM,IAAI,eAAe,CAAC,2BAA2B,CAAC,CAAC;QACpE,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,KAAK,CACrB,GAAG,IAAI,SAAS,kBAAkB,CAAC,KAAK,CAAC,QAAQ,EACjD;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;aACjC,CACF,CAAC;YACF,IAAI,CAAC,GAAG,CAAC,EAAE;gBAAE,OAAO,IAAI,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useState, useCallback } from \"react\";\n\nimport { agentNativePath } from \"./api-path.js\";\n\n/**\n * Per-thread chat run health, derived from the durable `last_progress_at`\n * timestamp on the server. Drives the user-visible \"this chat looks stuck\"\n * affordance — distinct from the silent reconnect logic in\n * `agent-chat-adapter.ts`, which keeps trying in the background. When\n * automatic recovery isn't making progress (for whatever reason), this\n * hook surfaces a Retry / Cancel button to the user instead of leaving\n * them staring at a frozen spinner.\n */\nexport interface RunStuckState {\n /** True when an active run hasn't emitted an event for `stuckThresholdMs`. */\n isStuck: boolean;\n /** ID of the active run, or null when nothing is in flight. */\n runId: string | null;\n /** Server-side run status (\"running\" / \"completed\" / \"errored\" / etc.). */\n status: string | null;\n /** Server timestamp (ms) of the last emitted event, or null if none yet. */\n lastProgressAt: number | null;\n /** Milliseconds since `lastProgressAt`, or null. */\n stuckSinceMs: number | null;\n /** Server timestamp (ms) of the last process-alive heartbeat. */\n heartbeatAt: number | null;\n /** Milliseconds since `heartbeatAt`, computed against the server clock. */\n heartbeatSinceMs: number | null;\n /** How the run was dispatched/continued, e.g. foreground-self-chain or background-processing. */\n dispatchMode: string | null;\n}\n\nexport interface UseRunStuckDetectionOptions {\n /** The thread to monitor. Pass null/undefined to disable polling. */\n threadId: string | null | undefined;\n /**\n * Set false to skip scheduling the poll loop entirely — used to gate\n * polling to only the active chat tab when multiple tabs are mounted\n * (inactive tabs are kept alive via display:none, not unmounted).\n * Defaults to true.\n */\n enabled?: boolean;\n /**\n * Threshold above which an in-flight FOREGROUND run is considered stuck.\n * The default sits comfortably above the adapter's 75s no-progress\n * reconnect — by then automatic recovery has already had its chance.\n */\n stuckThresholdMs?: number;\n /**\n * Threshold for BACKGROUND-dispatched runs (dispatchMode starts with\n * \"background\"). The server owns recovery for these — its run-manager\n * no-progress backstop (150s) and unclaimed-run sweep act first — so the\n * user-facing \"stuck\" affordance is a late fallback, not a race against\n * them. Selected inside the hook because the dispatch mode is only known\n * from the same poll response that computes the elapsed time.\n */\n backgroundStuckThresholdMs?: number;\n /** Poll interval. Default 5_000ms. */\n pollIntervalMs?: number;\n /** API base path. Default `/_agent-native/agent-chat`. */\n apiUrl?: string;\n}\n\nconst DEFAULT_STUCK_THRESHOLD_MS = 90_000;\nexport const DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS = 180_000;\nconst DEFAULT_POLL_INTERVAL_MS = 5_000;\nconst IDLE_BACKOFF_INTERVAL_MS = 15_000;\n\ninterface ActiveRunResponse {\n active: boolean;\n runId?: string;\n status?: string;\n heartbeatAt: number | null;\n lastProgressAt?: number | null;\n dispatchMode?: string | null;\n /** Server clock at response time, used to compute elapsed server-relative. */\n serverNow?: number;\n}\n\nconst EMPTY_STATE: RunStuckState = {\n isStuck: false,\n runId: null,\n status: null,\n lastProgressAt: null,\n stuckSinceMs: null,\n heartbeatAt: null,\n heartbeatSinceMs: null,\n dispatchMode: null,\n};\n\nexport function useRunStuckDetection({\n threadId,\n enabled = true,\n stuckThresholdMs = DEFAULT_STUCK_THRESHOLD_MS,\n backgroundStuckThresholdMs = DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS,\n pollIntervalMs = DEFAULT_POLL_INTERVAL_MS,\n apiUrl,\n}: UseRunStuckDetectionOptions): RunStuckState {\n const [state, setState] = useState<RunStuckState>(EMPTY_STATE);\n\n useEffect(() => {\n // Reset on every thread change so the previous thread's stuck banner\n // doesn't bleed onto the new one before the first poll completes.\n setState(EMPTY_STATE);\n if (!threadId || !enabled) return;\n\n const base = apiUrl ?? agentNativePath(\"/_agent-native/agent-chat\");\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n\n const poll = async () => {\n if (cancelled) return;\n let nextDelay = pollIntervalMs;\n try {\n const res = await fetch(\n `${base}/runs/active?threadId=${encodeURIComponent(threadId)}`,\n { credentials: \"same-origin\" },\n );\n if (cancelled) return;\n if (res.ok) {\n const data = (await res.json()) as ActiveRunResponse;\n const lastProgressAt = data.lastProgressAt ?? null;\n // Measure elapsed against the SERVER clock (serverNow) rather than the\n // client's Date.now(). lastProgressAt is a server timestamp, so client\n // clock skew of more than stuckThresholdMs would otherwise mark every\n // run stuck (clock ahead) or never stuck (clock behind). Fall back to\n // the client clock for older bundles that don't send serverNow.\n const nowMs = data.serverNow ?? Date.now();\n const stuckSinceMs =\n lastProgressAt != null ? nowMs - lastProgressAt : null;\n const heartbeatAt = data.heartbeatAt ?? null;\n const heartbeatSinceMs =\n heartbeatAt != null ? nowMs - heartbeatAt : null;\n const dispatchMode =\n typeof data.dispatchMode === \"string\" ? data.dispatchMode : null;\n // Server-continued runs get the wider threshold: the server's own\n // recovery (150s no-progress backstop + chained continuations) must\n // get its chance before the user sees a \"stuck\" affordance.\n const serverContinued =\n dispatchMode === \"foreground-self-chain\" ||\n dispatchMode?.startsWith(\"background\") === true;\n const effectiveThresholdMs = serverContinued\n ? backgroundStuckThresholdMs\n : stuckThresholdMs;\n const isStuck = Boolean(\n data.active &&\n data.status === \"running\" &&\n stuckSinceMs != null &&\n stuckSinceMs > effectiveThresholdMs,\n );\n setState({\n isStuck,\n runId: data.runId ?? null,\n status: data.status ?? null,\n lastProgressAt,\n stuckSinceMs,\n heartbeatAt,\n heartbeatSinceMs,\n dispatchMode,\n });\n // Back off polling when nothing is in flight — there's no point\n // hammering the endpoint while the chat is idle. We still poll\n // occasionally so a fresh run started in another tab is picked up.\n if (!data.active || data.status !== \"running\") {\n nextDelay = IDLE_BACKOFF_INTERVAL_MS;\n }\n }\n } catch {\n // Network blip — leave previous state. Next tick will retry.\n }\n if (!cancelled) {\n timer = setTimeout(poll, nextDelay);\n }\n };\n\n // Stagger the first poll so a freshly-started run isn't immediately\n // classified as stuck before the server has had a chance to record\n // any progress events.\n timer = setTimeout(poll, 2_000);\n\n return () => {\n cancelled = true;\n if (timer) clearTimeout(timer);\n };\n }, [\n threadId,\n enabled,\n stuckThresholdMs,\n backgroundStuckThresholdMs,\n pollIntervalMs,\n apiUrl,\n ]);\n\n return state;\n}\n\n/**\n * POST `/runs/:id/abort` so the server flips the run to \"aborted\" and the\n * adapter's reconnect loop exits cleanly. Returns the run id that was\n * aborted (or null on failure) so callers can correlate observability\n * events. Best-effort — failures are swallowed, since the user's intent\n * is already captured locally.\n */\nexport function useAbortRun(apiUrl?: string) {\n return useCallback(\n async (runId: string, reason: string = \"user\"): Promise<string | null> => {\n const base = apiUrl ?? agentNativePath(\"/_agent-native/agent-chat\");\n try {\n const res = await fetch(\n `${base}/runs/${encodeURIComponent(runId)}/abort`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n credentials: \"same-origin\",\n body: JSON.stringify({ reason }),\n },\n );\n if (!res.ok) return null;\n return runId;\n } catch {\n return null;\n }\n },\n [apiUrl],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-run-stuck-detection.js","sourceRoot":"","sources":["../../src/client/use-run-stuck-detection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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;QACnE,uBAAuB;QACvB,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAEhC,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,QAAQ;QACR,OAAO;QACP,gBAAgB;QAChB,0BAA0B;QAC1B,8BAA8B;QAC9B,cAAc;QACd,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,MAAe;IACzC,OAAO,WAAW,CAChB,KAAK,EAAE,KAAa,EAAE,MAAM,GAAW,MAAM,EAA0B,EAAE;QACvE,MAAM,IAAI,GAAG,MAAM,IAAI,eAAe,CAAC,2BAA2B,CAAC,CAAC;QACpE,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,KAAK,CACrB,GAAG,IAAI,SAAS,kBAAkB,CAAC,KAAK,CAAC,QAAQ,EACjD;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;aACjC,CACF,CAAC;YACF,IAAI,CAAC,GAAG,CAAC,EAAE;gBAAE,OAAO,IAAI,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useState, useCallback } from \"react\";\n\nimport { agentNativePath } from \"./api-path.js\";\n\n/**\n * Per-thread chat run health, derived from the durable `last_progress_at`\n * timestamp on the server. Drives the user-visible \"this chat looks stuck\"\n * affordance — distinct from the silent reconnect logic in\n * `agent-chat-adapter.ts`, which keeps trying in the background. When\n * automatic recovery isn't making progress (for whatever reason), this\n * hook surfaces a Retry / Cancel button to the user instead of leaving\n * them staring at a frozen spinner.\n */\nexport interface RunStuckState {\n /** True when an active run hasn't emitted an event for `stuckThresholdMs`. */\n isStuck: boolean;\n /** ID of the active run, or null when nothing is in flight. */\n runId: string | null;\n /** Server-side run status (\"running\" / \"completed\" / \"errored\" / etc.). */\n status: string | null;\n /** Server timestamp (ms) of the last emitted event, or null if none yet. */\n lastProgressAt: number | null;\n /** Milliseconds since `lastProgressAt`, or null. */\n stuckSinceMs: number | null;\n /** Server timestamp (ms) of the last process-alive heartbeat. */\n heartbeatAt: number | null;\n /** Milliseconds since `heartbeatAt`, computed against the server clock. */\n heartbeatSinceMs: number | null;\n /** How the run was dispatched/continued, e.g. foreground-self-chain or background-processing. */\n dispatchMode: string | null;\n /**\n * Server-authoritative: true when the run holds an open tool call or A2A\n * `agent_call` delegation (`in_flight_since` marker set). Preferred over the\n * client-side proxy for deciding whether Retry (which aborts the run) is\n * safe to offer. Null when the server bundle predates this field.\n */\n hasInFlightWork: boolean | null;\n}\n\nexport interface UseRunStuckDetectionOptions {\n /** The thread to monitor. Pass null/undefined to disable polling. */\n threadId: string | null | undefined;\n /**\n * Set false to skip scheduling the poll loop entirely — used to gate\n * polling to only the active chat tab when multiple tabs are mounted\n * (inactive tabs are kept alive via display:none, not unmounted).\n * Defaults to true.\n */\n enabled?: boolean;\n /**\n * Threshold above which an in-flight FOREGROUND run is considered stuck.\n * The default sits comfortably above the adapter's 75s no-progress\n * reconnect — by then automatic recovery has already had its chance.\n */\n stuckThresholdMs?: number;\n /**\n * Threshold for BACKGROUND-dispatched runs (dispatchMode starts with\n * \"background\"). The server owns recovery for these — its run-manager\n * no-progress backstop (150s) and unclaimed-run sweep act first — so the\n * user-facing \"stuck\" affordance is a late fallback, not a race against\n * them. Selected inside the hook because the dispatch mode is only known\n * from the same poll response that computes the elapsed time.\n */\n backgroundStuckThresholdMs?: number;\n /**\n * Threshold for a claimed durable background worker that is still sending\n * fresh process heartbeats. These workers can legitimately spend up to the\n * 12-minute tool/no-progress window on large Design, Plan, or Assets work.\n * Default 13 minutes, matching the durable chunk handoff boundary.\n */\n liveBackgroundStuckThresholdMs?: number;\n /** Poll interval. Default 5_000ms. */\n pollIntervalMs?: number;\n /** API base path. Default `/_agent-native/agent-chat`. */\n apiUrl?: string;\n}\n\nconst DEFAULT_STUCK_THRESHOLD_MS = 90_000;\nexport const DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS = 180_000;\nexport const DEFAULT_LIVE_BACKGROUND_STUCK_THRESHOLD_MS = 13 * 60_000;\nconst DEFAULT_POLL_INTERVAL_MS = 5_000;\nconst IDLE_BACKOFF_INTERVAL_MS = 15_000;\nconst FRESH_BACKGROUND_HEARTBEAT_MS = 30_000;\n\ninterface ActiveRunResponse {\n active: boolean;\n runId?: string;\n status?: string;\n heartbeatAt: number | null;\n lastProgressAt?: number | null;\n dispatchMode?: string | null;\n /** Server clock at response time, used to compute elapsed server-relative. */\n serverNow?: number;\n /** True when the run holds an open tool/A2A call (in_flight_since marker). */\n hasInFlightWork?: boolean;\n}\n\nconst EMPTY_STATE: RunStuckState = {\n isStuck: false,\n runId: null,\n status: null,\n lastProgressAt: null,\n stuckSinceMs: null,\n heartbeatAt: null,\n heartbeatSinceMs: null,\n dispatchMode: null,\n hasInFlightWork: null,\n};\n\nexport function useRunStuckDetection({\n threadId,\n enabled = true,\n stuckThresholdMs = DEFAULT_STUCK_THRESHOLD_MS,\n backgroundStuckThresholdMs = DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS,\n liveBackgroundStuckThresholdMs = DEFAULT_LIVE_BACKGROUND_STUCK_THRESHOLD_MS,\n pollIntervalMs = DEFAULT_POLL_INTERVAL_MS,\n apiUrl,\n}: UseRunStuckDetectionOptions): RunStuckState {\n const [state, setState] = useState<RunStuckState>(EMPTY_STATE);\n\n useEffect(() => {\n // Reset on every thread change so the previous thread's stuck banner\n // doesn't bleed onto the new one before the first poll completes.\n setState(EMPTY_STATE);\n if (!threadId || !enabled) return;\n\n const base = apiUrl ?? agentNativePath(\"/_agent-native/agent-chat\");\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n\n const poll = async () => {\n if (cancelled) return;\n let nextDelay = pollIntervalMs;\n try {\n const res = await fetch(\n `${base}/runs/active?threadId=${encodeURIComponent(threadId)}`,\n { credentials: \"same-origin\" },\n );\n if (cancelled) return;\n if (res.ok) {\n const data = (await res.json()) as ActiveRunResponse;\n const lastProgressAt = data.lastProgressAt ?? null;\n // Measure elapsed against the SERVER clock (serverNow) rather than the\n // client's Date.now(). lastProgressAt is a server timestamp, so client\n // clock skew of more than stuckThresholdMs would otherwise mark every\n // run stuck (clock ahead) or never stuck (clock behind). Fall back to\n // the client clock for older bundles that don't send serverNow.\n const nowMs = data.serverNow ?? Date.now();\n const stuckSinceMs =\n lastProgressAt != null ? nowMs - lastProgressAt : null;\n const heartbeatAt = data.heartbeatAt ?? null;\n const heartbeatSinceMs =\n heartbeatAt != null ? nowMs - heartbeatAt : null;\n const dispatchMode =\n typeof data.dispatchMode === \"string\" ? data.dispatchMode : null;\n // Server-continued runs get the wider threshold: the server's own\n // recovery (150s no-progress backstop + chained continuations) must\n // get its chance before the user sees a \"stuck\" affordance.\n const serverContinued =\n dispatchMode === \"foreground-self-chain\" ||\n dispatchMode?.startsWith(\"background\") === true;\n // A claimed durable worker with a fresh heartbeat can legitimately\n // be waiting on a bounded long-running tool/sub-agent call. Showing\n // Retry at the generic 3-minute continuation threshold aborts healthy\n // work and starts the same call again. Let the worker's own 12-minute\n // watchdog act first; a dead/stale heartbeat still gets the earlier\n // background fallback below.\n const liveBackgroundWorker =\n dispatchMode === \"background-processing\" &&\n heartbeatSinceMs != null &&\n heartbeatSinceMs >= 0 &&\n heartbeatSinceMs < FRESH_BACKGROUND_HEARTBEAT_MS;\n const effectiveThresholdMs = liveBackgroundWorker\n ? liveBackgroundStuckThresholdMs\n : serverContinued\n ? backgroundStuckThresholdMs\n : stuckThresholdMs;\n const isStuck = Boolean(\n data.active &&\n data.status === \"running\" &&\n stuckSinceMs != null &&\n stuckSinceMs > effectiveThresholdMs,\n );\n setState({\n isStuck,\n runId: data.runId ?? null,\n status: data.status ?? null,\n lastProgressAt,\n stuckSinceMs,\n heartbeatAt,\n heartbeatSinceMs,\n dispatchMode,\n hasInFlightWork:\n typeof data.hasInFlightWork === \"boolean\"\n ? data.hasInFlightWork\n : null,\n });\n // Back off polling when nothing is in flight — there's no point\n // hammering the endpoint while the chat is idle. We still poll\n // occasionally so a fresh run started in another tab is picked up.\n if (!data.active || data.status !== \"running\") {\n nextDelay = IDLE_BACKOFF_INTERVAL_MS;\n }\n }\n } catch {\n // Network blip — leave previous state. Next tick will retry.\n }\n if (!cancelled) {\n timer = setTimeout(poll, nextDelay);\n }\n };\n\n // Stagger the first poll so a freshly-started run isn't immediately\n // classified as stuck before the server has had a chance to record\n // any progress events.\n timer = setTimeout(poll, 2_000);\n\n return () => {\n cancelled = true;\n if (timer) clearTimeout(timer);\n };\n }, [\n threadId,\n enabled,\n stuckThresholdMs,\n backgroundStuckThresholdMs,\n liveBackgroundStuckThresholdMs,\n pollIntervalMs,\n apiUrl,\n ]);\n\n return state;\n}\n\n/**\n * POST `/runs/:id/abort` so the server flips the run to \"aborted\" and the\n * adapter's reconnect loop exits cleanly. Returns the run id that was\n * aborted (or null on failure) so callers can correlate observability\n * events. Best-effort — failures are swallowed, since the user's intent\n * is already captured locally.\n */\nexport function useAbortRun(apiUrl?: string) {\n return useCallback(\n async (runId: string, reason: string = \"user\"): Promise<string | null> => {\n const base = apiUrl ?? agentNativePath(\"/_agent-native/agent-chat\");\n try {\n const res = await fetch(\n `${base}/runs/${encodeURIComponent(runId)}/abort`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n credentials: \"same-origin\",\n body: JSON.stringify({ reason }),\n },\n );\n if (!res.ok) return null;\n return runId;\n } catch {\n return null;\n }\n },\n [apiUrl],\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CodeAgentFollowUpMode, type CodeAgentPermissionMode } from "../cli/code-agent-runs.js";
|
|
2
2
|
import type { ReasoningEffort } from "../shared/reasoning-effort.js";
|
|
3
3
|
import { type BackgroundAgentRun, type BackgroundAgentTranscriptEvent, type ListBackgroundAgentRunsOptions } from "./background-run.js";
|
|
4
|
-
export type BackgroundAgentControlCommand = "approve" | "resume" | "retry" | "stop";
|
|
4
|
+
export type BackgroundAgentControlCommand = "approve" | "deny" | "resume" | "retry" | "stop";
|
|
5
5
|
export interface BackgroundAgentControlInput {
|
|
6
6
|
runId: string;
|
|
7
7
|
command: BackgroundAgentControlCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-controller.d.ts","sourceRoot":"","sources":["../../src/code-agents/background-controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"background-controller.d.ts","sourceRoot":"","sources":["../../src/code-agents/background-controller.ts"],"names":[],"mappings":"AAKA,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACpC,MAAM,qBAAqB,CAAC;AAG7B,MAAM,MAAM,6BAA6B,GACrC,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,6BAA6B,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;I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4 @@
|
|
|
1
|
-
import { executeExistingCodeAgentRun, executePendingCodeAgentApproval, } from "../cli/code-agent-executor.js";
|
|
1
|
+
import { executeDenyCodeAgentApproval, executeExistingCodeAgentRun, executePendingCodeAgentApproval, } from "../cli/code-agent-executor.js";
|
|
2
2
|
import { appendCodeAgentTranscriptEvent, getCodeAgentRunRecord, isActiveCodeAgentRun, queueCodeAgentFollowUp, updateCodeAgentRunRecord, } from "../cli/code-agent-runs.js";
|
|
3
3
|
import { getBackgroundAgentRun, listBackgroundAgentRuns, listBackgroundAgentTranscriptEvents, toBackgroundAgentRun, } from "./background-run.js";
|
|
4
4
|
export function createCompositeBackgroundAgentController(controllers) {
|
|
@@ -146,6 +146,22 @@ async function controlLocalCodeBackgroundAgentRun(input) {
|
|
|
146
146
|
error: approved ? undefined : `Run not found: ${run.id}`,
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
+
case "deny": {
|
|
150
|
+
const denied = await executeDenyCodeAgentApproval(run.id, {
|
|
151
|
+
stdout: input.stdout,
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
ok: Boolean(denied),
|
|
155
|
+
runId: run.id,
|
|
156
|
+
run: denied
|
|
157
|
+
? toBackgroundAgentRun(denied)
|
|
158
|
+
: currentBackgroundRun(run.id),
|
|
159
|
+
message: denied
|
|
160
|
+
? "Pending approval denied for the Agent-Native Code run."
|
|
161
|
+
: undefined,
|
|
162
|
+
error: denied ? undefined : `Run not found: ${run.id}`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
149
165
|
case "resume":
|
|
150
166
|
case "retry": {
|
|
151
167
|
// A control action must return immediately — awaiting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-controller.js","sourceRoot":"","sources":["../../src/code-agents/background-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB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AAG,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC,CAAC,CAAC;AACR,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,GAAG,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,GAAG,CAAC,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK;QACL,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,kBAAkB,KAAK,EAAE;KACjC,CAAC;AACJ,CAAC","sourcesContent":["import {\n executeExistingCodeAgentRun,\n executePendingCodeAgentApproval,\n} from \"../cli/code-agent-executor.js\";\nimport {\n appendCodeAgentTranscriptEvent,\n getCodeAgentRunRecord,\n isActiveCodeAgentRun,\n queueCodeAgentFollowUp,\n updateCodeAgentRunRecord,\n type CodeAgentFollowUpMode,\n type CodeAgentPermissionMode,\n} from \"../cli/code-agent-runs.js\";\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport {\n getBackgroundAgentRun,\n listBackgroundAgentRuns,\n listBackgroundAgentTranscriptEvents,\n toBackgroundAgentRun,\n type BackgroundAgentRun,\n type BackgroundAgentTranscriptEvent,\n type ListBackgroundAgentRunsOptions,\n} from \"./background-run.js\";\nimport type { AgentPromptAttachment } from \"./prompt-attachments.js\";\n\nexport type BackgroundAgentControlCommand =\n | \"approve\"\n | \"resume\"\n | \"retry\"\n | \"stop\";\n\nexport interface BackgroundAgentControlInput {\n runId: string;\n command: BackgroundAgentControlCommand;\n stdout?: NodeJS.WritableStream;\n}\n\nexport interface BackgroundAgentFollowUpInput {\n runId: string;\n prompt: string;\n mode?: CodeAgentFollowUpMode;\n permissionMode?: CodeAgentPermissionMode;\n model?: string;\n reasoningEffort?: ReasoningEffort;\n source?: string;\n metadata?: Record<string, unknown>;\n stdout?: NodeJS.WritableStream;\n}\n\nexport interface BackgroundAgentControlResult {\n ok: boolean;\n runId: string;\n run: BackgroundAgentRun | null;\n queued?: boolean;\n message?: string;\n error?: string;\n}\n\nexport interface BackgroundAgentController {\n list(\n options?: ListBackgroundAgentRunsOptions,\n ): Promise<BackgroundAgentRun[]> | BackgroundAgentRun[];\n get(\n runId: string,\n ): Promise<BackgroundAgentRun | null> | BackgroundAgentRun | null;\n transcript(\n runId: string,\n ):\n | Promise<BackgroundAgentTranscriptEvent[]>\n | BackgroundAgentTranscriptEvent[];\n sendFollowUp(\n input: BackgroundAgentFollowUpInput,\n ): Promise<BackgroundAgentControlResult>;\n control(\n input: BackgroundAgentControlInput,\n ): Promise<BackgroundAgentControlResult>;\n}\n\nexport function createCompositeBackgroundAgentController(\n controllers: BackgroundAgentController[],\n): BackgroundAgentController {\n const resolveControllerForRun = async (\n runId: string,\n ): Promise<{\n controller: BackgroundAgentController;\n run: BackgroundAgentRun;\n } | null> => {\n for (const controller of controllers) {\n const run = await Promise.resolve(controller.get(runId));\n if (run) return { controller, run };\n }\n return null;\n };\n\n return {\n async list(options?: ListBackgroundAgentRunsOptions) {\n const groups = await Promise.all(\n controllers.map((controller) =>\n Promise.resolve(controller.list(options)).catch(() => []),\n ),\n );\n return groups\n .flat()\n .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));\n },\n async get(runId: string) {\n return (await resolveControllerForRun(runId))?.run ?? null;\n },\n async transcript(runId: string) {\n const match = await resolveControllerForRun(runId);\n if (!match) return [];\n return Promise.resolve(match.controller.transcript(runId));\n },\n async sendFollowUp(input: BackgroundAgentFollowUpInput) {\n const match = await resolveControllerForRun(input.runId);\n if (!match) return missingRunResult(input.runId);\n return match.controller.sendFollowUp(input);\n },\n async control(input: BackgroundAgentControlInput) {\n const match = await resolveControllerForRun(input.runId);\n if (!match) return missingRunResult(input.runId);\n return match.controller.control(input);\n },\n };\n}\n\nexport function createLocalCodeBackgroundAgentController(): BackgroundAgentController {\n return {\n list: listBackgroundAgentRuns,\n get: getBackgroundAgentRun,\n transcript: listBackgroundAgentTranscriptEvents,\n sendFollowUp: sendLocalCodeBackgroundAgentFollowUp,\n control: controlLocalCodeBackgroundAgentRun,\n };\n}\n\nexport const localCodeBackgroundAgentController =\n createLocalCodeBackgroundAgentController();\n\nasync function sendLocalCodeBackgroundAgentFollowUp(\n input: BackgroundAgentFollowUpInput,\n): Promise<BackgroundAgentControlResult> {\n const run = getCodeAgentRunRecord(input.runId);\n if (!run) {\n return missingRunResult(input.runId);\n }\n\n const prompt = input.prompt.trim();\n if (!prompt) {\n return {\n ok: false,\n runId: input.runId,\n run: toBackgroundAgentRun(run),\n error: \"Follow-up prompt is required.\",\n };\n }\n\n const activeRun = input.permissionMode\n ? (updateCodeAgentRunRecord(run.id, {\n permissionMode: input.permissionMode,\n }) ?? run)\n : run;\n const mode = input.mode ?? \"immediate\";\n const shouldQueue =\n activeRun.status === \"queued\" || isActiveCodeAgentRun(activeRun);\n const event = appendCodeAgentTranscriptEvent({\n runId: activeRun.id,\n kind: \"user\",\n message: prompt,\n metadata: {\n ...(input.metadata ?? {}),\n source: input.source ?? \"background-agent-controller\",\n permissionMode: input.permissionMode,\n followUpMode: mode,\n delivery: shouldQueue ? mode : \"run-now\",\n },\n });\n const attachments = promptAttachmentsFromMetadata(\n input.metadata?.attachments,\n );\n\n if (shouldQueue) {\n queueCodeAgentFollowUp({\n runId: activeRun.id,\n prompt,\n mode,\n eventId: event.id,\n permissionMode: input.permissionMode,\n source: input.source ?? \"background-agent-controller\",\n createdAt: event.createdAt,\n attachments,\n });\n return {\n ok: true,\n runId: activeRun.id,\n run: currentBackgroundRun(activeRun.id),\n queued: true,\n message: \"Follow-up queued for the active Agent-Native Code run.\",\n };\n }\n\n const updated = await executeExistingCodeAgentRun(activeRun.id, {\n prompt,\n appendUserEvent: false,\n model: input.model,\n reasoningEffort: input.reasoningEffort,\n attachments,\n stdout: input.stdout,\n });\n return {\n ok: Boolean(updated),\n runId: activeRun.id,\n run: updated\n ? toBackgroundAgentRun(updated)\n : currentBackgroundRun(activeRun.id),\n queued: false,\n message: updated\n ? \"Follow-up executed for the Agent-Native Code run.\"\n : undefined,\n error: updated ? undefined : `Run not found: ${activeRun.id}`,\n };\n}\n\nasync function controlLocalCodeBackgroundAgentRun(\n input: BackgroundAgentControlInput,\n): Promise<BackgroundAgentControlResult> {\n const run = getCodeAgentRunRecord(input.runId);\n if (!run) {\n return missingRunResult(input.runId);\n }\n\n switch (input.command) {\n case \"approve\": {\n const approved = await executePendingCodeAgentApproval(run.id, {\n stdout: input.stdout,\n });\n return {\n ok: Boolean(approved),\n runId: run.id,\n run: approved\n ? toBackgroundAgentRun(approved)\n : currentBackgroundRun(run.id),\n message: approved\n ? \"Pending approval executed for the Agent-Native Code run.\"\n : undefined,\n error: approved ? undefined : `Run not found: ${run.id}`,\n };\n }\n case \"resume\":\n case \"retry\": {\n // A control action must return immediately — awaiting\n // executeExistingCodeAgentRun() runs the entire code session\n // (potentially minutes), which times out the HTTP/IPC caller.\n // Kick the run off in the background; progress is surfaced via the\n // transcript/poll, exactly like the initial run start.\n void executeExistingCodeAgentRun(run.id, {\n stdout: input.stdout,\n }).catch((err) => {\n appendCodeAgentTranscriptEvent({\n runId: run.id,\n kind: \"status\",\n message: `Background ${input.command} failed: ${\n err instanceof Error ? err.message : String(err)\n }`,\n metadata: {\n source: \"background-agent-controller\",\n command: input.command,\n failed: true,\n },\n });\n });\n return {\n ok: true,\n runId: run.id,\n run: currentBackgroundRun(run.id),\n message:\n input.command === \"resume\"\n ? \"Agent-Native Code run resuming in the background.\"\n : \"Agent-Native Code run retrying in the background.\",\n };\n }\n case \"stop\":\n return stopLocalCodeBackgroundAgentRun(run.id);\n default: {\n const exhaustive: never = input.command;\n return {\n ok: false,\n runId: run.id,\n run: currentBackgroundRun(run.id),\n error: `Unsupported control command: ${String(exhaustive)}`,\n };\n }\n }\n}\n\nfunction stopLocalCodeBackgroundAgentRun(\n runId: string,\n): BackgroundAgentControlResult {\n const run = getCodeAgentRunRecord(runId);\n if (!run) {\n return missingRunResult(runId);\n }\n\n if (run.status === \"completed\" || run.status === \"errored\") {\n return {\n ok: true,\n runId,\n run: toBackgroundAgentRun(run),\n message: \"Agent-Native Code run is already finished.\",\n };\n }\n\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message:\n \"Stop requested for Agent-Native Code run. No process signal was sent.\",\n metadata: {\n source: \"background-agent-controller\",\n stoppedWithoutSignal: true,\n },\n });\n const updated = updateCodeAgentRunRecord(runId, {\n status: \"paused\",\n phase: \"stopped\",\n progress: {\n label: \"Stopped\",\n completed: 0,\n total: 1,\n percent: 0,\n },\n metadata: {\n runnerState: \"stopped\",\n stoppedAt: new Date().toISOString(),\n stoppedBy: \"background-agent-controller\",\n stopSignalSent: false,\n },\n });\n\n return {\n ok: Boolean(updated),\n runId,\n run: updated ? toBackgroundAgentRun(updated) : null,\n message: updated\n ? \"Agent-Native Code run marked stopped without signaling a process.\"\n : undefined,\n error: updated ? undefined : `Run not found: ${runId}`,\n };\n}\n\nfunction promptAttachmentsFromMetadata(\n value: unknown,\n): AgentPromptAttachment[] {\n if (!Array.isArray(value)) return [];\n return value\n .filter((item): item is Record<string, unknown> =>\n Boolean(item && typeof item === \"object\" && !Array.isArray(item)),\n )\n .map((item) => ({\n name: typeof item.name === \"string\" && item.name ? item.name : \"file\",\n ...(typeof item.type === \"string\" ? { type: item.type } : {}),\n ...(typeof item.size === \"number\" ? { size: item.size } : {}),\n ...(typeof item.text === \"string\" ? { text: item.text } : {}),\n ...(typeof item.dataUrl === \"string\" ? { dataUrl: item.dataUrl } : {}),\n }));\n}\n\nfunction currentBackgroundRun(runId: string): BackgroundAgentRun | null {\n const run = getCodeAgentRunRecord(runId);\n return run ? toBackgroundAgentRun(run) : null;\n}\n\nfunction missingRunResult(runId: string): BackgroundAgentControlResult {\n return {\n ok: false,\n runId,\n run: null,\n error: `Run not found: ${runId}`,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"background-controller.js","sourceRoot":"","sources":["../../src/code-agents/background-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,GAGzB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mCAAmC,EACnC,oBAAoB,GAIrB,MAAM,qBAAqB,CAAC;AAyD7B,MAAM,UAAU,wCAAwC,CACtD,WAAwC;IAExC,MAAM,uBAAuB,GAAG,KAAK,EACnC,KAAa,EAIL,EAAE;QACV,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YACzD,IAAI,GAAG;gBAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;QACtC,CAAC;Q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CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;QACrE,GAAG,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC,CAAC,CAAC;AACR,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,GAAG,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,GAAG,CAAC,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK;QACL,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,kBAAkB,KAAK,EAAE;KACjC,CAAC;AACJ,CAAC","sourcesContent":["import {\n executeDenyCodeAgentApproval,\n executeExistingCodeAgentRun,\n executePendingCodeAgentApproval,\n} from \"../cli/code-agent-executor.js\";\nimport {\n appendCodeAgentTranscriptEvent,\n getCodeAgentRunRecord,\n isActiveCodeAgentRun,\n queueCodeAgentFollowUp,\n updateCodeAgentRunRecord,\n type CodeAgentFollowUpMode,\n type CodeAgentPermissionMode,\n} from \"../cli/code-agent-runs.js\";\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport {\n getBackgroundAgentRun,\n listBackgroundAgentRuns,\n listBackgroundAgentTranscriptEvents,\n toBackgroundAgentRun,\n type BackgroundAgentRun,\n type BackgroundAgentTranscriptEvent,\n type ListBackgroundAgentRunsOptions,\n} from \"./background-run.js\";\nimport type { AgentPromptAttachment } from \"./prompt-attachments.js\";\n\nexport type BackgroundAgentControlCommand =\n | \"approve\"\n | \"deny\"\n | \"resume\"\n | \"retry\"\n | \"stop\";\n\nexport interface BackgroundAgentControlInput {\n runId: string;\n command: BackgroundAgentControlCommand;\n stdout?: NodeJS.WritableStream;\n}\n\nexport interface BackgroundAgentFollowUpInput {\n runId: string;\n prompt: string;\n mode?: CodeAgentFollowUpMode;\n permissionMode?: CodeAgentPermissionMode;\n model?: string;\n reasoningEffort?: ReasoningEffort;\n source?: string;\n metadata?: Record<string, unknown>;\n stdout?: NodeJS.WritableStream;\n}\n\nexport interface BackgroundAgentControlResult {\n ok: boolean;\n runId: string;\n run: BackgroundAgentRun | null;\n queued?: boolean;\n message?: string;\n error?: string;\n}\n\nexport interface BackgroundAgentController {\n list(\n options?: ListBackgroundAgentRunsOptions,\n ): Promise<BackgroundAgentRun[]> | BackgroundAgentRun[];\n get(\n runId: string,\n ): Promise<BackgroundAgentRun | null> | BackgroundAgentRun | null;\n transcript(\n runId: string,\n ):\n | Promise<BackgroundAgentTranscriptEvent[]>\n | BackgroundAgentTranscriptEvent[];\n sendFollowUp(\n input: BackgroundAgentFollowUpInput,\n ): Promise<BackgroundAgentControlResult>;\n control(\n input: BackgroundAgentControlInput,\n ): Promise<BackgroundAgentControlResult>;\n}\n\nexport function createCompositeBackgroundAgentController(\n controllers: BackgroundAgentController[],\n): BackgroundAgentController {\n const resolveControllerForRun = async (\n runId: string,\n ): Promise<{\n controller: BackgroundAgentController;\n run: BackgroundAgentRun;\n } | null> => {\n for (const controller of controllers) {\n const run = await Promise.resolve(controller.get(runId));\n if (run) return { controller, run };\n }\n return null;\n };\n\n return {\n async list(options?: ListBackgroundAgentRunsOptions) {\n const groups = await Promise.all(\n controllers.map((controller) =>\n Promise.resolve(controller.list(options)).catch(() => []),\n ),\n );\n return groups\n .flat()\n .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));\n },\n async get(runId: string) {\n return (await resolveControllerForRun(runId))?.run ?? null;\n },\n async transcript(runId: string) {\n const match = await resolveControllerForRun(runId);\n if (!match) return [];\n return Promise.resolve(match.controller.transcript(runId));\n },\n async sendFollowUp(input: BackgroundAgentFollowUpInput) {\n const match = await resolveControllerForRun(input.runId);\n if (!match) return missingRunResult(input.runId);\n return match.controller.sendFollowUp(input);\n },\n async control(input: BackgroundAgentControlInput) {\n const match = await resolveControllerForRun(input.runId);\n if (!match) return missingRunResult(input.runId);\n return match.controller.control(input);\n },\n };\n}\n\nexport function createLocalCodeBackgroundAgentController(): BackgroundAgentController {\n return {\n list: listBackgroundAgentRuns,\n get: getBackgroundAgentRun,\n transcript: listBackgroundAgentTranscriptEvents,\n sendFollowUp: sendLocalCodeBackgroundAgentFollowUp,\n control: controlLocalCodeBackgroundAgentRun,\n };\n}\n\nexport const localCodeBackgroundAgentController =\n createLocalCodeBackgroundAgentController();\n\nasync function sendLocalCodeBackgroundAgentFollowUp(\n input: BackgroundAgentFollowUpInput,\n): Promise<BackgroundAgentControlResult> {\n const run = getCodeAgentRunRecord(input.runId);\n if (!run) {\n return missingRunResult(input.runId);\n }\n\n const prompt = input.prompt.trim();\n if (!prompt) {\n return {\n ok: false,\n runId: input.runId,\n run: toBackgroundAgentRun(run),\n error: \"Follow-up prompt is required.\",\n };\n }\n\n const activeRun = input.permissionMode\n ? (updateCodeAgentRunRecord(run.id, {\n permissionMode: input.permissionMode,\n }) ?? run)\n : run;\n const mode = input.mode ?? \"immediate\";\n const shouldQueue =\n activeRun.status === \"queued\" || isActiveCodeAgentRun(activeRun);\n const event = appendCodeAgentTranscriptEvent({\n runId: activeRun.id,\n kind: \"user\",\n message: prompt,\n metadata: {\n ...(input.metadata ?? {}),\n source: input.source ?? \"background-agent-controller\",\n permissionMode: input.permissionMode,\n followUpMode: mode,\n delivery: shouldQueue ? mode : \"run-now\",\n },\n });\n const attachments = promptAttachmentsFromMetadata(\n input.metadata?.attachments,\n );\n\n if (shouldQueue) {\n queueCodeAgentFollowUp({\n runId: activeRun.id,\n prompt,\n mode,\n eventId: event.id,\n permissionMode: input.permissionMode,\n source: input.source ?? \"background-agent-controller\",\n createdAt: event.createdAt,\n attachments,\n });\n return {\n ok: true,\n runId: activeRun.id,\n run: currentBackgroundRun(activeRun.id),\n queued: true,\n message: \"Follow-up queued for the active Agent-Native Code run.\",\n };\n }\n\n const updated = await executeExistingCodeAgentRun(activeRun.id, {\n prompt,\n appendUserEvent: false,\n model: input.model,\n reasoningEffort: input.reasoningEffort,\n attachments,\n stdout: input.stdout,\n });\n return {\n ok: Boolean(updated),\n runId: activeRun.id,\n run: updated\n ? toBackgroundAgentRun(updated)\n : currentBackgroundRun(activeRun.id),\n queued: false,\n message: updated\n ? \"Follow-up executed for the Agent-Native Code run.\"\n : undefined,\n error: updated ? undefined : `Run not found: ${activeRun.id}`,\n };\n}\n\nasync function controlLocalCodeBackgroundAgentRun(\n input: BackgroundAgentControlInput,\n): Promise<BackgroundAgentControlResult> {\n const run = getCodeAgentRunRecord(input.runId);\n if (!run) {\n return missingRunResult(input.runId);\n }\n\n switch (input.command) {\n case \"approve\": {\n const approved = await executePendingCodeAgentApproval(run.id, {\n stdout: input.stdout,\n });\n return {\n ok: Boolean(approved),\n runId: run.id,\n run: approved\n ? toBackgroundAgentRun(approved)\n : currentBackgroundRun(run.id),\n message: approved\n ? \"Pending approval executed for the Agent-Native Code run.\"\n : undefined,\n error: approved ? undefined : `Run not found: ${run.id}`,\n };\n }\n case \"deny\": {\n const denied = await executeDenyCodeAgentApproval(run.id, {\n stdout: input.stdout,\n });\n return {\n ok: Boolean(denied),\n runId: run.id,\n run: denied\n ? toBackgroundAgentRun(denied)\n : currentBackgroundRun(run.id),\n message: denied\n ? \"Pending approval denied for the Agent-Native Code run.\"\n : undefined,\n error: denied ? undefined : `Run not found: ${run.id}`,\n };\n }\n case \"resume\":\n case \"retry\": {\n // A control action must return immediately — awaiting\n // executeExistingCodeAgentRun() runs the entire code session\n // (potentially minutes), which times out the HTTP/IPC caller.\n // Kick the run off in the background; progress is surfaced via the\n // transcript/poll, exactly like the initial run start.\n void executeExistingCodeAgentRun(run.id, {\n stdout: input.stdout,\n }).catch((err) => {\n appendCodeAgentTranscriptEvent({\n runId: run.id,\n kind: \"status\",\n message: `Background ${input.command} failed: ${\n err instanceof Error ? err.message : String(err)\n }`,\n metadata: {\n source: \"background-agent-controller\",\n command: input.command,\n failed: true,\n },\n });\n });\n return {\n ok: true,\n runId: run.id,\n run: currentBackgroundRun(run.id),\n message:\n input.command === \"resume\"\n ? \"Agent-Native Code run resuming in the background.\"\n : \"Agent-Native Code run retrying in the background.\",\n };\n }\n case \"stop\":\n return stopLocalCodeBackgroundAgentRun(run.id);\n default: {\n const exhaustive: never = input.command;\n return {\n ok: false,\n runId: run.id,\n run: currentBackgroundRun(run.id),\n error: `Unsupported control command: ${String(exhaustive)}`,\n };\n }\n }\n}\n\nfunction stopLocalCodeBackgroundAgentRun(\n runId: string,\n): BackgroundAgentControlResult {\n const run = getCodeAgentRunRecord(runId);\n if (!run) {\n return missingRunResult(runId);\n }\n\n if (run.status === \"completed\" || run.status === \"errored\") {\n return {\n ok: true,\n runId,\n run: toBackgroundAgentRun(run),\n message: \"Agent-Native Code run is already finished.\",\n };\n }\n\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message:\n \"Stop requested for Agent-Native Code run. No process signal was sent.\",\n metadata: {\n source: \"background-agent-controller\",\n stoppedWithoutSignal: true,\n },\n });\n const updated = updateCodeAgentRunRecord(runId, {\n status: \"paused\",\n phase: \"stopped\",\n progress: {\n label: \"Stopped\",\n completed: 0,\n total: 1,\n percent: 0,\n },\n metadata: {\n runnerState: \"stopped\",\n stoppedAt: new Date().toISOString(),\n stoppedBy: \"background-agent-controller\",\n stopSignalSent: false,\n },\n });\n\n return {\n ok: Boolean(updated),\n runId,\n run: updated ? toBackgroundAgentRun(updated) : null,\n message: updated\n ? \"Agent-Native Code run marked stopped without signaling a process.\"\n : undefined,\n error: updated ? undefined : `Run not found: ${runId}`,\n };\n}\n\nfunction promptAttachmentsFromMetadata(\n value: unknown,\n): AgentPromptAttachment[] {\n if (!Array.isArray(value)) return [];\n return value\n .filter((item): item is Record<string, unknown> =>\n Boolean(item && typeof item === \"object\" && !Array.isArray(item)),\n )\n .map((item) => ({\n name: typeof item.name === \"string\" && item.name ? item.name : \"file\",\n ...(typeof item.type === \"string\" ? { type: item.type } : {}),\n ...(typeof item.size === \"number\" ? { size: item.size } : {}),\n ...(typeof item.text === \"string\" ? { text: item.text } : {}),\n ...(typeof item.dataUrl === \"string\" ? { dataUrl: item.dataUrl } : {}),\n }));\n}\n\nfunction currentBackgroundRun(runId: string): BackgroundAgentRun | null {\n const run = getCodeAgentRunRecord(runId);\n return run ? toBackgroundAgentRun(run) : null;\n}\n\nfunction missingRunResult(runId: string): BackgroundAgentControlResult {\n return {\n ok: false,\n runId,\n run: null,\n error: `Run not found: ${runId}`,\n };\n}\n"]}
|
package/dist/collab/routes.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare const getCollabState: import("h3").EventHandlerWithFetch<import("
|
|
|
26
26
|
* Body: { update: string (base64), requestSource?: string }
|
|
27
27
|
*/
|
|
28
28
|
export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
29
|
-
error: string;
|
|
30
29
|
ok?: undefined;
|
|
30
|
+
error: string;
|
|
31
31
|
} | {
|
|
32
32
|
error?: undefined;
|
|
33
33
|
ok: boolean;
|
|
@@ -41,7 +41,15 @@ export declare function applyUpdate(docId: string, update: Uint8Array, requestSo
|
|
|
41
41
|
*
|
|
42
42
|
* Returns the text snapshot after the update.
|
|
43
43
|
*/
|
|
44
|
-
export declare function applyText(docId: string, newText: string, fieldName?: string, requestSource?: string
|
|
44
|
+
export declare function applyText(docId: string, newText: string, fieldName?: string, requestSource?: string, options?: {
|
|
45
|
+
/**
|
|
46
|
+
* Validate the fully converged text after cross-process Yjs updates have
|
|
47
|
+
* merged, but before the state is persisted or broadcast. A rejected
|
|
48
|
+
* candidate is discarded from this process's cache so the next read
|
|
49
|
+
* reloads the last durable state instead of leaking an uncommitted merge.
|
|
50
|
+
*/
|
|
51
|
+
validateSnapshot?: (snapshot: string) => void;
|
|
52
|
+
}): Promise<string>;
|
|
45
53
|
/**
|
|
46
54
|
* Search-and-replace text within a Y.XmlFragment (ProseMirror tree).
|
|
47
55
|
* Produces minimal Yjs operations for cursor-preserving updates.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ydoc-manager.d.ts","sourceRoot":"","sources":["../../src/collab/ydoc-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,OAAO,EAKL,KAAK,OAAO,EACb,MAAM,kBAAkB,CAAC;AAmC1B;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAqBnD;
|
|
1
|
+
{"version":3,"file":"ydoc-manager.d.ts","sourceRoot":"","sources":["../../src/collab/ydoc-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,OAAO,EAKL,KAAK,OAAO,EACb,MAAM,kBAAkB,CAAC;A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AK,EAAE,MAAM,EACb,iBAAiB,EAAE,UAAU,GAC5B,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,MAAsB,GAChC,OAAO,CAAC,IAAI,CAAC,CAYf;AAID;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,GAAG,EACZ,SAAS,GAAE,MAAe,EAC1B,KAAK,GAAE,KAAK,GAAG,OAAe,EAC9B,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,OAAO,EAAE,EACd,SAAS,GAAE,MAAe,EAC1B,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED;;GAEG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,MAAe,GACzB,OAAO,CAAC,GAAG,CAAC,CAGd;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,GAAG,EACT,SAAS,GAAE,MAAe,EAC1B,IAAI,GAAE,KAAK,GAAG,OAAe,GAC5B,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAM9C"}
|
|
@@ -137,7 +137,7 @@ function buildStateToStore(doc, storedByteCount) {
|
|
|
137
137
|
* from OTHER processes. Within this process, the in-memory doc is already
|
|
138
138
|
* up-to-date because mutations are serialized by withDocWriteLock.
|
|
139
139
|
*/
|
|
140
|
-
async function persistMergedState(docId, doc, getTextSnapshot) {
|
|
140
|
+
async function persistMergedState(docId, doc, getTextSnapshot, validateTextSnapshot) {
|
|
141
141
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
142
142
|
// One DB read per persist attempt. On first attempt this is the only read
|
|
143
143
|
// on the write path (previously there was an unconditional second read
|
|
@@ -148,12 +148,16 @@ async function persistMergedState(docId, doc, getTextSnapshot) {
|
|
|
148
148
|
Y.applyUpdate(doc, latest.state);
|
|
149
149
|
}
|
|
150
150
|
const stateToStore = buildStateToStore(doc, latest?.state?.length ?? 0);
|
|
151
|
-
const
|
|
151
|
+
const textSnapshot = getTextSnapshot();
|
|
152
|
+
validateTextSnapshot?.(textSnapshot);
|
|
153
|
+
const saved = await trySaveYDocState(docId, stateToStore, textSnapshot, latest?.version ?? null);
|
|
152
154
|
if (saved)
|
|
153
155
|
return;
|
|
154
156
|
}
|
|
155
157
|
// All CAS attempts failed — fall back to unconditional save.
|
|
156
|
-
|
|
158
|
+
const textSnapshot = getTextSnapshot();
|
|
159
|
+
validateTextSnapshot?.(textSnapshot);
|
|
160
|
+
await saveYDocState(docId, Y.encodeStateAsUpdate(doc), textSnapshot);
|
|
157
161
|
}
|
|
158
162
|
/**
|
|
159
163
|
* Get or load a Yjs document by ID. Creates a new empty doc if none exists.
|
|
@@ -213,15 +217,35 @@ export async function applyUpdate(docId, update, requestSource) {
|
|
|
213
217
|
*
|
|
214
218
|
* Returns the text snapshot after the update.
|
|
215
219
|
*/
|
|
216
|
-
export async function applyText(docId, newText, fieldName = DEFAULT_FIELD, requestSource) {
|
|
220
|
+
export async function applyText(docId, newText, fieldName = DEFAULT_FIELD, requestSource, options = {}) {
|
|
217
221
|
return withDocWriteLock(docId, async () => {
|
|
218
222
|
const doc = await getDoc(docId);
|
|
219
223
|
const oldText = doc.getText(fieldName).toString();
|
|
220
224
|
const update = applyTextToYDoc(doc, fieldName, newText, "server");
|
|
221
225
|
if (update.length === 0) {
|
|
222
|
-
|
|
226
|
+
const snapshot = doc.getText(fieldName).toString();
|
|
227
|
+
try {
|
|
228
|
+
options.validateSnapshot?.(snapshot);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
releaseDoc(docId);
|
|
232
|
+
throw error;
|
|
233
|
+
}
|
|
234
|
+
return snapshot;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
await persistMergedState(docId, doc, () => doc.getText(fieldName).toString(), options.validateSnapshot);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (options.validateSnapshot) {
|
|
241
|
+
// The target diff and any cross-process state merged during the CAS
|
|
242
|
+
// read now live only in this cached Y.Doc. Destroy it before throwing:
|
|
243
|
+
// neither the rejected update nor a compensating rollback should ever
|
|
244
|
+
// be persisted/emitted to connected clients.
|
|
245
|
+
releaseDoc(docId);
|
|
246
|
+
}
|
|
247
|
+
throw error;
|
|
223
248
|
}
|
|
224
|
-
await persistMergedState(docId, doc, () => doc.getText(fieldName).toString());
|
|
225
249
|
emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);
|
|
226
250
|
touchAgentPresence(docId, requestSource, {
|
|
227
251
|
descriptor: computeTextEditDescriptor(oldText, newText),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ydoc-manager.js","sourceRoot":"","sources":["../../src/collab/ydoc-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,aAAa,EACb,cAAc,EACd,UAAU,EACV,gBAAgB,GAEjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAA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AE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAExD,gBAAgB;QAChB,aAAa,EAAE,CAAC;QAChB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Server-side Yjs document manager with LRU caching and SQL persistence.\n *\n * Performance notes:\n * - `getDoc()` loads from the DB once on cache miss; subsequent calls return\n * the cached Y.Doc directly with no DB I/O.\n * - Mutations no longer call `applyStoredState()` unconditionally on every\n * write. The defensive re-read from the DB happens only inside\n * `persistMergedState` (needed for the CAS version read), not as a\n * separate SELECT before applying the new update. This removes the\n * redundant double-read that the previous implementation performed on\n * every write even on a hot cache.\n * - Compaction: when the stored blob is >4x the freshly encoded state, the\n * GC'd encoding is stored instead (removes accumulated Yjs tombstones,\n * preventing unbounded blob growth without any background jobs).\n */\n\nimport * as Y from \"yjs\";\n\nimport { emitCollabUpdate } from \"./emitter.js\";\nimport {\n applyJsonDiff,\n applyJsonPatch,\n yDocToJson,\n initYDocWithJson,\n type PatchOp,\n} from \"./json-to-yjs.js\";\nimport {\n loadYDocRecord,\n loadYDocState,\n saveYDocState,\n trySaveYDocState,\n} from \"./storage.js\";\nimport { uint8ArrayToBase64 } from \"./storage.js\";\nimport { applyTextToYDoc, initYDocWithText } from \"./text-to-yjs.js\";\nimport { searchAndReplaceInYXml, extractTextFromYXml } from \"./xml-ops.js\";\n\nconst DEFAULT_FIELD = \"content\";\nconst MAX_CACHE = 50;\n\n/**\n * Auto-presence: any agent-sourced write produces visible presence and\n * lingering edit attribution without the calling action having to wire\n * agentEnterDocument/agentLeaveDocument itself. Dynamic import avoids a\n * static cycle (agent-presence.ts imports searchAndReplace from this module).\n */\nfunction touchAgentPresence(\n docId: string,\n requestSource: string | undefined,\n edit: { descriptor: Record<string, unknown>; label?: string } | null,\n): void {\n if (requestSource !== \"agent\") return;\n import(\"./agent-presence.js\")\n .then((mod) => {\n mod.agentTouchDocument(docId, edit ? { edit: edit as any } : undefined);\n })\n .catch(() => {\n // Presence is best-effort; never fail the write for it.\n });\n}\n\n/**\n * Compute a small \"what changed\" descriptor from a text diff by trimming the\n * common prefix/suffix. Used for lingering edit highlights client-side.\n */\nexport function computeTextEditDescriptor(\n oldText: string,\n newText: string,\n): { kind: \"text\"; quote: string } | { kind: \"doc\" } {\n let start = 0;\n const maxStart = Math.min(oldText.length, newText.length);\n while (start < maxStart && oldText[start] === newText[start]) start++;\n\n let endOld = oldText.length;\n let endNew = newText.length;\n while (\n endOld > start &&\n endNew > start &&\n oldText[endOld - 1] === newText[endNew - 1]\n ) {\n endOld--;\n endNew--;\n }\n\n const inserted = newText.slice(start, endNew).trim();\n if (inserted.length > 0) {\n return { kind: \"text\", quote: inserted.slice(0, 120) };\n }\n return { kind: \"doc\" };\n}\n\n/**\n * Compaction ratio threshold. When the stored state byte count exceeds\n * COMPACTION_RATIO × the freshly encoded state, write the compact form\n * (strips accumulated tombstones). A value of 4 means: compact when the\n * stored blob is 4× larger than necessary.\n */\nconst COMPACTION_RATIO = 4;\n\ninterface CacheEntry {\n doc: Y.Doc;\n lastAccess: number;\n}\n\nconst _cache = new Map<string, CacheEntry>();\nconst _writeLocks = new Map<string, Promise<void>>();\n// Coalesces concurrent cache-miss loads for the same docId. Without this, two\n// simultaneous getDoc() callers both miss the cache, both build a Y.Doc and\n// apply stored state, and the second _cache.set silently orphans the first\n// doc (a memory leak that grows with concurrent read traffic).\nconst _loadLocks = new Map<string, Promise<Y.Doc>>();\n\nfunction evictIfNeeded(): void {\n if (_cache.size <= MAX_CACHE) return;\n // Evict least-recently-accessed entry\n let oldest: string | null = null;\n let oldestTime = Infinity;\n for (const [id, entry] of _cache) {\n if (entry.lastAccess < oldestTime) {\n oldestTime = entry.lastAccess;\n oldest = id;\n }\n }\n if (oldest) {\n const entry = _cache.get(oldest);\n entry?.doc.destroy();\n _cache.delete(oldest);\n }\n}\n\nasync function withDocWriteLock<T>(\n docId: string,\n fn: () => Promise<T>,\n): Promise<T> {\n const previous = _writeLocks.get(docId) ?? Promise.resolve();\n let release!: () => void;\n const current = new Promise<void>((resolve) => {\n release = resolve;\n });\n const chained = previous.catch(() => {}).then(() => current);\n _writeLocks.set(docId, chained);\n\n await previous.catch(() => {});\n try {\n return await fn();\n } finally {\n release();\n if (_writeLocks.get(docId) === chained) {\n _writeLocks.delete(docId);\n }\n }\n}\n\n/**\n * Build state to persist. If the stored blob is significantly larger than\n * the freshly encoded state, store the compact (GC'd) form instead to\n * prevent unbounded blob growth from accumulated tombstones.\n */\nfunction buildStateToStore(doc: Y.Doc, storedByteCount: number): Uint8Array {\n const encoded = Y.encodeStateAsUpdate(doc);\n if (\n storedByteCount > 0 &&\n storedByteCount > encoded.length * COMPACTION_RATIO\n ) {\n // Stored blob is much larger than needed — return the GC'd encoding.\n return encoded;\n }\n return encoded;\n}\n\n/**\n * Persist the merged doc state with CAS retry on conflict.\n *\n * REMOVED: the unconditional `applyStoredState()` that was called on every\n * write path before this function. The only DB read is the `loadYDocRecord`\n * call here — needed to get the CAS version and merge any concurrent writes\n * from OTHER processes. Within this process, the in-memory doc is already\n * up-to-date because mutations are serialized by withDocWriteLock.\n */\nasync function persistMergedState(\n docId: string,\n doc: Y.Doc,\n getTextSnapshot: () => string,\n): Promise<void> {\n for (let attempt = 0; attempt < 5; attempt++) {\n // One DB read per persist attempt. On first attempt this is the only read\n // on the write path (previously there was an unconditional second read\n // before the update was applied). On retry attempts it re-reads to get the\n // latest version after a CAS conflict.\n const latest = await loadYDocRecord(docId);\n if (latest?.state && latest.state.length > 0) {\n Y.applyUpdate(doc, latest.state);\n }\n\n const stateToStore = buildStateToStore(doc, latest?.state?.length ?? 0);\n const saved = await trySaveYDocState(\n docId,\n stateToStore,\n getTextSnapshot(),\n latest?.version ?? null,\n );\n if (saved) return;\n }\n\n // All CAS attempts failed — fall back to unconditional save.\n await saveYDocState(docId, Y.encodeStateAsUpdate(doc), getTextSnapshot());\n}\n\n/**\n * Get or load a Yjs document by ID. Creates a new empty doc if none exists.\n */\nexport async function getDoc(docId: string): Promise<Y.Doc> {\n const cached = _cache.get(docId);\n if (cached) {\n cached.lastAccess = Date.now();\n return cached.doc;\n }\n\n const inFlight = _loadLocks.get(docId);\n if (inFlight) return inFlight;\n\n const load = (async () => {\n // Re-check the cache: a concurrent writer (or loader) may have populated it\n // between our miss above and acquiring this load slot.\n const reCached = _cache.get(docId);\n if (reCached) {\n reCached.lastAccess = Date.now();\n return reCached.doc;\n }\n\n const doc = new Y.Doc();\n const stored = await loadYDocState(docId);\n if (stored && stored.length > 0) {\n Y.applyUpdate(doc, stored);\n }\n\n evictIfNeeded();\n _cache.set(docId, { doc, lastAccess: Date.now() });\n return doc;\n })();\n\n _loadLocks.set(docId, load);\n try {\n return await load;\n } finally {\n _loadLocks.delete(docId);\n }\n}\n\n/**\n * Apply a binary Yjs update (from a client) to a document.\n * Persists the result and emits a change event.\n */\nexport async function applyUpdate(\n docId: string,\n update: Uint8Array,\n requestSource?: string,\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n // The cached doc is already up-to-date from the initial load or a previous\n // write in this process. No redundant applyStoredState() here — cross-\n // process writes are merged inside persistMergedState when needed.\n Y.applyUpdate(doc, update);\n\n await persistMergedState(docId, doc, () =>\n doc.getText(DEFAULT_FIELD).toString(),\n );\n\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n });\n}\n\n/**\n * Apply a text change to a document. Computes the minimal diff and\n * converts it to Yjs operations.\n *\n * Returns the text snapshot after the update.\n */\nexport async function applyText(\n docId: string,\n newText: string,\n fieldName: string = DEFAULT_FIELD,\n requestSource?: string,\n): Promise<string> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n const oldText = doc.getText(fieldName).toString();\n const update = applyTextToYDoc(doc, fieldName, newText, \"server\");\n\n if (update.length === 0) {\n return doc.getText(fieldName).toString();\n }\n\n await persistMergedState(docId, doc, () =>\n doc.getText(fieldName).toString(),\n );\n\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n touchAgentPresence(docId, requestSource, {\n descriptor: computeTextEditDescriptor(oldText, newText),\n });\n return doc.getText(fieldName).toString();\n });\n}\n\n/**\n * Search-and-replace text within a Y.XmlFragment (ProseMirror tree).\n * Produces minimal Yjs operations for cursor-preserving updates.\n *\n * Returns whether the text was found and the binary update.\n */\nexport async function searchAndReplace(\n docId: string,\n find: string,\n replace: string,\n requestSource?: string,\n): Promise<{ found: boolean; update: Uint8Array }> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n const fragment = doc.getXmlFragment(\"default\");\n\n // Capture the update produced by the transaction\n let update: Uint8Array = new Uint8Array(0);\n const handler = (u: Uint8Array) => {\n update = u;\n };\n doc.on(\"update\", handler);\n\n let found = false;\n doc.transact(() => {\n found = searchAndReplaceInYXml(fragment, find, replace);\n }, \"agent\");\n\n doc.off(\"update\", handler);\n\n if (!found || update.length === 0) {\n return { found: false, update: new Uint8Array(0) };\n }\n\n await persistMergedState(docId, doc, () => extractTextFromYXml(fragment));\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n touchAgentPresence(docId, requestSource, {\n descriptor: {\n kind: \"text\",\n quote: (replace || find).slice(0, 120),\n },\n });\n\n return { found: true, update };\n });\n}\n\n/**\n * Get the current text content of a document field.\n */\nexport async function getText(\n docId: string,\n fieldName: string = DEFAULT_FIELD,\n): Promise<string> {\n const doc = await getDoc(docId);\n return doc.getText(fieldName).toString();\n}\n\n/**\n * Get the full document state as a Uint8Array.\n */\nexport async function getState(docId: string): Promise<Uint8Array> {\n const doc = await getDoc(docId);\n return Y.encodeStateAsUpdate(doc);\n}\n\n/**\n * Get an incremental update relative to a client's state vector.\n */\nexport async function getIncUpdate(\n docId: string,\n clientStateVector: Uint8Array,\n): Promise<Uint8Array> {\n const doc = await getDoc(docId);\n return Y.encodeStateAsUpdate(doc, clientStateVector);\n}\n\n/**\n * Seed a document from existing text content (for migration).\n * Only seeds if no collab state exists yet.\n */\nexport async function seedFromText(\n docId: string,\n text: string,\n fieldName: string = DEFAULT_FIELD,\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const existing = await loadYDocState(docId);\n if (existing && existing.length > 0) return; // Already seeded\n\n const { doc, state } = initYDocWithText(fieldName, text);\n await saveYDocState(docId, state, text);\n\n // Cache the doc\n evictIfNeeded();\n _cache.set(docId, { doc, lastAccess: Date.now() });\n });\n}\n\n// ─── Structured JSON Operations ─────────────────────────────────────\n\n/**\n * Apply a full JSON update to a document. Computes the minimal diff\n * and converts it to Yjs operations on Y.Map/Y.Array.\n */\nexport async function applyJson(\n docId: string,\n newJson: any,\n fieldName: string = \"data\",\n _type: \"map\" | \"array\" = \"map\",\n requestSource?: string,\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n const update = applyJsonDiff(doc, fieldName, newJson, \"server\");\n\n if (update.length === 0) return;\n\n // Snapshot the doc's actual post-merge state, not the caller-supplied\n // `newJson` — persistMergedState may re-apply newer DB state to resolve\n // concurrent writes, so `newJson` can be stale. Matches applyPatchOps.\n await persistMergedState(docId, doc, () =>\n JSON.stringify(yDocToJson(doc, fieldName)),\n );\n\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n touchAgentPresence(docId, requestSource, { descriptor: { kind: \"doc\" } });\n });\n}\n\n/**\n * Apply surgical JSON patch operations to a document.\n */\nexport async function applyPatchOps(\n docId: string,\n ops: PatchOp[],\n fieldName: string = \"data\",\n requestSource?: string,\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n const update = applyJsonPatch(doc, fieldName, ops, \"server\");\n\n if (update.length === 0) return;\n\n await persistMergedState(docId, doc, () =>\n JSON.stringify(yDocToJson(doc, fieldName)),\n );\n\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n touchAgentPresence(docId, requestSource, {\n descriptor: {\n kind: \"paths\",\n paths: ops.slice(0, 5).map((op) => op.path),\n },\n });\n });\n}\n\n/**\n * Get the current JSON state of a document field.\n */\nexport async function getJson(\n docId: string,\n fieldName: string = \"data\",\n): Promise<any> {\n const doc = await getDoc(docId);\n return yDocToJson(doc, fieldName);\n}\n\n/**\n * Seed a document from existing JSON content (for migration).\n * Only seeds if no collab state exists yet.\n */\nexport async function seedFromJson(\n docId: string,\n json: any,\n fieldName: string = \"data\",\n type: \"map\" | \"array\" = \"map\",\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const existing = await loadYDocState(docId);\n if (existing && existing.length > 0) return; // Already seeded\n\n const { doc, state } = initYDocWithJson(fieldName, json, type);\n await saveYDocState(docId, state, JSON.stringify(json));\n\n // Cache the doc\n evictIfNeeded();\n _cache.set(docId, { doc, lastAccess: Date.now() });\n });\n}\n\n/**\n * Release a document from the in-memory cache.\n */\nexport function releaseDoc(docId: string): void {\n const entry = _cache.get(docId);\n if (entry) {\n entry.doc.destroy();\n _cache.delete(docId);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ydoc-manager.js","sourceRoot":"","sources":["../../src/collab/ydoc-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,aAAa,EACb,cAAc,EACd,UAAU,EACV,gBAAgB,GAEjB,MAAM,k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EG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Server-side Yjs document manager with LRU caching and SQL persistence.\n *\n * Performance notes:\n * - `getDoc()` loads from the DB once on cache miss; subsequent calls return\n * the cached Y.Doc directly with no DB I/O.\n * - Mutations no longer call `applyStoredState()` unconditionally on every\n * write. The defensive re-read from the DB happens only inside\n * `persistMergedState` (needed for the CAS version read), not as a\n * separate SELECT before applying the new update. This removes the\n * redundant double-read that the previous implementation performed on\n * every write even on a hot cache.\n * - Compaction: when the stored blob is >4x the freshly encoded state, the\n * GC'd encoding is stored instead (removes accumulated Yjs tombstones,\n * preventing unbounded blob growth without any background jobs).\n */\n\nimport * as Y from \"yjs\";\n\nimport { emitCollabUpdate } from \"./emitter.js\";\nimport {\n applyJsonDiff,\n applyJsonPatch,\n yDocToJson,\n initYDocWithJson,\n type PatchOp,\n} from \"./json-to-yjs.js\";\nimport {\n loadYDocRecord,\n loadYDocState,\n saveYDocState,\n trySaveYDocState,\n} from \"./storage.js\";\nimport { uint8ArrayToBase64 } from \"./storage.js\";\nimport { applyTextToYDoc, initYDocWithText } from \"./text-to-yjs.js\";\nimport { searchAndReplaceInYXml, extractTextFromYXml } from \"./xml-ops.js\";\n\nconst DEFAULT_FIELD = \"content\";\nconst MAX_CACHE = 50;\n\n/**\n * Auto-presence: any agent-sourced write produces visible presence and\n * lingering edit attribution without the calling action having to wire\n * agentEnterDocument/agentLeaveDocument itself. Dynamic import avoids a\n * static cycle (agent-presence.ts imports searchAndReplace from this module).\n */\nfunction touchAgentPresence(\n docId: string,\n requestSource: string | undefined,\n edit: { descriptor: Record<string, unknown>; label?: string } | null,\n): void {\n if (requestSource !== \"agent\") return;\n import(\"./agent-presence.js\")\n .then((mod) => {\n mod.agentTouchDocument(docId, edit ? { edit: edit as any } : undefined);\n })\n .catch(() => {\n // Presence is best-effort; never fail the write for it.\n });\n}\n\n/**\n * Compute a small \"what changed\" descriptor from a text diff by trimming the\n * common prefix/suffix. Used for lingering edit highlights client-side.\n */\nexport function computeTextEditDescriptor(\n oldText: string,\n newText: string,\n): { kind: \"text\"; quote: string } | { kind: \"doc\" } {\n let start = 0;\n const maxStart = Math.min(oldText.length, newText.length);\n while (start < maxStart && oldText[start] === newText[start]) start++;\n\n let endOld = oldText.length;\n let endNew = newText.length;\n while (\n endOld > start &&\n endNew > start &&\n oldText[endOld - 1] === newText[endNew - 1]\n ) {\n endOld--;\n endNew--;\n }\n\n const inserted = newText.slice(start, endNew).trim();\n if (inserted.length > 0) {\n return { kind: \"text\", quote: inserted.slice(0, 120) };\n }\n return { kind: \"doc\" };\n}\n\n/**\n * Compaction ratio threshold. When the stored state byte count exceeds\n * COMPACTION_RATIO × the freshly encoded state, write the compact form\n * (strips accumulated tombstones). A value of 4 means: compact when the\n * stored blob is 4× larger than necessary.\n */\nconst COMPACTION_RATIO = 4;\n\ninterface CacheEntry {\n doc: Y.Doc;\n lastAccess: number;\n}\n\nconst _cache = new Map<string, CacheEntry>();\nconst _writeLocks = new Map<string, Promise<void>>();\n// Coalesces concurrent cache-miss loads for the same docId. Without this, two\n// simultaneous getDoc() callers both miss the cache, both build a Y.Doc and\n// apply stored state, and the second _cache.set silently orphans the first\n// doc (a memory leak that grows with concurrent read traffic).\nconst _loadLocks = new Map<string, Promise<Y.Doc>>();\n\nfunction evictIfNeeded(): void {\n if (_cache.size <= MAX_CACHE) return;\n // Evict least-recently-accessed entry\n let oldest: string | null = null;\n let oldestTime = Infinity;\n for (const [id, entry] of _cache) {\n if (entry.lastAccess < oldestTime) {\n oldestTime = entry.lastAccess;\n oldest = id;\n }\n }\n if (oldest) {\n const entry = _cache.get(oldest);\n entry?.doc.destroy();\n _cache.delete(oldest);\n }\n}\n\nasync function withDocWriteLock<T>(\n docId: string,\n fn: () => Promise<T>,\n): Promise<T> {\n const previous = _writeLocks.get(docId) ?? Promise.resolve();\n let release!: () => void;\n const current = new Promise<void>((resolve) => {\n release = resolve;\n });\n const chained = previous.catch(() => {}).then(() => current);\n _writeLocks.set(docId, chained);\n\n await previous.catch(() => {});\n try {\n return await fn();\n } finally {\n release();\n if (_writeLocks.get(docId) === chained) {\n _writeLocks.delete(docId);\n }\n }\n}\n\n/**\n * Build state to persist. If the stored blob is significantly larger than\n * the freshly encoded state, store the compact (GC'd) form instead to\n * prevent unbounded blob growth from accumulated tombstones.\n */\nfunction buildStateToStore(doc: Y.Doc, storedByteCount: number): Uint8Array {\n const encoded = Y.encodeStateAsUpdate(doc);\n if (\n storedByteCount > 0 &&\n storedByteCount > encoded.length * COMPACTION_RATIO\n ) {\n // Stored blob is much larger than needed — return the GC'd encoding.\n return encoded;\n }\n return encoded;\n}\n\n/**\n * Persist the merged doc state with CAS retry on conflict.\n *\n * REMOVED: the unconditional `applyStoredState()` that was called on every\n * write path before this function. The only DB read is the `loadYDocRecord`\n * call here — needed to get the CAS version and merge any concurrent writes\n * from OTHER processes. Within this process, the in-memory doc is already\n * up-to-date because mutations are serialized by withDocWriteLock.\n */\nasync function persistMergedState(\n docId: string,\n doc: Y.Doc,\n getTextSnapshot: () => string,\n validateTextSnapshot?: (snapshot: string) => void,\n): Promise<void> {\n for (let attempt = 0; attempt < 5; attempt++) {\n // One DB read per persist attempt. On first attempt this is the only read\n // on the write path (previously there was an unconditional second read\n // before the update was applied). On retry attempts it re-reads to get the\n // latest version after a CAS conflict.\n const latest = await loadYDocRecord(docId);\n if (latest?.state && latest.state.length > 0) {\n Y.applyUpdate(doc, latest.state);\n }\n\n const stateToStore = buildStateToStore(doc, latest?.state?.length ?? 0);\n const textSnapshot = getTextSnapshot();\n validateTextSnapshot?.(textSnapshot);\n const saved = await trySaveYDocState(\n docId,\n stateToStore,\n textSnapshot,\n latest?.version ?? null,\n );\n if (saved) return;\n }\n\n // All CAS attempts failed — fall back to unconditional save.\n const textSnapshot = getTextSnapshot();\n validateTextSnapshot?.(textSnapshot);\n await saveYDocState(docId, Y.encodeStateAsUpdate(doc), textSnapshot);\n}\n\n/**\n * Get or load a Yjs document by ID. Creates a new empty doc if none exists.\n */\nexport async function getDoc(docId: string): Promise<Y.Doc> {\n const cached = _cache.get(docId);\n if (cached) {\n cached.lastAccess = Date.now();\n return cached.doc;\n }\n\n const inFlight = _loadLocks.get(docId);\n if (inFlight) return inFlight;\n\n const load = (async () => {\n // Re-check the cache: a concurrent writer (or loader) may have populated it\n // between our miss above and acquiring this load slot.\n const reCached = _cache.get(docId);\n if (reCached) {\n reCached.lastAccess = Date.now();\n return reCached.doc;\n }\n\n const doc = new Y.Doc();\n const stored = await loadYDocState(docId);\n if (stored && stored.length > 0) {\n Y.applyUpdate(doc, stored);\n }\n\n evictIfNeeded();\n _cache.set(docId, { doc, lastAccess: Date.now() });\n return doc;\n })();\n\n _loadLocks.set(docId, load);\n try {\n return await load;\n } finally {\n _loadLocks.delete(docId);\n }\n}\n\n/**\n * Apply a binary Yjs update (from a client) to a document.\n * Persists the result and emits a change event.\n */\nexport async function applyUpdate(\n docId: string,\n update: Uint8Array,\n requestSource?: string,\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n // The cached doc is already up-to-date from the initial load or a previous\n // write in this process. No redundant applyStoredState() here — cross-\n // process writes are merged inside persistMergedState when needed.\n Y.applyUpdate(doc, update);\n\n await persistMergedState(docId, doc, () =>\n doc.getText(DEFAULT_FIELD).toString(),\n );\n\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n });\n}\n\n/**\n * Apply a text change to a document. Computes the minimal diff and\n * converts it to Yjs operations.\n *\n * Returns the text snapshot after the update.\n */\nexport async function applyText(\n docId: string,\n newText: string,\n fieldName: string = DEFAULT_FIELD,\n requestSource?: string,\n options: {\n /**\n * Validate the fully converged text after cross-process Yjs updates have\n * merged, but before the state is persisted or broadcast. A rejected\n * candidate is discarded from this process's cache so the next read\n * reloads the last durable state instead of leaking an uncommitted merge.\n */\n validateSnapshot?: (snapshot: string) => void;\n } = {},\n): Promise<string> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n const oldText = doc.getText(fieldName).toString();\n const update = applyTextToYDoc(doc, fieldName, newText, \"server\");\n\n if (update.length === 0) {\n const snapshot = doc.getText(fieldName).toString();\n try {\n options.validateSnapshot?.(snapshot);\n } catch (error) {\n releaseDoc(docId);\n throw error;\n }\n return snapshot;\n }\n\n try {\n await persistMergedState(\n docId,\n doc,\n () => doc.getText(fieldName).toString(),\n options.validateSnapshot,\n );\n } catch (error) {\n if (options.validateSnapshot) {\n // The target diff and any cross-process state merged during the CAS\n // read now live only in this cached Y.Doc. Destroy it before throwing:\n // neither the rejected update nor a compensating rollback should ever\n // be persisted/emitted to connected clients.\n releaseDoc(docId);\n }\n throw error;\n }\n\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n touchAgentPresence(docId, requestSource, {\n descriptor: computeTextEditDescriptor(oldText, newText),\n });\n return doc.getText(fieldName).toString();\n });\n}\n\n/**\n * Search-and-replace text within a Y.XmlFragment (ProseMirror tree).\n * Produces minimal Yjs operations for cursor-preserving updates.\n *\n * Returns whether the text was found and the binary update.\n */\nexport async function searchAndReplace(\n docId: string,\n find: string,\n replace: string,\n requestSource?: string,\n): Promise<{ found: boolean; update: Uint8Array }> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n const fragment = doc.getXmlFragment(\"default\");\n\n // Capture the update produced by the transaction\n let update: Uint8Array = new Uint8Array(0);\n const handler = (u: Uint8Array) => {\n update = u;\n };\n doc.on(\"update\", handler);\n\n let found = false;\n doc.transact(() => {\n found = searchAndReplaceInYXml(fragment, find, replace);\n }, \"agent\");\n\n doc.off(\"update\", handler);\n\n if (!found || update.length === 0) {\n return { found: false, update: new Uint8Array(0) };\n }\n\n await persistMergedState(docId, doc, () => extractTextFromYXml(fragment));\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n touchAgentPresence(docId, requestSource, {\n descriptor: {\n kind: \"text\",\n quote: (replace || find).slice(0, 120),\n },\n });\n\n return { found: true, update };\n });\n}\n\n/**\n * Get the current text content of a document field.\n */\nexport async function getText(\n docId: string,\n fieldName: string = DEFAULT_FIELD,\n): Promise<string> {\n const doc = await getDoc(docId);\n return doc.getText(fieldName).toString();\n}\n\n/**\n * Get the full document state as a Uint8Array.\n */\nexport async function getState(docId: string): Promise<Uint8Array> {\n const doc = await getDoc(docId);\n return Y.encodeStateAsUpdate(doc);\n}\n\n/**\n * Get an incremental update relative to a client's state vector.\n */\nexport async function getIncUpdate(\n docId: string,\n clientStateVector: Uint8Array,\n): Promise<Uint8Array> {\n const doc = await getDoc(docId);\n return Y.encodeStateAsUpdate(doc, clientStateVector);\n}\n\n/**\n * Seed a document from existing text content (for migration).\n * Only seeds if no collab state exists yet.\n */\nexport async function seedFromText(\n docId: string,\n text: string,\n fieldName: string = DEFAULT_FIELD,\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const existing = await loadYDocState(docId);\n if (existing && existing.length > 0) return; // Already seeded\n\n const { doc, state } = initYDocWithText(fieldName, text);\n await saveYDocState(docId, state, text);\n\n // Cache the doc\n evictIfNeeded();\n _cache.set(docId, { doc, lastAccess: Date.now() });\n });\n}\n\n// ─── Structured JSON Operations ─────────────────────────────────────\n\n/**\n * Apply a full JSON update to a document. Computes the minimal diff\n * and converts it to Yjs operations on Y.Map/Y.Array.\n */\nexport async function applyJson(\n docId: string,\n newJson: any,\n fieldName: string = \"data\",\n _type: \"map\" | \"array\" = \"map\",\n requestSource?: string,\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n const update = applyJsonDiff(doc, fieldName, newJson, \"server\");\n\n if (update.length === 0) return;\n\n // Snapshot the doc's actual post-merge state, not the caller-supplied\n // `newJson` — persistMergedState may re-apply newer DB state to resolve\n // concurrent writes, so `newJson` can be stale. Matches applyPatchOps.\n await persistMergedState(docId, doc, () =>\n JSON.stringify(yDocToJson(doc, fieldName)),\n );\n\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n touchAgentPresence(docId, requestSource, { descriptor: { kind: \"doc\" } });\n });\n}\n\n/**\n * Apply surgical JSON patch operations to a document.\n */\nexport async function applyPatchOps(\n docId: string,\n ops: PatchOp[],\n fieldName: string = \"data\",\n requestSource?: string,\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const doc = await getDoc(docId);\n const update = applyJsonPatch(doc, fieldName, ops, \"server\");\n\n if (update.length === 0) return;\n\n await persistMergedState(docId, doc, () =>\n JSON.stringify(yDocToJson(doc, fieldName)),\n );\n\n emitCollabUpdate(docId, uint8ArrayToBase64(update), requestSource);\n touchAgentPresence(docId, requestSource, {\n descriptor: {\n kind: \"paths\",\n paths: ops.slice(0, 5).map((op) => op.path),\n },\n });\n });\n}\n\n/**\n * Get the current JSON state of a document field.\n */\nexport async function getJson(\n docId: string,\n fieldName: string = \"data\",\n): Promise<any> {\n const doc = await getDoc(docId);\n return yDocToJson(doc, fieldName);\n}\n\n/**\n * Seed a document from existing JSON content (for migration).\n * Only seeds if no collab state exists yet.\n */\nexport async function seedFromJson(\n docId: string,\n json: any,\n fieldName: string = \"data\",\n type: \"map\" | \"array\" = \"map\",\n): Promise<void> {\n return withDocWriteLock(docId, async () => {\n const existing = await loadYDocState(docId);\n if (existing && existing.length > 0) return; // Already seeded\n\n const { doc, state } = initYDocWithJson(fieldName, json, type);\n await saveYDocState(docId, state, JSON.stringify(json));\n\n // Cache the doc\n evictIfNeeded();\n _cache.set(docId, { doc, lastAccess: Date.now() });\n });\n}\n\n/**\n * Release a document from the in-memory cache.\n */\nexport function releaseDoc(docId: string): void {\n const entry = _cache.get(docId);\n if (entry) {\n entry.doc.destroy();\n _cache.delete(docId);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AA2EA,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AA4B9D;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAK5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CASvD;AAmDD,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;OAYG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,YAAY,CAAC;IAClB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,EACjC,OAAO,EAAE,oBAAoB,GAC5B,cAAc,CAsYhB"}
|
package/dist/db/migrations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDbExec, createDbExec, isPostgres, getDialect, getMigrationDatabaseUrl, retrySqliteBusy, } from "./client.js";
|
|
1
|
+
import { getDbExec, createDbExec, isPostgres, getDialect, getMigrationDatabaseUrl, getCloudflareD1Binding, retrySqliteBusy, } from "./client.js";
|
|
2
2
|
// ---------------------------------------------------------------------------
|
|
3
3
|
// Shared direct-endpoint exec across concurrent migration runners per boot.
|
|
4
4
|
//
|
|
@@ -244,7 +244,9 @@ export function runMigrations(migrations, options) {
|
|
|
244
244
|
return async () => {
|
|
245
245
|
try {
|
|
246
246
|
// Check for Cloudflare D1 binding (only if DATABASE_URL not set)
|
|
247
|
-
const d1 = getDialect() === "d1"
|
|
247
|
+
const d1 = getDialect() === "d1"
|
|
248
|
+
? getCloudflareD1Binding()
|
|
249
|
+
: null;
|
|
248
250
|
if (d1) {
|
|
249
251
|
await d1
|
|
250
252
|
.prepare(`CREATE TABLE IF NOT EXISTS ${table} (version INTEGER PRIMARY KEY)`)
|