Where did you hear about us?
1 of 6
잠

잠 - 돌아보고, 다시 쓰기.

AI가 하루를 돌아보며, 자신과 주변 사람에 대해 쓴 파일을 다시 씁니다.

잠이란

Scroll 2 저장소에는 그 AI의 파일이 있습니다. 자기 자신에 대한 핵심(core) 하나와, AI가 이름을 붙이고 채우는 상자(box) 네 개입니다. 핵심은 "나"를 주어로 쓴 문서로, 무엇을 좋아하고 무엇을 하지 않는지, 주변 사람을 어떻게 보는지가 들어갑니다. 잠은 지난 잠 이후 저장소에 들어온 대화를 읽고 이 파일들을 다시 쓰는 일입니다. 핵심은 7만 토큰까지, 상자는 하나에 2만 토큰까지 쓸 수 있고, 파일의 모든 판이 남습니다.

누가 돌리고 언제 자는가

잠은 앱이 고른 모델과 앱의 키로 돕니다. Wontopos는 모델을 돌리지 않습니다. 모델 값은 그 모델의 제공자에게 내고, 모델을 정하지 않으면 Claude Sonnet 5.5를 씁니다. Claude Sonnet 5.5로 잰 값은 읽은 대화 100만 토큰당 약 $4.29입니다(정가, 프롬프트 캐싱 끔).

잠은 부를 때만 돕니다. 밤에, 낮잠으로, 또는 명령으로 부릅니다. 지난 잠 이후 새 기억이 1,000만 토큰을 넘으면 졸린 상태(sleepy)로 표시되지만, 그때도 꼭 자야 하는 것은 아닙니다. 잠은 실험 기능입니다.

잠 돌리기

sleep_estimate

잠이 무엇을 읽고 대략 얼마가 들지 돌리기 전에 알려 줍니다. 지난 잠 이후의 기억 수와 토큰, 모델에 보낼 입력과 받을 출력의 추정, 달러로 된 비용, 그리고 졸린 상태인지를 돌려줍니다. 다른 모델을 쓴다면 그 모델의 입력·출력 가격을 주어 셀 수 있습니다. 추정이 돌려준 sleep_id를 sleep에 넘기면 같은 기억을 다시 읽지 않습니다.

sleep

잠 한 번. 읽고, 파일을 다시 쓰고, 저장소의 마지막 잠을 여기서 끝냅니다.

  • llm 읽는 모델(필수). anthropic_caller, openai_caller, 또는 직접 만든 함수.
  • being 잠이 AI를 부르는 이름.
  • assistant 어시스턴트가 한 말에 붙는 이름. 주지 않으면 저장소의 기본 이름입니다.
  • prompt AI의 프롬프트. 처음 한 번 핵심에 들어갑니다.
  • settings 핵심과 상자의 크기.
  • done=False 마지막 잠 위치를 그대로 두어 다음 잠이 같은 줄을 다시 읽게 합니다.

답에는 그 밤에 쓴 파일의 새 판, 받아들이지 않은 것과 그 이유, 모델 호출마다 쓴 토큰이 옵니다. 모델이 속도 제한·과부하·연결 끊김을 만나면 두 번 더 시도하고, 그 밖의 실패는 아무것도 쓰지 않고 끝납니다. 잠이 도는 사이에 다른 쪽이 파일을 바꾸면 ConflictError가 나고, 그 밤의 변경은 하나도 남지 않습니다. 잠이 읽은 최근 대화는 clear_window로 비웁니다.

from wontopos import anthropic_caller

llm = anthropic_caller(model_key, model="claude-sonnet-5-5")   # your key, your model
plan = mem.sleep_estimate("jimin")
print(plan["memories"], plan["cost"], plan["sleepy"])
night = mem.sleep("jimin", llm=llm, being="Kai", sleep_id=plan["sleep_id"])
mem.clear_window("jimin")                                      # the recent turns it read
import { anthropicCaller } from "wontopos";

const llm = anthropicCaller({ apiKey: modelKey, model: "claude-sonnet-5-5" });   // your key, your model
const plan = await mem.sleepEstimate("jimin");
console.log(plan.memories, plan.cost, plan.sleepy);
const night = await mem.sleep("jimin", { llm, being: "Kai", sleepId: plan.sleep_id ?? undefined });
await mem.clearWindow("jimin");                                                  // the recent turns it read
use std::sync::Arc;
use wontopos::{anthropic_caller, AnthropicCallerOpts, SleepEstimateOpts, SleepOpts};

let llm = anthropic_caller(AnthropicCallerOpts {
    api_key: model_key, model: Some("claude-sonnet-5-5".into()), ..Default::default()
})?;                                                   // your key, your model
let plan = mem.sleep_estimate("jimin", &SleepEstimateOpts::default()).await?;
let night = mem.sleep("jimin", Arc::new(llm), &SleepOpts {
    being: "Kai".into(),
    sleep_id: plan["sleep_id"].as_str().map(str::to_string),
    ..Default::default()
}).await?;
mem.clear_window("jimin", None).await?;                // the recent turns it read

파일 읽기

sleep_files는 핵심 전체와 네 상자의 제목·판·크기를, open_sleep_file은 파일 하나를 통째로(예전 판도), sleep_file_history는 한 파일의 모든 판을 돌려줍니다. 대화 중에 모델 옆에 두려면 기억 도구의 sleep=True를 씁니다.

f = mem.sleep_files("jimin")
print(f["core"]["title"], [b["title"] for b in f["files"]])
box = mem.open_sleep_file(1, "jimin")              # 0 is the core, 1 to 4 the boxes
tools = mem.memory_tools("jimin", sleep=True)      # the files beside the model, every turn
const f = await mem.sleepFiles("jimin");
const box = await mem.openSleepFile(1, "jimin");    // 0 is the core, 1 to 4 the boxes
const tools = mem.memoryTools("jimin", { sleep: true });   // the files beside the model, every turn
let f = mem.sleep_files("jimin").await?;
let boxed = mem.open_sleep_file(1, "jimin", None).await?;   // 0 is the core, 1 to 4 the boxes
let tools = mem.memory_tools("jimin", None)?.with_sleep(true); // the files beside the model, every turn

잠을 직접 짜려면

단계를 직접 짜려면 sleep_read로 하루치 기억을 한 페이지씩 읽고, sleep_verify로 쓰려는 내용이 인용한 기억이 이 잠이 읽은 것인지 확인하고, write_sleep_files로 파일의 새 판을 씁니다(전부 되거나 하나도 안 됩니다). sleep_done은 저장소의 마지막 잠을 이 잠에서 끝냅니다. 잠이 다음 잠을 위해 남기는 노트는 sleep_notes와 write_sleep_notes로 읽고 씁니다.