clay-server 3.5.0 → 3.5.1
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.
|
@@ -157,6 +157,9 @@ function attachMessageProcessor(ctx) {
|
|
|
157
157
|
if (parsed.sessionId && !session.cliSessionId) {
|
|
158
158
|
session.cliSessionId = parsed.sessionId;
|
|
159
159
|
sm.saveSessionFile(session);
|
|
160
|
+
if (typeof sm.notifySessionIdentityAssigned === "function") {
|
|
161
|
+
sm.notifySessionIdentityAssigned(session.localId);
|
|
162
|
+
}
|
|
160
163
|
sendAndRecord(session, { type: "session_id", cliSessionId: session.cliSessionId });
|
|
161
164
|
} else if (parsed.sessionId) {
|
|
162
165
|
session.cliSessionId = parsed.sessionId;
|
|
@@ -238,6 +238,16 @@ function createSplitGroupStore(opts) {
|
|
|
238
238
|
return true;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
function refreshAnchors(localId) {
|
|
242
|
+
var group = groupForMember(localId);
|
|
243
|
+
if (!group) return false;
|
|
244
|
+
var fresh = currentCliIds(group);
|
|
245
|
+
var prev = Array.isArray(group.memberCliIds) ? group.memberCliIds : [null, null];
|
|
246
|
+
if (fresh[0] === prev[0] && fresh[1] === prev[1]) return false;
|
|
247
|
+
save();
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
|
|
241
251
|
function refreshAutoName(localId) {
|
|
242
252
|
var group = groupForMember(localId);
|
|
243
253
|
if (!group) return false;
|
|
@@ -245,9 +255,7 @@ function createSplitGroupStore(opts) {
|
|
|
245
255
|
// Auto-title fires on a member's first message, which is also when a
|
|
246
256
|
// blank member gains its cliSessionId. Re-save so the durable anchor
|
|
247
257
|
// is captured even when the name itself stays untouched.
|
|
248
|
-
|
|
249
|
-
var prev = Array.isArray(group.memberCliIds) ? group.memberCliIds : [null, null];
|
|
250
|
-
if (fresh[0] !== prev[0] || fresh[1] !== prev[1]) save();
|
|
258
|
+
refreshAnchors(localId);
|
|
251
259
|
return false;
|
|
252
260
|
}
|
|
253
261
|
group.name = autoGroupName(sessions.get(group.members[0]).title, sessions.get(group.members[1]).title);
|
|
@@ -258,7 +266,7 @@ function createSplitGroupStore(opts) {
|
|
|
258
266
|
|
|
259
267
|
load();
|
|
260
268
|
return { create: create, rename: rename, setPair: setPair, dissolve: dissolve, dissolveBySession: dissolveBySession,
|
|
261
|
-
refreshAutoName: refreshAutoName,
|
|
269
|
+
refreshAutoName: refreshAutoName, refreshAnchors: refreshAnchors,
|
|
262
270
|
listFor: listFor, groupForMember: groupForMember, get groups() { return groups; } };
|
|
263
271
|
}
|
|
264
272
|
|
|
@@ -296,6 +304,7 @@ function attachSplitGroups(ctx) {
|
|
|
296
304
|
|
|
297
305
|
ctx.sm.setOnSessionDeleted(store.dissolveBySession);
|
|
298
306
|
ctx.sm.setOnSessionRenamed(store.refreshAutoName);
|
|
307
|
+
ctx.sm.setOnSessionIdentityAssigned(store.refreshAnchors);
|
|
299
308
|
return { handleMessage: handleMessage, sendConnectionState: sendState, store: store };
|
|
300
309
|
}
|
|
301
310
|
|
package/lib/sessions.js
CHANGED
|
@@ -15,6 +15,7 @@ function createSessionManager(opts) {
|
|
|
15
15
|
var onSessionDone = opts.onSessionDone || function () {};
|
|
16
16
|
var onSessionDeleted = opts.onSessionDeleted || function () {};
|
|
17
17
|
var onSessionRenamed = opts.onSessionRenamed || function () {};
|
|
18
|
+
var onSessionIdentityAssigned = opts.onSessionIdentityAssigned || function () {};
|
|
18
19
|
|
|
19
20
|
// --- Multi-session state ---
|
|
20
21
|
var nextLocalId = 1;
|
|
@@ -1184,7 +1185,9 @@ function createSessionManager(opts) {
|
|
|
1184
1185
|
sessionsDir: sessionsDir,
|
|
1185
1186
|
setOnSessionDeleted: function (fn) { onSessionDeleted = fn || function () {}; },
|
|
1186
1187
|
setOnSessionRenamed: function (fn) { onSessionRenamed = fn || function () {}; },
|
|
1188
|
+
setOnSessionIdentityAssigned: function (fn) { onSessionIdentityAssigned = fn || function () {}; },
|
|
1187
1189
|
notifySessionRenamed: function (localId) { onSessionRenamed(localId); },
|
|
1190
|
+
notifySessionIdentityAssigned: function (localId) { onSessionIdentityAssigned(localId); },
|
|
1188
1191
|
HISTORY_PAGE_SIZE: HISTORY_PAGE_SIZE,
|
|
1189
1192
|
getActiveSession: getActiveSession,
|
|
1190
1193
|
createSession: createSession,
|
|
@@ -1044,6 +1044,9 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
1044
1044
|
state.threadId = threadResult.thread.id;
|
|
1045
1045
|
handlerEntry.threadId = state.threadId;
|
|
1046
1046
|
}
|
|
1047
|
+
if (state.threadId) {
|
|
1048
|
+
pushEvent({ yokeType: "session_started", sessionId: state.threadId });
|
|
1049
|
+
}
|
|
1047
1050
|
|
|
1048
1051
|
while (!isCancelled()) {
|
|
1049
1052
|
// Reset per-turn state
|
package/package.json
CHANGED