MCPcopy Create free account
hub / github.com/allocnode/oh-my-sage / createSession

Method createSession

src/server/session/store.ts:118–141  ·  view source on GitHub ↗

* 创建新 session

(title?: string)

Source from the content-addressed store, hash-verified

116 * 创建新 Session
117 */
118 async createSession(title?: string): Promise<SessionMeta> {
119 const id = this.generateId();
120 const now = new Date().toISOString();
121
122 const meta: SessionMeta = {
123 id,
124 title: title || '新对话',
125 summary: '',
126 createdAt: now,
127 updatedAt: now,
128 messageCount: 0,
129 isActive: true,
130 };
131
132 // 创建空的 Session 文件
133 fs.writeFileSync(this.getSessionPath(id), '');
134
135 // 更新索引
136 const index = this.readIndex();
137 index.sessions.unshift(meta);
138 this.writeIndex(index);
139
140 return meta;
141 }
142
143 /**
144 * 获取 Session 列表

Callers 2

POSTFunction · 0.80
POSTFunction · 0.80

Calls 4

generateIdMethod · 0.95
getSessionPathMethod · 0.95
readIndexMethod · 0.95
writeIndexMethod · 0.95

Tested by

no test coverage detected