durable-streams-yjs
하는 일
이 스킬은 Yjs와 durable streams를 표준 HTTP로 사용해 사용자 간 공유 문서를 동기화하는 방법을 AI 에이전트에게 보여 줍니다. 공동 편집 기능을 만드는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓Yjs를 쓰는 앱에 실시간 공동 편집을 추가할 때.
- ✓다른 사용자가 어디에 있고 커서가 어디 있는지 보여 줘야 할 때.
- ✓동기화에 서버 전송 이벤트와 롱 폴링 중 무엇을 쓸지 골라야 하는 경우.
스킬 링크
https://github.com/humanlayer/humanlayer/blob/main/.claude/skills/sync/durable-streams-yjs/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Yjs와 HTTP 스트림을 사용해 제 공유 메모 문서를 실시간 동기화하도록 설정해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 Yjs 문서를 문서 스트림과 인식 스트림에 연결하는 제공자를 만듭니다. 그다음 연결, 연결 해제, 상태 이벤트를 처리해 문서가 동기화된 상태를 유지하게 합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Durable Streams — Yjs Sync
Sync Yjs documents over HTTP durable streams. No WebSocket infrastructure needed — uses standard HTTP with SSE or long-poll transport. Built-in persistence through stream history, presence support via awareness streams.
Setup
import { DurableStreamsProvider } from "@durable-streams/y-durable-streams"
import * as Y from "yjs"
import { Awareness } from "y-protocols/awareness"
const doc = new Y.Doc()
const awareness = new Awareness(doc)
const provider = new DurableStreamsProvider({
doc,
documentStream: {
url: "https://your-server.com/v1/stream/doc-updates",
transport: "sse",
},
awarenessStream: {
url: "https://your-server.com/v1/stream/doc-awareness",
protocol: awareness,
transport: "sse",
},
})
provider.on("synced", (synced) => {
console.log("Synced:", synced)
})
provider.on("status", (status) => {
console.log("Status:", status) // "disconnected" | "connecting" | "connected"
})
Core Patterns
Document-only sync (no presence)
import { DurableStreamsProvider } from "@durable-streams/y-durable-streams"
import * as Y from "yjs"
const doc = new Y.Doc()
const provider = new DurableStreamsProvider({
doc,
documentStream: {
url: "https://your-server.com/v1/stream/my-doc",
transport: "sse",
},
})
Manual connect/disconnect
const provider = new DurableStreamsProvider({
doc,
documentStream: { url, transport: "sse" },
connect: false, // Don't auto-connect
})
// Connect when ready
provider.connect()
// Temporarily disconnect (can reconnect later)
provider.disconnect()
// Permanently destroy (cleanup all listeners and timers)
provider.destroy()
Dynamic auth headers
const provider = new DurableStreamsProvider({
doc,
documentStream: {
url: "https://your-server.com/v1/stream/my-doc",
transport: "sse",
headers: {
Authorization: () => `Bearer ${getAccessToken()}`,
},
},
})
Common Mistakes
HIGH Forgetting peer dependencies for Yjs
Wrong:
npm install @durable-streams/y-durable-streams
Correct:
npm install @durable-streams/y-durable-streams yjs y-protocols lib0
yjs, y-protocols, and lib0 are peer dependencies. Missing them causes import errors at runtime.
Source: packages/y-durable-streams/package.json peerDependencies
HIGH Using application/json content type for Yjs streams
Wrong:
documentStream: {
url: "https://server.com/v1/stream/doc-1",
transport: "sse",
contentType: "application/json",
}
Correct:
documentStream: {
url: "https://server.com/v1/stream/doc-1",
transport: "sse",
// Content type defaults to application/octet-stream (binary)
}
Yjs documents use binary encoding (lib0 VarUint8Array). The stream must use application/octet-stream, not application/json. The provider handles this automatically — don't override the content type.
Source: packages/y-durable-streams/src/y-durable-streams.ts BINARY_CONTENT_TYPE
HIGH Not calling destroy() on cleanup
Wrong:
useEffect(() => {
const provider = new DurableStreamsProvider({ doc, documentStream: config })
return () => provider.disconnect() // Only disconnects, doesn't clean up!
}, [])
Correct:
useEffect(() => {
const provider = new DurableStreamsProvider({ doc, documentStream: config })
return () => provider.destroy() // Full cleanup
}, [])
disconnect() only closes the connection — destroy() also removes doc/awareness listeners and clears the 15-second awareness heartbeat interval.
Source: packages/y-durable-streams/README.md API methods
See also
- reading-streams — Yjs provider uses SSE/long-poll transport from the client library
Version
Targets @durable-streams/y-durable-streams v0.2.1.
자주 묻는 질문
WebSocket이 필요한가요?
아니요. 서버 전송 이벤트나 롱 폴링을 써서 일반 HTTP로 작동하도록 설계되었습니다.
필요한 패키지는 무엇인가요?
yjs, y-protocols, lib0를 반드시 설치해야 하는 피어 의존성으로 나열합니다.
문서의 기록이 남나요?
네. 기본 제공 저장은 스트림 기록에서 옵니다.
상세 정보
작성자의 원본 설명
Yjs CRDT sync over durable streams with @durable-streams/y-durable-streams. DurableStreamsProvider setup, document stream and awareness stream config, transport modes (SSE vs long-poll), provider lifecycle (connect, disconnect, destroy), synced/status/error events, lib0 VarUint8Array framing, awareness heartbeat. Requires yjs, y-protocols, lib0 peer dependencies. Load when integrating Yjs collaborative editing with durable streams.
repo: humanlayer/humanlayer
인기도
- GitHub 스타
- 13k
- 순위
- #11392
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 10. 31.
댓글
- …
이 저장소의 다른 스킬
asd-ste100
13k혼동되는 영어를 짧고 뜻이 하나뿐인 문장으로 다시 써서, 사람과 다른 소프트웨어가 쉽게 읽을 수 있게 하도록 에이전트를 가르칩니다.
better-github-skill
13k풀 리퀘스트 상태를 확인하고, 리뷰 댓글을 읽고, 준비된 GitHub 스크립트로 CI 빌드가 실패한 이유를 찾도록 에이전트를 돕습니다.
calldiff
13k두 git 버전 사이 코드베이스의 함수 호출 체인을 비교해, 코드 리뷰에서 어떤 동작이 바뀌었는지 볼 수 있도록 에이전트를 돕습니다.
chrome-devtools-cli
13k에이전트가 터미널에서 Chrome을 제어해 페이지를 열고, 클릭하고, 양식을 채우고, 페이지 스냅숏을 찍어 브라우저 자동화와 테스트를 하도록 돕습니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.