real-time-collab
यह क्या करती है
यह स्किल बताती है कि agent-native ऐप में रियल-टाइम सहयोगी संपादन कैसे बनाएं, Yjs और TipTap का उपयोग करके ताकि बदलाव साफ़ मिलें। यह साझा दस्तावेज़ जोड़ने या sync समस्याएं ठीक करने वाले डेवलपर्स के लिए है।
कब इस्तेमाल करें
- ✓जब आप ऐप के किसी दस्तावेज़ में लाइव सहयोगी संपादन जोड़ते हैं।
- ✓जब दो लोग या एजेंट एक ही दस्तावेज़ बदलते हैं और कुछ बदलाव गायब हो जाते हैं।
- ✓जब आपको यूज़र और एजेंट के बीच sync समस्या की जांच करनी है।
Skill का लिंक
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/real-time-collab/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“दो लोगों को एक ही दस्तावेज़ एक साथ संपादित करने दीजिए, और AI के संपादन दोनों को दिखाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
संपादन एक साझा दस्तावेज़ के रूप में सहेजे जाते हैं जो बदलावों को अपने-आप मिलाता है। अपडेट यूज़र तक भेजे जाते हैं, और लाइव कनेक्शन टूटने पर नियमित जांच पर लौट आते हैं।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Real-Time Collaboration
Rule
Collaborative editing uses Yjs CRDT via TipTap. The agent and human users are
equal participants — both edit the same Y.Doc and changes merge cleanly without
conflicts. Always choose an explicit access mode on createCollabPlugin.
How It Works
Y.Docstores the document as aY.XmlFragment(ProseMirror node tree)- TipTap's Collaboration extension binds the editor to the Y.XmlFragment
via
ySyncPlugin - CollaborationCaret extension renders remote users' cursors with names and colors
- SSE fast-path —
/_agent-native/poll-eventsEventSourcedelivers collab events push-style; while SSE is healthy the collab poll interval relaxes to ~12 s - Polling fallback —
/_agent-native/pollis polled every 2 s when SSE drops mid-session. On serverless,/eventsanswers 204 up front (poll-live) and this client relaxes to ~12 s, because/pollis the only channel. - Collab poll boost — while the awareness set shows another visible human
on the doc (agent and hidden tabs do not count), the connection holds
acquireCollabPollBoost()and the shared transport polls every 2.5 s whenever no stream is connected: a no-op while SSE or the hosted gateway is live. A joiner is noticed on the existing user's next ~12 s collab poll (the joiner sees them at once), a leaver within one poll plus the 30 s awareness TTL. The boost lapses after 3 minutes with no input and no remote events. Lone tabs pay nothing extra. Events under the request source a connection posts with (any app-chosen tab id, not onlygetBrowserTabId()) are this tab's own and never count. A read-only viewer must join the doc too (Design'suseViewerPresence; it never uses theydoc), or it never sees an editor and stays on the idle cadence. A viewer on a different screen than the editor shares no doc with them; its own collab poll sees the design's resource-scoped events from other tabs and starts the boost (60 s) itself. - Update batching — local Yjs updates are debounced ~80 ms and coalesced
with
Y.mergeUpdatesbefore sending; flushed immediately onvisibilitychange/pagehide - SQL
_collab_docstable persists Yjs state as base64 in Postgres. Tombstone compaction fires automatically when the stored blob exceeds 4× the fresh encoded size.
Agent + Human Editing
- Human edits → TipTap → ySyncPlugin → Y.XmlFragment →
POST /_agent-native/collab/:docId/update - Agent edits → action edits canonical SQL content + bumps
updatedAt→ change-sync refetch → the open editor reconciles the new content into the live Y.Doc (see below) → poll update → all clients
Both produce Yjs operations that merge cleanly. Agent edits appear without destroying cursor position, selection, or undo history.
The agent does not push edits into Yjs in-process and does not call any localhost probe — those approaches silently no-op on serverless (the action runs in a different process). The peer-editor model below replaced them.
Agent Edits As A Real-Time Peer Editor
SQL is the durable source of truth for document body content. The agent
action edits the canonical content column and bumps updatedAt. No localhost
calls, no in-process Yjs mutation.
The open editor reconciles authoritative external content into the live
Y.Doc. The updatedAt bump flows through change-sync, which refetches the
record. The lead client applies the new content via setContent, producing Yjs
operations that merge with concurrent human edits. Every connected client
receives the result through normal Yjs sync.
The updatedAt gate
// In the editor's reconcile effect
if (loaded.updatedAt > lastAppliedUpdatedAt.current) {
applyAuthoritativeContent(loaded.content); // adopt
lastAppliedUpdatedAt.current = loaded.updatedAt;
}
// else: lagging poll / stale snapshot → ignore
Without the gate, a slightly-behind poll response re-applies old content and the edit "reverts on next poll". A fresh mount always adopts whatever content it loaded.
Lead-client election
Exactly ONE connected client applies the authoritative snapshot; the rest receive it through Yjs sync:
import { isReconcileLeadClient } from "@agent-native/core/client/collab";
if (
loaded.updatedAt > lastAppliedUpdatedAt.current &&
isReconcileLeadClient(awareness, ydoc.clientID)
) {
applyAuthoritativeContent(loaded.content);
}
The agent's awareness entry (`AGENT
अक्सर पूछे जाने वाले सवाल
क्या एजेंट और लोग एक साथ संपादित कर सकते हैं?
हां। स्किल एजेंट और मानव यूज़र को एक ही दस्तावेज़ में बराबर के भागीदार मानती है।
दूसरे यूज़र के cursors कैसे दिखते हैं?
एक cursor extension दूसरे यूज़र के cursors उनके नाम और रंग के साथ दिखाता है।
लाइव कनेक्शन टूटे तो क्या होता है?
ऐप हर कुछ सेकंड में सर्वर से पूछने वाली polling पर लौट आता है।
जानकारी
लेखक का मूल विवरण
Multi-user collaborative editing with Yjs CRDT, SSE fast-path transport, and granular server-side merge. Use when adding real-time collaborative editing to a template, debugging sync issues, or understanding how the agent and humans edit documents simultaneously.
repo: BuilderIO/agent-native
लोकप्रियता
- GitHub स्टार
- 7.6k
- रैंकिंग में स्थान
- #13174
- लाइसेंस
- MIT
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
design-exploration
7.6kयह आपके एजेंट को UI के कई डिज़ाइन विकल्प साथ-साथ दिखाने, आपकी पसंद चुनवाने और फिर चुने डिज़ाइन को सुधारने में मदद करती है।
visual-edit
7.6kयह आपके एजेंट को चल रहे लोकल ऐप को विज़ुअल एडिटर में खोलने देती है, ताकि आप उसकी असली स्क्रीन एक साथ देखकर संपादित कर सकें।
turn-into-app
7.6kयह किसी वर्कफ़्लो, स्प्रेडशीट या प्रोजेक्ट को भरी हुई स्क्रीन वाले विज़ुअल ऐप में बदलती है, जिसके कंट्रोल के पीछे एजेंट काम करता है।
visual-plan
7.6kयह सादे टेक्स्ट वाली योजना को डायग्राम, फ़ाइल नक्शों, कोड अंश और खुले सवालों वाली इंटरैक्टिव विज़ुअल योजना में बदलती है।
मिलती-जुलती skills
angular-developer
280kआपके एजेंट को Angular code बनाने और प्रोजेक्ट स्ट्रक्चर पर सलाह देने में मदद करता है। नए प्रोजेक्ट शुरू करने, code के हिस्से बनाने, या performance और accessibility सुधारने में उपयोगी है।
frontend-a11y
280kआपके एजेंट को web interfaces को सबके लिए accessible बनाने में मदद करता है। यह सुनिश्चित करता है कि websites और apps screen readers और keyboard navigation के साथ अच्छे से काम करें।
frontend-patterns
280kआपके एजेंट को React और Next.js में frontend development के modern patterns लागू करने में मदद करता है। यह performance optimize करता है, state manage करता है और best practices फॉलो करवाता है।